diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 841413dee1f..796fa371767 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -168,8 +168,11 @@ void Painter::render(const Style& style, const FrameData& frame_, View& view, Sp annotationSpriteAtlas.upload(context, 0); for (const auto& item : order) { - if (item.bucket && item.bucket->needsUpload()) { - item.bucket->upload(context); + for (const auto& tileRef : item.tiles) { + const auto& bucket = tileRef.get().tile.getBucket(item.layer); + if (bucket && bucket->needsUpload()) { + bucket->upload(context); + } } } } @@ -217,6 +220,7 @@ void Painter::render(const Style& style, const FrameData& frame_, View& view, Sp if (debug::renderTree) { Log::Info(Event::Render, "{"); indent++; } // TODO: Correctly compute the number of layers recursively beforehand. + // TODO TODO : this actually sounds like the one-order-item-per-layer might *fix* the above todo. Y/N? depthRangeSize = 1 - (order.size() + 2) * numSublayers * depthEpsilon; // - OPAQUE PASS ------------------------------------------------------------------------------- @@ -311,8 +315,14 @@ void Painter::renderPass(PaintParameters& parameters, parameters.view.bind(); context.setDirtyState(); } else { - MBGL_DEBUG_GROUP(layer.baseImpl->id + " - " + util::toString(item.tile->id)); - item.bucket->render(*this, parameters, layer, *item.tile); + for (auto& tileRef : item.tiles) { + auto& tile = tileRef.get(); + MBGL_DEBUG_GROUP(layer.baseImpl->id + " - " + util::toString(tile.id)); + auto bucket = tile.tile.getBucket(layer); + if (bucket) { + bucket->render(*this, parameters, layer, tile); + } + } } } diff --git a/src/mbgl/renderer/render_item.hpp b/src/mbgl/renderer/render_item.hpp index b4b1f4aec23..fc79ef72239 100644 --- a/src/mbgl/renderer/render_item.hpp +++ b/src/mbgl/renderer/render_item.hpp @@ -18,14 +18,12 @@ class Source; class RenderItem { public: RenderItem(const style::Layer& layer_, - const RenderTile* tile_ = nullptr, - Bucket* bucket_ = nullptr) - : tile(tile_), bucket(bucket_), layer(layer_) { + std::vector> tiles_ = {}) + : layer(layer_), tiles(std::move(tiles_)) { } - const RenderTile* const tile; - Bucket* const bucket; const style::Layer& layer; + std::vector> tiles; }; class RenderData { diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index b6f14ecf4bd..48a3cd3ab50 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -466,9 +466,10 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions, float angle) const }); } - for (auto& tileRef : sortedTiles) { - auto& tile = tileRef.get(); + for (auto tileIt = sortedTiles.begin(); tileIt != sortedTiles.end(); ++tileIt) { + auto& tile = tileIt->get(); if (!tile.tile.isRenderable()) { + sortedTiles.erase(tileIt); continue; } @@ -480,9 +481,10 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions, float angle) const // Look back through the buckets we decided to render to find out whether there is // already a bucket from this layer that is a parent of this tile. Tiles are ordered // by zoom level when we obtain them from getTiles(). - for (auto it = result.order.rbegin(); it != result.order.rend() && (&it->layer == layer.get()); ++it) { - if (tile.tile.id.isChildOf(it->tile->tile.id)) { + for (auto it = sortedTiles.rbegin() + (sortedTiles.end() - tileIt); it != sortedTiles.rend(); ++it) { + if (tile.tile.id.isChildOf(it->get().tile.id)) { skip = true; + sortedTiles.erase(--(it.base())); break; } } @@ -491,12 +493,9 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions, float angle) const } } - auto bucket = tile.tile.getBucket(*layer); - if (bucket) { - result.order.emplace_back(*layer, &tile, bucket); - tile.used = true; - } } + + result.order.emplace_back(*layer, std::move(sortedTiles)); } return result;