From df89de5cc5bf043ca2fe57ef4dd9a7b5d25464cb Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 19 Oct 2015 13:19:52 -0700 Subject: [PATCH] [core] Rationalize style property classes: {Paint,Layout}Properties --- android/cpp/jni.cpp | 8 +- include/mbgl/style/style_properties.hpp | 124 ++++++++++---- platform/default/glfw_view.cpp | 4 +- platform/ios/MGLMapView.mm | 8 +- src/mbgl/annotation/shape_annotation_impl.cpp | 14 +- src/mbgl/map/raster_tile_data.hpp | 4 +- src/mbgl/renderer/circle_bucket.hpp | 2 +- src/mbgl/renderer/fill_bucket.cpp | 2 +- src/mbgl/renderer/line_bucket.cpp | 2 +- src/mbgl/renderer/line_bucket.hpp | 4 +- src/mbgl/renderer/painter.cpp | 6 +- src/mbgl/renderer/painter_circle.cpp | 4 +- src/mbgl/renderer/painter_fill.cpp | 4 +- src/mbgl/renderer/painter_line.cpp | 6 +- src/mbgl/renderer/painter_raster.cpp | 2 +- src/mbgl/renderer/painter_symbol.cpp | 6 +- src/mbgl/renderer/raster_bucket.cpp | 2 +- src/mbgl/renderer/raster_bucket.hpp | 6 +- src/mbgl/renderer/symbol_bucket.cpp | 10 +- src/mbgl/renderer/symbol_bucket.hpp | 12 +- src/mbgl/style/property_fallback.cpp | 154 +++++++++--------- src/mbgl/style/style_layer.cpp | 62 +++---- src/mbgl/style/style_layer.hpp | 8 +- src/mbgl/style/style_layout.cpp | 11 -- src/mbgl/style/style_layout.hpp | 110 ------------- src/mbgl/style/style_properties.cpp | 8 - src/mbgl/text/quads.cpp | 12 +- src/mbgl/text/quads.hpp | 12 +- src/mbgl/text/shaping.cpp | 4 +- src/mbgl/text/shaping.hpp | 4 +- test/api/annotations.cpp | 16 +- 31 files changed, 279 insertions(+), 352 deletions(-) delete mode 100644 src/mbgl/style/style_layout.cpp delete mode 100644 src/mbgl/style/style_layout.hpp diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index ac9256bb7..ae1066f38 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -356,11 +356,11 @@ std::pair annotation_std_pair_fr int aS = (strokeColor >> 24) & 0xFF; mbgl::StyleProperties shapeProperties; - mbgl::FillProperties fillProperties; + mbgl::FillPaintProperties fillProperties; fillProperties.opacity = alpha; fillProperties.stroke_color = {{ static_cast(rS) / 255.0f, static_cast(gS) / 255.0f, static_cast(bS) / 255.0f, static_cast(aS) / 255.0f }}; fillProperties.fill_color = {{ static_cast(rF) / 255.0f, static_cast(gF) / 255.0f, static_cast(bF) / 255.0f, static_cast(aF) / 255.0f }}; - shapeProperties.set(fillProperties); + shapeProperties.set(fillProperties); jobject points = env->GetObjectField(polygon, polygonPointsId); mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points); @@ -940,11 +940,11 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr } mbgl::StyleProperties shapeProperties; - mbgl::LineProperties lineProperties; + mbgl::LinePaintProperties lineProperties; lineProperties.opacity = alpha; lineProperties.color = {{ static_cast(r) / 255.0f, static_cast(g) / 255.0f, static_cast(b) / 255.0f, static_cast(a) / 255.0f }}; lineProperties.width = width; - shapeProperties.set(lineProperties); + shapeProperties.set(lineProperties); jobject points = env->GetObjectField(polyline, polylinePointsId); mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points); diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp index c0ecc3520..aacac3387 100644 --- a/include/mbgl/style/style_properties.hpp +++ b/include/mbgl/style/style_properties.hpp @@ -13,8 +13,8 @@ namespace mbgl { -struct FillProperties { - FillProperties() {} +class FillPaintProperties { +public: bool antialias = true; float opacity = 1.0f; Color fill_color = {{ 0, 0, 0, 1 }}; @@ -28,8 +28,12 @@ struct FillProperties { } }; -struct LineProperties { - inline LineProperties() {} +class FillLayoutProperties { +public: +}; + +class LinePaintProperties { +public: float opacity = 1.0f; Color color = {{ 0, 0, 0, 1 }}; std::array translate = {{ 0, 0 }}; @@ -46,23 +50,16 @@ struct LineProperties { } }; -struct CircleProperties { - inline CircleProperties() {} - float radius = 5.0f; - Color color = {{ 0, 0, 0, 1 }}; - float opacity = 1.0f; - std::array translate = {{ 0, 0 }}; - TranslateAnchorType translateAnchor = TranslateAnchorType::Map; - float blur = 0; - - inline bool isVisible() const { - return radius > 0 && color[3] > 0 && opacity > 0; - } +class LineLayoutProperties { +public: + CapType cap = CapType::Butt; + JoinType join = JoinType::Miter; + float miter_limit = 2.0f; + float round_limit = 1.0f; }; -struct SymbolProperties { - inline SymbolProperties() {} - +class SymbolPaintProperties { +public: struct { float opacity = 1.0f; float size = 1.0f; @@ -91,8 +88,66 @@ struct SymbolProperties { } }; -struct RasterProperties { - inline RasterProperties() {} +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; + Color color = {{ 0, 0, 0, 1 }}; + float opacity = 1.0f; + std::array translate = {{ 0, 0 }}; + TranslateAnchorType translateAnchor = TranslateAnchorType::Map; + float blur = 0; + + inline bool isVisible() const { + return radius > 0 && color[3] > 0 && opacity > 0; + } +}; + +class RasterPaintProperties { +public: float opacity = 1.0f; float hue_rotate = 0.0f; std::array brightness = {{ 0, 1 }}; @@ -105,26 +160,31 @@ struct RasterProperties { } }; -struct BackgroundProperties { - inline BackgroundProperties() {} +class RasterLayoutProperties { +public: +}; + +class BackgroundPaintProperties { +public: float opacity = 1.0f; Color color = {{ 0, 0, 0, 1 }}; Faded image; }; +class BackgroundLayoutProperties { +public: +}; + typedef mapbox::util::variant< - FillProperties, - LineProperties, - CircleProperties, - SymbolProperties, - RasterProperties, - BackgroundProperties, + FillPaintProperties, + LinePaintProperties, + CirclePaintProperties, + SymbolPaintProperties, + RasterPaintProperties, + BackgroundPaintProperties, std::false_type > StyleProperties; -template -const T &defaultStyleProperties(); - } #endif diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index cf7bb0121..78461462d 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -223,11 +223,11 @@ void GLFWView::addRandomPointAnnotations(int count) { void GLFWView::addRandomShapeAnnotations(int count) { std::vector shapes; - mbgl::FillProperties fillProperties; + mbgl::FillPaintProperties fillProperties; fillProperties.opacity = .1; mbgl::StyleProperties properties; - properties.set(fillProperties); + properties.set(fillProperties); for (int i = 0; i < count; i++) { mbgl::AnnotationSegment triangle; diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index ae9411dfc..4165cd397 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -2175,11 +2175,11 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) [self.delegate mapView:self lineWidthForPolylineAnnotation:(MGLPolyline *)annotation] : 3.0); - mbgl::LineProperties lineProperties; + mbgl::LinePaintProperties lineProperties; lineProperties.opacity = alpha; lineProperties.color = strokeNativeColor; lineProperties.width = lineWidth; - shapeProperties.set(lineProperties); + shapeProperties.set(lineProperties); } else if ([annotation isKindOfClass:[MGLPolygon class]]) @@ -2193,11 +2193,11 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) [fillColor getRed:&r green:&g blue:&b alpha:&a]; mbgl::Color fillNativeColor({{ (float)r, (float)g, (float)b, (float)a }}); - mbgl::FillProperties fillProperties; + mbgl::FillPaintProperties fillProperties; fillProperties.opacity = alpha; fillProperties.stroke_color = strokeNativeColor; fillProperties.fill_color = fillNativeColor; - shapeProperties.set(fillProperties); + shapeProperties.set(fillProperties); } else { diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index e17509d66..74daf849e 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -33,7 +33,7 @@ ShapeAnnotationImpl::ShapeAnnotationImpl(const AnnotationID id_, ProjectedFeatureType featureType; - if (shape.styleProperties.is()) { + if (shape.styleProperties.is()) { featureType = ProjectedFeatureType::Polygon; if (points.front().lon != points.back().lon || points.front().lat != points.back().lat) { @@ -57,13 +57,13 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { ClassProperties paintProperties; - if (shape.styleProperties.is()) { - const LineProperties& lineProperties = shape.styleProperties.get(); + if (shape.styleProperties.is()) { + const LinePaintProperties& lineProperties = shape.styleProperties.get(); paintProperties.set(PropertyKey::LineOpacity, ConstantFunction(lineProperties.opacity)); paintProperties.set(PropertyKey::LineWidth, ConstantFunction(lineProperties.width)); paintProperties.set(PropertyKey::LineColor, ConstantFunction(lineProperties.color)); - } else if (shape.styleProperties.is()) { - const FillProperties& fillProperties = shape.styleProperties.get(); + } else if (shape.styleProperties.is()) { + const FillPaintProperties& fillProperties = shape.styleProperties.get(); paintProperties.set(PropertyKey::FillOpacity, ConstantFunction(fillProperties.opacity)); paintProperties.set(PropertyKey::FillColor, ConstantFunction(fillProperties.fill_color)); paintProperties.set(PropertyKey::FillOutlineColor, ConstantFunction(fillProperties.stroke_color)); @@ -72,13 +72,13 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { std::map shapePaints; shapePaints.emplace(ClassID::Default, std::move(paintProperties)); std::unique_ptr shapeLayer = std::make_unique(layerID, std::move(shapePaints)); - shapeLayer->type = (shape.styleProperties.is() ? StyleLayerType::Line : StyleLayerType::Fill); + shapeLayer->type = (shape.styleProperties.is() ? StyleLayerType::Line : StyleLayerType::Fill); util::ptr shapeBucket = std::make_shared(shapeLayer->type); shapeBucket->name = shapeLayer->id; shapeBucket->source = AnnotationManager::SourceID; shapeBucket->source_layer = shapeLayer->id; - if (shape.styleProperties.is()) { + if (shape.styleProperties.is()) { shapeBucket->layout.set(PropertyKey::LineJoin, ConstantFunction(JoinType::Round)); } diff --git a/src/mbgl/map/raster_tile_data.hpp b/src/mbgl/map/raster_tile_data.hpp index 93d018bce..f5711e506 100644 --- a/src/mbgl/map/raster_tile_data.hpp +++ b/src/mbgl/map/raster_tile_data.hpp @@ -2,7 +2,7 @@ #define MBGL_MAP_RASTER_TILE_DATA #include -#include +#include #include namespace mbgl { @@ -30,7 +30,7 @@ private: Worker& worker; Request* req = nullptr; - StyleLayoutRaster layout; + RasterLayoutProperties layout; RasterBucket bucket; std::unique_ptr workRequest; diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp index d7908cf02..a83d158cb 100644 --- a/src/mbgl/renderer/circle_bucket.hpp +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace mbgl { diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 0fbb02e7c..38582c012 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -3,7 +3,7 @@ #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 8824b6fed..d2d7650d7 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp index ce93cb76f..2e220829b 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -52,7 +52,7 @@ private: std::vector& triangleStore); public: - StyleLayoutLine layout; + LineLayoutProperties layout; private: LineVertexBuffer vertexBuffer; diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 5670c4098..d5dfed442 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -303,8 +303,8 @@ std::vector Painter::determineRenderOrder(const Style& style) { if (layer.bucket->visibility == VisibilityType::None) continue; if (layer.type == StyleLayerType::Background) { // This layer defines a background color/image. - if (layer.properties.is()) { - auto &props = layer.properties.get(); + if (layer.properties.is()) { + auto& props = layer.properties.get(); if (props.image.from.empty()) { // This is a solid background. We can use glClear(). background = props.color; @@ -381,7 +381,7 @@ std::vector Painter::determineRenderOrder(const Style& style) { void Painter::renderBackground(const StyleLayer &layer_desc) { // Note: This function is only called for textured background. Otherwise, the background color // is created with glClear. - const BackgroundProperties& properties = layer_desc.getProperties(); + const BackgroundPaintProperties& properties = layer_desc.getProperties(); if (!properties.image.to.empty()) { if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque)) diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp index 538ba9e6a..a7aa6ac45 100644 --- a/src/mbgl/renderer/painter_circle.cpp +++ b/src/mbgl/renderer/painter_circle.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -22,7 +22,7 @@ void Painter::renderCircle(CircleBucket& bucket, config.stencilTest = false; - const CircleProperties& properties = layer_desc.getProperties(); + const CirclePaintProperties& properties = layer_desc.getProperties(); mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); Color color = properties.color; diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp index d27feb469..33fc14a0d 100644 --- a/src/mbgl/renderer/painter_fill.cpp +++ b/src/mbgl/renderer/painter_fill.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -14,7 +14,7 @@ using namespace mbgl; void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const TileID& id, const mat4 &matrix) { - const FillProperties &properties = layer_desc.getProperties(); + const FillPaintProperties& properties = layer_desc.getProperties(); mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); Color fill_color = properties.fill_color; diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp index 258bab6ae..fdbe690f7 100644 --- a/src/mbgl/renderer/painter_line.cpp +++ b/src/mbgl/renderer/painter_line.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -23,8 +23,8 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const config.depthTest = true; config.depthMask = GL_FALSE; - const auto &properties = layer_desc.getProperties(); - const auto &layout = bucket.layout; + const auto& properties = layer_desc.getProperties(); + const auto& layout = bucket.layout; // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp index 70cbcb4ca..f05256318 100644 --- a/src/mbgl/renderer/painter_raster.cpp +++ b/src/mbgl/renderer/painter_raster.cpp @@ -9,7 +9,7 @@ using namespace mbgl; void Painter::renderRaster(RasterBucket& bucket, const StyleLayer &layer_desc, const TileID&, const mat4 &matrix) { if (pass != RenderPass::Translucent) return; - const RasterProperties &properties = layer_desc.getProperties(); + const RasterPaintProperties& properties = layer_desc.getProperties(); if (bucket.hasData()) { useProgram(rasterShader->program); diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index c6ea37239..f1ebef398 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -132,8 +132,8 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c return; } - const auto &properties = layer_desc.getProperties(); - const auto &layout = bucket.layout; + const auto& properties = layer_desc.getProperties(); + const auto& layout = bucket.layout; config.depthMask = GL_FALSE; diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp index cf72f860a..9f28dfd32 100644 --- a/src/mbgl/renderer/raster_bucket.cpp +++ b/src/mbgl/renderer/raster_bucket.cpp @@ -4,7 +4,7 @@ using namespace mbgl; -RasterBucket::RasterBucket(TexturePool& texturePool, const StyleLayoutRaster& layout_) +RasterBucket::RasterBucket(TexturePool& texturePool, const RasterLayoutProperties& layout_) : layout(layout_), raster(texturePool) { } diff --git a/src/mbgl/renderer/raster_bucket.hpp b/src/mbgl/renderer/raster_bucket.hpp index 3c8730e61..a20828102 100644 --- a/src/mbgl/renderer/raster_bucket.hpp +++ b/src/mbgl/renderer/raster_bucket.hpp @@ -7,14 +7,14 @@ namespace mbgl { -class StyleLayoutRaster; +class RasterLayoutProperties; class RasterShader; class StaticVertexBuffer; class VertexArrayObject; class RasterBucket : public Bucket { public: - RasterBucket(TexturePool&, const StyleLayoutRaster&); + RasterBucket(TexturePool&, const RasterLayoutProperties&); void upload() override; void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; @@ -22,7 +22,7 @@ public: bool setImage(std::unique_ptr image); - const StyleLayoutRaster &layout; + const RasterLayoutProperties& layout; void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array); diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index dabffa14f..a56a926b7 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -27,12 +27,12 @@ namespace mbgl { -SymbolInstance::SymbolInstance(Anchor &anchor, const std::vector &line, - const Shaping &shapedText, const PositionedIcon &shapedIcon, - const StyleLayoutSymbol &layout, const bool addToBuffers, +SymbolInstance::SymbolInstance(Anchor& anchor, const std::vector& line, + const Shaping& shapedText, const PositionedIcon& shapedIcon, + const SymbolLayoutProperties& layout, const bool addToBuffers, const float textBoxScale, const float textPadding, const float textAlongLine, const float iconBoxScale, const float iconPadding, const float iconAlongLine, - const GlyphPositions &face) : + const GlyphPositions& face) : x(anchor.x), y(anchor.y), hasText(shapedText), diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index c8264bc43..c3c39627c 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -42,12 +42,12 @@ struct Anchor; class SymbolInstance { public: - explicit SymbolInstance(Anchor &anchor, const std::vector &line, - const Shaping &shapedText, const PositionedIcon &shapedIcon, - const StyleLayoutSymbol &layout, const bool inside, + explicit SymbolInstance(Anchor& anchor, const std::vector& line, + const Shaping& shapedText, const PositionedIcon& shapedIcon, + const SymbolLayoutProperties& layout, const bool inside, const float textBoxScale, const float textPadding, const float textAlongLine, const float iconBoxScale, const float iconPadding, const float iconAlongLine, - const GlyphPositions &face); + const GlyphPositions& face); float x; float y; bool hasText; @@ -109,7 +109,7 @@ private: const bool keepUpright, const bool alongLine, const float placementAngle); public: - StyleLayoutSymbol layout; + SymbolLayoutProperties layout; bool sdfIcons = false; private: diff --git a/src/mbgl/style/property_fallback.cpp b/src/mbgl/style/property_fallback.cpp index 0c4a01ef4..4b60b7939 100644 --- a/src/mbgl/style/property_fallback.cpp +++ b/src/mbgl/style/property_fallback.cpp @@ -1,98 +1,98 @@ #include #include #include -#include +#include namespace mbgl { const std::map PropertyFallbackValue::properties = { - { PropertyKey::FillAntialias, defaultStyleProperties().antialias }, - { PropertyKey::FillOpacity, defaultStyleProperties().opacity }, - { PropertyKey::FillColor, defaultStyleProperties().fill_color }, + { PropertyKey::FillAntialias, FillPaintProperties().antialias }, + { PropertyKey::FillOpacity, FillPaintProperties().opacity }, + { PropertyKey::FillColor, FillPaintProperties().fill_color }, // no FillOutlineColor on purpose. - { PropertyKey::FillTranslate, defaultStyleProperties().translate }, - { PropertyKey::FillTranslateAnchor, defaultStyleProperties().translateAnchor }, + { PropertyKey::FillTranslate, FillPaintProperties().translate }, + { PropertyKey::FillTranslateAnchor, FillPaintProperties().translateAnchor }, - { PropertyKey::LineOpacity, defaultStyleProperties().opacity }, - { PropertyKey::LineColor, defaultStyleProperties().color }, - { PropertyKey::LineTranslate, defaultStyleProperties().translate }, - { PropertyKey::LineTranslateAnchor, defaultStyleProperties().translateAnchor }, - { PropertyKey::LineWidth, defaultStyleProperties().width }, - { PropertyKey::LineGapWidth, defaultStyleProperties().gap_width }, - { PropertyKey::LineBlur, defaultStyleProperties().blur }, + { PropertyKey::LineOpacity, LinePaintProperties().opacity }, + { PropertyKey::LineColor, LinePaintProperties().color }, + { PropertyKey::LineTranslate, LinePaintProperties().translate }, + { PropertyKey::LineTranslateAnchor, LinePaintProperties().translateAnchor }, + { PropertyKey::LineWidth, LinePaintProperties().width }, + { PropertyKey::LineGapWidth, LinePaintProperties().gap_width }, + { PropertyKey::LineBlur, LinePaintProperties().blur }, - { PropertyKey::CircleRadius, defaultStyleProperties().radius }, - { PropertyKey::CircleColor, defaultStyleProperties().color }, - { PropertyKey::CircleOpacity, defaultStyleProperties().opacity }, - { PropertyKey::CircleTranslate, defaultStyleProperties().translate }, - { PropertyKey::CircleTranslateAnchor, defaultStyleProperties().translateAnchor }, - { PropertyKey::CircleBlur, defaultStyleProperties().blur }, + { PropertyKey::CircleRadius, CirclePaintProperties().radius }, + { PropertyKey::CircleColor, CirclePaintProperties().color }, + { PropertyKey::CircleOpacity, CirclePaintProperties().opacity }, + { PropertyKey::CircleTranslate, CirclePaintProperties().translate }, + { PropertyKey::CircleTranslateAnchor, CirclePaintProperties().translateAnchor }, + { PropertyKey::CircleBlur, CirclePaintProperties().blur }, - { PropertyKey::IconOpacity, defaultStyleProperties().icon.opacity }, - { PropertyKey::IconSize, defaultStyleProperties().icon.size }, - { PropertyKey::IconColor, defaultStyleProperties().icon.color }, - { PropertyKey::IconHaloColor, defaultStyleProperties().icon.halo_color }, - { PropertyKey::IconHaloWidth, defaultStyleProperties().icon.halo_width }, - { PropertyKey::IconHaloBlur, defaultStyleProperties().icon.halo_blur }, - { PropertyKey::IconTranslate, defaultStyleProperties().icon.translate }, - { PropertyKey::IconTranslateAnchor, defaultStyleProperties().icon.translate_anchor }, + { 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 }, + { PropertyKey::IconHaloBlur, SymbolPaintProperties().icon.halo_blur }, + { PropertyKey::IconTranslate, SymbolPaintProperties().icon.translate }, + { PropertyKey::IconTranslateAnchor, SymbolPaintProperties().icon.translate_anchor }, - { PropertyKey::TextOpacity, defaultStyleProperties().text.opacity }, - { PropertyKey::TextSize, defaultStyleProperties().text.size }, - { PropertyKey::TextColor, defaultStyleProperties().text.color }, - { PropertyKey::TextHaloColor, defaultStyleProperties().text.halo_color }, - { PropertyKey::TextHaloWidth, defaultStyleProperties().text.halo_width }, - { PropertyKey::TextHaloBlur, defaultStyleProperties().text.halo_blur }, - { PropertyKey::TextTranslate, defaultStyleProperties().text.translate }, - { PropertyKey::TextTranslateAnchor, defaultStyleProperties().text.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 }, + { PropertyKey::TextHaloBlur, SymbolPaintProperties().text.halo_blur }, + { PropertyKey::TextTranslate, SymbolPaintProperties().text.translate }, + { PropertyKey::TextTranslateAnchor, SymbolPaintProperties().text.translate_anchor }, - { PropertyKey::RasterOpacity, defaultStyleProperties().opacity }, - { PropertyKey::RasterHueRotate, defaultStyleProperties().hue_rotate }, - { PropertyKey::RasterBrightnessLow, defaultStyleProperties().brightness[0] }, - { PropertyKey::RasterBrightnessHigh, defaultStyleProperties().brightness[1] }, - { PropertyKey::RasterSaturation, defaultStyleProperties().saturation }, - { PropertyKey::RasterContrast, defaultStyleProperties().contrast }, - { PropertyKey::RasterFade, defaultStyleProperties().fade }, + { PropertyKey::RasterOpacity, RasterPaintProperties().opacity }, + { PropertyKey::RasterHueRotate, RasterPaintProperties().hue_rotate }, + { PropertyKey::RasterBrightnessLow, RasterPaintProperties().brightness[0] }, + { PropertyKey::RasterBrightnessHigh, RasterPaintProperties().brightness[1] }, + { PropertyKey::RasterSaturation, RasterPaintProperties().saturation }, + { PropertyKey::RasterContrast, RasterPaintProperties().contrast }, + { PropertyKey::RasterFade, RasterPaintProperties().fade }, - { PropertyKey::BackgroundOpacity, defaultStyleProperties().opacity }, - { PropertyKey::BackgroundColor, defaultStyleProperties().color }, + { PropertyKey::BackgroundOpacity, BackgroundPaintProperties().opacity }, + { PropertyKey::BackgroundColor, BackgroundPaintProperties().color }, - { PropertyKey::LineCap, defaultStyleLayout().cap }, - { PropertyKey::LineJoin, defaultStyleLayout().join }, - { PropertyKey::LineMiterLimit, defaultStyleLayout().miter_limit }, - { PropertyKey::LineRoundLimit, defaultStyleLayout().round_limit }, + { PropertyKey::LineCap, LineLayoutProperties().cap }, + { PropertyKey::LineJoin, LineLayoutProperties().join }, + { PropertyKey::LineMiterLimit, LineLayoutProperties().miter_limit }, + { PropertyKey::LineRoundLimit, LineLayoutProperties().round_limit }, - { PropertyKey::SymbolPlacement, defaultStyleLayout().placement }, - { PropertyKey::SymbolSpacing, defaultStyleLayout().spacing }, - { PropertyKey::SymbolAvoidEdges, defaultStyleLayout().avoid_edges }, + { PropertyKey::SymbolPlacement, SymbolLayoutProperties().placement }, + { PropertyKey::SymbolSpacing, SymbolLayoutProperties().spacing }, + { PropertyKey::SymbolAvoidEdges, SymbolLayoutProperties().avoid_edges }, - { PropertyKey::IconAllowOverlap, defaultStyleLayout().icon.allow_overlap }, - { PropertyKey::IconIgnorePlacement, defaultStyleLayout().icon.ignore_placement }, - { PropertyKey::IconOptional, defaultStyleLayout().icon.optional }, - { PropertyKey::IconRotationAlignment, defaultStyleLayout().icon.rotation_alignment }, - { PropertyKey::IconImage, defaultStyleLayout().icon.image }, - { PropertyKey::IconRotate, defaultStyleLayout().icon.rotate }, - { PropertyKey::IconPadding, defaultStyleLayout().icon.padding }, - { PropertyKey::IconKeepUpright, defaultStyleLayout().icon.keep_upright }, - { PropertyKey::IconOffset, defaultStyleLayout().icon.offset }, + { 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, defaultStyleLayout().text.rotation_alignment }, - { PropertyKey::TextField, defaultStyleLayout().text.field }, - { PropertyKey::TextFont, defaultStyleLayout().text.font }, - { PropertyKey::TextMaxWidth, defaultStyleLayout().text.max_width }, - { PropertyKey::TextLineHeight, defaultStyleLayout().text.line_height }, - { PropertyKey::TextLetterSpacing, defaultStyleLayout().text.letter_spacing }, - { PropertyKey::TextJustify, defaultStyleLayout().text.justify }, - { PropertyKey::TextAnchor, defaultStyleLayout().text.anchor }, - { PropertyKey::TextMaxAngle, defaultStyleLayout().text.max_angle }, - { PropertyKey::TextRotate, defaultStyleLayout().text.rotate }, - { PropertyKey::TextPadding, defaultStyleLayout().text.padding }, - { PropertyKey::TextKeepUpright, defaultStyleLayout().text.keep_upright }, - { PropertyKey::TextTransform, defaultStyleLayout().text.transform }, - { PropertyKey::TextOffset, defaultStyleLayout().text.offset }, - { PropertyKey::TextAllowOverlap, defaultStyleLayout().text.allow_overlap }, - { PropertyKey::TextIgnorePlacement, defaultStyleLayout().text.ignore_placement }, - { PropertyKey::TextOptional, defaultStyleLayout().text.optional }, + { 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 }, }; diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp index 8ab5b3e50..17c6fa938 100644 --- a/src/mbgl/style/style_layer.cpp +++ b/src/mbgl/style/style_layer.cpp @@ -16,15 +16,15 @@ bool StyleLayer::isBackground() const { bool StyleLayer::isVisible() const { switch (type) { case StyleLayerType::Fill: - return getProperties().isVisible(); + return getProperties().isVisible(); case StyleLayerType::Line: - return getProperties().isVisible(); + return getProperties().isVisible(); case StyleLayerType::Circle: - return getProperties().isVisible(); + return getProperties().isVisible(); case StyleLayerType::Symbol: - return getProperties().isVisible(); + return getProperties().isVisible(); case StyleLayerType::Raster: - return getProperties().isVisible(); + return getProperties().isVisible(); default: return false; } @@ -189,9 +189,9 @@ void StyleLayer::applyTransitionedStyleProperty(PropertyKey key, T &target, cons } template <> -void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { - properties.set(); - FillProperties &fill = properties.get(); +void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { + properties.set(); + FillPaintProperties& fill = properties.get(); applyStyleProperty(PropertyKey::FillAntialias, fill.antialias, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::FillOpacity, fill.opacity, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::FillColor, fill.fill_color, z, now, zoomHistory); @@ -202,9 +202,9 @@ void StyleLayer::applyStyleProperties(const float z, const TimeP } template <> -void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { - properties.set(); - LineProperties &line = properties.get(); +void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { + properties.set(); + LinePaintProperties& line = properties.get(); applyTransitionedStyleProperty(PropertyKey::LineOpacity, line.opacity, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::LineColor, line.color, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::LineTranslate, line.translate, z, now, zoomHistory); @@ -220,9 +220,9 @@ void StyleLayer::applyStyleProperties(const float z, const TimeP } template <> -void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { - properties.set(); - CircleProperties& circle = properties.get(); +void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { + properties.set(); + CirclePaintProperties& circle = properties.get(); applyTransitionedStyleProperty(PropertyKey::CircleRadius, circle.radius, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::CircleColor, circle.color, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::CircleOpacity, circle.opacity, z, now, zoomHistory); @@ -232,9 +232,9 @@ void StyleLayer::applyStyleProperties(const float z, const Tim } template <> -void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { - properties.set(); - SymbolProperties &symbol = properties.get(); +void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { + properties.set(); + SymbolPaintProperties& symbol = properties.get(); applyTransitionedStyleProperty(PropertyKey::IconOpacity, symbol.icon.opacity, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::IconColor, symbol.icon.color, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::IconHaloColor, symbol.icon.halo_color, z, now, zoomHistory); @@ -265,9 +265,9 @@ void StyleLayer::applyStyleProperties(const float z, const Tim } template <> -void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { - properties.set(); - RasterProperties &raster = properties.get(); +void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { + properties.set(); + RasterPaintProperties& raster = properties.get(); applyTransitionedStyleProperty(PropertyKey::RasterOpacity, raster.opacity, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::RasterHueRotate, raster.hue_rotate, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::RasterBrightnessLow, raster.brightness[0], z, now, zoomHistory); @@ -278,9 +278,9 @@ void StyleLayer::applyStyleProperties(const float z, const Tim } template <> -void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { - properties.set(); - BackgroundProperties &background = properties.get(); +void StyleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory &zoomHistory) { + properties.set(); + BackgroundPaintProperties& background = properties.get(); applyTransitionedStyleProperty(PropertyKey::BackgroundOpacity, background.opacity, z, now, zoomHistory); applyTransitionedStyleProperty(PropertyKey::BackgroundColor, background.color, z, now, zoomHistory); applyStyleProperty(PropertyKey::BackgroundImage, background.image, z, now, zoomHistory); @@ -293,20 +293,20 @@ void StyleLayer::updateProperties(float z, const TimePoint& now, ZoomHistory &zo hasPendingTransitions = false; switch (type) { - case StyleLayerType::Fill: applyStyleProperties(z, now, zoomHistory); break; - case StyleLayerType::Line: applyStyleProperties(z, now, zoomHistory); break; - case StyleLayerType::Circle: applyStyleProperties(z, now, zoomHistory); break; - case StyleLayerType::Symbol: applyStyleProperties(z, now, zoomHistory); break; - case StyleLayerType::Raster: applyStyleProperties(z, now, zoomHistory); break; - case StyleLayerType::Background: applyStyleProperties(z, now, zoomHistory); break; + case StyleLayerType::Fill: applyStyleProperties(z, now, zoomHistory); break; + case StyleLayerType::Line: applyStyleProperties(z, now, zoomHistory); break; + case StyleLayerType::Circle: applyStyleProperties(z, now, zoomHistory); break; + case StyleLayerType::Symbol: applyStyleProperties(z, now, zoomHistory); break; + case StyleLayerType::Raster: applyStyleProperties(z, now, zoomHistory); break; + case StyleLayerType::Background: applyStyleProperties(z, now, zoomHistory); break; default: properties.set(); break; } // Update the render passes when this layer is visible. passes = RenderPass::None; if (isVisible()) { - if (properties.is()) { - const FillProperties &fillProperties = properties.get(); + if (properties.is()) { + const FillPaintProperties &fillProperties = properties.get(); const float alpha = fillProperties.fill_color[3] * fillProperties.opacity; if (fillProperties.antialias) { diff --git a/src/mbgl/style/style_layer.hpp b/src/mbgl/style/style_layer.hpp index 28d3f5ca9..fdba82764 100644 --- a/src/mbgl/style/style_layer.hpp +++ b/src/mbgl/style/style_layer.hpp @@ -26,12 +26,8 @@ class StyleLayer : public util::noncopyable { public: StyleLayer(const std::string &id, std::map &&styles); - template const T &getProperties() const { - if (properties.is()) { - return properties.get(); - } else { - return defaultStyleProperties(); - } + template const T& getProperties() const { + return properties.get(); } // Determines whether this layer is the background layer. diff --git a/src/mbgl/style/style_layout.cpp b/src/mbgl/style/style_layout.cpp deleted file mode 100644 index 1071c8b73..000000000 --- a/src/mbgl/style/style_layout.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -namespace mbgl { - -template<> const StyleLayoutFill &defaultStyleLayout() { static StyleLayoutFill p; return p; } -template<> const StyleLayoutLine &defaultStyleLayout() { static StyleLayoutLine p; return p; } -template<> const StyleLayoutSymbol &defaultStyleLayout() { static StyleLayoutSymbol p; return p; } -template<> const StyleLayoutRaster &defaultStyleLayout() { static StyleLayoutRaster p; return p; } -template<> const StyleLayoutBackground &defaultStyleLayout() { static StyleLayoutBackground p; return p; } - -} \ No newline at end of file diff --git a/src/mbgl/style/style_layout.hpp b/src/mbgl/style/style_layout.hpp deleted file mode 100644 index 6db8ce193..000000000 --- a/src/mbgl/style/style_layout.hpp +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_LAYOUT -#define MBGL_STYLE_STYLE_LAYOUT - -#include - -namespace mbgl { - -class Source; - -class StyleLayoutFill { -public: - // Make movable only. - StyleLayoutFill() = default; - StyleLayoutFill(StyleLayoutFill &&) = default; - StyleLayoutFill& operator=(StyleLayoutFill &&) = default; - StyleLayoutFill(const StyleLayoutFill &) = delete; - StyleLayoutFill& operator=(const StyleLayoutFill &) = delete; -}; - -class StyleLayoutLine { -public: - // Make movable only. - StyleLayoutLine() = default; - StyleLayoutLine(StyleLayoutLine &&) = default; - StyleLayoutLine& operator=(StyleLayoutLine &&) = default; - StyleLayoutLine(const StyleLayoutLine &) = delete; - StyleLayoutLine& operator=(const StyleLayoutLine &) = delete; - - CapType cap = CapType::Butt; - JoinType join = JoinType::Miter; - float miter_limit = 2.0f; - float round_limit = 1.0f; -}; - -class StyleLayoutSymbol { -public: - // Make movable only. - StyleLayoutSymbol() = default; - StyleLayoutSymbol(StyleLayoutSymbol &&) = default; - StyleLayoutSymbol& operator=(StyleLayoutSymbol &&) = default; - StyleLayoutSymbol(const StyleLayoutSymbol &) = delete; - StyleLayoutSymbol& operator=(const StyleLayoutSymbol &) = delete; - - 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 StyleLayoutRaster { -public: - // Make movable only. - StyleLayoutRaster() = default; - StyleLayoutRaster(StyleLayoutRaster &&) = default; - StyleLayoutRaster& operator=(StyleLayoutRaster &&) = default; - StyleLayoutRaster(const StyleLayoutRaster &) = delete; - StyleLayoutRaster& operator=(const StyleLayoutRaster &) = delete; -}; - -class StyleLayoutBackground { -public: - // Make movable only. - StyleLayoutBackground() = default; - StyleLayoutBackground(StyleLayoutBackground &&) = default; - StyleLayoutBackground& operator=(StyleLayoutBackground &&) = default; - StyleLayoutBackground(const StyleLayoutBackground &) = delete; - StyleLayoutBackground& operator=(const StyleLayoutBackground &) = delete; -}; - -template -const T &defaultStyleLayout(); - -}; - -#endif diff --git a/src/mbgl/style/style_properties.cpp b/src/mbgl/style/style_properties.cpp index aa4c7e29c..69a9cede5 100644 --- a/src/mbgl/style/style_properties.cpp +++ b/src/mbgl/style/style_properties.cpp @@ -1,13 +1,5 @@ #include -#include namespace mbgl { -template<> const FillProperties &defaultStyleProperties() { static const FillProperties p; return p; } -template<> const LineProperties &defaultStyleProperties() { static const LineProperties p; return p; } -template<> const CircleProperties &defaultStyleProperties() { static const CircleProperties p; return p; } -template<> const SymbolProperties &defaultStyleProperties() { static const SymbolProperties p; return p; } -template<> const RasterProperties &defaultStyleProperties() { static const RasterProperties p; return p; } -template<> const BackgroundProperties &defaultStyleProperties() { static const BackgroundProperties p; return p; } - } diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 61f5eef71..35f224ac1 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -9,8 +9,8 @@ namespace mbgl { const float globalMinScale = 0.5f; // underscale by 1 zoom level -SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, - const std::vector &line, const StyleLayoutSymbol &layout, +SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, + const std::vector& line, const SymbolLayoutProperties& layout, const bool alongLine) { const float border = 1.0; @@ -128,9 +128,9 @@ void getSegmentGlyphs(std::back_insert_iterator glyphs, Anchor & } } -SymbolQuads getGlyphQuads(Anchor &anchor, const Shaping &shapedText, - const float boxScale, const std::vector &line, const StyleLayoutSymbol &layout, - const bool alongLine, const GlyphPositions &face) { +SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, + const float boxScale, const std::vector& line, const SymbolLayoutProperties& layout, + const bool alongLine, const GlyphPositions& face) { const float textRotate = layout.text.rotate * M_PI / 180; const bool keepUpright = layout.text.keep_upright; diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index 97fdb6a1f..814452a72 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -33,16 +33,16 @@ namespace mbgl { typedef std::vector SymbolQuads; struct Anchor; - class StyleLayoutSymbol; + class SymbolLayoutProperties; class PositionedIcon; - SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, - const std::vector &line, const StyleLayoutSymbol &layout, + SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, + const std::vector& line, const SymbolLayoutProperties& layout, const bool alongLine); - SymbolQuads getGlyphQuads(Anchor &anchor, const Shaping &shapedText, - const float boxScale, const std::vector &line, const StyleLayoutSymbol &layout, - const bool alongLine, const GlyphPositions &face); + SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, + const float boxScale, const std::vector& line, const SymbolLayoutProperties& layout, + const bool alongLine, const GlyphPositions& face); } #endif diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 35fe5dc24..c3911718e 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -1,9 +1,9 @@ #include -#include +#include namespace mbgl { -PositionedIcon shapeIcon(const Rect &image, const StyleLayoutSymbol &layout) { +PositionedIcon shapeIcon(const Rect& image, const SymbolLayoutProperties& layout) { float dx = layout.icon.offset[0]; float dy = layout.icon.offset[1]; float x1 = dx - image.originalW / 2.0f; diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index c409e6ed0..32b34cf5b 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -22,9 +22,9 @@ namespace mbgl { operator bool() const { return image.hasArea(); } }; - class StyleLayoutSymbol; + class SymbolLayoutProperties; - PositionedIcon shapeIcon(const Rect &image, const StyleLayoutSymbol &layout); + PositionedIcon shapeIcon(const Rect& image, const SymbolLayoutProperties&); } diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp index 0918d7893..907f0446b 100644 --- a/test/api/annotations.cpp +++ b/test/api/annotations.cpp @@ -48,12 +48,12 @@ TEST(Annotations, LineAnnotation) { AnnotationSegments segments = {{ {{ { 0, 0 }, { 45, 45 } }} }}; - LineProperties lineProperties; + LinePaintProperties lineProperties; lineProperties.color = {{ 255, 0, 0, 1 }}; lineProperties.width = 5; StyleProperties styleProperties; - styleProperties.set(lineProperties); + styleProperties.set(lineProperties); map.addShapeAnnotation(ShapeAnnotation(segments, styleProperties)); @@ -70,11 +70,11 @@ TEST(Annotations, FillAnnotation) { AnnotationSegments segments = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; - FillProperties fillProperties; + FillPaintProperties fillProperties; fillProperties.fill_color = {{ 255, 0, 0, 1 }}; StyleProperties styleProperties; - styleProperties.set(fillProperties); + styleProperties.set(fillProperties); map.addShapeAnnotation(ShapeAnnotation(segments, styleProperties)); @@ -109,11 +109,11 @@ TEST(Annotations, NonImmediateAdd) { AnnotationSegments segments = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }}; - FillProperties fillProperties; + FillPaintProperties fillProperties; fillProperties.fill_color = {{ 255, 0, 0, 1 }}; StyleProperties styleProperties; - styleProperties.set(fillProperties); + styleProperties.set(fillProperties); map.addShapeAnnotation(ShapeAnnotation(segments, styleProperties)); @@ -143,12 +143,12 @@ TEST(Annotations, RemoveShape) { AnnotationSegments segments = {{ {{ { 0, 0 }, { 45, 45 } }} }}; - LineProperties lineProperties; + LinePaintProperties lineProperties; lineProperties.color = {{ 255, 0, 0, 1 }}; lineProperties.width = 5; StyleProperties styleProperties; - styleProperties.set(lineProperties); + styleProperties.set(lineProperties); Map map(view, fileSource, MapMode::Still); map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");