diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-10-26 10:14:24 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-10 11:33:17 -0800 |
commit | a5625675890213f94de7632d4ef152ade627c9a5 (patch) | |
tree | d6a3f816e80417bbedc16d0b34383d8ee191bf92 /src | |
parent | 728a9858ea88751e74de57694746c2ea1546ce25 (diff) | |
download | qtlocation-mapboxgl-a5625675890213f94de7632d4ef152ade627c9a5.tar.gz |
[core] Eliminate use of ClassProperties for layout
Diffstat (limited to 'src')
31 files changed, 239 insertions, 261 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 4f8504930e..43dfb8361b 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<std::string>("{sprite}")); - layer->layout.set(PropertyKey::IconAllowOverlap, Function<bool>(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 5d5f4e859b..bb6642c600 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<LineLayer> layer = std::make_unique<LineLayer>(); layer->type = StyleLayerType::Line; - - layer->layout.set(PropertyKey::LineJoin, Function<JoinType>(JoinType::Round)); + layer->layout.join = JoinType::Round; const LinePaintProperties& properties = shape.properties.get<LinePaintProperties>(); ClassProperties paintProperties; diff --git a/src/mbgl/layer/background_layer.cpp b/src/mbgl/layer/background_layer.cpp index 67e39a6899..0a86e2db14 100644 --- a/src/mbgl/layer/background_layer.cpp +++ b/src/mbgl/layer/background_layer.cpp @@ -7,7 +7,6 @@ namespace mbgl { std::unique_ptr<StyleLayer> BackgroundLayer::clone() const { std::unique_ptr<BackgroundLayer> result = std::make_unique<BackgroundLayer>(); 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 5a8b3496e4..11d06b2cd2 100644 --- a/src/mbgl/layer/background_layer.hpp +++ b/src/mbgl/layer/background_layer.hpp @@ -4,7 +4,6 @@ #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_properties.hpp> #include <mbgl/style/paint_properties_map.hpp> -#include <mbgl/style/class_properties.hpp> 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 c36d21c088..7680136555 100644 --- a/src/mbgl/layer/circle_layer.cpp +++ b/src/mbgl/layer/circle_layer.cpp @@ -8,7 +8,6 @@ namespace mbgl { std::unique_ptr<StyleLayer> CircleLayer::clone() const { std::unique_ptr<CircleLayer> result = std::make_unique<CircleLayer>(); 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 28943bff64..29cdf513df 100644 --- a/src/mbgl/layer/circle_layer.hpp +++ b/src/mbgl/layer/circle_layer.hpp @@ -4,7 +4,6 @@ #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_properties.hpp> #include <mbgl/style/paint_properties_map.hpp> -#include <mbgl/style/class_properties.hpp> 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 29982d933b..ad68a240fc 100644 --- a/src/mbgl/layer/fill_layer.cpp +++ b/src/mbgl/layer/fill_layer.cpp @@ -8,7 +8,6 @@ namespace mbgl { std::unique_ptr<StyleLayer> FillLayer::clone() const { std::unique_ptr<FillLayer> result = std::make_unique<FillLayer>(); 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 dbab5e9a8b..5a543889c5 100644 --- a/src/mbgl/layer/fill_layer.hpp +++ b/src/mbgl/layer/fill_layer.hpp @@ -4,7 +4,6 @@ #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_properties.hpp> #include <mbgl/style/paint_properties_map.hpp> -#include <mbgl/style/class_properties.hpp> 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 6b98ffa9ad..fa1f22d5f7 100644 --- a/src/mbgl/layer/line_layer.cpp +++ b/src/mbgl/layer/line_layer.cpp @@ -15,10 +15,10 @@ std::unique_ptr<StyleLayer> LineLayer::clone() const { } void LineLayer::parseLayout(const JSVal& value) { - parseProperty<Function<CapType>>("line-cap", PropertyKey::LineCap, layout, value); - parseProperty<Function<JoinType>>("line-join", PropertyKey::LineJoin, layout, value); - parseProperty<Function<float>>("line-miter-limit", PropertyKey::LineMiterLimit, layout, value); - parseProperty<Function<float>>("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<Bucket> LineLayer::createBucket(StyleBucketParameters& parameters) const { auto bucket = std::make_unique<LineBucket>(); - 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 1faf26b28f..d35461131e 100644 --- a/src/mbgl/layer/line_layer.hpp +++ b/src/mbgl/layer/line_layer.hpp @@ -4,10 +4,18 @@ #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_properties.hpp> #include <mbgl/style/paint_properties_map.hpp> -#include <mbgl/style/class_properties.hpp> +#include <mbgl/style/layout_property.hpp> namespace mbgl { +class LineLayoutProperties { +public: + LayoutProperty<CapType> cap = CapType::Butt; + LayoutProperty<JoinType> join = JoinType::Miter; + LayoutProperty<float> miterLimit = 2.0f; + LayoutProperty<float> roundLimit = 1.0f; +}; + class LineLayer : public StyleLayer { public: std::unique_ptr<StyleLayer> 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 f0bc94e3a8..3e3536afc3 100644 --- a/src/mbgl/layer/raster_layer.cpp +++ b/src/mbgl/layer/raster_layer.cpp @@ -7,7 +7,6 @@ namespace mbgl { std::unique_ptr<StyleLayer> RasterLayer::clone() const { std::unique_ptr<RasterLayer> result = std::make_unique<RasterLayer>(); 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 543c6c8d07..650ffc8ef1 100644 --- a/src/mbgl/layer/raster_layer.hpp +++ b/src/mbgl/layer/raster_layer.hpp @@ -4,7 +4,6 @@ #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_properties.hpp> #include <mbgl/style/paint_properties_map.hpp> -#include <mbgl/style/class_properties.hpp> 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 1e06a3ea71..932e500c5e 100644 --- a/src/mbgl/layer/symbol_layer.cpp +++ b/src/mbgl/layer/symbol_layer.cpp @@ -16,45 +16,45 @@ std::unique_ptr<StyleLayer> SymbolLayer::clone() const { } void SymbolLayer::parseLayout(const JSVal& value) { - parseProperty<Function<PlacementType>>("symbol-placement", PropertyKey::SymbolPlacement, layout, value); - parseProperty<Function<float>>("symbol-spacing", PropertyKey::SymbolSpacing, layout, value); - parseProperty<Function<bool>>("symbol-avoid-edges", PropertyKey::SymbolAvoidEdges, layout, value); - parseProperty<Function<bool>>("icon-allow-overlap", PropertyKey::IconAllowOverlap, layout, value); - parseProperty<Function<bool>>("icon-ignore-placement", PropertyKey::IconIgnorePlacement, layout, value); - parseProperty<Function<bool>>("icon-optional", PropertyKey::IconOptional, layout, value); - parseProperty<Function<RotationAlignmentType>>("icon-rotation-alignment", PropertyKey::IconRotationAlignment, layout, value); - parseProperty<Function<float>>("icon-size", PropertyKey::IconSize, layout, value); - parseProperty<Function<std::string>>("icon-image", PropertyKey::IconImage, layout, value); - parseProperty<Function<float>>("icon-rotate", PropertyKey::IconRotate, layout, value); - parseProperty<Function<float>>("icon-padding", PropertyKey::IconPadding, layout, value); - parseProperty<Function<bool>>("icon-keep-upright", PropertyKey::IconKeepUpright, layout, value); - parseProperty<Function<std::array<float, 2>>>("icon-offset", PropertyKey::IconOffset, layout, value); - parseProperty<Function<RotationAlignmentType>>("text-rotation-alignment", PropertyKey::TextRotationAlignment, layout, value); - parseProperty<Function<std::string>>("text-field", PropertyKey::TextField, layout, value); - parseProperty<Function<std::string>>("text-font", PropertyKey::TextFont, layout, value); - parseProperty<Function<float>>("text-size", PropertyKey::TextSize, layout, value); - parseProperty<Function<float>>("text-max-width", PropertyKey::TextMaxWidth, layout, value); - parseProperty<Function<float>>("text-line-height", PropertyKey::TextLineHeight, layout, value); - parseProperty<Function<float>>("text-letter-spacing", PropertyKey::TextLetterSpacing, layout, value); - parseProperty<Function<TextJustifyType>>("text-justify", PropertyKey::TextJustify, layout, value); - parseProperty<Function<TextAnchorType>>("text-anchor", PropertyKey::TextAnchor, layout, value); - parseProperty<Function<float>>("text-max-angle", PropertyKey::TextMaxAngle, layout, value); - parseProperty<Function<float>>("text-rotate", PropertyKey::TextRotate, layout, value); - parseProperty<Function<float>>("text-padding", PropertyKey::TextPadding, layout, value); - parseProperty<Function<bool>>("text-keep-upright", PropertyKey::TextKeepUpright, layout, value); - parseProperty<Function<TextTransformType>>("text-transform", PropertyKey::TextTransform, layout, value); - parseProperty<Function<std::array<float, 2>>>("text-offset", PropertyKey::TextOffset, layout, value); - parseProperty<Function<bool>>("text-allow-overlap", PropertyKey::TextAllowOverlap, layout, value); - parseProperty<Function<bool>>("text-ignore-placement", PropertyKey::TextIgnorePlacement, layout, value); - parseProperty<Function<bool>>("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<Function<float>>("icon-opacity", PropertyKey::IconOpacity, paint, value); parseProperty<PropertyTransition>("icon-opacity-transition", PropertyKey::IconOpacity, paint, value); - parseProperty<Function<float>>("icon-size", PropertyKey::IconSize, paint, value); - parseProperty<PropertyTransition>("icon-size-transition", PropertyKey::IconSize, paint, value); parseProperty<Function<Color>>("icon-color", PropertyKey::IconColor, paint, value); parseProperty<PropertyTransition>("icon-color-transition", PropertyKey::IconColor, paint, value); parseProperty<Function<Color>>("icon-halo-color", PropertyKey::IconHaloColor, paint, value); @@ -69,8 +69,6 @@ void SymbolLayer::parsePaints(const JSVal& layer) { parseProperty<Function<float>>("text-opacity", PropertyKey::TextOpacity, paint, value); parseProperty<PropertyTransition>("text-opacity-transition", PropertyKey::TextOpacity, paint, value); - parseProperty<Function<float>>("text-size", PropertyKey::TextSize, paint, value); - parseProperty<PropertyTransition>("text-size-transition", PropertyKey::TextSize, paint, value); parseProperty<Function<Color>>("text-color", PropertyKey::TextColor, paint, value); parseProperty<PropertyTransition>("text-color-transition", PropertyKey::TextColor, paint, value); parseProperty<Function<Color>>("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<float> 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<float> 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<Bucket> SymbolLayer::createBucket(StyleBucketParameters& parameters) const { - const float z = parameters.tileID.z; - auto bucket = std::make_unique<SymbolBucket>(parameters.tileID.overscaling, z); + auto bucket = std::make_unique<SymbolBucket>(parameters.tileID.overscaling, + parameters.tileID.z); + + bucket->layout = layout; - 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; + 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); - - 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); - - 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); - - 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.spacing.calculate(p); + bucket->layout.avoidEdges.calculate(p); + + 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); + + 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); + + 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 4fb6623742..3871d7a2d4 100644 --- a/src/mbgl/layer/symbol_layer.hpp +++ b/src/mbgl/layer/symbol_layer.hpp @@ -4,10 +4,57 @@ #include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_properties.hpp> #include <mbgl/style/paint_properties_map.hpp> -#include <mbgl/style/class_properties.hpp> +#include <mbgl/style/layout_property.hpp> namespace mbgl { +class SymbolLayoutProperties { +public: + LayoutProperty<PlacementType> placement = PlacementType::Point; + LayoutProperty<float> spacing = 250.0f; + LayoutProperty<bool> avoidEdges = false; + + class IconProperties { + public: + LayoutProperty<bool> allowOverlap = false; + LayoutProperty<bool> ignorePlacement = false; + LayoutProperty<bool> optional = false; + LayoutProperty<RotationAlignmentType> rotationAlignment = RotationAlignmentType::Viewport; + LayoutProperty<float> size = 1.0f; + LayoutProperty<std::string> image = { "" }; + LayoutProperty<float> rotate = 0.0f; + LayoutProperty<float> padding = 2.0f; + LayoutProperty<bool> keepUpright = false; + LayoutProperty<std::array<float, 2>> offset = { {{ 0, 0 }} }; + } icon; + + class TextProperties { + public: + LayoutProperty<RotationAlignmentType> rotationAlignment = RotationAlignmentType::Viewport; + LayoutProperty<std::string> field = { "" }; + LayoutProperty<std::string> font = { "Open Sans Regular, Arial Unicode MS Regular" }; + LayoutProperty<float> size = 16.0f; + LayoutProperty<float> maxWidth = 15.0f /* em */; + LayoutProperty<float> lineHeight = 1.2f /* em */; + LayoutProperty<float> letterSpacing = 0.0f /* em */; + LayoutProperty<TextJustifyType> justify = TextJustifyType::Center; + LayoutProperty<TextAnchorType> anchor = TextAnchorType::Center; + LayoutProperty<float> maxAngle = 45.0f /* degrees */; + LayoutProperty<float> rotate = 0.0f; + LayoutProperty<float> padding = 2.0f; + LayoutProperty<bool> keepUpright = true; + LayoutProperty<TextTransformType> transform = TextTransformType::None; + LayoutProperty<std::array<float, 2>> offset = { {{ 0, 0 }} }; + LayoutProperty<bool> allowOverlap = false; + LayoutProperty<bool> ignorePlacement = false; + LayoutProperty<bool> optional = false; + } text; + + // Special case. + float iconMaxSize = 1.0f; + float textMaxSize = 16.0f; +}; + class SymbolLayer : public StyleLayer { public: std::unique_ptr<StyleLayer> 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 775619ff05..f29fa86b8e 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<RasterBucket>(texturePool, layout), res.data, [this, callback] (RasterTileParseResult result) { + workRequest = worker.parseRasterTile(std::make_unique<RasterBucket>(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 64bcb777db..d03e3954ba 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 <mbgl/map/tile_data.hpp> -#include <mbgl/style/style_properties.hpp> #include <mbgl/renderer/raster_bucket.hpp> #include <mbgl/storage/request_holder.hpp> @@ -32,7 +31,6 @@ private: Worker& worker; RequestHolder req; - RasterLayoutProperties layout; std::unique_ptr<Bucket> bucket; std::unique_ptr<WorkRequest> workRequest; diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp index 8b7651e9c6..f85c9267d3 100644 --- a/src/mbgl/renderer/circle_bucket.hpp +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -8,8 +8,6 @@ #include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/circle_buffer.hpp> -#include <mbgl/style/style_properties.hpp> - namespace mbgl { class CircleVertexBuffer; diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 5b60be3c7c..1a183265f8 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -3,8 +3,6 @@ #include <mbgl/layer/fill_layer.hpp> #include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/renderer/painter.hpp> -#include <mbgl/style/style.hpp> -#include <mbgl/style/style_properties.hpp> #include <mbgl/shader/plain_shader.hpp> #include <mbgl/shader/pattern_shader.hpp> #include <mbgl/shader/outline_shader.hpp> diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index a7c3f00676..43bb8132de 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -2,8 +2,6 @@ #include <mbgl/layer/line_layer.hpp> #include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/renderer/painter.hpp> -#include <mbgl/style/style.hpp> -#include <mbgl/style/style_properties.hpp> #include <mbgl/shader/line_shader.hpp> #include <mbgl/shader/linesdf_shader.hpp> #include <mbgl/shader/linepattern_shader.hpp> @@ -42,7 +40,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& 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<Coordinate>& 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<Coordinate>& 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 98805702c0..9a38edbc31 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -6,8 +6,8 @@ #include <mbgl/geometry/vao.hpp> #include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/line_buffer.hpp> -#include <mbgl/style/style_properties.hpp> #include <mbgl/util/vec.hpp> +#include <mbgl/layer/line_layer.hpp> #include <vector> diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index 496b9ee9cc..48ed4bd43f 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 d9146f0e88..4a7dfeda05 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 5637c5ae26..2882a94bbd 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<util::Image> 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 281888d9c5..ee42d7f47e 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -1,7 +1,6 @@ #include <mbgl/renderer/symbol_bucket.hpp> #include <mbgl/layer/symbol_layer.hpp> #include <mbgl/map/geometry_tile.hpp> -#include <mbgl/style/style_properties.hpp> #include <mbgl/annotation/sprite_image.hpp> #include <mbgl/geometry/text_buffer.hpp> #include <mbgl/geometry/icon_buffer.hpp> @@ -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<float>(layout.text.offset[0], layout.text.offset[1])); + /* spacing: ems */ layout.text.letterSpacing * 24, + /* translate */ vec2<float>(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<std::vector<Coordinate>> &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<SymbolRenderData::TextBuffer, TextElementGroup>( 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<SymbolRenderData::IconBuffer, IconElementGroup>( 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 2c7e2e3980..3c6f5f6d25 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -12,8 +12,8 @@ #include <mbgl/text/collision_feature.hpp> #include <mbgl/text/shaping.hpp> #include <mbgl/text/quads.hpp> -#include <mbgl/style/style_properties.hpp> #include <mbgl/style/filter_expression.hpp> +#include <mbgl/layer/symbol_layer.hpp> #include <memory> #include <map> diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp new file mode 100644 index 0000000000..5f24e5b133 --- /dev/null +++ b/src/mbgl/style/layout_property.hpp @@ -0,0 +1,38 @@ +#ifndef MBGL_LAYOUT_PROPERTY +#define MBGL_LAYOUT_PROPERTY + +#include <mbgl/style/property_parsing.hpp> +#include <mbgl/style/function.hpp> + +#include <rapidjson/document.h> + +namespace mbgl { + +using JSVal = rapidjson::Value; + +template <typename T> +class LayoutProperty { +public: + LayoutProperty(T v) : value(v) {} + + void parse(const char * name, const JSVal& layout) { + if (layout.HasMember(name)) { + parsedValue = detail::parseProperty<Function<T>>(name, layout[name]); + } + } + + void calculate(const StyleCalculationParameters& parameters) { + if (parsedValue) { + value = (*parsedValue).evaluate(parameters); + } + } + + operator T() const { return value; } + + mapbox::util::optional<Function<T>> parsedValue; + T value; +}; + +} + +#endif diff --git a/src/mbgl/style/property_fallback.cpp b/src/mbgl/style/property_fallback.cpp index d606888551..31e46640be 100644 --- a/src/mbgl/style/property_fallback.cpp +++ b/src/mbgl/style/property_fallback.cpp @@ -27,7 +27,6 @@ const std::map<PropertyKey, PropertyValue> 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<PropertyKey, PropertyValue> 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<PropertyKey, PropertyValue> 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 4349035f58..f9b6b796cf 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 69a9cede50..0000000000 --- a/src/mbgl/style/style_properties.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include <mbgl/style/style_properties.hpp> - -namespace mbgl { - -} diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 35f224ac12..379a6e71ee 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -1,7 +1,7 @@ #include <mbgl/text/quads.hpp> #include <mbgl/text/shaping.hpp> #include <mbgl/geometry/anchor.hpp> -#include <mbgl/style/style_properties.hpp> +#include <mbgl/layer/symbol_layer.hpp> #include <mbgl/util/math.hpp> #include <cassert> @@ -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 c3911718e0..6709a49aa2 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -1,11 +1,11 @@ #include <mbgl/text/shaping.hpp> -#include <mbgl/style/style_properties.hpp> +#include <mbgl/layer/symbol_layer.hpp> namespace mbgl { PositionedIcon shapeIcon(const Rect<uint16_t>& 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; |