diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-08-20 15:34:32 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-11-05 10:33:21 +0100 |
commit | 177372b83657cda9696ff68fd5cbb872b87ce324 (patch) | |
tree | b067aa7eb0a404ff218cd7a08c325f2821d205f1 /src | |
parent | 24285926c21fd1ea36157895de2d55e489b63f9f (diff) | |
download | qtlocation-mapboxgl-177372b83657cda9696ff68fd5cbb872b87ce324.tar.gz |
[core] only update the render order array when there are changes to tiles
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map_context.cpp | 10 | ||||
-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, 31 insertions, 22 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 8935457ca5..9f803c87c9 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -242,7 +242,11 @@ 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); + if (!painter) { + painter = std::make_unique<Painter>(data); + painter->updateRenderOrder(*style); + } + painter->render(*style, transformState, frame); if (data.mode == MapMode::Still) { @@ -314,6 +318,10 @@ 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 a6fd9665bb..569109a998 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -527,9 +527,14 @@ bool Source::update(MapData& data, } void Source::updateTilePtrs() { - tilePtrs.clear(); + std::vector<Tile*> newPtrs; for (const auto& pair : tiles) { - tilePtrs.push_back(pair.second.get()); + newPtrs.push_back(pair.second.get()); + } + + if (tilePtrs != newPtrs) { + tilePtrs.swap(newPtrs); + emitTileLoaded(true); } } diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index b947ff24a0..788e290f63 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -146,9 +146,6 @@ 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. { @@ -167,7 +164,6 @@ void Painter::render(const Style& style, TransformState state_, const FrameData& } } - // - CLIPPING MASKS ---------------------------------------------------------------------------- // Draws the clipping masks to the stencil buffer. { @@ -241,6 +237,8 @@ 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) { @@ -254,6 +252,13 @@ 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); @@ -270,8 +275,8 @@ void Painter::renderPass(RenderPass pass_, } } -std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) { - std::vector<RenderItem> order; +void Painter::updateRenderOrder(const Style& style) { + order.clear(); for (const auto& layerPtr : style.layers) { const auto& layer = *layerPtr; @@ -300,15 +305,6 @@ std::vector<RenderItem> Painter::determineRenderOrder(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,8 +337,6 @@ std::vector<RenderItem> Painter::determineRenderOrder(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 8f63388461..28008c5ac5 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,6 +198,8 @@ private: float depthRangeSize; const float depthEpsilon = 1.0f / (1 << 16); + std::vector<RenderItem> order; + public: FrameHistory frameHistory; |