diff options
-rw-r--r-- | src/mbgl/geometry/line_atlas.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/pattern_atlas.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/render_orchestrator.cpp | 19 | ||||
-rw-r--r-- | src/mbgl/renderer/render_orchestrator.hpp | 1 |
4 files changed, 19 insertions, 5 deletions
diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp index 1be7cbf073..0ac5a489ce 100644 --- a/src/mbgl/geometry/line_atlas.hpp +++ b/src/mbgl/geometry/line_atlas.hpp @@ -69,6 +69,8 @@ public: // Uploads the textures to the GPU to be available when we need it. void upload(gfx::UploadPass&); + bool isEmpty() const { return textures.empty(); } + private: std::map<size_t, DashPatternTexture> textures; diff --git a/src/mbgl/renderer/pattern_atlas.hpp b/src/mbgl/renderer/pattern_atlas.hpp index f39ba25233..813c8f0247 100644 --- a/src/mbgl/renderer/pattern_atlas.hpp +++ b/src/mbgl/renderer/pattern_atlas.hpp @@ -38,6 +38,8 @@ public: return atlasImage; } + bool isEmpty() const { return patterns.empty(); } + private: struct Pattern { mapbox::Bin* bin; diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index 5851da98eb..0b85f893d7 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -142,10 +142,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree( // Reset zoom history state. zoomHistory.first = true; if (!updateParameters->keepRenderData && stillImageRequest != updateParameters->stillImageRequest) { - sourceImpls = makeMutable<std::vector<Immutable<style::Source::Impl>>>(); - layerImpls = makeMutable<std::vector<Immutable<style::Layer::Impl>>>(); - renderSources.clear(); - renderLayers.clear(); + clearData(); stillImageRequest = updateParameters->stillImageRequest; } } @@ -433,7 +430,6 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree( placementController.getPlacement()->symbolFadeChange(updateParameters->timePoint); renderTreeParameters->needsRepaint = hasTransitions(updateParameters->timePoint); } else { - crossTileSymbolIndex.reset(); renderTreeParameters->placementChanged = symbolBucketsChanged = !layersNeedPlacement.empty(); if (renderTreeParameters->placementChanged) { Mutable<Placement> placement = makeMutable<Placement>(updateParameters); @@ -703,6 +699,19 @@ bool RenderOrchestrator::isLoaded() const { return true; } +void RenderOrchestrator::clearData() { + if (!sourceImpls->empty()) sourceImpls = makeMutable<std::vector<Immutable<style::Source::Impl>>>(); + if (!layerImpls->empty()) layerImpls = makeMutable<std::vector<Immutable<style::Layer::Impl>>>(); + + renderSources.clear(); + renderLayers.clear(); + + crossTileSymbolIndex.reset(); + + if (!lineAtlas->isEmpty()) lineAtlas = std::make_unique<LineAtlas>(); + if (!patternAtlas->isEmpty()) patternAtlas = std::make_unique<PatternAtlas>(); +} + void RenderOrchestrator::onGlyphsError(const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) { Log::Error(Event::Style, "Failed to load glyph range %d-%d for font stack %s: %s", glyphRange.first, glyphRange.second, fontStackToString(fontStack).c_str(), util::toString(error).c_str()); diff --git a/src/mbgl/renderer/render_orchestrator.hpp b/src/mbgl/renderer/render_orchestrator.hpp index 7ede688dd7..312b28fd56 100644 --- a/src/mbgl/renderer/render_orchestrator.hpp +++ b/src/mbgl/renderer/render_orchestrator.hpp @@ -79,6 +79,7 @@ public: private: bool isLoaded() const; bool hasTransitions(TimePoint) const; + void clearData(); RenderSource* getRenderSource(const std::string& id) const; |