summaryrefslogtreecommitdiff
path: root/src/mbgl/text
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-11-14 15:23:15 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-02 17:11:49 +0200
commit2c49c4374cb9e3654c1d347b1071542918ce5fd2 (patch)
tree9791f6f960939e92a5c891160d86065cc0cf0184 /src/mbgl/text
parent2bb2a40b6d13d4fe44e8879003a3e53416033a34 (diff)
downloadqtlocation-mapboxgl-2c49c4374cb9e3654c1d347b1071542918ce5fd2.tar.gz
[core] Store 'sdf' flag in vertex attribute
Diffstat (limited to 'src/mbgl/text')
-rw-r--r--src/mbgl/text/quads.cpp17
-rw-r--r--src/mbgl/text/quads.hpp7
2 files changed, 15 insertions, 9 deletions
diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp
index ee17510c35..480bcd79a9 100644
--- a/src/mbgl/text/quads.cpp
+++ b/src/mbgl/text/quads.cpp
@@ -1,10 +1,11 @@
+#include <mbgl/geometry/anchor.hpp>
+#include <mbgl/layout/symbol_instance.hpp>
+#include <mbgl/style/layers/symbol_layer_properties.hpp>
#include <mbgl/text/quads.hpp>
#include <mbgl/text/shaping.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
-#include <mbgl/geometry/anchor.hpp>
-#include <mbgl/style/layers/symbol_layer_properties.hpp>
-#include <mbgl/util/math.hpp>
#include <mbgl/util/constants.hpp>
+#include <mbgl/util/math.hpp>
#include <mbgl/util/optional.hpp>
#include <cassert>
@@ -13,8 +14,7 @@ namespace mbgl {
using namespace style;
-SymbolQuad getIconQuad(const PositionedIcon& shapedIcon,
- WritingModeType writingMode) {
+SymbolQuad getIconQuad(const PositionedIcon& shapedIcon, WritingModeType writingMode, 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
@@ -70,7 +70,7 @@ SymbolQuad getIconQuad(const PositionedIcon& shapedIcon,
static_cast<uint16_t>(image.textureRect.h + border * 2)
};
- return SymbolQuad { tl, tr, bl, br, textureRect, writingMode, { 0.0f, 0.0f } };
+ return SymbolQuad{tl, tr, bl, br, textureRect, writingMode, {0.0f, 0.0f}, iconType == SymbolContent::IconSDF};
}
SymbolQuads getGlyphQuads(const Shaping& shapedText,
@@ -96,6 +96,7 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
const bool rotateVerticalGlyph = (alongLine || allowVerticalPlacement) && positionedGlyph.vertical;
const float halfAdvance = positionedGlyph.metrics.advance * positionedGlyph.scale / 2.0;
const Rect<uint16_t>& rect = positionedGlyph.rect;
+ bool isSDF = true;
// Align images and scaled glyphs in the middle of a vertical line.
if (allowVerticalPlacement && shapedText.verticalizable) {
@@ -111,6 +112,7 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
}
pixelRatio = image->second->pixelRatio;
rectBuffer = ImagePosition::padding / pixelRatio;
+ isSDF = image->second->sdf;
}
const Point<float> glyphOffset =
@@ -179,7 +181,8 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
br = util::matrixMultiply(matrix, br);
}
- quads.emplace_back(tl, tr, bl, br, rect, shapedText.writingMode, glyphOffset, positionedGlyph.sectionIndex);
+ quads.emplace_back(
+ tl, tr, bl, br, rect, shapedText.writingMode, glyphOffset, isSDF, positionedGlyph.sectionIndex);
}
}
diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp
index f67266b1ec..29f798ba0d 100644
--- a/src/mbgl/text/quads.hpp
+++ b/src/mbgl/text/quads.hpp
@@ -12,6 +12,7 @@ namespace mbgl {
class Anchor;
class PositionedIcon;
+enum class SymbolContent : uint8_t;
class SymbolQuad {
public:
@@ -22,6 +23,7 @@ public:
Rect<uint16_t> tex_,
WritingModeType writingMode_,
Point<float> glyphOffset_,
+ bool isSDF_,
size_t sectionIndex_ = 0)
: tl(tl_),
tr(tr_),
@@ -30,6 +32,7 @@ public:
tex(tex_),
writingMode(writingMode_),
glyphOffset(glyphOffset_),
+ isSDF(isSDF_),
sectionIndex(sectionIndex_) {}
Point<float> tl;
@@ -39,13 +42,13 @@ public:
Rect<uint16_t> tex;
WritingModeType writingMode;
Point<float> glyphOffset;
+ bool isSDF;
size_t sectionIndex;
};
using SymbolQuads = std::vector<SymbolQuad>;
-SymbolQuad getIconQuad(const PositionedIcon& shapedIcon,
- WritingModeType writingMode);
+SymbolQuad getIconQuad(const PositionedIcon& shapedIcon, WritingModeType writingMode, SymbolContent iconType);
SymbolQuads getGlyphQuads(const Shaping& shapedText,
const std::array<float, 2> textOffset,