From 141e995806576364d185626176c1b993fc519291 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 28 Oct 2016 16:39:50 -0700 Subject: [core] Add support for data-driven styling --- src/mbgl/text/quads.cpp | 2 +- src/mbgl/text/shaping.cpp | 13 ++++++------- src/mbgl/text/shaping.hpp | 41 ++++++++++++++++++++++++++--------------- 3 files changed, 33 insertions(+), 23 deletions(-) (limited to 'src/mbgl/text') diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 1a05e6f94f..10c4dfea90 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -62,7 +62,7 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, bl = {left, bottom}; } - float angle = layout.get() * util::DEG2RAD; + float angle = shapedIcon.angle; if (placement == style::SymbolPlacementType::Line) { assert(static_cast(anchor.segment) < line.size()); const GeometryCoordinate &prev= line[anchor.segment]; diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 062066aaf4..b43ba0220c 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -1,19 +1,18 @@ #include -#include +#include namespace mbgl { -using namespace style; - -PositionedIcon shapeIcon(const SpriteAtlasElement& image, const SymbolLayoutProperties::Evaluated& layout) { - float dx = layout.get()[0]; - float dy = layout.get()[1]; +PositionedIcon shapeIcon(const SpriteAtlasElement& image, + const SymbolFeature& feature) { + float dx = feature.iconOffset[0]; + float dy = feature.iconOffset[1]; float x1 = dx - image.spriteImage->getWidth() / 2.0f; float x2 = x1 + image.spriteImage->getWidth(); float y1 = dy - image.spriteImage->getHeight() / 2.0f; float y2 = y1 + image.spriteImage->getHeight(); - return PositionedIcon(image, y1, y2, x1, x2); + return PositionedIcon(image, y1, y2, x1, x2, feature.iconRotation); } } // namespace mbgl diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index 30375179b6..b0e6ae3b1d 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -3,29 +3,40 @@ #include #include #include -#include #include namespace mbgl { class SpriteAtlasElement; +class SymbolFeature; class PositionedIcon { - public: - explicit PositionedIcon() {} - explicit PositionedIcon(const SpriteAtlasElement& _image, - float _top, float _bottom, float _left, float _right) : - image(_image), top(_top), bottom(_bottom), left(_left), right(_right) {} - - optional image; - float top = 0; - float bottom = 0; - float left = 0; - float right = 0; - - explicit operator bool() const { return image && (*image).pos.hasArea(); } +public: + PositionedIcon() = default; + PositionedIcon(const SpriteAtlasElement& image_, + float top_, + float bottom_, + float left_, + float right_, + float angle_) + : image(image_), + top(top_), + bottom(bottom_), + left(left_), + right(right_), + angle(angle_) {} + + optional image; + float top = 0; + float bottom = 0; + float left = 0; + float right = 0; + float angle = 0; + + explicit operator bool() const { return image && (*image).pos.hasArea(); } }; -PositionedIcon shapeIcon(const SpriteAtlasElement& image, const style::SymbolLayoutProperties::Evaluated&); +PositionedIcon shapeIcon(const SpriteAtlasElement&, + const SymbolFeature&); } // namespace mbgl -- cgit v1.2.1