summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp20
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.cpp24
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.hpp16
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp16
-rw-r--r--src/mbgl/text/placement.cpp16
5 files changed, 52 insertions, 40 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 098a872c06..21642b01e3 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -73,7 +73,7 @@ inline Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> createLayout(
layout->get<IconPitchAlignment>() = layout->get<IconRotationAlignment>();
}
- return layout;
+ return std::move(layout);
}
} // namespace
@@ -738,8 +738,8 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) {
for (const SymbolInstance &symbolInstance : symbolInstances) {
auto populateCollisionBox = [&](const auto& feature) {
SymbolBucket::CollisionBuffer& collisionBuffer = feature.alongLine ?
- static_cast<SymbolBucket::CollisionBuffer&>(bucket.collisionCircle) :
- static_cast<SymbolBucket::CollisionBuffer&>(bucket.collisionBox);
+ static_cast<SymbolBucket::CollisionBuffer&>(bucket.getOrCreateCollisionCircleBuffer()) :
+ static_cast<SymbolBucket::CollisionBuffer&>(bucket.getOrCreateCollisionBox());
for (const CollisionBox &box : feature.boxes) {
auto& anchor = box.anchor;
@@ -753,7 +753,7 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) {
if (collisionBuffer.segments.empty() || collisionBuffer.segments.back().vertexLength + vertexLength > std::numeric_limits<uint16_t>::max()) {
collisionBuffer.segments.emplace_back(collisionBuffer.vertices.elements(),
- feature.alongLine? bucket.collisionCircle.triangles.elements() : bucket.collisionBox.lines.elements());
+ feature.alongLine ? bucket.collisionCircle->triangles.elements() : bucket.collisionBox->lines.elements());
}
auto& segment = collisionBuffer.segments.back();
@@ -773,13 +773,13 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) {
collisionBuffer.dynamicVertices.emplace_back(dynamicVertex);
if (feature.alongLine) {
- bucket.collisionCircle.triangles.emplace_back(index, index + 1, index + 2);
- bucket.collisionCircle.triangles.emplace_back(index, index + 2, index + 3);
+ bucket.collisionCircle->triangles.emplace_back(index, index + 1, index + 2);
+ bucket.collisionCircle->triangles.emplace_back(index, index + 2, index + 3);
} else {
- bucket.collisionBox.lines.emplace_back(index + 0, index + 1);
- bucket.collisionBox.lines.emplace_back(index + 1, index + 2);
- bucket.collisionBox.lines.emplace_back(index + 2, index + 3);
- bucket.collisionBox.lines.emplace_back(index + 3, index + 0);
+ bucket.collisionBox->lines.emplace_back(index + 0, index + 1);
+ bucket.collisionBox->lines.emplace_back(index + 1, index + 2);
+ bucket.collisionBox->lines.emplace_back(index + 2, index + 3);
+ bucket.collisionBox->lines.emplace_back(index + 3, index + 0);
}
segment.vertexLength += vertexLength;
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp
index cd9fb08d34..83efb232c2 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.cpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp
@@ -111,28 +111,28 @@ void SymbolBucket::upload(gfx::UploadPass& uploadPass) {
if (hasCollisionBoxData()) {
if (!staticUploaded) {
- collisionBox.indexBuffer = uploadPass.createIndexBuffer(std::move(collisionBox.lines));
- collisionBox.vertexBuffer = uploadPass.createVertexBuffer(std::move(collisionBox.vertices));
+ collisionBox->indexBuffer = uploadPass.createIndexBuffer(std::move(collisionBox->lines));
+ collisionBox->vertexBuffer = uploadPass.createVertexBuffer(std::move(collisionBox->vertices));
}
if (!placementChangesUploaded) {
- if (!collisionBox.dynamicVertexBuffer) {
- collisionBox.dynamicVertexBuffer = uploadPass.createVertexBuffer(std::move(collisionBox.dynamicVertices), gfx::BufferUsageType::StreamDraw);
+ if (!collisionBox->dynamicVertexBuffer) {
+ collisionBox->dynamicVertexBuffer = uploadPass.createVertexBuffer(std::move(collisionBox->dynamicVertices), gfx::BufferUsageType::StreamDraw);
} else {
- uploadPass.updateVertexBuffer(*collisionBox.dynamicVertexBuffer, std::move(collisionBox.dynamicVertices));
+ uploadPass.updateVertexBuffer(*collisionBox->dynamicVertexBuffer, std::move(collisionBox->dynamicVertices));
}
}
}
if (hasCollisionCircleData()) {
if (!staticUploaded) {
- collisionCircle.indexBuffer = uploadPass.createIndexBuffer(std::move(collisionCircle.triangles));
- collisionCircle.vertexBuffer = uploadPass.createVertexBuffer(std::move(collisionCircle.vertices));
+ collisionCircle->indexBuffer = uploadPass.createIndexBuffer(std::move(collisionCircle->triangles));
+ collisionCircle->vertexBuffer = uploadPass.createVertexBuffer(std::move(collisionCircle->vertices));
}
if (!placementChangesUploaded) {
- if (!collisionCircle.dynamicVertexBuffer) {
- collisionCircle.dynamicVertexBuffer = uploadPass.createVertexBuffer(std::move(collisionCircle.dynamicVertices), gfx::BufferUsageType::StreamDraw);
+ if (!collisionCircle->dynamicVertexBuffer) {
+ collisionCircle->dynamicVertexBuffer = uploadPass.createVertexBuffer(std::move(collisionCircle->dynamicVertices), gfx::BufferUsageType::StreamDraw);
} else {
- uploadPass.updateVertexBuffer(*collisionCircle.dynamicVertexBuffer, std::move(collisionCircle.dynamicVertices));
+ uploadPass.updateVertexBuffer(*collisionCircle->dynamicVertexBuffer, std::move(collisionCircle->dynamicVertices));
}
}
}
@@ -157,11 +157,11 @@ bool SymbolBucket::hasIconData() const {
}
bool SymbolBucket::hasCollisionBoxData() const {
- return !collisionBox.segments.empty();
+ return collisionBox && !collisionBox->segments.empty();
}
bool SymbolBucket::hasCollisionCircleData() const {
- return !collisionCircle.segments.empty();
+ return collisionCircle && !collisionCircle->segments.empty();
}
void addPlacedSymbol(gfx::IndexVector<gfx::Triangles>& triangles, const PlacedSymbol& placedSymbol) {
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp
index 1c975e93e8..7876937b1e 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.hpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp
@@ -129,12 +129,24 @@ public:
struct CollisionBoxBuffer : public CollisionBuffer {
gfx::IndexVector<gfx::Lines> lines;
optional<gfx::IndexBuffer> indexBuffer;
- } collisionBox;
+ };
+ std::unique_ptr<CollisionBoxBuffer> collisionBox;
+
+ CollisionBoxBuffer& getOrCreateCollisionBox() {
+ if (!collisionBox) collisionBox = std::make_unique<CollisionBoxBuffer>();
+ return *collisionBox;
+ }
struct CollisionCircleBuffer : public CollisionBuffer {
gfx::IndexVector<gfx::Triangles> triangles;
optional<gfx::IndexBuffer> indexBuffer;
- } collisionCircle;
+ };
+ std::unique_ptr<CollisionCircleBuffer> collisionCircle;
+
+ CollisionCircleBuffer& getOrCreateCollisionCircleBuffer() {
+ if (!collisionCircle) collisionCircle = std::make_unique<CollisionCircleBuffer>();
+ return *collisionCircle;
+ }
const float tilePixelRatio;
uint32_t bucketInstanceId;
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 8c3bae383f..4dddd57009 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -405,10 +405,10 @@ void RenderSymbolLayer::render(PaintParameters& parameters) {
uniforms::extrude_scale::Value( extrudeScale ),
uniforms::camera_to_center_distance::Value( parameters.state.getCameraToCenterDistance() )
},
- *bucket.collisionBox.vertexBuffer,
- *bucket.collisionBox.dynamicVertexBuffer,
- *bucket.collisionBox.indexBuffer,
- bucket.collisionBox.segments,
+ *bucket.collisionBox->vertexBuffer,
+ *bucket.collisionBox->dynamicVertexBuffer,
+ *bucket.collisionBox->indexBuffer,
+ bucket.collisionBox->segments,
paintAttributeData,
properties,
CollisionBoxProgram::TextureBindings{},
@@ -443,10 +443,10 @@ void RenderSymbolLayer::render(PaintParameters& parameters) {
uniforms::overscale_factor::Value( float(tile.getOverscaledTileID().overscaleFactor()) ),
uniforms::camera_to_center_distance::Value( parameters.state.getCameraToCenterDistance() )
},
- *bucket.collisionCircle.vertexBuffer,
- *bucket.collisionCircle.dynamicVertexBuffer,
- *bucket.collisionCircle.indexBuffer,
- bucket.collisionCircle.segments,
+ *bucket.collisionCircle->vertexBuffer,
+ *bucket.collisionCircle->dynamicVertexBuffer,
+ *bucket.collisionCircle->indexBuffer,
+ bucket.collisionCircle->segments,
paintAttributeData,
properties,
CollisionCircleProgram::TextureBindings{},
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 99c7b7f16b..1795b0dcb7 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -507,8 +507,8 @@ bool Placement::updateBucketDynamicVertices(SymbolBucket& bucket, const Transfor
void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState& state, std::set<uint32_t>& seenCrossTileIDs) {
if (bucket.hasTextData()) bucket.text.opacityVertices.clear();
if (bucket.hasIconData()) bucket.icon.opacityVertices.clear();
- if (bucket.hasCollisionBoxData()) bucket.collisionBox.dynamicVertices.clear();
- if (bucket.hasCollisionCircleData()) bucket.collisionCircle.dynamicVertices.clear();
+ if (bucket.hasCollisionBoxData()) bucket.collisionBox->dynamicVertices.clear();
+ if (bucket.hasCollisionCircleData()) bucket.collisionCircle->dynamicVertices.clear();
JointOpacityState duplicateOpacityState(false, false, true);
@@ -598,7 +598,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState
}
auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false, {});
for (size_t i = 0; i < feature.boxes.size() * 4; i++) {
- bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionBox->dynamicVertices.emplace_back(dynamicVertex);
}
};
@@ -633,7 +633,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState
}
auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !used, shift);
for (size_t i = 0; i < feature.boxes.size() * 4; i++) {
- bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionBox->dynamicVertices.emplace_back(dynamicVertex);
}
};
@@ -643,10 +643,10 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState
}
for (const CollisionBox& box : feature.boxes) {
auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !box.used, {});
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex);
}
};