diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-12-10 13:38:36 +0100 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-01-15 15:02:11 +0200 |
commit | 027e803b722301a03e9ef53b584c2795ff47e7bd (patch) | |
tree | d40e718688a00980ad5c40dc5db7200fb732410a /src/mbgl | |
parent | 1342cb44b3f8bb0cd5c019174b62886b84d62cf8 (diff) | |
download | qtlocation-mapboxgl-027e803b722301a03e9ef53b584c2795ff47e7bd.tar.gz |
[core] move icon rotation from shaping to quad generation to mirror JS
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/layout/symbol_instance.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_instance.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/quads.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/shaping.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/text/shaping.hpp | 9 |
7 files changed, 14 insertions, 16 deletions
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index 3a16d25de6..01ba3e26a6 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -26,14 +26,15 @@ SymbolInstanceSharedData::SymbolInstanceSharedData(GeometryCoordinates line_, const style::SymbolPlacementType textPlacement, const std::array<float, 2>& textOffset, const ImageMap& imageMap, + float iconRotation, SymbolContent iconType, bool allowVerticalPlacement) : line(std::move(line_)) { // Create the quads used for rendering the icon and glyphs. if (shapedIcon) { - iconQuads = getIconQuads(*shapedIcon, iconType); + iconQuads = getIconQuads(*shapedIcon, iconRotation, iconType); if (verticallyShapedIcon) { - verticalIconQuads = getIconQuads(*verticallyShapedIcon, iconType); + verticalIconQuads = getIconQuads(*verticallyShapedIcon, iconRotation, iconType); } } diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp index 74124d3364..56dd82240e 100644 --- a/src/mbgl/layout/symbol_instance.hpp +++ b/src/mbgl/layout/symbol_instance.hpp @@ -32,6 +32,7 @@ struct SymbolInstanceSharedData { const style::SymbolPlacementType textPlacement, const std::array<float, 2>& textOffset, const ImageMap& imageMap, + float iconRotation, SymbolContent iconType, bool allowVerticalPlacement); bool empty() const; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 98274136ec..1772d1ef91 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -474,8 +474,7 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, iconType = SymbolContent::IconRGBA; shapedIcon = PositionedIcon::shapeIcon(imagePositions.at(feature.icon->id()), layout->evaluate<IconOffset>(zoom, feature), - layout->evaluate<IconAnchor>(zoom, feature), - layout->evaluate<IconRotate>(zoom, feature) * util::DEG2RAD); + layout->evaluate<IconAnchor>(zoom, feature)); if (image->second->sdf) { iconType = SymbolContent::IconSDF; } @@ -601,6 +600,7 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, textPlacement, textOffset, imageMap, + iconRotation, iconType, allowVerticalPlacement); }; diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index fe683f7d98..b6427d0d04 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -14,7 +14,7 @@ namespace mbgl { using namespace style; -SymbolQuads getIconQuads(const PositionedIcon& shapedIcon, SymbolContent iconType) { +SymbolQuads getIconQuads(const PositionedIcon& shapedIcon, const float iconRotate, const SymbolContent iconType) { const ImagePosition& image = shapedIcon.image(); // If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual @@ -42,7 +42,7 @@ SymbolQuads getIconQuads(const PositionedIcon& shapedIcon, SymbolContent iconTyp Point<float> br{right, bottom}; Point<float> bl{left, bottom}; - const float angle = shapedIcon.angle(); + const float angle = iconRotate * util::DEG2RAD; if (angle) { // Compute the transformation matrix. diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index aa1913204e..ef058989a5 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -57,7 +57,7 @@ public: using SymbolQuads = std::vector<SymbolQuad>; -SymbolQuads getIconQuads(const PositionedIcon& shapedIcon, SymbolContent iconType); +SymbolQuads getIconQuads(const PositionedIcon& shapedIcon, float iconRotate, SymbolContent iconType); SymbolQuads getGlyphQuads(const Shaping& shapedText, const std::array<float, 2> textOffset, diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 2b23deadea..033cbdf4e5 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -70,8 +70,7 @@ style::TextJustifyType getAnchorJustification(style::SymbolAnchorType anchor) { PositionedIcon PositionedIcon::shapeIcon(const ImagePosition& image, const std::array<float, 2>& iconOffset, - style::SymbolAnchorType iconAnchor, - const float iconRotation) { + style::SymbolAnchorType iconAnchor) { AnchorAlignment anchorAlign = AnchorAlignment::getAnchorAlignment(iconAnchor); float dx = iconOffset[0]; float dy = iconOffset[1]; @@ -80,7 +79,7 @@ PositionedIcon PositionedIcon::shapeIcon(const ImagePosition& image, float top = dy - image.displaySize()[1] * anchorAlign.verticalAlign; float bottom = top + image.displaySize()[1]; - return PositionedIcon { image, top, bottom, left, right, iconRotation }; + return PositionedIcon{image, top, bottom, left, right}; } void PositionedIcon::fitIconToText(const Shaping& shapedText, diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index 1f62f38521..0c238d36b0 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -28,21 +28,19 @@ class BiDi; class PositionedIcon { private: - PositionedIcon(ImagePosition image_, float top_, float bottom_, float left_, float right_, float angle_) - : _image(image_), _top(top_), _bottom(bottom_), _left(left_), _right(right_), _angle(angle_) {} + PositionedIcon(ImagePosition image_, float top_, float bottom_, float left_, float right_) + : _image(image_), _top(top_), _bottom(bottom_), _left(left_), _right(right_) {} ImagePosition _image; float _top; float _bottom; float _left; float _right; - float _angle; public: static PositionedIcon shapeIcon(const ImagePosition&, const std::array<float, 2>& iconOffset, - style::SymbolAnchorType iconAnchor, - const float iconRotation); + style::SymbolAnchorType iconAnchor); // Updates shaped icon's bounds based on shaped text's bounds and provided // layout properties. @@ -57,7 +55,6 @@ public: float bottom() const { return _bottom; } float left() const { return _left; } float right() const { return _right; } - float angle() const { return _angle; } }; const Shaping getShaping(const TaggedString& string, |