diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-11-06 11:52:26 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2017-11-06 11:59:06 -0800 |
commit | bc4f35cd7b743b04d1910ab28a612d1c49be910d (patch) | |
tree | f11e8c7f47122d715ae4a65bb6f45763c4a81d05 | |
parent | 3b3009014fff3704a4d836dc4617cd603e6f40ee (diff) | |
download | qtlocation-mapboxgl-bc4f35cd7b743b04d1910ab28a612d1c49be910d.tar.gz |
Rename CollisionBoxOpacityAttributes -> CollisionBoxDynamicAttributes.
They're not really about opacity.
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 16 | ||||
-rw-r--r-- | src/mbgl/programs/collision_box_program.hpp | 16 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.cpp | 24 | ||||
-rw-r--r-- | src/mbgl/renderer/buckets/symbol_bucket.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_symbol_layer.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/placement.cpp | 24 |
6 files changed, 49 insertions, 45 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 3b2ab9eeb2..1a8b55a51b 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -529,13 +529,15 @@ size_t SymbolLayout::addSymbol(Buffer& buffer, buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(labelAnchor.point, bl, symbol.glyphOffset.y, tex.x, tex.y + tex.h, sizeData)); buffer.vertices.emplace_back(SymbolLayoutAttributes::vertex(labelAnchor.point, br, symbol.glyphOffset.y, tex.x + tex.w, tex.y + tex.h, sizeData)); + // Dynamic/Opacity vertices are initialized so that the vertex count always agrees with + // the layout vertex buffer, but they will always be updated before rendering happens auto dynamicVertex = SymbolDynamicLayoutAttributes::vertex(labelAnchor.point, 0); buffer.dynamicVertices.emplace_back(dynamicVertex); buffer.dynamicVertices.emplace_back(dynamicVertex); buffer.dynamicVertices.emplace_back(dynamicVertex); buffer.dynamicVertices.emplace_back(dynamicVertex); - auto opacityVertex = SymbolOpacityAttributes::vertex(1.0, 1.0); // TODO: This data doesn't matter, it's just a kind-of-silly way to set the size of the opacity buffer + auto opacityVertex = SymbolOpacityAttributes::vertex(1.0, 1.0); buffer.opacityVertices.emplace_back(opacityVertex); buffer.opacityVertices.emplace_back(opacityVertex); buffer.opacityVertices.emplace_back(opacityVertex); @@ -588,11 +590,13 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) { collisionBuffer.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, symbolInstance.anchor.point, br)); collisionBuffer.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, symbolInstance.anchor.point, bl)); - auto opacityVertex = CollisionBoxOpacityAttributes::vertex(false, false); // TODO: This data doesn't matter, it's just a kind-of-silly way to set the size of the opacity buffer - collisionBuffer.opacityVertices.emplace_back(opacityVertex); - collisionBuffer.opacityVertices.emplace_back(opacityVertex); - collisionBuffer.opacityVertices.emplace_back(opacityVertex); - collisionBuffer.opacityVertices.emplace_back(opacityVertex); + // Dynamic vertices are initialized so that the vertex count always agrees with + // the layout vertex buffer, but they will always be updated before rendering happens + auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(false, false); + collisionBuffer.dynamicVertices.emplace_back(dynamicVertex); + collisionBuffer.dynamicVertices.emplace_back(dynamicVertex); + collisionBuffer.dynamicVertices.emplace_back(dynamicVertex); + collisionBuffer.dynamicVertices.emplace_back(dynamicVertex); if (feature.alongLine) { bucket.collisionCircle.triangles.emplace_back(index, index + 1, index + 2); diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp index dfb2f66b30..46f65a905a 100644 --- a/src/mbgl/programs/collision_box_program.hpp +++ b/src/mbgl/programs/collision_box_program.hpp @@ -17,7 +17,7 @@ using CollisionBoxLayoutAttributes = gl::Attributes< attributes::a_anchor_pos, attributes::a_extrude>; -struct CollisionBoxOpacityAttributes : gl::Attributes<attributes::a_placed> { +struct CollisionBoxDynamicAttributes : gl::Attributes<attributes::a_placed> { static Vertex vertex(bool placed, bool notUsed) { return Vertex { {{ static_cast<uint8_t>(placed), static_cast<uint8_t>(notUsed) }} @@ -28,7 +28,7 @@ struct CollisionBoxOpacityAttributes : gl::Attributes<attributes::a_placed> { class CollisionBoxProgram : public Program< shaders::collision_box, gl::Line, - gl::ConcatenateAttributes<CollisionBoxLayoutAttributes, CollisionBoxOpacityAttributes>, + gl::ConcatenateAttributes<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>, gl::Uniforms< uniforms::u_matrix, uniforms::u_extrude_scale, @@ -63,7 +63,7 @@ public: gl::ColorMode colorMode, const UniformValues& uniformValues, const gl::VertexBuffer<CollisionBoxLayoutAttributes::Vertex>& layoutVertexBuffer, - const gl::VertexBuffer<CollisionBoxOpacityAttributes::Vertex>& opacityVertexBuffer, + const gl::VertexBuffer<CollisionBoxDynamicAttributes::Vertex>& dynamicVertexBuffer, const gl::IndexBuffer<DrawMode>& indexBuffer, const SegmentVector<Attributes>& segments, const PaintPropertyBinders& paintPropertyBinders, @@ -74,10 +74,10 @@ public: .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); typename Attributes::Bindings allAttributeBindings = CollisionBoxLayoutAttributes::bindings(layoutVertexBuffer) - .concat(CollisionBoxOpacityAttributes::bindings(opacityVertexBuffer)) + .concat(CollisionBoxDynamicAttributes::bindings(dynamicVertexBuffer)) .concat(paintPropertyBinders.attributeBindings(currentProperties)); - assert(layoutVertexBuffer.vertexCount == opacityVertexBuffer.vertexCount); + assert(layoutVertexBuffer.vertexCount == dynamicVertexBuffer.vertexCount); for (auto& segment : segments) { auto vertexArrayIt = segment.vertexArrays.find(layerID); @@ -107,7 +107,7 @@ public: class CollisionCircleProgram : public Program< shaders::collision_circle, gl::Triangle, - gl::ConcatenateAttributes<CollisionBoxLayoutAttributes, CollisionBoxOpacityAttributes>, + gl::ConcatenateAttributes<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>, gl::Uniforms< uniforms::u_matrix, uniforms::u_extrude_scale, @@ -142,7 +142,7 @@ public: gl::ColorMode colorMode, const UniformValues& uniformValues, const gl::VertexBuffer<CollisionBoxLayoutAttributes::Vertex>& layoutVertexBuffer, - const gl::VertexBuffer<CollisionBoxOpacityAttributes::Vertex>& opacityVertexBuffer, + const gl::VertexBuffer<CollisionBoxDynamicAttributes::Vertex>& dynamicVertexBuffer, const gl::IndexBuffer<DrawMode>& indexBuffer, const SegmentVector<Attributes>& segments, const PaintPropertyBinders& paintPropertyBinders, @@ -153,7 +153,7 @@ public: .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); typename Attributes::Bindings allAttributeBindings = CollisionBoxLayoutAttributes::bindings(layoutVertexBuffer) - .concat(CollisionBoxOpacityAttributes::bindings(opacityVertexBuffer)) + .concat(CollisionBoxDynamicAttributes::bindings(dynamicVertexBuffer)) .concat(paintPropertyBinders.attributeBindings(currentProperties)); for (auto& segment : segments) { diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index f11679aafa..d1b3c3469b 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -50,7 +50,7 @@ void SymbolBucket::upload(gl::Context& context) { if (!dynamicUploaded) { text.dynamicVertexBuffer = context.createVertexBuffer(std::move(text.dynamicVertices), gl::BufferUsage::StreamDraw); } - if (!opacityUploaded) { + if (!placementChangesUploaded) { if (!text.opacityVertexBuffer) { text.opacityVertexBuffer = context.createVertexBuffer(std::move(text.opacityVertices), gl::BufferUsage::StreamDraw); } else { @@ -69,7 +69,7 @@ void SymbolBucket::upload(gl::Context& context) { if (!dynamicUploaded) { icon.dynamicVertexBuffer = context.createVertexBuffer(std::move(icon.dynamicVertices), gl::BufferUsage::StreamDraw); } - if (!opacityUploaded) { + if (!placementChangesUploaded) { if (!icon.opacityVertexBuffer) { icon.opacityVertexBuffer = context.createVertexBuffer(std::move(icon.opacityVertices), gl::BufferUsage::StreamDraw); } else { @@ -83,11 +83,11 @@ void SymbolBucket::upload(gl::Context& context) { collisionBox.indexBuffer = context.createIndexBuffer(std::move(collisionBox.lines)); collisionBox.vertexBuffer = context.createVertexBuffer(std::move(collisionBox.vertices)); } - if (!opacityUploaded) { - if (!collisionBox.opacityVertexBuffer) { - collisionBox.opacityVertexBuffer = context.createVertexBuffer(std::move(collisionBox.opacityVertices), gl::BufferUsage::StreamDraw); + if (!placementChangesUploaded) { + if (!collisionBox.dynamicVertexBuffer) { + collisionBox.dynamicVertexBuffer = context.createVertexBuffer(std::move(collisionBox.dynamicVertices), gl::BufferUsage::StreamDraw); } else { - context.updateVertexBuffer(*collisionBox.opacityVertexBuffer, std::move(collisionBox.opacityVertices)); + context.updateVertexBuffer(*collisionBox.dynamicVertexBuffer, std::move(collisionBox.dynamicVertices)); } } } @@ -97,11 +97,11 @@ void SymbolBucket::upload(gl::Context& context) { collisionCircle.indexBuffer = context.createIndexBuffer(std::move(collisionCircle.triangles)); collisionCircle.vertexBuffer = context.createVertexBuffer(std::move(collisionCircle.vertices)); } - if (!opacityUploaded) { - if (!collisionCircle.opacityVertexBuffer) { - collisionCircle.opacityVertexBuffer = context.createVertexBuffer(std::move(collisionCircle.opacityVertices), gl::BufferUsage::StreamDraw); + if (!placementChangesUploaded) { + if (!collisionCircle.dynamicVertexBuffer) { + collisionCircle.dynamicVertexBuffer = context.createVertexBuffer(std::move(collisionCircle.dynamicVertices), gl::BufferUsage::StreamDraw); } else { - context.updateVertexBuffer(*collisionCircle.opacityVertexBuffer, std::move(collisionCircle.opacityVertices)); + context.updateVertexBuffer(*collisionCircle.dynamicVertexBuffer, std::move(collisionCircle.dynamicVertices)); } } } @@ -115,7 +115,7 @@ void SymbolBucket::upload(gl::Context& context) { uploaded = true; staticUploaded = true; - opacityUploaded = true; + placementChangesUploaded = true; dynamicUploaded = true; sortUploaded = true; } @@ -141,7 +141,7 @@ bool SymbolBucket::hasCollisionCircleData() const { } void SymbolBucket::updateOpacity() { - opacityUploaded = false; + placementChangesUploaded = false; uploaded = false; } diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index 5fc3fae8a9..bcf470be87 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -67,7 +67,7 @@ public: optional<float> sortedAngle; bool staticUploaded = false; - bool opacityUploaded = false; + bool placementChangesUploaded = false; bool dynamicUploaded = false; bool sortUploaded = false; @@ -112,11 +112,11 @@ public: struct CollisionBuffer { gl::VertexVector<CollisionBoxLayoutAttributes::Vertex> vertices; - gl::VertexVector<CollisionBoxOpacityAttributes::Vertex> opacityVertices; + gl::VertexVector<CollisionBoxDynamicAttributes::Vertex> dynamicVertices; SegmentVector<CollisionBoxProgram::Attributes> segments; optional<gl::VertexBuffer<CollisionBoxLayoutAttributes::Vertex>> vertexBuffer; - optional<gl::VertexBuffer<CollisionBoxOpacityAttributes::Vertex>> opacityVertexBuffer; + optional<gl::VertexBuffer<CollisionBoxDynamicAttributes::Vertex>> dynamicVertexBuffer; }; struct CollisionBoxBuffer : public CollisionBuffer { diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 7352b766d9..e194c9c857 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -237,7 +237,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { parameters.context, gl::Lines { 1.0f }, gl::DepthMode::disabled(), - gl::StencilMode::disabled(), // TODO //parameters.stencilModeForClipping(tile.clip), + gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), CollisionBoxProgram::UniformValues { uniforms::u_matrix::Value{ tile.matrix }, @@ -245,7 +245,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { uniforms::u_camera_to_center_distance::Value{ parameters.state.getCameraToCenterDistance() } }, *bucket.collisionBox.vertexBuffer, - *bucket.collisionBox.opacityVertexBuffer, + *bucket.collisionBox.dynamicVertexBuffer, *bucket.collisionBox.indexBuffer, bucket.collisionBox.segments, paintAttributeData, @@ -271,7 +271,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { parameters.context, gl::Triangles(), gl::DepthMode::disabled(), - gl::StencilMode::disabled(), // TODO //parameters.stencilModeForClipping(tile.clip), + gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), CollisionBoxProgram::UniformValues { uniforms::u_matrix::Value{ tile.matrix }, @@ -279,7 +279,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { uniforms::u_camera_to_center_distance::Value{ parameters.state.getCameraToCenterDistance() } }, *bucket.collisionCircle.vertexBuffer, - *bucket.collisionCircle.opacityVertexBuffer, + *bucket.collisionCircle.dynamicVertexBuffer, *bucket.collisionCircle.indexBuffer, bucket.collisionCircle.segments, paintAttributeData, diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 8ab6bd8efb..4abf154d5c 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -208,8 +208,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::unordered_set<u // TODO check if this clear is necessary, whether the vector has been moved out if (bucket.hasTextData()) bucket.text.opacityVertices.clear(); if (bucket.hasIconData()) bucket.icon.opacityVertices.clear(); - if (bucket.hasCollisionBoxData()) bucket.collisionBox.opacityVertices.clear(); - if (bucket.hasCollisionCircleData()) bucket.collisionCircle.opacityVertices.clear(); + if (bucket.hasCollisionBoxData()) bucket.collisionBox.dynamicVertices.clear(); + if (bucket.hasCollisionCircleData()) bucket.collisionCircle.dynamicVertices.clear(); for (SymbolInstance& symbolInstance : bucket.symbolInstances) { auto opacityState = seenCrossTileIDs.count(symbolInstance.crossTileID) == 0 ? @@ -249,17 +249,17 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::unordered_set<u auto updateCollisionBox = [&](const auto& feature, const bool placed) { for (const CollisionBox& box : feature.boxes) { if (feature.alongLine) { - auto opacityVertex = CollisionBoxOpacityAttributes::vertex(placed, !box.used); - bucket.collisionCircle.opacityVertices.emplace_back(opacityVertex); - bucket.collisionCircle.opacityVertices.emplace_back(opacityVertex); - bucket.collisionCircle.opacityVertices.emplace_back(opacityVertex); - bucket.collisionCircle.opacityVertices.emplace_back(opacityVertex); + auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(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); } else { - auto opacityVertex = CollisionBoxOpacityAttributes::vertex(placed, false); - bucket.collisionBox.opacityVertices.emplace_back(opacityVertex); - bucket.collisionBox.opacityVertices.emplace_back(opacityVertex); - bucket.collisionBox.opacityVertices.emplace_back(opacityVertex); - bucket.collisionBox.opacityVertices.emplace_back(opacityVertex); + auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, false); + bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex); + bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex); + bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex); + bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex); } } }; |