diff options
author | zmiao <zmiao.jamie@gmail.com> | 2019-08-22 12:13:39 +0300 |
---|---|---|
committer | zmiao <zmiao.jamie@gmail.com> | 2019-08-22 12:13:39 +0300 |
commit | 048a43a78984914a135380e3c8ce21790e860327 (patch) | |
tree | d49517456257267e3784f192d1985f6950b2caf7 | |
parent | b02dcf8133f5fedbe7ca82e2b9baccf0d7079f34 (diff) | |
download | qtlocation-mapboxgl-048a43a78984914a135380e3c8ce21790e860327.tar.gz |
refine sdf icon flag
-rw-r--r-- | src/mbgl/layout/symbol_instance.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_instance.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 6 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index 620921699d..c5b11dbe00 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -94,7 +94,6 @@ SymbolInstance::SymbolInstance(Anchor& anchor_, anchor(anchor_), // 'hasText' depends on finding at least one glyph in the shaping that's also in the GlyphPositionMap hasText(!sharedData->empty()), - iconStatus(iconFlag), // Create the collision features that will be used to check whether this symbol instance can be placed // As a collision approximation, we can use either the vertical or any of the horizontal versions of the feature textCollisionFeature(sharedData->line, anchor, getAnyShaping(shapedTextOrientations), textBoxScale_, textPadding, textPlacement, indexedFeature, overscaling, textRotation), @@ -108,7 +107,9 @@ SymbolInstance::SymbolInstance(Anchor& anchor_, textBoxScale(textBoxScale_), radialTextOffset(radialTextOffset_), singleLine(shapedTextOrientations.singleLine) { - + assert(iconFlag < 3); + sdfIcon = iconFlag & 0x02; + normalIcon = iconFlag & 0x01; if (allowVerticalPlacement && shapedTextOrientations.vertical) { const float verticalPointLabelAngle = 90.0f; verticalTextCollisionFeature = CollisionFeature(line(), anchor, shapedTextOrientations.vertical, textBoxScale_, textPadding, textPlacement, indexedFeature, overscaling, textRotation + verticalPointLabelAngle); @@ -172,11 +173,11 @@ const optional<SymbolQuad>& SymbolInstance::verticalIconQuad() const { } bool SymbolInstance::hasIcon() const { - return iconStatus & 0x01; + return normalIcon || sdfIcon; } bool SymbolInstance::hasSdfIcon() const { - return iconStatus & 0x02; + return sdfIcon; } void SymbolInstance::releaseSharedData() { diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp index 8223594ec3..3560ef0f8f 100644 --- a/src/mbgl/layout/symbol_instance.hpp +++ b/src/mbgl/layout/symbol_instance.hpp @@ -84,9 +84,9 @@ private: public: Anchor anchor; - bool hasText; - // Bitwise icon status flag, 0x00 => not an icon; 0x01 => normal icon; 0x03 => sdfIcon. default value 0x00 - uint8_t iconStatus; + bool hasText : 1; + bool sdfIcon : 1; + bool normalIcon : 1; std::size_t rightJustifiedGlyphQuadsSize; std::size_t centerJustifiedGlyphQuadsSize; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 69ef4b1cf0..0f4cef4e4a 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -398,18 +398,20 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions } // if feature has icon, get sprite atlas position + + // Bitwise flag for icon status. 0x00 => not an icon, 0x01 => normal icon, 0x02 => sdf icon uint8_t iconFlag{0x00}; if (feature.icon) { auto image = imageMap.find(*feature.icon); if (image != imageMap.end()) { - iconFlag |= 0x01; + iconFlag = 0x01; shapedIcon = PositionedIcon::shapeIcon( imagePositions.at(*feature.icon), layout->evaluate<IconOffset>(zoom, feature), layout->evaluate<IconAnchor>(zoom, feature), layout->evaluate<IconRotate>(zoom, feature) * util::DEG2RAD); if (image->second->sdf) { - iconFlag |= 0x02; + iconFlag = 0x02; } if (image->second->pixelRatio != pixelRatio) { iconsNeedLinear = true; |