diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-04-28 14:53:50 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-05-05 18:35:40 +0300 |
commit | 071e2e1731b447e195290936c9bf52d28f52b2d9 (patch) | |
tree | 5524cbfcbd94a09ff589ca047c16d5f3ec41637e /src/mbgl/renderer | |
parent | f10839bac21a067bd4eff50a160223e5796a587e (diff) | |
download | qtlocation-mapboxgl-071e2e1731b447e195290936c9bf52d28f52b2d9.tar.gz |
Do not process buckets depending on Glyphs that were not loaded
For now, the buckets depending on Glyphs that are not yet available
are simply not created (or created and discarded). In the future
we could refactor the code to not create the bucket at all or put
the bucket in a suspended state until the glyph range is available.
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.cpp | 17 | ||||
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.hpp | 3 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index d6ae6c397f..dbaa177fcb 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -29,7 +29,7 @@ namespace mbgl { SymbolBucket::SymbolBucket(Collision &collision_) - : collision(collision_) { + : collision(collision_), needsGlyphs_(false) { } SymbolBucket::~SymbolBucket() { @@ -134,7 +134,10 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const GeometryTileLayer util::mergeLines(features); } - glyphStore.waitForGlyphRanges(layout.text.font, ranges); + if (glyphStore.requestGlyphRangesIfNeeded(layout.text.font, ranges)) { + needsGlyphs_ = true; + return {}; + } return features; } @@ -148,6 +151,12 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer, GlyphStore& glyphStore) { const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore); + // Stop if we still need glyphs because the + // bucket will be discarded. + if (needsGlyphs()) { + return; + } + float horizontalAlign = 0.5; float verticalAlign = 0.5; @@ -189,7 +198,7 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer, if (layout.text.justify == TextJustifyType::Right) justify = 1; else if (layout.text.justify == TextJustifyType::Left) justify = 0; - const auto &fontStack = glyphStore.getFontStack(layout.text.font); + auto* fontStack = glyphStore.getFontStack(layout.text.font); for (const auto& feature : features) { if (!feature.geometry.size()) continue; @@ -213,7 +222,7 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer, // Add the glyphs we need for this label to the glyph atlas. if (shaping.size()) { - glyphAtlas.addGlyphs(tileUID, feature.label, layout.text.font, fontStack, face); + glyphAtlas.addGlyphs(tileUID, feature.label, layout.text.font, *fontStack, face); } } diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 54a77b5099..9c67d66a52 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -69,6 +69,8 @@ public: GlyphAtlas&, GlyphStore&); + inline bool needsGlyphs() const { return needsGlyphs_; } + void drawGlyphs(SDFShader& shader); void drawIcons(SDFShader& shader); void drawIcons(IconShader& shader); @@ -103,6 +105,7 @@ private: std::vector<std::unique_ptr<IconElementGroup>> groups; } icon; + bool needsGlyphs_; }; } |