Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Change rendering from per-tile to per-tile vector (allowing layers to…
Browse files Browse the repository at this point in the history
… be grouped)
  • Loading branch information
Lauren Budorick committed Mar 3, 2017
1 parent 69ef0bc commit 9514b62
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
18 changes: 14 additions & 4 deletions src/mbgl/renderer/painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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 -------------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/mbgl/renderer/render_item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::reference_wrapper<RenderTile>> tiles_ = {})
: layer(layer_), tiles(std::move(tiles_)) {
}

const RenderTile* const tile;
Bucket* const bucket;
const style::Layer& layer;
std::vector<std::reference_wrapper<RenderTile>> tiles;
};

class RenderData {
Expand Down
17 changes: 8 additions & 9 deletions src/mbgl/style/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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;
Expand Down

0 comments on commit 9514b62

Please sign in to comment.