summaryrefslogtreecommitdiff
path: root/src/mbgl/programs
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-04-10 11:57:11 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-04-17 15:04:08 +0300
commit113e96e03c1ad923f481f9215f6cac83451263ef (patch)
treeccf1ba7529a8e3a711d596678e658f15b35293ec /src/mbgl/programs
parent2a169b07e8d47dec018c2429bcfcb1e6ff0a4ead (diff)
downloadqtlocation-mapboxgl-113e96e03c1ad923f481f9215f6cac83451263ef.tar.gz
[core] Sort cross-tile symbol segments using symbol-sort-key
Diffstat (limited to 'src/mbgl/programs')
-rw-r--r--src/mbgl/programs/symbol_program.hpp78
1 files changed, 56 insertions, 22 deletions
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index 56477166d8..2ad446ae2a 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -307,6 +307,48 @@ public:
const gfx::ColorMode& colorMode,
const gfx::CullFaceMode& cullFaceMode,
const gfx::IndexBuffer& indexBuffer,
+ const Segment<AttributeList>& segment,
+ const UniformValues& uniformValues,
+ const AttributeBindings& allAttributeBindings,
+ const TextureBindings& textureBindings,
+ const std::string& layerID) {
+ static_assert(Primitive == gfx::PrimitiveTypeOf<DrawMode>::value, "incompatible draw mode");
+
+ if (!program) {
+ return;
+ }
+
+ auto drawScopeIt = segment.drawScopes.find(layerID);
+ if (drawScopeIt == segment.drawScopes.end()) {
+ drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first;
+ }
+
+ program->draw(
+ context,
+ renderPass,
+ drawMode,
+ depthMode,
+ stencilMode,
+ colorMode,
+ cullFaceMode,
+ uniformValues,
+ drawScopeIt->second,
+ allAttributeBindings.offset(segment.vertexOffset),
+ textureBindings,
+ indexBuffer,
+ segment.indexOffset,
+ segment.indexLength);
+ }
+
+ template <class DrawMode>
+ void draw(gfx::Context& context,
+ gfx::RenderPass& renderPass,
+ const DrawMode& drawMode,
+ const gfx::DepthMode& depthMode,
+ const gfx::StencilMode& stencilMode,
+ const gfx::ColorMode& colorMode,
+ const gfx::CullFaceMode& cullFaceMode,
+ const gfx::IndexBuffer& indexBuffer,
const SegmentVector<AttributeList>& segments,
const UniformValues& uniformValues,
const AttributeBindings& allAttributeBindings,
@@ -318,28 +360,20 @@ public:
return;
}
- for (auto& segment : segments) {
- auto drawScopeIt = segment.drawScopes.find(layerID);
-
- if (drawScopeIt == segment.drawScopes.end()) {
- drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first;
- }
-
- program->draw(
- context,
- renderPass,
- drawMode,
- depthMode,
- stencilMode,
- colorMode,
- cullFaceMode,
- uniformValues,
- drawScopeIt->second,
- allAttributeBindings.offset(segment.vertexOffset),
- textureBindings,
- indexBuffer,
- segment.indexOffset,
- segment.indexLength);
+ for (const auto& segment : segments) {
+ draw(context,
+ renderPass,
+ drawMode,
+ depthMode,
+ stencilMode,
+ colorMode,
+ cullFaceMode,
+ indexBuffer,
+ segment,
+ uniformValues,
+ allAttributeBindings,
+ textureBindings,
+ layerID);
}
}
};