diff --git a/src/mbgl/map/tile_worker.cpp b/src/mbgl/map/tile_worker.cpp index 68b0e15dc..32d45df31 100644 --- a/src/mbgl/map/tile_worker.cpp +++ b/src/mbgl/map/tile_worker.cpp @@ -241,7 +241,6 @@ std::unique_ptr 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 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 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; } diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 6d12768e2..c6da657c2 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -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; diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 71f4dc3d3..e8ad132c5 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -274,9 +274,10 @@ void SymbolBucket::addFeature(const std::vector> &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> &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. diff --git a/src/mbgl/style/property_fallback.cpp b/src/mbgl/style/property_fallback.cpp index 74dd247b0..0c4a01ef4 100644 --- a/src/mbgl/style/property_fallback.cpp +++ b/src/mbgl/style/property_fallback.cpp @@ -70,7 +70,6 @@ const std::map PropertyFallbackValue::properties = { { PropertyKey::IconIgnorePlacement, defaultStyleLayout().icon.ignore_placement }, { PropertyKey::IconOptional, defaultStyleLayout().icon.optional }, { PropertyKey::IconRotationAlignment, defaultStyleLayout().icon.rotation_alignment }, - { PropertyKey::IconMaxSize, defaultStyleLayout().icon.max_size }, { PropertyKey::IconImage, defaultStyleLayout().icon.image }, { PropertyKey::IconRotate, defaultStyleLayout().icon.rotate }, { PropertyKey::IconPadding, defaultStyleLayout().icon.padding }, @@ -80,7 +79,6 @@ const std::map PropertyFallbackValue::properties = { { PropertyKey::TextRotationAlignment, defaultStyleLayout().text.rotation_alignment }, { PropertyKey::TextField, defaultStyleLayout().text.field }, { PropertyKey::TextFont, defaultStyleLayout().text.font }, - { PropertyKey::TextMaxSize, defaultStyleLayout().text.max_size }, { PropertyKey::TextMaxWidth, defaultStyleLayout().text.max_width }, { PropertyKey::TextLineHeight, defaultStyleLayout().text.line_height }, { PropertyKey::TextLetterSpacing, defaultStyleLayout().text.letter_spacing }, diff --git a/src/mbgl/style/property_key.hpp b/src/mbgl/style/property_key.hpp index e7ddef51c..4349035f5 100644 --- a/src/mbgl/style/property_key.hpp +++ b/src/mbgl/style/property_key.hpp @@ -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, diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp index 33fe3285a..fa37bcc2a 100644 --- a/src/mbgl/style/style_layer.cpp +++ b/src/mbgl/style/style_layer.cpp @@ -223,7 +223,6 @@ void StyleLayer::applyStyleProperties(const float z, const Tim properties.set(); SymbolProperties &symbol = properties.get(); 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(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 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 evaluator(z, zoomHistory); + symbol.text.size = mapbox::util::apply_visitor(evaluator, it->second); + } } template <> diff --git a/src/mbgl/style/style_layout.hpp b/src/mbgl/style/style_layout.hpp index 5561a6777..6db8ce193 100644 --- a/src/mbgl/style/style_layout.hpp +++ b/src/mbgl/style/style_layout.hpp @@ -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 */; diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index adcc9013f..6dc92a8d3 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -875,7 +875,7 @@ void StyleParser::parseLayout(JSVal value, util::ptr &bucket) { parseOptionalProperty>("icon-ignore-placement", Key::IconIgnorePlacement, bucket->layout, value); parseOptionalProperty>("icon-optional", Key::IconOptional, bucket->layout, value); parseOptionalProperty>("icon-rotation-alignment", Key::IconRotationAlignment, bucket->layout, value); - parseOptionalProperty>("icon-max-size", Key::IconMaxSize, bucket->layout, value); + parseOptionalProperty>("icon-size", Key::IconSize, bucket->layout, value); parseOptionalProperty>("icon-image", Key::IconImage, bucket->layout, value); parseOptionalProperty>("icon-rotate", Key::IconRotate, bucket->layout, value); parseOptionalProperty>("icon-padding", Key::IconPadding, bucket->layout, value); @@ -884,7 +884,7 @@ void StyleParser::parseLayout(JSVal value, util::ptr &bucket) { parseOptionalProperty>("text-rotation-alignment", Key::TextRotationAlignment, bucket->layout, value); parseOptionalProperty>("text-field", Key::TextField, bucket->layout, value); parseOptionalProperty>("text-font", Key::TextFont, bucket->layout, value); - parseOptionalProperty>("text-max-size", Key::TextMaxSize, bucket->layout, value); + parseOptionalProperty>("text-size", Key::TextSize, bucket->layout, value); parseOptionalProperty>("text-max-width", Key::TextMaxWidth, bucket->layout, value); parseOptionalProperty>("text-line-height", Key::TextLineHeight, bucket->layout, value); parseOptionalProperty>("text-letter-spacing", Key::TextLetterSpacing, bucket->layout, value); diff --git a/src/mbgl/util/geojsonvt b/src/mbgl/util/geojsonvt index 995ffc72c..ed99a6290 160000 --- a/src/mbgl/util/geojsonvt +++ b/src/mbgl/util/geojsonvt @@ -1 +1 @@ -Subproject commit 995ffc72c556da4b4880a6036fbcf7159fc5ecce +Subproject commit ed99a6290fa42107a982e7f3675aae49d29026b1