diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-07-21 23:11:27 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-07-22 12:23:39 +0300 |
commit | 11bfe2398111dbca232b744db9b50119e7d3c495 (patch) | |
tree | 02bc511e315832a780d18ca8f51a8003e5741cb2 | |
parent | 3184cb29db069e990dab1ea4e784aad0aaa1048b (diff) | |
download | qtlocation-mapboxgl-11bfe2398111dbca232b744db9b50119e7d3c495.tar.gz |
[core] Symbol bucket uses shared layout
sizeof(SymbolBucket): 2296 -> 1024
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 148 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_symbol_layer.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/placement.cpp | 18 | ||||
-rw-r--r-- | test/gl/bucket.test.cpp | 4 | ||||
-rw-r--r-- | test/text/cross_tile_symbol_index.test.cpp | 12 |
8 files changed, 103 insertions, 97 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index d8d143632c..098a872c06 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -46,7 +46,38 @@ inline const SymbolLayerProperties& toSymbolLayerProperties(const Immutable<Laye return static_cast<const SymbolLayerProperties&>(*layer); } +inline Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> createLayout(const SymbolLayoutProperties::Unevaluated& unevaluated, float zoom) { + auto layout = makeMutable<style::SymbolLayoutProperties::PossiblyEvaluated>(unevaluated.evaluate(PropertyEvaluationParameters(zoom))); + + if (layout->get<IconRotationAlignment>() == AlignmentType::Auto) { + if (layout->get<SymbolPlacement>() != SymbolPlacementType::Point) { + layout->get<IconRotationAlignment>() = AlignmentType::Map; + } else { + layout->get<IconRotationAlignment>() = AlignmentType::Viewport; + } + } + + if (layout->get<TextRotationAlignment>() == AlignmentType::Auto) { + if (layout->get<SymbolPlacement>() != SymbolPlacementType::Point) { + layout->get<TextRotationAlignment>() = AlignmentType::Map; + } else { + layout->get<TextRotationAlignment>() = AlignmentType::Viewport; + } + } + + // If unspecified `*-pitch-alignment` inherits `*-rotation-alignment` + if (layout->get<TextPitchAlignment>() == AlignmentType::Auto) { + layout->get<TextPitchAlignment>() = layout->get<TextRotationAlignment>(); + } + if (layout->get<IconPitchAlignment>() == AlignmentType::Auto) { + layout->get<IconPitchAlignment>() = layout->get<IconRotationAlignment>(); + } + + return layout; +} + } // namespace + SymbolLayout::SymbolLayout(const BucketParameters& parameters, const std::vector<Immutable<style::LayerProperties>>& layers, std::unique_ptr<GeometryTileLayer> sourceLayer_, @@ -61,50 +92,23 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, tileSize(util::tileSize * overscaling), tilePixelRatio(float(util::EXTENT) / tileSize), textSize(toSymbolLayerProperties(layers.at(0)).layerImpl().layout.get<TextSize>()), - iconSize(toSymbolLayerProperties(layers.at(0)).layerImpl().layout.get<IconSize>()) - { - + iconSize(toSymbolLayerProperties(layers.at(0)).layerImpl().layout.get<IconSize>()), + layout(createLayout(toSymbolLayerProperties(layers.at(0)).layerImpl().layout, zoom)) { const SymbolLayer::Impl& leader = toSymbolLayerProperties(layers.at(0)).layerImpl(); - layout = leader.layout.evaluate(PropertyEvaluationParameters(zoom)); - - if (layout.get<IconRotationAlignment>() == AlignmentType::Auto) { - if (layout.get<SymbolPlacement>() != SymbolPlacementType::Point) { - layout.get<IconRotationAlignment>() = AlignmentType::Map; - } else { - layout.get<IconRotationAlignment>() = AlignmentType::Viewport; - } - } - - if (layout.get<TextRotationAlignment>() == AlignmentType::Auto) { - if (layout.get<SymbolPlacement>() != SymbolPlacementType::Point) { - layout.get<TextRotationAlignment>() = AlignmentType::Map; - } else { - layout.get<TextRotationAlignment>() = AlignmentType::Viewport; - } - } - - // If unspecified `*-pitch-alignment` inherits `*-rotation-alignment` - if (layout.get<TextPitchAlignment>() == AlignmentType::Auto) { - layout.get<TextPitchAlignment>() = layout.get<TextRotationAlignment>(); - } - if (layout.get<IconPitchAlignment>() == AlignmentType::Auto) { - layout.get<IconPitchAlignment>() = layout.get<IconRotationAlignment>(); - } - - const bool hasText = has<TextField>(layout) && has<TextFont>(layout); - const bool hasIcon = has<IconImage>(layout); + const bool hasText = has<TextField>(*layout) && has<TextFont>(*layout); + const bool hasIcon = has<IconImage>(*layout); if (!hasText && !hasIcon) { return; } const bool hasSymbolSortKey = !leader.layout.get<SymbolSortKey>().isUndefined(); - const auto symbolZOrder = layout.get<SymbolZOrder>(); + const auto symbolZOrder = layout->get<SymbolZOrder>(); const bool sortFeaturesByKey = symbolZOrder != SymbolZOrderType::ViewportY && hasSymbolSortKey; const bool zOrderByViewportY = symbolZOrder == SymbolZOrderType::ViewportY || (symbolZOrder == SymbolZOrderType::Auto && !sortFeaturesByKey); - sortFeaturesByY = zOrderByViewportY && (layout.get<TextAllowOverlap>() || layout.get<IconAllowOverlap>() || - layout.get<TextIgnorePlacement>() || layout.get<IconIgnorePlacement>()); + sortFeaturesByY = zOrderByViewportY && (layout->get<TextAllowOverlap>() || layout->get<IconAllowOverlap>() || + layout->get<TextIgnorePlacement>() || layout->get<IconIgnorePlacement>()); for (const auto& layer : layers) { layerPaintProperties.emplace(layer->baseImpl->id, layer); @@ -122,9 +126,9 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, ft.index = i; if (hasText) { - auto formatted = layout.evaluate<TextField>(zoom, ft); - auto textTransform = layout.evaluate<TextTransform>(zoom, ft); - FontStack baseFontStack = layout.evaluate<TextFont>(zoom, ft); + auto formatted = layout->evaluate<TextField>(zoom, ft); + auto textTransform = layout->evaluate<TextTransform>(zoom, ft); + FontStack baseFontStack = layout->evaluate<TextFont>(zoom, ft); ft.formattedText = TaggedString(); for (const auto & section : formatted.sections) { @@ -142,8 +146,8 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, } - const bool canVerticalizeText = layout.get<TextRotationAlignment>() == AlignmentType::Map - && layout.get<SymbolPlacement>() != SymbolPlacementType::Point + const bool canVerticalizeText = layout->get<TextRotationAlignment>() == AlignmentType::Map + && layout->get<SymbolPlacement>() != SymbolPlacementType::Point && util::i18n::allowsVerticalWritingMode(ft.formattedText->rawText()); // Loop through all characters of this text and collect unique codepoints. @@ -161,13 +165,13 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, } if (hasIcon) { - ft.icon = layout.evaluate<IconImage>(zoom, ft); + ft.icon = layout->evaluate<IconImage>(zoom, ft); imageDependencies.emplace(*ft.icon, ImageType::Icon); } if (ft.formattedText || ft.icon) { if (sortFeaturesByKey) { - ft.sortKey = layout.evaluate<SymbolSortKey>(zoom, ft); + ft.sortKey = layout->evaluate<SymbolSortKey>(zoom, ft); const auto lowerBound = std::lower_bound(features.begin(), features.end(), ft); features.insert(lowerBound, std::move(ft)); } else { @@ -176,7 +180,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, } } - if (layout.get<SymbolPlacement>() == SymbolPlacementType::Line) { + if (layout->get<SymbolPlacement>() == SymbolPlacementType::Line) { util::mergeLines(features); } } @@ -270,8 +274,8 @@ Point<float> SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float r void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions, const ImageMap& imageMap, const ImagePositions& imagePositions) { - const bool isPointPlacement = layout.get<SymbolPlacement>() == SymbolPlacementType::Point; - const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map && !isPointPlacement; + const bool isPointPlacement = layout->get<SymbolPlacement>() == SymbolPlacementType::Point; + const bool textAlongLine = layout->get<TextRotationAlignment>() == AlignmentType::Map && !isPointPlacement; for (auto it = features.begin(); it != features.end(); ++it) { auto& feature = *it; @@ -283,13 +287,13 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions // if feature has text, shape the text if (feature.formattedText) { - const float lineHeight = layout.get<TextLineHeight>() * util::ONE_EM; - const float spacing = util::i18n::allowsLetterSpacing(feature.formattedText->rawText()) ? layout.evaluate<TextLetterSpacing>(zoom, feature) * util::ONE_EM : 0.0f; + const float lineHeight = layout->get<TextLineHeight>() * util::ONE_EM; + const float spacing = util::i18n::allowsLetterSpacing(feature.formattedText->rawText()) ? layout->evaluate<TextLetterSpacing>(zoom, feature) * util::ONE_EM : 0.0f; auto applyShaping = [&] (const TaggedString& formattedText, WritingModeType writingMode, SymbolAnchorType textAnchor, TextJustifyType textJustify) { const Shaping result = getShaping( /* string */ formattedText, - /* maxWidth: ems */ isPointPlacement ? layout.evaluate<TextMaxWidth>(zoom, feature) * util::ONE_EM : 0.0f, + /* maxWidth: ems */ isPointPlacement ? layout->evaluate<TextMaxWidth>(zoom, feature) * util::ONE_EM : 0.0f, /* ems */ lineHeight, textAnchor, textJustify, @@ -301,9 +305,9 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions return result; }; - const std::vector<style::TextVariableAnchorType> variableTextAnchor = layout.evaluate<TextVariableAnchor>(zoom, feature); - const float radialOffset = layout.evaluate<TextRadialOffset>(zoom, feature); - const SymbolAnchorType textAnchor = layout.evaluate<TextAnchor>(zoom, feature); + const std::vector<style::TextVariableAnchorType> variableTextAnchor = layout->evaluate<TextVariableAnchor>(zoom, feature); + const float radialOffset = layout->evaluate<TextRadialOffset>(zoom, feature); + const SymbolAnchorType textAnchor = layout->evaluate<TextAnchor>(zoom, feature); if (variableTextAnchor.empty()) { // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector // is calculated at placement time instead of layout time @@ -312,11 +316,11 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions // but doesn't actually specify what happens if you use both. We go with the radial offset. textOffset = evaluateRadialOffset(textAnchor, radialOffset * util::ONE_EM); } else { - textOffset = { layout.evaluate<TextOffset>(zoom, feature)[0] * util::ONE_EM, - layout.evaluate<TextOffset>(zoom, feature)[1] * util::ONE_EM}; + textOffset = { layout->evaluate<TextOffset>(zoom, feature)[0] * util::ONE_EM, + layout->evaluate<TextOffset>(zoom, feature)[1] * util::ONE_EM}; } } - TextJustifyType textJustify = textAlongLine ? TextJustifyType::Center : layout.evaluate<TextJustify>(zoom, feature); + TextJustifyType textJustify = textAlongLine ? TextJustifyType::Center : layout->evaluate<TextJustify>(zoom, feature); // If this layer uses text-variable-anchor, generate shapings for all justification possibilities. if (!textAlongLine && !variableTextAnchor.empty()) { std::vector<TextJustifyType> justifications; @@ -365,15 +369,15 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions if (image != imageMap.end()) { shapedIcon = PositionedIcon::shapeIcon( imagePositions.at(*feature.icon), - layout.evaluate<IconOffset>(zoom, feature), - layout.evaluate<IconAnchor>(zoom, feature), - layout.evaluate<IconRotate>(zoom, feature) * util::DEG2RAD); + layout->evaluate<IconOffset>(zoom, feature), + layout->evaluate<IconAnchor>(zoom, feature), + layout->evaluate<IconRotate>(zoom, feature) * util::DEG2RAD); if (image->second->sdf) { sdfIcons = true; } if (image->second->pixelRatio != pixelRatio) { iconsNeedLinear = true; - } else if (layout.get<IconRotate>().constantOr(1) != 0) { + } else if (layout->get<IconRotate>().constantOr(1) != 0) { iconsNeedLinear = true; } } @@ -399,34 +403,34 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, const float minScale = 0.5f; const float glyphSize = 24.0f; - const float layoutTextSize = layout.evaluate<TextSize>(zoom + 1, feature); - const float layoutIconSize = layout.evaluate<IconSize>(zoom + 1, feature); + const float layoutTextSize = layout->evaluate<TextSize>(zoom + 1, feature); + const float layoutIconSize = layout->evaluate<IconSize>(zoom + 1, feature); const std::array<float, 2> textOffset = {{ offset.x, offset.y }}; - const std::array<float, 2> iconOffset = layout.evaluate<IconOffset>(zoom, feature); + const std::array<float, 2> iconOffset = layout->evaluate<IconOffset>(zoom, feature); // To reduce the number of labels that jump around when zooming we need // to use a text-size value that is the same for all zoom levels. // This calculates text-size at a high zoom level so that all tiles can // use the same value when calculating anchor positions. - const float textMaxSize = layout.evaluate<TextSize>(18, feature); + const float textMaxSize = layout->evaluate<TextSize>(18, feature); const float fontScale = layoutTextSize / glyphSize; const float textBoxScale = tilePixelRatio * fontScale; const float textMaxBoxScale = tilePixelRatio * textMaxSize / glyphSize; const float iconBoxScale = tilePixelRatio * layoutIconSize; - const float symbolSpacing = tilePixelRatio * layout.get<SymbolSpacing>(); - const float textPadding = layout.get<TextPadding>() * tilePixelRatio; - const float iconPadding = layout.get<IconPadding>() * tilePixelRatio; - const float textMaxAngle = layout.get<TextMaxAngle>() * util::DEG2RAD; - const float rotation = layout.evaluate<IconRotate>(zoom, feature); - const float radialTextOffset = layout.evaluate<TextRadialOffset>(zoom, feature) * util::ONE_EM; - const SymbolPlacementType textPlacement = layout.get<TextRotationAlignment>() != AlignmentType::Map + const float symbolSpacing = tilePixelRatio * layout->get<SymbolSpacing>(); + const float textPadding = layout->get<TextPadding>() * tilePixelRatio; + const float iconPadding = layout->get<IconPadding>() * tilePixelRatio; + const float textMaxAngle = layout->get<TextMaxAngle>() * util::DEG2RAD; + const float rotation = layout->evaluate<IconRotate>(zoom, feature); + const float radialTextOffset = layout->evaluate<TextRadialOffset>(zoom, feature) * util::ONE_EM; + const SymbolPlacementType textPlacement = layout->get<TextRotationAlignment>() != AlignmentType::Map ? SymbolPlacementType::Point - : layout.get<SymbolPlacement>(); + : layout->get<SymbolPlacement>(); const float textRepeatDistance = symbolSpacing / 2; - const auto evaluatedLayoutProperties = layout.evaluate(zoom, feature); + const auto evaluatedLayoutProperties = layout->evaluate(zoom, feature); IndexedSubfeature indexedFeature(feature.index, sourceLayer->getName(), bucketLeaderID, symbolInstances.size()); auto addSymbolInstance = [&] (const GeometryCoordinates& line, Anchor& anchor) { @@ -449,7 +453,7 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, const auto& type = feature.getType(); - if (layout.get<SymbolPlacement>() == SymbolPlacementType::Line) { + if (layout->get<SymbolPlacement>() == SymbolPlacementType::Line) { auto clippedLines = util::clipLines(feature.geometry, 0, 0, util::EXTENT, util::EXTENT); for (const auto& line : clippedLines) { Anchors anchors = getAnchors(line, @@ -469,7 +473,7 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, } } } - } else if (layout.get<SymbolPlacement>() == SymbolPlacementType::LineCenter) { + } else if (layout->get<SymbolPlacement>() == SymbolPlacementType::LineCenter) { // No clipping, multiple lines per feature are allowed // "lines" with only one point are ignored as in clipLines for (const auto& line : feature.geometry) { diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 4397c5543e..23f883f56c 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -90,8 +90,6 @@ private: const MapMode mode; const float pixelRatio; - style::SymbolLayoutProperties::PossiblyEvaluated layout; - const uint32_t tileSize; const float tilePixelRatio; @@ -101,7 +99,7 @@ private: style::TextSize::UnevaluatedType textSize; style::IconSize::UnevaluatedType iconSize; - + Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout; std::vector<SymbolFeature> features; BiDi bidi; // Consider moving this up to geometry tile worker to reduce reinstantiation costs; use of BiDi/ubiditransform object must be constrained to one thread diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index cc26f1b26b..cd9fb08d34 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -13,7 +13,7 @@ namespace { std::atomic<uint32_t> maxBucketInstanceId; } // namespace -SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layout_, +SymbolBucket::SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout_, const std::map<std::string, Immutable<style::LayerProperties>>& paintProperties_, const style::PropertyValue<float>& textSize, const style::PropertyValue<float>& iconSize, @@ -176,7 +176,7 @@ void SymbolBucket::sortFeatures(const float angle) { if (!sortFeaturesByY) { return; } - assert (angle != std::numeric_limits<float>::max()); + assert(angle != std::numeric_limits<float>::max()); if (sortedAngle == angle) { return; @@ -246,7 +246,7 @@ std::vector<std::reference_wrapper<SymbolInstance>> SymbolBucket::getSortedSymbo bool SymbolBucket::hasFormatSectionOverrides() const { if (!hasFormatSectionOverrides_) { - hasFormatSectionOverrides_= SymbolLayerPaintPropertyOverrides::hasOverrides(layout.get<TextField>()); + hasFormatSectionOverrides_= SymbolLayerPaintPropertyOverrides::hasOverrides(layout->get<TextField>()); } return *hasFormatSectionOverrides_; } diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index bee3e3f7c2..1c975e93e8 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -43,7 +43,7 @@ public: class SymbolBucket final : public Bucket { public: - SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated, + SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEvaluated>, const std::map<std::string, Immutable<style::LayerProperties>>&, const style::PropertyValue<float>& textSize, const style::PropertyValue<float>& iconSize, @@ -72,7 +72,7 @@ public: // The result contains references to the `symbolInstances` items, sorted by viewport Y. std::vector<std::reference_wrapper<SymbolInstance>> getSortedSymbols(const float angle); - const style::SymbolLayoutProperties::PossiblyEvaluated layout; + Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout; const std::string bucketLeaderID; float sortedAngle = std::numeric_limits<float>::max(); diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index c79008d08b..8c3bae383f 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -113,7 +113,7 @@ void drawIcon(const DrawFn& draw, const PaintParameters& parameters) { auto& bucket = static_cast<SymbolBucket&>(*renderData.bucket); const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData.layerProperties); - const auto& layout = bucket.layout; + const auto& layout = *bucket.layout; auto values = iconPropertyValues(evaluated, layout); const auto& paintPropertyValues = RenderSymbolLayer::iconPaintProperties(evaluated); @@ -184,7 +184,7 @@ void drawText(const DrawFn& draw, const PaintParameters& parameters) { auto& bucket = static_cast<SymbolBucket&>(*renderData.bucket); const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData.layerProperties); - const auto& layout = bucket.layout; + const auto& layout = *bucket.layout; const gfx::TextureBinding textureBinding{ tile.getGlyphAtlasTexture().getResource(), gfx::TextureFilterType::Linear }; diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 130c2d050c..99c7b7f16b 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -101,7 +101,7 @@ void Placement::placeBucket( SymbolBucket& bucket, const BucketPlacementParameters& params, std::set<uint32_t>& seenCrossTileIDs) { - const auto& layout = bucket.layout; + const auto& layout = *bucket.layout; const auto& renderTile = params.tile; const auto& state = collisionIndex.getTransformState(); const float pixelsToTileUnits = renderTile.id.pixelsToTileUnits(1, state.getZoom()); @@ -409,7 +409,7 @@ Point<float> calculateVariableRenderShift(style::SymbolAnchorType anchor, float bool Placement::updateBucketDynamicVertices(SymbolBucket& bucket, const TransformState& state, const RenderTile& tile) { using namespace style; - const auto& layout = bucket.layout; + const auto& layout = *bucket.layout; const bool alongLine = layout.get<SymbolPlacement>() != SymbolPlacementType::Point; bool result = false; @@ -512,19 +512,19 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState JointOpacityState duplicateOpacityState(false, false, true); - const bool textAllowOverlap = bucket.layout.get<style::TextAllowOverlap>(); - const bool iconAllowOverlap = bucket.layout.get<style::IconAllowOverlap>(); - const bool variablePlacement = !bucket.layout.get<style::TextVariableAnchor>().empty(); - const bool rotateWithMap = bucket.layout.get<style::TextRotationAlignment>() == style::AlignmentType::Map; - const bool pitchWithMap = bucket.layout.get<style::TextPitchAlignment>() == style::AlignmentType::Map; + const bool textAllowOverlap = bucket.layout->get<style::TextAllowOverlap>(); + const bool iconAllowOverlap = bucket.layout->get<style::IconAllowOverlap>(); + const bool variablePlacement = !bucket.layout->get<style::TextVariableAnchor>().empty(); + const bool rotateWithMap = bucket.layout->get<style::TextRotationAlignment>() == style::AlignmentType::Map; + const bool pitchWithMap = bucket.layout->get<style::TextPitchAlignment>() == style::AlignmentType::Map; // If allow-overlap is true, we can show symbols before placement runs on them // But we have to wait for placement if we potentially depend on a paired icon/text // with allow-overlap: false. // See https://github.com/mapbox/mapbox-gl-native/issues/12483 JointOpacityState defaultOpacityState( - textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || bucket.layout.get<style::IconOptional>()), - iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || bucket.layout.get<style::TextOptional>()), + textAllowOverlap && (iconAllowOverlap || !bucket.hasIconData() || bucket.layout->get<style::IconOptional>()), + iconAllowOverlap && (textAllowOverlap || !bucket.hasTextData() || bucket.layout->get<style::TextOptional>()), true); for (SymbolInstance& symbolInstance : bucket.symbolInstances) { diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index ff01b590fc..9c9847cf4d 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -114,7 +114,7 @@ TEST(Buckets, SymbolBucket) { gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; - style::SymbolLayoutProperties::PossiblyEvaluated layout; + auto layout = makeMutable<style::SymbolLayoutProperties::PossiblyEvaluated>(); bool sdfIcons = false; bool iconsNeedLinear = false; bool sortFeaturesByY = false; @@ -122,7 +122,7 @@ TEST(Buckets, SymbolBucket) { std::vector<SymbolInstance> symbolInstances; gl::Context context{ backend }; - SymbolBucket bucket { layout, {}, 16.0f, 1.0f, 0, sdfIcons, iconsNeedLinear, sortFeaturesByY, bucketLeaderID, std::move(symbolInstances), 1.0f }; + SymbolBucket bucket { std::move(layout), {}, 16.0f, 1.0f, 0, sdfIcons, iconsNeedLinear, sortFeaturesByY, bucketLeaderID, std::move(symbolInstances), 1.0f }; ASSERT_FALSE(bucket.hasIconData()); ASSERT_FALSE(bucket.hasTextData()); ASSERT_FALSE(bucket.hasCollisionBoxData()); diff --git a/test/text/cross_tile_symbol_index.test.cpp b/test/text/cross_tile_symbol_index.test.cpp index f121781766..841f73c699 100644 --- a/test/text/cross_tile_symbol_index.test.cpp +++ b/test/text/cross_tile_symbol_index.test.cpp @@ -21,7 +21,8 @@ TEST(CrossTileSymbolLayerIndex, addBucket) { uint32_t maxBucketInstanceId = 0; CrossTileSymbolLayerIndex index; - style::SymbolLayoutProperties::PossiblyEvaluated layout; + Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout = + makeMutable<style::SymbolLayoutProperties::PossiblyEvaluated>(); bool sdfIcons = false; bool iconsNeedLinear = false; bool sortFeaturesByY = false; @@ -95,7 +96,8 @@ TEST(CrossTileSymbolLayerIndex, resetIDs) { uint32_t maxBucketInstanceId = 0; CrossTileSymbolLayerIndex index; - style::SymbolLayoutProperties::PossiblyEvaluated layout; + Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout = + makeMutable<style::SymbolLayoutProperties::PossiblyEvaluated>(); bool sdfIcons = false; bool iconsNeedLinear = false; bool sortFeaturesByY = false; @@ -135,7 +137,8 @@ TEST(CrossTileSymbolLayerIndex, noDuplicatesWithinZoomLevel) { uint32_t maxBucketInstanceId = 0; CrossTileSymbolLayerIndex index; - style::SymbolLayoutProperties::PossiblyEvaluated layout; + Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout = + makeMutable<style::SymbolLayoutProperties::PossiblyEvaluated>(); bool sdfIcons = false; bool iconsNeedLinear = false; bool sortFeaturesByY = false; @@ -173,7 +176,8 @@ TEST(CrossTileSymbolLayerIndex, bucketReplacement) { uint32_t maxBucketInstanceId = 0; CrossTileSymbolLayerIndex index; - style::SymbolLayoutProperties::PossiblyEvaluated layout; + Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout = + makeMutable<style::SymbolLayoutProperties::PossiblyEvaluated>(); bool sdfIcons = false; bool iconsNeedLinear = false; bool sortFeaturesByY = false; |