From a5625675890213f94de7632d4ef152ade627c9a5 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 26 Oct 2015 10:14:24 -0700 Subject: [PATCH] [core] Eliminate use of ClassProperties for layout --- include/mbgl/style/style_properties.hpp | 64 ------- src/mbgl/annotation/annotation_manager.cpp | 4 +- src/mbgl/annotation/shape_annotation_impl.cpp | 3 +- src/mbgl/layer/background_layer.cpp | 1 - src/mbgl/layer/background_layer.hpp | 2 - src/mbgl/layer/circle_layer.cpp | 1 - src/mbgl/layer/circle_layer.hpp | 2 - src/mbgl/layer/fill_layer.cpp | 1 - src/mbgl/layer/fill_layer.hpp | 2 - src/mbgl/layer/line_layer.cpp | 19 +- src/mbgl/layer/line_layer.hpp | 12 +- src/mbgl/layer/raster_layer.cpp | 1 - src/mbgl/layer/raster_layer.hpp | 2 - src/mbgl/layer/symbol_layer.cpp | 163 +++++++++--------- src/mbgl/layer/symbol_layer.hpp | 51 +++++- src/mbgl/map/raster_tile_data.cpp | 2 +- src/mbgl/map/raster_tile_data.hpp | 2 - src/mbgl/renderer/circle_bucket.hpp | 2 - src/mbgl/renderer/fill_bucket.cpp | 2 - src/mbgl/renderer/line_bucket.cpp | 8 +- src/mbgl/renderer/line_bucket.hpp | 2 +- src/mbgl/renderer/painter_symbol.cpp | 15 +- src/mbgl/renderer/raster_bucket.cpp | 5 +- src/mbgl/renderer/raster_bucket.hpp | 5 +- src/mbgl/renderer/symbol_bucket.cpp | 51 +++--- src/mbgl/renderer/symbol_bucket.hpp | 2 +- src/mbgl/style/layout_property.hpp | 38 ++++ src/mbgl/style/property_fallback.cpp | 40 ----- src/mbgl/style/property_key.hpp | 41 ----- src/mbgl/style/style_properties.cpp | 5 - src/mbgl/text/quads.cpp | 4 +- src/mbgl/text/shaping.cpp | 6 +- .../style_parser/text-size.style.json | 2 +- 33 files changed, 237 insertions(+), 323 deletions(-) create mode 100644 src/mbgl/style/layout_property.hpp delete mode 100644 src/mbgl/style/style_properties.cpp diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp index 221649113..2571a77d9 100644 --- a/include/mbgl/style/style_properties.hpp +++ b/include/mbgl/style/style_properties.hpp @@ -24,10 +24,6 @@ public: } }; -class FillLayoutProperties { -public: -}; - class LinePaintProperties { public: float opacity = 1.0f; @@ -46,14 +42,6 @@ public: } }; -class LineLayoutProperties { -public: - CapType cap = CapType::Butt; - JoinType join = JoinType::Miter; - float miter_limit = 2.0f; - float round_limit = 1.0f; -}; - class SymbolPaintProperties { public: struct { @@ -84,50 +72,6 @@ public: } }; -class SymbolLayoutProperties { -public: - PlacementType placement = PlacementType::Point; - float spacing = 250.0f; - bool avoid_edges = false; - - struct { - bool allow_overlap = false; - 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; - float padding = 2.0f; - bool keep_upright = false; - std::array offset = {{ 0, 0 }}; - } icon; - - struct { - 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 */; - float letter_spacing = 0.0f /* em */; - TextJustifyType justify = TextJustifyType::Center; - TextAnchorType anchor = TextAnchorType::Center; - float max_angle = 45.0f /* degrees */; - float rotate = 0.0f; - float padding = 2.0f; - bool keep_upright = true; - TextTransformType transform = TextTransformType::None; - std::array offset = {{ 0, 0 }}; - bool allow_overlap = false; - bool ignore_placement = false; - bool optional = false; - } text; -}; - - class CirclePaintProperties { public: float radius = 5.0f; @@ -156,10 +100,6 @@ public: } }; -class RasterLayoutProperties { -public: -}; - class BackgroundPaintProperties { public: float opacity = 1.0f; @@ -171,10 +111,6 @@ public: } }; -class BackgroundLayoutProperties { -public: -}; - } #endif diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 4f8504930..43dfb8361 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -120,8 +120,8 @@ void AnnotationManager::updateStyle(Style& style) { layer->source = SourceID; layer->sourceLayer = PointLayerID; - layer->layout.set(PropertyKey::IconImage, Function("{sprite}")); - layer->layout.set(PropertyKey::IconAllowOverlap, Function(true)); + layer->layout.icon.image = std::string("{sprite}"); + layer->layout.icon.allowOverlap = true; style.addLayer(std::move(layer)); } diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index 5d5f4e859..bb6642c60 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -31,8 +31,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { std::unique_ptr layer = std::make_unique(); layer->type = StyleLayerType::Line; - - layer->layout.set(PropertyKey::LineJoin, Function(JoinType::Round)); + layer->layout.join = JoinType::Round; const LinePaintProperties& properties = shape.properties.get(); ClassProperties paintProperties; diff --git a/src/mbgl/layer/background_layer.cpp b/src/mbgl/layer/background_layer.cpp index 67e39a689..0a86e2db1 100644 --- a/src/mbgl/layer/background_layer.cpp +++ b/src/mbgl/layer/background_layer.cpp @@ -7,7 +7,6 @@ namespace mbgl { std::unique_ptr BackgroundLayer::clone() const { std::unique_ptr result = std::make_unique(); result->copy(*this); - result->layout = layout; result->paints.paints = paints.paints; return std::move(result); } diff --git a/src/mbgl/layer/background_layer.hpp b/src/mbgl/layer/background_layer.hpp index 5a8b3496e..11d06b2cd 100644 --- a/src/mbgl/layer/background_layer.hpp +++ b/src/mbgl/layer/background_layer.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace mbgl { @@ -22,7 +21,6 @@ public: bool hasTransitions() const override; - ClassProperties layout; PaintPropertiesMap paints; BackgroundPaintProperties properties; diff --git a/src/mbgl/layer/circle_layer.cpp b/src/mbgl/layer/circle_layer.cpp index c36d21c08..768013655 100644 --- a/src/mbgl/layer/circle_layer.cpp +++ b/src/mbgl/layer/circle_layer.cpp @@ -8,7 +8,6 @@ namespace mbgl { std::unique_ptr CircleLayer::clone() const { std::unique_ptr result = std::make_unique(); result->copy(*this); - result->layout = layout; result->paints.paints = paints.paints; return std::move(result); } diff --git a/src/mbgl/layer/circle_layer.hpp b/src/mbgl/layer/circle_layer.hpp index 28943bff6..29cdf513d 100644 --- a/src/mbgl/layer/circle_layer.hpp +++ b/src/mbgl/layer/circle_layer.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace mbgl { @@ -22,7 +21,6 @@ public: bool hasTransitions() const override; - ClassProperties layout; PaintPropertiesMap paints; CirclePaintProperties properties; diff --git a/src/mbgl/layer/fill_layer.cpp b/src/mbgl/layer/fill_layer.cpp index 29982d933..ad68a240f 100644 --- a/src/mbgl/layer/fill_layer.cpp +++ b/src/mbgl/layer/fill_layer.cpp @@ -8,7 +8,6 @@ namespace mbgl { std::unique_ptr FillLayer::clone() const { std::unique_ptr result = std::make_unique(); result->copy(*this); - result->layout = layout; result->paints.paints = paints.paints; return std::move(result); } diff --git a/src/mbgl/layer/fill_layer.hpp b/src/mbgl/layer/fill_layer.hpp index dbab5e9a8..5a543889c 100644 --- a/src/mbgl/layer/fill_layer.hpp +++ b/src/mbgl/layer/fill_layer.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace mbgl { @@ -22,7 +21,6 @@ public: bool hasTransitions() const override; - ClassProperties layout; PaintPropertiesMap paints; FillPaintProperties properties; diff --git a/src/mbgl/layer/line_layer.cpp b/src/mbgl/layer/line_layer.cpp index 6b98ffa9a..fa1f22d5f 100644 --- a/src/mbgl/layer/line_layer.cpp +++ b/src/mbgl/layer/line_layer.cpp @@ -15,10 +15,10 @@ std::unique_ptr LineLayer::clone() const { } void LineLayer::parseLayout(const JSVal& value) { - parseProperty>("line-cap", PropertyKey::LineCap, layout, value); - parseProperty>("line-join", PropertyKey::LineJoin, layout, value); - parseProperty>("line-miter-limit", PropertyKey::LineMiterLimit, layout, value); - parseProperty>("line-round-limit", PropertyKey::LineRoundLimit, layout, value); + layout.cap.parse("line-cap", value); + layout.join.parse("line-join", value); + layout.miterLimit.parse("line-miter-limit", value); + layout.roundLimit.parse("line-round-limit", value); } void LineLayer::parsePaints(const JSVal& layer) { @@ -73,12 +73,13 @@ void LineLayer::recalculate(const StyleCalculationParameters& parameters) { std::unique_ptr LineLayer::createBucket(StyleBucketParameters& parameters) const { auto bucket = std::make_unique(); - const float z = parameters.tileID.z; + bucket->layout = layout; - layout.calculate(PropertyKey::LineCap, bucket->layout.cap, z); - layout.calculate(PropertyKey::LineJoin, bucket->layout.join, z); - layout.calculate(PropertyKey::LineMiterLimit, bucket->layout.miter_limit, z); - layout.calculate(PropertyKey::LineRoundLimit, bucket->layout.round_limit, z); + StyleCalculationParameters p(parameters.tileID.z); + bucket->layout.cap.calculate(p); + bucket->layout.join.calculate(p); + bucket->layout.miterLimit.calculate(p); + bucket->layout.roundLimit.calculate(p); parameters.eachFilteredFeature(filter, [&] (const auto& feature) { bucket->addGeometry(feature.getGeometries()); diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp index 1faf26b28..d35461131 100644 --- a/src/mbgl/layer/line_layer.hpp +++ b/src/mbgl/layer/line_layer.hpp @@ -4,10 +4,18 @@ #include #include #include -#include +#include namespace mbgl { +class LineLayoutProperties { +public: + LayoutProperty cap = CapType::Butt; + LayoutProperty join = JoinType::Miter; + LayoutProperty miterLimit = 2.0f; + LayoutProperty roundLimit = 1.0f; +}; + class LineLayer : public StyleLayer { public: std::unique_ptr clone() const override; @@ -22,7 +30,7 @@ public: bool hasTransitions() const override; - ClassProperties layout; + LineLayoutProperties layout; PaintPropertiesMap paints; LinePaintProperties properties; diff --git a/src/mbgl/layer/raster_layer.cpp b/src/mbgl/layer/raster_layer.cpp index f0bc94e3a..3e3536afc 100644 --- a/src/mbgl/layer/raster_layer.cpp +++ b/src/mbgl/layer/raster_layer.cpp @@ -7,7 +7,6 @@ namespace mbgl { std::unique_ptr RasterLayer::clone() const { std::unique_ptr result = std::make_unique(); result->copy(*this); - result->layout = layout; result->paints.paints = paints.paints; return std::move(result); } diff --git a/src/mbgl/layer/raster_layer.hpp b/src/mbgl/layer/raster_layer.hpp index 543c6c8d0..650ffc8ef 100644 --- a/src/mbgl/layer/raster_layer.hpp +++ b/src/mbgl/layer/raster_layer.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace mbgl { @@ -22,7 +21,6 @@ public: bool hasTransitions() const override; - ClassProperties layout; PaintPropertiesMap paints; RasterPaintProperties properties; diff --git a/src/mbgl/layer/symbol_layer.cpp b/src/mbgl/layer/symbol_layer.cpp index 1e06a3ea7..932e500c5 100644 --- a/src/mbgl/layer/symbol_layer.cpp +++ b/src/mbgl/layer/symbol_layer.cpp @@ -16,45 +16,45 @@ std::unique_ptr SymbolLayer::clone() const { } void SymbolLayer::parseLayout(const JSVal& value) { - parseProperty>("symbol-placement", PropertyKey::SymbolPlacement, layout, value); - parseProperty>("symbol-spacing", PropertyKey::SymbolSpacing, layout, value); - parseProperty>("symbol-avoid-edges", PropertyKey::SymbolAvoidEdges, layout, value); - parseProperty>("icon-allow-overlap", PropertyKey::IconAllowOverlap, layout, value); - parseProperty>("icon-ignore-placement", PropertyKey::IconIgnorePlacement, layout, value); - parseProperty>("icon-optional", PropertyKey::IconOptional, layout, value); - parseProperty>("icon-rotation-alignment", PropertyKey::IconRotationAlignment, layout, value); - parseProperty>("icon-size", PropertyKey::IconSize, layout, value); - parseProperty>("icon-image", PropertyKey::IconImage, layout, value); - parseProperty>("icon-rotate", PropertyKey::IconRotate, layout, value); - parseProperty>("icon-padding", PropertyKey::IconPadding, layout, value); - parseProperty>("icon-keep-upright", PropertyKey::IconKeepUpright, layout, value); - parseProperty>>("icon-offset", PropertyKey::IconOffset, layout, value); - parseProperty>("text-rotation-alignment", PropertyKey::TextRotationAlignment, layout, value); - parseProperty>("text-field", PropertyKey::TextField, layout, value); - parseProperty>("text-font", PropertyKey::TextFont, layout, value); - parseProperty>("text-size", PropertyKey::TextSize, layout, value); - parseProperty>("text-max-width", PropertyKey::TextMaxWidth, layout, value); - parseProperty>("text-line-height", PropertyKey::TextLineHeight, layout, value); - parseProperty>("text-letter-spacing", PropertyKey::TextLetterSpacing, layout, value); - parseProperty>("text-justify", PropertyKey::TextJustify, layout, value); - parseProperty>("text-anchor", PropertyKey::TextAnchor, layout, value); - parseProperty>("text-max-angle", PropertyKey::TextMaxAngle, layout, value); - parseProperty>("text-rotate", PropertyKey::TextRotate, layout, value); - parseProperty>("text-padding", PropertyKey::TextPadding, layout, value); - parseProperty>("text-keep-upright", PropertyKey::TextKeepUpright, layout, value); - parseProperty>("text-transform", PropertyKey::TextTransform, layout, value); - parseProperty>>("text-offset", PropertyKey::TextOffset, layout, value); - parseProperty>("text-allow-overlap", PropertyKey::TextAllowOverlap, layout, value); - parseProperty>("text-ignore-placement", PropertyKey::TextIgnorePlacement, layout, value); - parseProperty>("text-optional", PropertyKey::TextOptional, layout, value); + layout.placement.parse("symbol-placement", value); + layout.spacing.parse("symbol-spacing", value); + layout.avoidEdges.parse("symbol-avoid-edges", value); + + layout.icon.allowOverlap.parse("icon-allow-overlap", value); + layout.icon.ignorePlacement.parse("icon-ignore-placement", value); + layout.icon.optional.parse("icon-optional", value); + layout.icon.rotationAlignment.parse("icon-rotation-alignment", value); + layout.icon.size.parse("icon-size", value); + layout.icon.image.parse("icon-image", value); + layout.icon.rotate.parse("icon-rotate", value); + layout.icon.padding.parse("icon-padding", value); + layout.icon.keepUpright.parse("icon-keep-upright", value); + layout.icon.offset.parse("icon-offset", value); + + layout.text.rotationAlignment.parse("text-rotation-alignment", value); + layout.text.field.parse("text-field", value); + layout.text.font.parse("text-font", value); + layout.text.size.parse("text-size", value); + layout.text.maxWidth.parse("text-max-width", value); + layout.text.lineHeight.parse("text-line-height", value); + layout.text.letterSpacing.parse("text-letter-spacing", value); + layout.text.justify.parse("text-justify", value); + layout.text.anchor.parse("text-anchor", value); + layout.text.maxAngle.parse("text-max-angle", value); + layout.text.rotate.parse("text-rotate", value); + layout.text.padding.parse("text-padding", value); + layout.text.keepUpright.parse("text-keep-upright", value); + layout.text.transform.parse("text-transform", value); + layout.text.offset.parse("text-offset", value); + layout.text.allowOverlap.parse("text-allow-overlap", value); + layout.text.ignorePlacement.parse("text-ignore-placement", value); + layout.text.optional.parse("text-optional", value); } void SymbolLayer::parsePaints(const JSVal& layer) { paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) { parseProperty>("icon-opacity", PropertyKey::IconOpacity, paint, value); parseProperty("icon-opacity-transition", PropertyKey::IconOpacity, paint, value); - parseProperty>("icon-size", PropertyKey::IconSize, paint, value); - parseProperty("icon-size-transition", PropertyKey::IconSize, paint, value); parseProperty>("icon-color", PropertyKey::IconColor, paint, value); parseProperty("icon-color-transition", PropertyKey::IconColor, paint, value); parseProperty>("icon-halo-color", PropertyKey::IconHaloColor, paint, value); @@ -69,8 +69,6 @@ void SymbolLayer::parsePaints(const JSVal& layer) { parseProperty>("text-opacity", PropertyKey::TextOpacity, paint, value); parseProperty("text-opacity-transition", PropertyKey::TextOpacity, paint, value); - parseProperty>("text-size", PropertyKey::TextSize, paint, value); - parseProperty("text-size-transition", PropertyKey::TextSize, paint, value); parseProperty>("text-color", PropertyKey::TextColor, paint, value); parseProperty("text-color-transition", PropertyKey::TextColor, paint, value); parseProperty>("text-halo-color", PropertyKey::TextHaloColor, paint, value); @@ -113,64 +111,63 @@ void SymbolLayer::recalculate(const StyleCalculationParameters& parameters) { paints.calculate(PropertyKey::TextTranslateAnchor, properties.text.translate_anchor, parameters); // text-size and icon-size are layout properties but they also need to be evaluated as paint properties: - auto it = layout.properties.find(PropertyKey::IconSize); - if (it != layout.properties.end()) { - const PropertyEvaluator evaluator(parameters); - properties.icon.size = mapbox::util::apply_visitor(evaluator, it->second); - } - it = layout.properties.find(PropertyKey::TextSize); - if (it != layout.properties.end()) { - const PropertyEvaluator evaluator(parameters); - properties.text.size = mapbox::util::apply_visitor(evaluator, it->second); - } + layout.icon.size.calculate(parameters); + layout.text.size.calculate(parameters); + properties.icon.size = layout.icon.size; + properties.text.size = layout.text.size; passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None; } std::unique_ptr SymbolLayer::createBucket(StyleBucketParameters& parameters) const { - const float z = parameters.tileID.z; - auto bucket = std::make_unique(parameters.tileID.overscaling, z); + auto bucket = std::make_unique(parameters.tileID.overscaling, + parameters.tileID.z); - layout.calculate(PropertyKey::SymbolPlacement, bucket->layout.placement, z); - if (bucket->layout.placement == PlacementType::Line) { - bucket->layout.icon.rotation_alignment = RotationAlignmentType::Map; - bucket->layout.text.rotation_alignment = RotationAlignmentType::Map; + bucket->layout = layout; + + StyleCalculationParameters p(parameters.tileID.z); + bucket->layout.placement.calculate(p); + if (bucket->layout.placement.value == PlacementType::Line) { + bucket->layout.icon.rotationAlignment = RotationAlignmentType::Map; + bucket->layout.text.rotationAlignment = RotationAlignmentType::Map; }; - layout.calculate(PropertyKey::SymbolSpacing, bucket->layout.spacing, z); - layout.calculate(PropertyKey::SymbolAvoidEdges, bucket->layout.avoid_edges, z); + bucket->layout.spacing.calculate(p); + bucket->layout.avoidEdges.calculate(p); - layout.calculate(PropertyKey::IconAllowOverlap, bucket->layout.icon.allow_overlap, z); - layout.calculate(PropertyKey::IconIgnorePlacement, bucket->layout.icon.ignore_placement, z); - layout.calculate(PropertyKey::IconOptional, bucket->layout.icon.optional, z); - layout.calculate(PropertyKey::IconRotationAlignment, bucket->layout.icon.rotation_alignment, z); - layout.calculate(PropertyKey::IconImage, bucket->layout.icon.image, z); - layout.calculate(PropertyKey::IconPadding, bucket->layout.icon.padding, z); - layout.calculate(PropertyKey::IconRotate, bucket->layout.icon.rotate, z); - layout.calculate(PropertyKey::IconKeepUpright, bucket->layout.icon.keep_upright, z); - layout.calculate(PropertyKey::IconOffset, bucket->layout.icon.offset, z); + bucket->layout.icon.allowOverlap.calculate(p); + bucket->layout.icon.ignorePlacement.calculate(p); + bucket->layout.icon.optional.calculate(p); + bucket->layout.icon.rotationAlignment.calculate(p); + bucket->layout.icon.image.calculate(p); + bucket->layout.icon.padding.calculate(p); + bucket->layout.icon.rotate.calculate(p); + bucket->layout.icon.keepUpright.calculate(p); + bucket->layout.icon.offset.calculate(p); - layout.calculate(PropertyKey::TextRotationAlignment, bucket->layout.text.rotation_alignment, z); - layout.calculate(PropertyKey::TextField, bucket->layout.text.field, z); - layout.calculate(PropertyKey::TextFont, bucket->layout.text.font, z); - layout.calculate(PropertyKey::TextMaxWidth, bucket->layout.text.max_width, z); - layout.calculate(PropertyKey::TextLineHeight, bucket->layout.text.line_height, z); - layout.calculate(PropertyKey::TextLetterSpacing, bucket->layout.text.letter_spacing, z); - layout.calculate(PropertyKey::TextMaxAngle, bucket->layout.text.max_angle, z); - layout.calculate(PropertyKey::TextRotate, bucket->layout.text.rotate, z); - layout.calculate(PropertyKey::TextPadding, bucket->layout.text.padding, z); - layout.calculate(PropertyKey::TextIgnorePlacement, bucket->layout.text.ignore_placement, z); - layout.calculate(PropertyKey::TextOptional, bucket->layout.text.optional, z); - layout.calculate(PropertyKey::TextJustify, bucket->layout.text.justify, z); - layout.calculate(PropertyKey::TextAnchor, bucket->layout.text.anchor, z); - layout.calculate(PropertyKey::TextKeepUpright, bucket->layout.text.keep_upright, z); - layout.calculate(PropertyKey::TextTransform, bucket->layout.text.transform, z); - layout.calculate(PropertyKey::TextOffset, bucket->layout.text.offset, z); - layout.calculate(PropertyKey::TextAllowOverlap, bucket->layout.text.allow_overlap, z); + bucket->layout.text.rotationAlignment.calculate(p); + bucket->layout.text.field.calculate(p); + bucket->layout.text.font.calculate(p); + bucket->layout.text.maxWidth.calculate(p); + bucket->layout.text.lineHeight.calculate(p); + bucket->layout.text.letterSpacing.calculate(p); + bucket->layout.text.maxAngle.calculate(p); + bucket->layout.text.rotate.calculate(p); + bucket->layout.text.padding.calculate(p); + bucket->layout.text.ignorePlacement.calculate(p); + bucket->layout.text.optional.calculate(p); + bucket->layout.text.justify.calculate(p); + bucket->layout.text.anchor.calculate(p); + bucket->layout.text.keepUpright.calculate(p); + bucket->layout.text.transform.calculate(p); + bucket->layout.text.offset.calculate(p); + bucket->layout.text.allowOverlap.calculate(p); - layout.calculate(PropertyKey::IconSize, bucket->layout.icon.size, z + 1); - layout.calculate(PropertyKey::IconSize, bucket->layout.icon.max_size, 18); - layout.calculate(PropertyKey::TextSize, bucket->layout.text.size, z + 1); - layout.calculate(PropertyKey::TextSize, bucket->layout.text.max_size, 18); + bucket->layout.icon.size.calculate(StyleCalculationParameters(18)); + bucket->layout.text.size.calculate(StyleCalculationParameters(18)); + bucket->layout.iconMaxSize = bucket->layout.icon.size; + bucket->layout.textMaxSize = bucket->layout.text.size; + bucket->layout.icon.size.calculate(StyleCalculationParameters(p.z + 1)); + bucket->layout.text.size.calculate(StyleCalculationParameters(p.z + 1)); bucket->parseFeatures(parameters.layer, filter); diff --git a/src/mbgl/layer/symbol_layer.hpp b/src/mbgl/layer/symbol_layer.hpp index 4fb662374..3871d7a2d 100644 --- a/src/mbgl/layer/symbol_layer.hpp +++ b/src/mbgl/layer/symbol_layer.hpp @@ -4,10 +4,57 @@ #include #include #include -#include +#include namespace mbgl { +class SymbolLayoutProperties { +public: + LayoutProperty placement = PlacementType::Point; + LayoutProperty spacing = 250.0f; + LayoutProperty avoidEdges = false; + + class IconProperties { + public: + LayoutProperty allowOverlap = false; + LayoutProperty ignorePlacement = false; + LayoutProperty optional = false; + LayoutProperty rotationAlignment = RotationAlignmentType::Viewport; + LayoutProperty size = 1.0f; + LayoutProperty image = { "" }; + LayoutProperty rotate = 0.0f; + LayoutProperty padding = 2.0f; + LayoutProperty keepUpright = false; + LayoutProperty> offset = { {{ 0, 0 }} }; + } icon; + + class TextProperties { + public: + LayoutProperty rotationAlignment = RotationAlignmentType::Viewport; + LayoutProperty field = { "" }; + LayoutProperty font = { "Open Sans Regular, Arial Unicode MS Regular" }; + LayoutProperty size = 16.0f; + LayoutProperty maxWidth = 15.0f /* em */; + LayoutProperty lineHeight = 1.2f /* em */; + LayoutProperty letterSpacing = 0.0f /* em */; + LayoutProperty justify = TextJustifyType::Center; + LayoutProperty anchor = TextAnchorType::Center; + LayoutProperty maxAngle = 45.0f /* degrees */; + LayoutProperty rotate = 0.0f; + LayoutProperty padding = 2.0f; + LayoutProperty keepUpright = true; + LayoutProperty transform = TextTransformType::None; + LayoutProperty> offset = { {{ 0, 0 }} }; + LayoutProperty allowOverlap = false; + LayoutProperty ignorePlacement = false; + LayoutProperty optional = false; + } text; + + // Special case. + float iconMaxSize = 1.0f; + float textMaxSize = 16.0f; +}; + class SymbolLayer : public StyleLayer { public: std::unique_ptr clone() const override; @@ -22,7 +69,7 @@ public: bool hasTransitions() const override; - ClassProperties layout; + SymbolLayoutProperties layout; PaintPropertiesMap paints; SymbolPaintProperties properties; diff --git a/src/mbgl/map/raster_tile_data.cpp b/src/mbgl/map/raster_tile_data.cpp index 775619ff0..f29fa86b8 100644 --- a/src/mbgl/map/raster_tile_data.cpp +++ b/src/mbgl/map/raster_tile_data.cpp @@ -55,7 +55,7 @@ void RasterTileData::request(float pixelRatio, state = State::loaded; } - workRequest = worker.parseRasterTile(std::make_unique(texturePool, layout), res.data, [this, callback] (RasterTileParseResult result) { + workRequest = worker.parseRasterTile(std::make_unique(texturePool), res.data, [this, callback] (RasterTileParseResult result) { workRequest.reset(); if (state != State::loaded) { return; diff --git a/src/mbgl/map/raster_tile_data.hpp b/src/mbgl/map/raster_tile_data.hpp index 64bcb777d..d03e3954b 100644 --- a/src/mbgl/map/raster_tile_data.hpp +++ b/src/mbgl/map/raster_tile_data.hpp @@ -2,7 +2,6 @@ #define MBGL_MAP_RASTER_TILE_DATA #include -#include #include #include @@ -32,7 +31,6 @@ private: Worker& worker; RequestHolder req; - RasterLayoutProperties layout; std::unique_ptr bucket; std::unique_ptr workRequest; diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp index 8b7651e9c..f85c9267d 100644 --- a/src/mbgl/renderer/circle_bucket.hpp +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -8,8 +8,6 @@ #include #include -#include - namespace mbgl { class CircleVertexBuffer; diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 5b60be3c7..1a183265f 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -3,8 +3,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index a7c3f0067..43bb8132d 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -2,8 +2,6 @@ #include #include #include -#include -#include #include #include #include @@ -42,7 +40,7 @@ void LineBucket::addGeometry(const std::vector& vertices) { return; } - const float miterLimit = layout.join == JoinType::Bevel ? 1.05f : layout.miter_limit; + const float miterLimit = layout.join == JoinType::Bevel ? 1.05f : float(layout.miterLimit); const Coordinate firstVertex = vertices.front(); const Coordinate lastVertex = vertices[len - 1]; @@ -54,7 +52,7 @@ void LineBucket::addGeometry(const std::vector& vertices) { } const CapType beginCap = layout.cap; - const CapType endCap = closed ? CapType::Butt : layout.cap; + const CapType endCap = closed ? CapType::Butt : CapType(layout.cap); int8_t flip = 1; double distance = 0; @@ -143,7 +141,7 @@ void LineBucket::addGeometry(const std::vector& vertices) { if (middleVertex) { if (currentJoin == JoinType::Round) { - if (miterLength < layout.round_limit) { + if (miterLength < layout.roundLimit) { currentJoin = JoinType::Miter; } else if (miterLength <= 2) { currentJoin = JoinType::FakeRound; diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp index 98805702c..9a38edbc3 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include #include diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 496b9ee9c..48ed4bd43 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -27,8 +27,7 @@ void Painter::renderSDF(SymbolBucket &bucket, { mat4 vtxMatrix = translatedMatrix(matrix, styleProperties.translate, id, styleProperties.translate_anchor); - bool aligned_with_map = (bucketProperties.rotation_alignment == RotationAlignmentType::Map); - bool skewed = aligned_with_map; + bool skewed = (bucketProperties.rotationAlignment == RotationAlignmentType::Map); mat4 exMatrix; float s; float gammaScale; @@ -160,8 +159,8 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const } // TODO remove the `true ||` when #1673 is implemented - const bool drawAcrossEdges = true || !(layout.text.allow_overlap || layout.icon.allow_overlap || - layout.text.ignore_placement || layout.icon.ignore_placement); + const bool drawAcrossEdges = true || !(layout.text.allowOverlap || layout.icon.allowOverlap || + layout.text.ignorePlacement || layout.icon.ignorePlacement); // Disable the stencil test so that labels aren't clipped to tile boundaries. // @@ -176,7 +175,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const } if (bucket.hasIconData()) { - if (layout.icon.rotation_alignment == RotationAlignmentType::Map) { + if (layout.icon.rotationAlignment == RotationAlignmentType::Map) { config.depthFunc.reset(); config.depthTest = GL_TRUE; } else { @@ -186,7 +185,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const bool sdf = bucket.sdfIcons; const float angleOffset = - layout.icon.rotation_alignment == RotationAlignmentType::Map + layout.icon.rotationAlignment == RotationAlignmentType::Map ? state.getAngle() : 0; @@ -209,7 +208,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const } else { mat4 vtxMatrix = translatedMatrix(matrix, properties.icon.translate, id, properties.icon.translate_anchor); - bool skewed = layout.icon.rotation_alignment == RotationAlignmentType::Map; + bool skewed = layout.icon.rotationAlignment == RotationAlignmentType::Map; mat4 exMatrix; float s; @@ -253,7 +252,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const } if (bucket.hasTextData()) { - if (layout.text.rotation_alignment == RotationAlignmentType::Map) { + if (layout.text.rotationAlignment == RotationAlignmentType::Map) { config.depthFunc.reset(); config.depthTest = GL_TRUE; } else { diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp index d9146f0e8..4a7dfeda0 100644 --- a/src/mbgl/renderer/raster_bucket.cpp +++ b/src/mbgl/renderer/raster_bucket.cpp @@ -5,9 +5,8 @@ using namespace mbgl; -RasterBucket::RasterBucket(TexturePool& texturePool, const RasterLayoutProperties& layout_) -: layout(layout_), - raster(texturePool) { +RasterBucket::RasterBucket(TexturePool& texturePool) +: raster(texturePool) { } void RasterBucket::upload() { diff --git a/src/mbgl/renderer/raster_bucket.hpp b/src/mbgl/renderer/raster_bucket.hpp index 5637c5ae2..2882a94bb 100644 --- a/src/mbgl/renderer/raster_bucket.hpp +++ b/src/mbgl/renderer/raster_bucket.hpp @@ -6,14 +6,13 @@ namespace mbgl { -class RasterLayoutProperties; class RasterShader; class StaticVertexBuffer; class VertexArrayObject; class RasterBucket : public Bucket { public: - RasterBucket(TexturePool&, const RasterLayoutProperties&); + RasterBucket(TexturePool&); void upload() override; void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; @@ -21,8 +20,6 @@ public: bool setImage(std::unique_ptr image); - const RasterLayoutProperties& layout; - void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array); Raster raster; diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 281888d9c..ee42d7f47 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -92,8 +91,8 @@ bool SymbolBucket::hasCollisionBoxData() const { return renderData && !renderDat void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, const FilterExpression& filter) { - const bool has_text = !layout.text.field.empty() && !layout.text.font.empty(); - const bool has_icon = !layout.icon.image.empty(); + const bool has_text = !layout.text.field.value.empty() && !layout.text.font.value.empty(); + const bool has_icon = !layout.icon.image.value.empty(); if (!has_text && !has_icon) { return; @@ -161,11 +160,11 @@ void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, bool SymbolBucket::needsDependencies(GlyphStore& glyphStore, Sprite& sprite) { - if (!layout.text.field.empty() && !layout.text.font.empty() && !glyphStore.hasGlyphRanges(layout.text.font, ranges)) { + if (!layout.text.field.value.empty() && !layout.text.font.value.empty() && !glyphStore.hasGlyphRanges(layout.text.font, ranges)) { return true; } - if (!layout.icon.image.empty() && !sprite.isLoaded()) { + if (!layout.icon.image.value.empty() && !sprite.isLoaded()) { return true; } @@ -232,13 +231,13 @@ void SymbolBucket::addFeatures(uintptr_t tileUID, shapedText = fontStack->getShaping( /* string */ feature.label, /* maxWidth: ems */ layout.placement != PlacementType::Line ? - layout.text.max_width * 24 : 0, - /* lineHeight: ems */ layout.text.line_height * 24, + layout.text.maxWidth * 24 : 0, + /* lineHeight: ems */ layout.text.lineHeight * 24, /* horizontalAlign */ horizontalAlign, /* verticalAlign */ verticalAlign, /* justify */ justify, - /* spacing: ems */ layout.text.letter_spacing * 24, - /* translate */ vec2(layout.text.offset[0], layout.text.offset[1])); + /* spacing: ems */ layout.text.letterSpacing * 24, + /* translate */ vec2(layout.text.offset.value[0], layout.text.offset.value[1])); // Add the glyphs we need for this label to the glyph atlas. if (shapedText) { @@ -278,21 +277,21 @@ void SymbolBucket::addFeature(const std::vector> &lines, const float fontScale = layout.text.size / glyphSize; const float textBoxScale = tilePixelRatio * fontScale; - const float textMaxBoxScale = tilePixelRatio * layout.text.max_size / glyphSize; + const float textMaxBoxScale = tilePixelRatio * layout.textMaxSize / glyphSize; const float iconBoxScale = tilePixelRatio * layout.icon.size; const float symbolSpacing = tilePixelRatio * layout.spacing; - const bool avoidEdges = layout.avoid_edges && layout.placement != PlacementType::Line; + const bool avoidEdges = layout.avoidEdges && layout.placement != PlacementType::Line; const float textPadding = layout.text.padding * tilePixelRatio; const float iconPadding = layout.icon.padding * tilePixelRatio; - const float textMaxAngle = layout.text.max_angle * M_PI / 180; + const float textMaxAngle = layout.text.maxAngle * M_PI / 180; const bool textAlongLine = - layout.text.rotation_alignment == RotationAlignmentType::Map && + layout.text.rotationAlignment == RotationAlignmentType::Map && layout.placement == PlacementType::Line; const bool iconAlongLine = - layout.icon.rotation_alignment == RotationAlignmentType::Map && + layout.icon.rotationAlignment == RotationAlignmentType::Map && layout.placement == PlacementType::Line; - const bool mayOverlap = layout.text.allow_overlap || layout.icon.allow_overlap || - layout.text.ignore_placement || layout.icon.ignore_placement; + const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap || + layout.text.ignorePlacement || layout.icon.ignorePlacement; const bool isLine = layout.placement == PlacementType::Line; const float textRepeatDistance = symbolSpacing / 2; @@ -368,14 +367,14 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile, bool swapImmediat // create the bufers used for rendering. const bool textAlongLine = - layout.text.rotation_alignment == RotationAlignmentType::Map && + layout.text.rotationAlignment == RotationAlignmentType::Map && layout.placement == PlacementType::Line; const bool iconAlongLine = - layout.icon.rotation_alignment == RotationAlignmentType::Map && + layout.icon.rotationAlignment == RotationAlignmentType::Map && layout.placement == PlacementType::Line; - const bool mayOverlap = layout.text.allow_overlap || layout.icon.allow_overlap || - layout.text.ignore_placement || layout.icon.ignore_placement; + const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap || + layout.text.ignorePlacement || layout.icon.ignorePlacement; // Sort symbols by their y position on the canvas so that they lower symbols // are drawn on top of higher symbols. @@ -402,9 +401,9 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile, bool swapImmediat // Calculate the scales at which the text and icon can be placed without collision. - float glyphScale = hasText && !layout.text.allow_overlap ? + float glyphScale = hasText && !layout.text.allowOverlap ? collisionTile.placeFeature(symbolInstance.textCollisionFeature) : collisionTile.minScale; - float iconScale = hasIcon && !layout.icon.allow_overlap ? + float iconScale = hasIcon && !layout.icon.allowOverlap ? collisionTile.placeFeature(symbolInstance.iconCollisionFeature) : collisionTile.minScale; @@ -422,24 +421,24 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile, bool swapImmediat // Insert final placement into collision tree and add glyphs/icons to buffers if (hasText) { - if (!layout.text.ignore_placement) { + if (!layout.text.ignorePlacement) { collisionTile.insertFeature(symbolInstance.textCollisionFeature, glyphScale); } if (glyphScale < collisionTile.maxScale) { addSymbols( renderDataInProgress->text, symbolInstance.glyphQuads, glyphScale, - layout.text.keep_upright, textAlongLine, collisionTile.config.angle); + layout.text.keepUpright, textAlongLine, collisionTile.config.angle); } } if (hasIcon) { - if (!layout.icon.ignore_placement) { + if (!layout.icon.ignorePlacement) { collisionTile.insertFeature(symbolInstance.iconCollisionFeature, iconScale); } if (iconScale < collisionTile.maxScale) { addSymbols( renderDataInProgress->icon, symbolInstance.iconQuads, iconScale, - layout.icon.keep_upright, iconAlongLine, collisionTile.config.angle); + layout.icon.keepUpright, iconAlongLine, collisionTile.config.angle); } } } diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 2c7e2e398..3c6f5f6d2 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp new file mode 100644 index 000000000..5f24e5b13 --- /dev/null +++ b/src/mbgl/style/layout_property.hpp @@ -0,0 +1,38 @@ +#ifndef MBGL_LAYOUT_PROPERTY +#define MBGL_LAYOUT_PROPERTY + +#include +#include + +#include + +namespace mbgl { + +using JSVal = rapidjson::Value; + +template +class LayoutProperty { +public: + LayoutProperty(T v) : value(v) {} + + void parse(const char * name, const JSVal& layout) { + if (layout.HasMember(name)) { + parsedValue = detail::parseProperty>(name, layout[name]); + } + } + + void calculate(const StyleCalculationParameters& parameters) { + if (parsedValue) { + value = (*parsedValue).evaluate(parameters); + } + } + + operator T() const { return value; } + + mapbox::util::optional> parsedValue; + T value; +}; + +} + +#endif diff --git a/src/mbgl/style/property_fallback.cpp b/src/mbgl/style/property_fallback.cpp index d60688855..31e46640b 100644 --- a/src/mbgl/style/property_fallback.cpp +++ b/src/mbgl/style/property_fallback.cpp @@ -27,7 +27,6 @@ const std::map PropertyFallbackValue::properties = { { PropertyKey::CircleBlur, CirclePaintProperties().blur }, { PropertyKey::IconOpacity, SymbolPaintProperties().icon.opacity }, - { PropertyKey::IconSize, SymbolPaintProperties().icon.size }, { PropertyKey::IconColor, SymbolPaintProperties().icon.color }, { PropertyKey::IconHaloColor, SymbolPaintProperties().icon.halo_color }, { PropertyKey::IconHaloWidth, SymbolPaintProperties().icon.halo_width }, @@ -36,7 +35,6 @@ const std::map PropertyFallbackValue::properties = { { PropertyKey::IconTranslateAnchor, SymbolPaintProperties().icon.translate_anchor }, { PropertyKey::TextOpacity, SymbolPaintProperties().text.opacity }, - { PropertyKey::TextSize, SymbolPaintProperties().text.size }, { PropertyKey::TextColor, SymbolPaintProperties().text.color }, { PropertyKey::TextHaloColor, SymbolPaintProperties().text.halo_color }, { PropertyKey::TextHaloWidth, SymbolPaintProperties().text.halo_width }, @@ -54,44 +52,6 @@ const std::map PropertyFallbackValue::properties = { { PropertyKey::BackgroundOpacity, BackgroundPaintProperties().opacity }, { PropertyKey::BackgroundColor, BackgroundPaintProperties().color }, - - { PropertyKey::LineCap, LineLayoutProperties().cap }, - { PropertyKey::LineJoin, LineLayoutProperties().join }, - { PropertyKey::LineMiterLimit, LineLayoutProperties().miter_limit }, - { PropertyKey::LineRoundLimit, LineLayoutProperties().round_limit }, - - { PropertyKey::SymbolPlacement, SymbolLayoutProperties().placement }, - { PropertyKey::SymbolSpacing, SymbolLayoutProperties().spacing }, - { PropertyKey::SymbolAvoidEdges, SymbolLayoutProperties().avoid_edges }, - - { PropertyKey::IconAllowOverlap, SymbolLayoutProperties().icon.allow_overlap }, - { PropertyKey::IconIgnorePlacement, SymbolLayoutProperties().icon.ignore_placement }, - { PropertyKey::IconOptional, SymbolLayoutProperties().icon.optional }, - { PropertyKey::IconRotationAlignment, SymbolLayoutProperties().icon.rotation_alignment }, - { PropertyKey::IconImage, SymbolLayoutProperties().icon.image }, - { PropertyKey::IconRotate, SymbolLayoutProperties().icon.rotate }, - { PropertyKey::IconPadding, SymbolLayoutProperties().icon.padding }, - { PropertyKey::IconKeepUpright, SymbolLayoutProperties().icon.keep_upright }, - { PropertyKey::IconOffset, SymbolLayoutProperties().icon.offset }, - - { PropertyKey::TextRotationAlignment, SymbolLayoutProperties().text.rotation_alignment }, - { PropertyKey::TextField, SymbolLayoutProperties().text.field }, - { PropertyKey::TextFont, SymbolLayoutProperties().text.font }, - { PropertyKey::TextMaxWidth, SymbolLayoutProperties().text.max_width }, - { PropertyKey::TextLineHeight, SymbolLayoutProperties().text.line_height }, - { PropertyKey::TextLetterSpacing, SymbolLayoutProperties().text.letter_spacing }, - { PropertyKey::TextJustify, SymbolLayoutProperties().text.justify }, - { PropertyKey::TextAnchor, SymbolLayoutProperties().text.anchor }, - { PropertyKey::TextMaxAngle, SymbolLayoutProperties().text.max_angle }, - { PropertyKey::TextRotate, SymbolLayoutProperties().text.rotate }, - { PropertyKey::TextPadding, SymbolLayoutProperties().text.padding }, - { PropertyKey::TextKeepUpright, SymbolLayoutProperties().text.keep_upright }, - { PropertyKey::TextTransform, SymbolLayoutProperties().text.transform }, - { PropertyKey::TextOffset, SymbolLayoutProperties().text.offset }, - { PropertyKey::TextAllowOverlap, SymbolLayoutProperties().text.allow_overlap }, - { PropertyKey::TextIgnorePlacement, SymbolLayoutProperties().text.ignore_placement }, - { PropertyKey::TextOptional, SymbolLayoutProperties().text.optional }, - }; const PropertyValue PropertyFallbackValue::defaultProperty = false; diff --git a/src/mbgl/style/property_key.hpp b/src/mbgl/style/property_key.hpp index 4349035f5..f9b6b796c 100644 --- a/src/mbgl/style/property_key.hpp +++ b/src/mbgl/style/property_key.hpp @@ -22,11 +22,6 @@ enum class PropertyKey { LineDashArray, // for transitions only LineImage, - LineCap, - LineJoin, - LineMiterLimit, - LineRoundLimit, - CircleRadius, CircleColor, CircleOpacity, @@ -34,12 +29,7 @@ enum class PropertyKey { CircleTranslateAnchor, CircleBlur, - SymbolPlacement, - SymbolSpacing, - SymbolAvoidEdges, - IconOpacity, - IconSize, IconColor, IconHaloColor, IconHaloWidth, @@ -47,16 +37,6 @@ enum class PropertyKey { IconTranslate, IconTranslateAnchor, - IconAllowOverlap, - IconIgnorePlacement, - IconOptional, - IconRotationAlignment, - IconImage, - IconOffset, - IconPadding, - IconRotate, - IconKeepUpright, - TextOpacity, TextColor, TextHaloColor, @@ -65,25 +45,6 @@ enum class PropertyKey { TextTranslate, TextTranslateAnchor, - TextRotationAlignment, - TextField, - TextFont, - TextSize, - TextMaxWidth, - TextLineHeight, - TextLetterSpacing, - TextMaxAngle, - TextRotate, - TextPadding, - TextIgnorePlacement, - TextOptional, - TextJustify, - TextAnchor, - TextKeepUpright, - TextTransform, - TextOffset, - TextAllowOverlap, - RasterOpacity, RasterHueRotate, RasterBrightness, // for transitions only @@ -96,8 +57,6 @@ enum class PropertyKey { BackgroundOpacity, BackgroundColor, BackgroundImage, - - Visibilty }; } diff --git a/src/mbgl/style/style_properties.cpp b/src/mbgl/style/style_properties.cpp deleted file mode 100644 index 69a9cede5..000000000 --- a/src/mbgl/style/style_properties.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -namespace mbgl { - -} diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 35f224ac1..379a6e71e 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -133,7 +133,7 @@ SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, const bool alongLine, const GlyphPositions& face) { const float textRotate = layout.text.rotate * M_PI / 180; - const bool keepUpright = layout.text.keep_upright; + const bool keepUpright = layout.text.keepUpright; SymbolQuads quads; diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index c3911718e..6709a49aa 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -1,11 +1,11 @@ #include -#include +#include namespace mbgl { PositionedIcon shapeIcon(const Rect& image, const SymbolLayoutProperties& layout) { - float dx = layout.icon.offset[0]; - float dy = layout.icon.offset[1]; + float dx = layout.icon.offset.value[0]; + float dy = layout.icon.offset.value[1]; float x1 = dx - image.originalW / 2.0f; float x2 = x1 + image.originalW; float y1 = dy - image.originalH / 2.0f; diff --git a/test/fixtures/style_parser/text-size.style.json b/test/fixtures/style_parser/text-size.style.json index 8c0076197..ee6a6c39e 100644 --- a/test/fixtures/style_parser/text-size.style.json +++ b/test/fixtures/style_parser/text-size.style.json @@ -13,7 +13,7 @@ "source": "mapbox", "source-layer": "country_label", "filter": ["==", "$type", "Point"], - "paint": { + "layout": { "text-size": null } }]