summaryrefslogtreecommitdiff
path: root/src/mbgl/layout
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-29 18:59:07 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-31 16:53:07 +0200
commit384f1a1960c9a21039642afe9bd1df58a93fddfc (patch)
treecd4a383d82ee78a8bb38f87703a19b61171c5f1d /src/mbgl/layout
parent38f536049a8ed8f4bdf7706f4afcbbaf06c974c9 (diff)
downloadqtlocation-mapboxgl-384f1a1960c9a21039642afe9bd1df58a93fddfc.tar.gz
[core] Use numeric_limits<>::max() for checking element groups
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 06f26b8ffb..fb0c67a481 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -418,6 +418,7 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
template <typename Buffer>
void SymbolLayout::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const style::SymbolPlacementType placement, const float placementAngle) {
+ constexpr const uint16_t vertexLength = 4;
const float placementZoom = util::max(util::log2(scale) + zoom, 0.0f);
for (const auto& symbol : symbols) {
@@ -447,16 +448,15 @@ void SymbolLayout::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float
minZoom = 0;
}
- const int glyph_vertex_length = 4;
-
- if (buffer.segments.empty() || buffer.segments.back().vertexLength + glyph_vertex_length > 65535) {
+ if (buffer.segments.back().vertexLength + vertexLength > std::numeric_limits<uint16_t>::max()) {
buffer.segments.emplace_back(buffer.vertices.size(), buffer.triangles.size());
}
// We're generating triangle fans, so we always start with the first
// coordinate in this polygon.
auto& segment = buffer.segments.back();
- size_t index = segment.vertexLength;
+ assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
+ uint16_t index = segment.vertexLength;
// Encode angle of glyph
uint8_t glyphAngle = std::round((symbol.glyphAngle / (M_PI * 2)) * 256);
@@ -472,14 +472,10 @@ void SymbolLayout::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float
minZoom, maxZoom, placementZoom, glyphAngle);
// add the two triangles, referencing the four coordinates we just inserted.
- buffer.triangles.emplace_back(static_cast<uint16_t>(index + 0),
- static_cast<uint16_t>(index + 1),
- static_cast<uint16_t>(index + 2));
- buffer.triangles.emplace_back(static_cast<uint16_t>(index + 1),
- static_cast<uint16_t>(index + 2),
- static_cast<uint16_t>(index + 3));
-
- segment.vertexLength += glyph_vertex_length;
+ buffer.triangles.emplace_back(index + 0, index + 1, index + 2);
+ buffer.triangles.emplace_back(index + 1, index + 2, index + 3);
+
+ segment.vertexLength += vertexLength;
segment.primitiveLength += 2;
}
}