diff options
Diffstat (limited to 'src/mbgl/renderer/buckets/symbol_bucket.cpp')
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 681a492e73..a46c25a13b 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -18,7 +18,6 @@ SymbolBucket::SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEval const style::PropertyValue<float>& textSize, const style::PropertyValue<float>& iconSize, float zoom, - bool sdfIcons_, bool iconsNeedLinear_, bool sortFeaturesByY_, const std::string bucketName_, @@ -28,7 +27,6 @@ SymbolBucket::SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEval std::vector<style::TextWritingModeType> placementModes_) : layout(std::move(layout_)), bucketLeaderID(std::move(bucketName_)), - sdfIcons(sdfIcons_), iconsNeedLinear(iconsNeedLinear_ || iconSize.isDataDriven() || !iconSize.isZoomConstant()), sortFeaturesByY(sortFeaturesByY_), staticUploaded(false), @@ -87,30 +85,37 @@ void SymbolBucket::upload(gfx::UploadPass& uploadPass) { } } - if (hasIconData()) { + auto updateIconBuffer = [&](Buffer& iconBuffer) { if (!staticUploaded) { - icon.indexBuffer = uploadPass.createIndexBuffer(std::move(icon.triangles), sortFeaturesByY ? gfx::BufferUsageType::StreamDraw : gfx::BufferUsageType::StaticDraw); - icon.vertexBuffer = uploadPass.createVertexBuffer(std::move(icon.vertices)); + iconBuffer.indexBuffer = uploadPass.createIndexBuffer(std::move(iconBuffer.triangles), sortFeaturesByY ? gfx::BufferUsageType::StreamDraw : gfx::BufferUsageType::StaticDraw); + iconBuffer.vertexBuffer = uploadPass.createVertexBuffer(std::move(iconBuffer.vertices)); for (auto& pair : paintProperties) { pair.second.iconBinders.upload(uploadPass); } } else if (!sortUploaded) { - uploadPass.updateIndexBuffer(*icon.indexBuffer, std::move(icon.triangles)); + uploadPass.updateIndexBuffer(*iconBuffer.indexBuffer, std::move(iconBuffer.triangles)); } if (!dynamicUploaded) { - if (!icon.dynamicVertexBuffer) { - icon.dynamicVertexBuffer = uploadPass.createVertexBuffer(std::move(icon.dynamicVertices), gfx::BufferUsageType::StreamDraw); + if (!iconBuffer.dynamicVertexBuffer) { + iconBuffer.dynamicVertexBuffer = uploadPass.createVertexBuffer(std::move(iconBuffer.dynamicVertices), gfx::BufferUsageType::StreamDraw); } else { - uploadPass.updateVertexBuffer(*icon.dynamicVertexBuffer, std::move(icon.dynamicVertices)); + uploadPass.updateVertexBuffer(*iconBuffer.dynamicVertexBuffer, std::move(iconBuffer.dynamicVertices)); } } if (!placementChangesUploaded) { - if (!icon.opacityVertexBuffer) { - icon.opacityVertexBuffer = uploadPass.createVertexBuffer(std::move(icon.opacityVertices), gfx::BufferUsageType::StreamDraw); + if (!iconBuffer.opacityVertexBuffer) { + iconBuffer.opacityVertexBuffer = uploadPass.createVertexBuffer(std::move(iconBuffer.opacityVertices), gfx::BufferUsageType::StreamDraw); } else { - uploadPass.updateVertexBuffer(*icon.opacityVertexBuffer, std::move(icon.opacityVertices)); + uploadPass.updateVertexBuffer(*iconBuffer.opacityVertexBuffer, std::move(iconBuffer.opacityVertices)); } } + }; + if (hasIconData()) { + updateIconBuffer(icon); + } + + if (hasSdfIconData()) { + updateIconBuffer(sdfIcon); } if (hasCollisionBoxData()) { @@ -149,7 +154,7 @@ void SymbolBucket::upload(gfx::UploadPass& uploadPass) { } bool SymbolBucket::hasData() const { - return hasTextData() || hasIconData() || hasCollisionBoxData(); + return hasTextData() || hasIconData() || hasSdfIconData() || hasCollisionBoxData(); } bool SymbolBucket::hasTextData() const { @@ -160,6 +165,10 @@ bool SymbolBucket::hasIconData() const { return !icon.segments.empty(); } +bool SymbolBucket::hasSdfIconData() const { + return !sdfIcon.segments.empty(); +} + bool SymbolBucket::hasCollisionBoxData() const { return collisionBox && !collisionBox->segments.empty(); } @@ -188,9 +197,9 @@ void SymbolBucket::sortFeatures(const float angle) { sortedAngle = angle; - // The current approach to sorting doesn't sort across segments so don't try. + // The current approach to sorting doesn't sort across text and icon segments so don't try. // Sorting within segments separately seemed not to be worth the complexity. - if (text.segments.size() > 1 || icon.segments.size() > 1) { + if (text.segments.size() > 1 || (icon.segments.size() > 1 || sdfIcon.segments.size() > 1)) { return; } @@ -199,6 +208,7 @@ void SymbolBucket::sortFeatures(const float angle) { text.triangles.clear(); icon.triangles.clear(); + sdfIcon.triangles.clear(); featureSortOrder = std::make_unique<std::vector<size_t>>(); featureSortOrder->reserve(symbolInstances.size()); @@ -225,12 +235,13 @@ void SymbolBucket::sortFeatures(const float angle) { addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedVerticalTextIndex]); } + auto& iconBuffer = symbolInstance.hasSdfIcon() ? sdfIcon : icon; if (symbolInstance.placedIconIndex) { - addPlacedSymbol(icon.triangles, icon.placedSymbols[*symbolInstance.placedIconIndex]); + addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.placedIconIndex]); } if (symbolInstance.placedVerticalIconIndex) { - addPlacedSymbol(icon.triangles, icon.placedSymbols[*symbolInstance.placedVerticalIconIndex]); + addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.placedVerticalIconIndex]); } } } |