summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/layout/symbol_instance.cpp17
-rw-r--r--src/mbgl/layout/symbol_instance.hpp9
-rw-r--r--src/mbgl/layout/symbol_layout.cpp32
-rw-r--r--src/mbgl/layout/symbol_layout.hpp6
-rw-r--r--src/mbgl/text/placement.cpp7
-rw-r--r--src/mbgl/text/quads.cpp24
-rw-r--r--src/mbgl/text/quads.hpp2
7 files changed, 64 insertions, 33 deletions
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp
index 094f859830..5c92d2f678 100644
--- a/src/mbgl/layout/symbol_instance.cpp
+++ b/src/mbgl/layout/symbol_instance.cpp
@@ -31,10 +31,10 @@ SymbolInstanceSharedData::SymbolInstanceSharedData(GeometryCoordinates line_,
: line(std::move(line_)) {
// Create the quads used for rendering the icon and glyphs.
if (shapedIcon) {
- iconQuad = getIconQuad(*shapedIcon, getAnyShaping(shapedTextOrientations).writingMode, iconType);
+ iconQuads = getIconQuads(*shapedIcon, getAnyShaping(shapedTextOrientations).writingMode, iconType);
if (verticallyShapedIcon) {
- verticalIconQuad =
- getIconQuad(*verticallyShapedIcon, shapedTextOrientations.vertical.writingMode, iconType);
+ verticalIconQuads =
+ getIconQuads(*verticallyShapedIcon, shapedTextOrientations.vertical.writingMode, iconType);
}
}
@@ -130,6 +130,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor_,
centerJustifiedGlyphQuadsSize = sharedData->centerJustifiedGlyphQuads.size();
leftJustifiedGlyphQuadsSize = sharedData->leftJustifiedGlyphQuads.size();
verticalGlyphQuadsSize = sharedData->verticalGlyphQuads.size();
+ iconQuadsSize = sharedData->iconQuads ? sharedData->iconQuads->size() : 0;
if (rightJustifiedGlyphQuadsSize || centerJustifiedGlyphQuadsSize || leftJustifiedGlyphQuadsSize) {
writingModes |= WritingModeType::Horizontal;
@@ -165,11 +166,11 @@ const SymbolQuads& SymbolInstance::verticalGlyphQuads() const {
return sharedData->verticalGlyphQuads;
}
-const optional<SymbolQuad>& SymbolInstance::iconQuad() const {
+const optional<SymbolQuads>& SymbolInstance::iconQuads() const {
assert(sharedData);
- return sharedData->iconQuad;
+ return sharedData->iconQuads;
}
-
+
bool SymbolInstance::hasText() const {
return static_cast<bool>(symbolContent & SymbolContent::Text);
}
@@ -182,9 +183,9 @@ bool SymbolInstance::hasSdfIcon() const {
return static_cast<bool>(symbolContent & SymbolContent::IconSDF);
}
-const optional<SymbolQuad>& SymbolInstance::verticalIconQuad() const {
+const optional<SymbolQuads>& SymbolInstance::verticalIconQuads() const {
assert(sharedData);
- return sharedData->verticalIconQuad;
+ return sharedData->verticalIconQuads;
}
void SymbolInstance::releaseSharedData() {
diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp
index e20c05a0ab..74124d3364 100644
--- a/src/mbgl/layout/symbol_instance.hpp
+++ b/src/mbgl/layout/symbol_instance.hpp
@@ -41,8 +41,8 @@ struct SymbolInstanceSharedData {
SymbolQuads centerJustifiedGlyphQuads;
SymbolQuads leftJustifiedGlyphQuads;
SymbolQuads verticalGlyphQuads;
- optional<SymbolQuad> iconQuad;
- optional<SymbolQuad> verticalIconQuad;
+ optional<SymbolQuads> iconQuads;
+ optional<SymbolQuads> verticalIconQuads;
};
class SymbolInstance {
@@ -79,8 +79,8 @@ public:
bool hasText() const;
bool hasIcon() const;
bool hasSdfIcon() const;
- const optional<SymbolQuad>& iconQuad() const;
- const optional<SymbolQuad>& verticalIconQuad() const;
+ const optional<SymbolQuads>& iconQuads() const;
+ const optional<SymbolQuads>& verticalIconQuads() const;
void releaseSharedData();
private:
@@ -94,6 +94,7 @@ public:
std::size_t centerJustifiedGlyphQuadsSize;
std::size_t leftJustifiedGlyphQuadsSize;
std::size_t verticalGlyphQuadsSize;
+ std::size_t iconQuadsSize;
CollisionFeature textCollisionFeature;
CollisionFeature iconCollisionFeature;
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 8fea0858e4..98274136ec 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -745,7 +745,7 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
if (hasIcon) {
const Range<float> sizeData = bucket->iconSizeBinder->getVertexSizeData(feature);
auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket->sdfIcon : bucket->icon;
- const auto placeIcon = [&](const SymbolQuad& iconQuad, auto& index, const WritingModeType writingMode) {
+ const auto placeIcon = [&](const SymbolQuads& iconQuads, auto& index, const WritingModeType writingMode) {
iconBuffer.placedSymbols.emplace_back(symbolInstance.anchor.point,
symbolInstance.anchor.segment.value_or(0u),
sizeData.min,
@@ -757,13 +757,15 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn
index = iconBuffer.placedSymbols.size() - 1;
PlacedSymbol& iconSymbol = iconBuffer.placedSymbols.back();
iconSymbol.angle = (allowVerticalPlacement && writingMode == WritingModeType::Vertical) ? M_PI_2 : 0;
- iconSymbol.vertexStartIndex = addSymbol(iconBuffer, sizeData, iconQuad,
- symbolInstance.anchor, iconSymbol, feature.sortKey);
+ iconSymbol.vertexStartIndex =
+ addSymbols(iconBuffer, sizeData, iconQuads, symbolInstance.anchor, iconSymbol, feature.sortKey);
};
- placeIcon(*symbolInstance.iconQuad(), symbolInstance.placedIconIndex, WritingModeType::None);
- if (symbolInstance.verticalIconQuad()) {
- placeIcon(*symbolInstance.verticalIconQuad(), symbolInstance.placedVerticalIconIndex, WritingModeType::Vertical);
+ placeIcon(*symbolInstance.iconQuads(), symbolInstance.placedIconIndex, WritingModeType::None);
+ if (symbolInstance.verticalIconQuads()) {
+ placeIcon(*symbolInstance.verticalIconQuads(),
+ symbolInstance.placedVerticalIconIndex,
+ WritingModeType::Vertical);
}
for (auto& pair : bucket->paintProperties) {
@@ -959,6 +961,24 @@ size_t SymbolLayout::addSymbol(SymbolBucket::Buffer& buffer,
return index;
}
+size_t SymbolLayout::addSymbols(SymbolBucket::Buffer& buffer,
+ const Range<float> sizeData,
+ const SymbolQuads& symbols,
+ const Anchor& labelAnchor,
+ PlacedSymbol& placedSymbol,
+ float sortKey) {
+ bool firstSymbol = true;
+ size_t firstIndex = 0;
+ for (auto& symbol : symbols) {
+ const size_t index = addSymbol(buffer, sizeData, symbol, labelAnchor, placedSymbol, sortKey);
+ if (firstSymbol) {
+ firstIndex = index;
+ firstSymbol = false;
+ }
+ }
+ return firstIndex;
+}
+
void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) {
if (!hasSymbolInstances()) {
diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp
index 57a104bf45..b906b0b36c 100644
--- a/src/mbgl/layout/symbol_layout.hpp
+++ b/src/mbgl/layout/symbol_layout.hpp
@@ -81,6 +81,12 @@ private:
const Anchor& labelAnchor,
PlacedSymbol& placedSymbol,
float sortKey);
+ size_t addSymbols(SymbolBucket::Buffer&,
+ const Range<float> sizeData,
+ const SymbolQuads&,
+ const Anchor& labelAnchor,
+ PlacedSymbol& placedSymbol,
+ float sortKey);
// Adds symbol quads to bucket and returns formatted section index of last
// added quad.
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 2a98935d73..d6a78082fa 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -945,19 +945,22 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
}
}
if (symbolInstance.hasIcon()) {
+ size_t iconOpacityVerticesSize = 0u;
const auto& opacityVertex =
SymbolIconProgram::opacityVertex(opacityState.icon.placed, opacityState.icon.opacity);
auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket.sdfIcon : bucket.icon;
if (symbolInstance.placedIconIndex) {
- iconBuffer.opacityVertices.extend(4, opacityVertex);
+ iconOpacityVerticesSize += symbolInstance.iconQuadsSize * 4;
iconBuffer.placedSymbols[*symbolInstance.placedIconIndex].hidden = opacityState.isHidden();
}
if (symbolInstance.placedVerticalIconIndex) {
- iconBuffer.opacityVertices.extend(4, opacityVertex);
+ iconOpacityVerticesSize += symbolInstance.iconQuadsSize * 4;
iconBuffer.placedSymbols[*symbolInstance.placedVerticalIconIndex].hidden = opacityState.isHidden();
}
+
+ iconBuffer.opacityVertices.extend(iconOpacityVerticesSize, opacityVertex);
}
auto updateIconCollisionBox = [&](const auto& feature, const bool placed, const Point<float>& shift) {
diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp
index 747a208ee1..1f07ad4427 100644
--- a/src/mbgl/text/quads.cpp
+++ b/src/mbgl/text/quads.cpp
@@ -14,7 +14,7 @@ namespace mbgl {
using namespace style;
-SymbolQuad getIconQuad(const PositionedIcon& shapedIcon, WritingModeType writingMode, SymbolContent iconType) {
+SymbolQuads getIconQuads(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
@@ -74,17 +74,17 @@ SymbolQuad getIconQuad(const PositionedIcon& shapedIcon, WritingModeType writing
Point<float> pixelOffsetBR;
Point<float> minFontScale;
- return SymbolQuad{tl,
- tr,
- bl,
- br,
- textureRect,
- writingMode,
- {0.0f, 0.0f},
- iconType == SymbolContent::IconSDF,
- pixelOffsetTL,
- pixelOffsetBR,
- minFontScale};
+ return {SymbolQuad{tl,
+ tr,
+ bl,
+ br,
+ textureRect,
+ writingMode,
+ {0.0f, 0.0f},
+ iconType == SymbolContent::IconSDF,
+ pixelOffsetTL,
+ pixelOffsetBR,
+ minFontScale}};
}
SymbolQuads getGlyphQuads(const Shaping& shapedText,
diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp
index c61c85f14c..b6d2687d07 100644
--- a/src/mbgl/text/quads.hpp
+++ b/src/mbgl/text/quads.hpp
@@ -57,7 +57,7 @@ public:
using SymbolQuads = std::vector<SymbolQuad>;
-SymbolQuad getIconQuad(const PositionedIcon& shapedIcon, WritingModeType writingMode, SymbolContent iconType);
+SymbolQuads getIconQuads(const PositionedIcon& shapedIcon, WritingModeType writingMode, SymbolContent iconType);
SymbolQuads getGlyphQuads(const Shaping& shapedText,
const std::array<float, 2> textOffset,