diff options
-rw-r--r-- | src/mbgl/map/map_context.cpp | 16 | ||||
-rw-r--r-- | src/mbgl/map/source.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.cpp | 28 | ||||
-rw-r--r-- | src/mbgl/renderer/painter.hpp | 6 |
4 files changed, 22 insertions, 37 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 3fc8159d1d..75f195a3f9 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -97,9 +97,6 @@ void MapContext::setStyleURL(const std::string& url) { styleJSON.clear(); style = std::make_unique<Style>(data); - if (painter) { - painter->updateRenderOrder(*style); - } const size_t pos = styleURL.rfind('/'); std::string base = ""; @@ -138,9 +135,6 @@ void MapContext::setStyleJSON(const std::string& json, const std::string& base) styleJSON = json; style = std::make_unique<Style>(data); - if (painter) { - painter->updateRenderOrder(*style); - } loadStyleJSON(json, base); } @@ -248,11 +242,7 @@ bool MapContext::renderSync(const TransformState& state, const FrameData& frame) // Cleanup OpenGL objects that we abandoned since the last render call. glObjectStore.performCleanup(); - if (!painter) { - painter = std::make_unique<Painter>(data); - painter->updateRenderOrder(*style); - } - + if (!painter) painter = std::make_unique<Painter>(data); painter->render(*style, transformState, frame); if (data.mode == MapMode::Still) { @@ -322,10 +312,6 @@ void MapContext::setSprite(const std::string& name, std::shared_ptr<const Sprite void MapContext::onTileDataChanged() { assert(util::ThreadContext::currentlyOn(util::ThreadType::Map)); - if (painter) { - painter->updateRenderOrder(*style); - } - updateFlags |= Update::Repaint; asyncUpdate->send(); } diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 569109a998..a6fd9665bb 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -527,14 +527,9 @@ bool Source::update(MapData& data, } void Source::updateTilePtrs() { - std::vector<Tile*> newPtrs; + tilePtrs.clear(); for (const auto& pair : tiles) { - newPtrs.push_back(pair.second.get()); - } - - if (tilePtrs != newPtrs) { - tilePtrs.swap(newPtrs); - emitTileLoaded(true); + tilePtrs.push_back(pair.second.get()); } } diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 4cf8626c60..c11463ee24 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -145,6 +145,9 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& resize(); changeMatrix(); + // Figure out what buckets we have to draw and what order we have to draw them in. + const auto order = determineRenderOrder(style); + // - UPLOAD PASS ------------------------------------------------------------------------------- // Uploads all required buffers and images before we do any actual rendering. { @@ -163,6 +166,7 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& } } + // - CLIPPING MASKS ---------------------------------------------------------------------------- // Draws the clipping masks to the stencil buffer. { @@ -236,8 +240,6 @@ void Painter::renderPass(RenderPass pass_, GLsizei i, int8_t increment) { pass = pass_; - const double zoom = state.getZoom(); - MBGL_DEBUG_GROUP(pass == RenderPass::Opaque ? "opaque" : "translucent"); if (debug::renderTree) { @@ -256,13 +258,6 @@ void Painter::renderPass(RenderPass pass_, currentLayer = i; const auto& item = *it; if (item.bucket && item.tile) { - // Skip this layer if it's outside the range of min/maxzoom. - // This may occur when there /is/ a bucket created for this layer, but the min/max-zoom - // is set to a fractional value, or value that is larger than the source maxzoom. - if (item.layer.minZoom > zoom || - item.layer.maxZoom <= zoom) { - continue; - } if (item.layer.hasRenderPass(pass)) { MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id)); prepareTile(*item.tile); @@ -279,8 +274,8 @@ void Painter::renderPass(RenderPass pass_, } } -void Painter::updateRenderOrder(const Style& style) { - order.clear(); +std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) { + std::vector<RenderItem> order; for (const auto& layerPtr : style.layers) { const auto& layer = *layerPtr; @@ -309,6 +304,15 @@ void Painter::updateRenderOrder(const Style& style) { continue; } + // Skip this layer if it's outside the range of min/maxzoom. + // This may occur when there /is/ a bucket created for this layer, but the min/max-zoom + // is set to a fractional value, or value that is larger than the source maxzoom. + const double zoom = state.getZoom(); + if (layer.minZoom > zoom || + layer.maxZoom <= zoom) { + continue; + } + const auto& tiles = source->getTiles(); for (auto tile : tiles) { assert(tile); @@ -341,6 +345,8 @@ void Painter::updateRenderOrder(const Style& style) { } } } + + return order; } void Painter::renderBackground(const BackgroundLayer& layer) { diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 28008c5ac5..8f63388461 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -134,13 +134,13 @@ public: bool needsAnimation() const; - void updateRenderOrder(const Style& style); - private: void setup(); void setupShaders(); mat4 translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const TileID &id, TranslateAnchorType anchor); + std::vector<RenderItem> determineRenderOrder(const Style& style); + template <class Iterator> void renderPass(RenderPass, Iterator it, Iterator end, @@ -198,8 +198,6 @@ private: float depthRangeSize; const float depthEpsilon = 1.0f / (1 << 16); - std::vector<RenderItem> order; - public: FrameHistory frameHistory; |