remove text-max-size and icon-max-size
port https://github.com/mapbox/mapbox-gl-js/pull/1419
This commit is contained in:
committed by
John Firebaugh
parent
d1a0d7a273
commit
60e9712916
@@ -241,7 +241,6 @@ std::unique_ptr<Bucket> TileWorker::createSymbolBucket(const GeometryTileLayer&
|
||||
applyLayoutProperty(PropertyKey::IconIgnorePlacement, bucket_desc.layout, layout.icon.ignore_placement, z);
|
||||
applyLayoutProperty(PropertyKey::IconOptional, bucket_desc.layout, layout.icon.optional, z);
|
||||
applyLayoutProperty(PropertyKey::IconRotationAlignment, bucket_desc.layout, layout.icon.rotation_alignment, z);
|
||||
applyLayoutProperty(PropertyKey::IconMaxSize, bucket_desc.layout, layout.icon.max_size, z);
|
||||
applyLayoutProperty(PropertyKey::IconImage, bucket_desc.layout, layout.icon.image, z);
|
||||
applyLayoutProperty(PropertyKey::IconPadding, bucket_desc.layout, layout.icon.padding, z);
|
||||
applyLayoutProperty(PropertyKey::IconRotate, bucket_desc.layout, layout.icon.rotate, z);
|
||||
@@ -251,7 +250,6 @@ std::unique_ptr<Bucket> TileWorker::createSymbolBucket(const GeometryTileLayer&
|
||||
applyLayoutProperty(PropertyKey::TextRotationAlignment, bucket_desc.layout, layout.text.rotation_alignment, z);
|
||||
applyLayoutProperty(PropertyKey::TextField, bucket_desc.layout, layout.text.field, z);
|
||||
applyLayoutProperty(PropertyKey::TextFont, bucket_desc.layout, layout.text.font, z);
|
||||
applyLayoutProperty(PropertyKey::TextMaxSize, bucket_desc.layout, layout.text.max_size, z);
|
||||
applyLayoutProperty(PropertyKey::TextMaxWidth, bucket_desc.layout, layout.text.max_width, z);
|
||||
applyLayoutProperty(PropertyKey::TextLineHeight, bucket_desc.layout, layout.text.line_height, z);
|
||||
applyLayoutProperty(PropertyKey::TextLetterSpacing, bucket_desc.layout, layout.text.letter_spacing, z);
|
||||
@@ -267,6 +265,11 @@ std::unique_ptr<Bucket> TileWorker::createSymbolBucket(const GeometryTileLayer&
|
||||
applyLayoutProperty(PropertyKey::TextOffset, bucket_desc.layout, layout.text.offset, z);
|
||||
applyLayoutProperty(PropertyKey::TextAllowOverlap, bucket_desc.layout, layout.text.allow_overlap, z);
|
||||
|
||||
applyLayoutProperty(PropertyKey::IconSize, bucket_desc.layout, layout.icon.size, z + 1);
|
||||
applyLayoutProperty(PropertyKey::IconSize, bucket_desc.layout, layout.icon.max_size, 18);
|
||||
applyLayoutProperty(PropertyKey::TextSize, bucket_desc.layout, layout.text.size, z + 1);
|
||||
applyLayoutProperty(PropertyKey::TextSize, bucket_desc.layout, layout.text.max_size, 18);
|
||||
|
||||
if (bucket->needsDependencies(layer, bucket_desc.filter, *style.glyphStore, *style.sprite)) {
|
||||
partialParse = true;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
|
||||
sdfShader.u_texsize = texsize;
|
||||
|
||||
// adjust min/max zooms for variable font sies
|
||||
float zoomAdjust = std::log(fontSize / bucketProperties.max_size) / std::log(2);
|
||||
float zoomAdjust = std::log(fontSize / bucketProperties.size) / std::log(2);
|
||||
|
||||
sdfShader.u_zoom = (state.getNormalizedZoom() - zoomAdjust) * 10; // current zoom level
|
||||
|
||||
@@ -157,8 +157,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c
|
||||
? state.getAngle()
|
||||
: 0;
|
||||
|
||||
// If layerStyle.size > bucket.info.fontSize then labels may collide
|
||||
const float fontSize = properties.icon.size != 0 ? properties.icon.size : layout.icon.max_size;
|
||||
const float fontSize = properties.icon.size;
|
||||
const float fontScale = fontSize / 1.0f;
|
||||
|
||||
spriteAtlas->bind(state.isChanging() || layout.placement == PlacementType::Line || angleOffset != 0 || fontScale != 1 || sdf);
|
||||
@@ -191,7 +190,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c
|
||||
iconShader->u_texsize = {{ float(spriteAtlas->getWidth()) / 4.0f, float(spriteAtlas->getHeight()) / 4.0f }};
|
||||
|
||||
// adjust min/max zooms for variable font sies
|
||||
float zoomAdjust = std::log(fontSize / layout.icon.max_size) / std::log(2);
|
||||
float zoomAdjust = std::log(fontSize / layout.icon.size) / std::log(2);
|
||||
|
||||
iconShader->u_zoom = (state.getNormalizedZoom() - zoomAdjust) * 10; // current zoom level
|
||||
iconShader->u_fadedist = 0 * 10;
|
||||
|
||||
@@ -274,9 +274,10 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
|
||||
const float minScale = 0.5f;
|
||||
const float glyphSize = 24.0f;
|
||||
|
||||
const float fontScale = layout.text.max_size / glyphSize;
|
||||
const float fontScale = layout.text.size / glyphSize;
|
||||
const float textBoxScale = collision.tilePixelRatio * fontScale;
|
||||
const float iconBoxScale = collision.tilePixelRatio * layout.icon.max_size;
|
||||
const float textMaxBoxScale = collision.tilePixelRatio * layout.text.max_size / glyphSize;
|
||||
const float iconBoxScale = collision.tilePixelRatio * layout.icon.size;
|
||||
const float symbolSpacing = collision.tilePixelRatio * layout.spacing;
|
||||
const bool avoidEdges = layout.avoid_edges && layout.placement != PlacementType::Line;
|
||||
const float textPadding = layout.text.padding * collision.tilePixelRatio;
|
||||
@@ -302,7 +303,7 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
|
||||
|
||||
// Calculate the anchor points around which you want to place labels
|
||||
Anchors anchors = isLine ?
|
||||
getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, shapedIcon.left, shapedIcon.right, glyphSize, textBoxScale, overscaling) :
|
||||
getAnchors(line, symbolSpacing, textMaxAngle, shapedText.left, shapedText.right, shapedIcon.left, shapedIcon.right, glyphSize, textMaxBoxScale, overscaling) :
|
||||
Anchors({ Anchor(float(line[0].x), float(line[0].y), 0, minScale) });
|
||||
|
||||
// For each potential label, create the placement features used to check for collisions, and the quads use for rendering.
|
||||
|
||||
@@ -70,7 +70,6 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::IconIgnorePlacement, defaultStyleLayout<StyleLayoutSymbol>().icon.ignore_placement },
|
||||
{ PropertyKey::IconOptional, defaultStyleLayout<StyleLayoutSymbol>().icon.optional },
|
||||
{ PropertyKey::IconRotationAlignment, defaultStyleLayout<StyleLayoutSymbol>().icon.rotation_alignment },
|
||||
{ PropertyKey::IconMaxSize, defaultStyleLayout<StyleLayoutSymbol>().icon.max_size },
|
||||
{ PropertyKey::IconImage, defaultStyleLayout<StyleLayoutSymbol>().icon.image },
|
||||
{ PropertyKey::IconRotate, defaultStyleLayout<StyleLayoutSymbol>().icon.rotate },
|
||||
{ PropertyKey::IconPadding, defaultStyleLayout<StyleLayoutSymbol>().icon.padding },
|
||||
@@ -80,7 +79,6 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::TextRotationAlignment, defaultStyleLayout<StyleLayoutSymbol>().text.rotation_alignment },
|
||||
{ PropertyKey::TextField, defaultStyleLayout<StyleLayoutSymbol>().text.field },
|
||||
{ PropertyKey::TextFont, defaultStyleLayout<StyleLayoutSymbol>().text.font },
|
||||
{ PropertyKey::TextMaxSize, defaultStyleLayout<StyleLayoutSymbol>().text.max_size },
|
||||
{ PropertyKey::TextMaxWidth, defaultStyleLayout<StyleLayoutSymbol>().text.max_width },
|
||||
{ PropertyKey::TextLineHeight, defaultStyleLayout<StyleLayoutSymbol>().text.line_height },
|
||||
{ PropertyKey::TextLetterSpacing, defaultStyleLayout<StyleLayoutSymbol>().text.letter_spacing },
|
||||
|
||||
@@ -51,7 +51,6 @@ enum class PropertyKey {
|
||||
IconIgnorePlacement,
|
||||
IconOptional,
|
||||
IconRotationAlignment,
|
||||
IconMaxSize,
|
||||
IconImage,
|
||||
IconOffset,
|
||||
IconPadding,
|
||||
@@ -59,7 +58,6 @@ enum class PropertyKey {
|
||||
IconKeepUpright,
|
||||
|
||||
TextOpacity,
|
||||
TextSize,
|
||||
TextColor,
|
||||
TextHaloColor,
|
||||
TextHaloWidth,
|
||||
@@ -70,7 +68,7 @@ enum class PropertyKey {
|
||||
TextRotationAlignment,
|
||||
TextField,
|
||||
TextFont,
|
||||
TextMaxSize,
|
||||
TextSize,
|
||||
TextMaxWidth,
|
||||
TextLineHeight,
|
||||
TextLetterSpacing,
|
||||
|
||||
@@ -223,7 +223,6 @@ void StyleLayer::applyStyleProperties<SymbolProperties>(const float z, const Tim
|
||||
properties.set<SymbolProperties>();
|
||||
SymbolProperties &symbol = properties.get<SymbolProperties>();
|
||||
applyTransitionedStyleProperty(PropertyKey::IconOpacity, symbol.icon.opacity, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::IconSize, symbol.icon.size, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::IconColor, symbol.icon.color, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::IconHaloColor, symbol.icon.halo_color, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::IconHaloWidth, symbol.icon.halo_width, z, now, zoomHistory);
|
||||
@@ -232,13 +231,24 @@ void StyleLayer::applyStyleProperties<SymbolProperties>(const float z, const Tim
|
||||
applyStyleProperty(PropertyKey::IconTranslateAnchor, symbol.icon.translate_anchor, z, now, zoomHistory);
|
||||
|
||||
applyTransitionedStyleProperty(PropertyKey::TextOpacity, symbol.text.opacity, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::TextSize, symbol.text.size, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::TextColor, symbol.text.color, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::TextHaloColor, symbol.text.halo_color, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::TextHaloWidth, symbol.text.halo_width, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::TextHaloBlur, symbol.text.halo_blur, z, now, zoomHistory);
|
||||
applyTransitionedStyleProperty(PropertyKey::TextTranslate, symbol.text.translate, z, now, zoomHistory);
|
||||
applyStyleProperty(PropertyKey::TextTranslateAnchor, symbol.text.translate_anchor, z, now, zoomHistory);
|
||||
|
||||
// text-size and icon-size are layout properties but they also need to be evaluated as paint properties:
|
||||
auto it = bucket->layout.properties.find(PropertyKey::IconSize);
|
||||
if (it != bucket->layout.properties.end()) {
|
||||
const PropertyEvaluator<float> evaluator(z, zoomHistory);
|
||||
symbol.icon.size = mapbox::util::apply_visitor(evaluator, it->second);
|
||||
}
|
||||
it = bucket->layout.properties.find(PropertyKey::TextSize);
|
||||
if (it != bucket->layout.properties.end()) {
|
||||
const PropertyEvaluator<float> evaluator(z, zoomHistory);
|
||||
symbol.text.size = mapbox::util::apply_visitor(evaluator, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
bool ignore_placement = false;
|
||||
bool optional = false;
|
||||
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
|
||||
float size = 1.0f;
|
||||
float max_size = 1.0f;
|
||||
std::string image;
|
||||
float rotate = 0.0f;
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
|
||||
std::string field;
|
||||
std::string font = "Open Sans Regular, Arial Unicode MS Regular";
|
||||
float size = 16.0f;
|
||||
float max_size = 16.0f;
|
||||
float max_width = 15.0f /* em */;
|
||||
float line_height = 1.2f /* em */;
|
||||
|
||||
@@ -875,7 +875,7 @@ void StyleParser::parseLayout(JSVal value, util::ptr<StyleBucket> &bucket) {
|
||||
parseOptionalProperty<Function<bool>>("icon-ignore-placement", Key::IconIgnorePlacement, bucket->layout, value);
|
||||
parseOptionalProperty<Function<bool>>("icon-optional", Key::IconOptional, bucket->layout, value);
|
||||
parseOptionalProperty<Function<RotationAlignmentType>>("icon-rotation-alignment", Key::IconRotationAlignment, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("icon-max-size", Key::IconMaxSize, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("icon-size", Key::IconSize, bucket->layout, value);
|
||||
parseOptionalProperty<Function<std::string>>("icon-image", Key::IconImage, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("icon-rotate", Key::IconRotate, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("icon-padding", Key::IconPadding, bucket->layout, value);
|
||||
@@ -884,7 +884,7 @@ void StyleParser::parseLayout(JSVal value, util::ptr<StyleBucket> &bucket) {
|
||||
parseOptionalProperty<Function<RotationAlignmentType>>("text-rotation-alignment", Key::TextRotationAlignment, bucket->layout, value);
|
||||
parseOptionalProperty<Function<std::string>>("text-field", Key::TextField, bucket->layout, value);
|
||||
parseOptionalProperty<Function<std::string>>("text-font", Key::TextFont, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("text-max-size", Key::TextMaxSize, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("text-size", Key::TextSize, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("text-max-width", Key::TextMaxWidth, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("text-line-height", Key::TextLineHeight, bucket->layout, value);
|
||||
parseOptionalProperty<Function<float>>("text-letter-spacing", Key::TextLetterSpacing, bucket->layout, value);
|
||||
|
||||
Submodule src/mbgl/util/geojsonvt updated: 995ffc72c5...ed99a6290f
Reference in New Issue
Block a user