diff options
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/renderer/render_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/render_source.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_geojson_source.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_raster_dem_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_raster_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_vector_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/tile_pyramid.cpp | 18 | ||||
-rw-r--r-- | src/mbgl/renderer/tile_pyramid.hpp | 8 |
8 files changed, 29 insertions, 20 deletions
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index c2c57deb22..8892991ac6 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -43,7 +43,7 @@ RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles) const } void RenderLayer::sortRenderTiles(const TransformState&) { - std::sort(renderTiles.begin(), renderTiles.end(), [](const auto& a, const auto& b) { return a.get().id < b.get().id; }); + // no-op } const RenderLayerSymbolInterface* RenderLayer::getSymbolInterface() const { diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp index 31c26fd09a..fe8ac364bc 100644 --- a/src/mbgl/renderer/render_source.hpp +++ b/src/mbgl/renderer/render_source.hpp @@ -58,7 +58,7 @@ public: virtual void startRender(PaintParameters&) = 0; virtual void finishRender(PaintParameters&) = 0; - // Returns an unsorted list of RenderTiles. + // Returns a list of RenderTiles, sorted by tile id. virtual std::vector<std::reference_wrapper<RenderTile>> getRenderTiles() = 0; virtual std::unordered_map<std::string, std::vector<Feature>> diff --git a/src/mbgl/renderer/sources/render_geojson_source.cpp b/src/mbgl/renderer/sources/render_geojson_source.cpp index a688026788..5eb6a931d3 100644 --- a/src/mbgl/renderer/sources/render_geojson_source.cpp +++ b/src/mbgl/renderer/sources/render_geojson_source.cpp @@ -96,11 +96,11 @@ void RenderGeoJSONSource::update(Immutable<style::Source::Impl> baseImpl_, if (data.lock() != data_) { data = data_; - tilePyramid.cache.clear(); + tilePyramid.reduceMemoryUse(); if (data_) { const uint8_t maxZ = impl().getZoomRange().max; - for (const auto& pair : tilePyramid.tiles) { + for (const auto& pair : tilePyramid.getTiles()) { if (pair.first.canonical.z <= maxZ) { static_cast<GeoJSONTile*>(pair.second.get())->updateData(data_->getTile(pair.first.canonical)); } @@ -109,8 +109,7 @@ void RenderGeoJSONSource::update(Immutable<style::Source::Impl> baseImpl_, } if (!data_) { - tilePyramid.tiles.clear(); - tilePyramid.renderTiles.clear(); + tilePyramid.clearAll(); return; } diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.cpp b/src/mbgl/renderer/sources/render_raster_dem_source.cpp index 2283a0e788..2bc3a91c7c 100644 --- a/src/mbgl/renderer/sources/render_raster_dem_source.cpp +++ b/src/mbgl/renderer/sources/render_raster_dem_source.cpp @@ -38,9 +38,7 @@ void RenderRasterDEMSource::update(Immutable<style::Source::Impl> baseImpl_, maxzoom = tileset->zoomRange.max; // TODO: this removes existing buckets, and will cause flickering. // Should instead refresh tile data in place. - tilePyramid.tiles.clear(); - tilePyramid.renderTiles.clear(); - tilePyramid.cache.clear(); + tilePyramid.clearAll(); } // Allow clearing the tile pyramid first, before the early return in case // the new tileset is not yet available or has an error in loading diff --git a/src/mbgl/renderer/sources/render_raster_source.cpp b/src/mbgl/renderer/sources/render_raster_source.cpp index f97ce4e65b..017763b96a 100644 --- a/src/mbgl/renderer/sources/render_raster_source.cpp +++ b/src/mbgl/renderer/sources/render_raster_source.cpp @@ -36,9 +36,7 @@ void RenderRasterSource::update(Immutable<style::Source::Impl> baseImpl_, // TODO: this removes existing buckets, and will cause flickering. // Should instead refresh tile data in place. - tilePyramid.tiles.clear(); - tilePyramid.renderTiles.clear(); - tilePyramid.cache.clear(); + tilePyramid.clearAll(); } // Allow clearing the tile pyramid first, before the early return in case // the new tileset is not yet available or has an error in loading diff --git a/src/mbgl/renderer/sources/render_vector_source.cpp b/src/mbgl/renderer/sources/render_vector_source.cpp index 4de4f01e3f..61954a68e6 100644 --- a/src/mbgl/renderer/sources/render_vector_source.cpp +++ b/src/mbgl/renderer/sources/render_vector_source.cpp @@ -39,9 +39,7 @@ void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_, // TODO: this removes existing buckets, and will cause flickering. // Should instead refresh tile data in place. - tilePyramid.tiles.clear(); - tilePyramid.renderTiles.clear(); - tilePyramid.cache.clear(); + tilePyramid.clearAll(); } // Allow clearing the tile pyramid first, before the early return in case // the new tileset is not yet available or has an error in loading diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp index 7a2e691af3..b169fddf9c 100644 --- a/src/mbgl/renderer/tile_pyramid.cpp +++ b/src/mbgl/renderer/tile_pyramid.cpp @@ -177,7 +177,7 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer } auto renderTileFn = [&](const UnwrappedTileID& tileID, Tile& tile) { - renderTiles.emplace_back(tileID, tile); + addRenderTile(tileID, tile); rendered.emplace(tileID); previouslyRenderedTiles.erase(tileID); // Still rendering this tile, no need for special fading logic. tile.markRenderedIdeal(); @@ -200,7 +200,7 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer // Since it was rendered in the last frame, we know we have it // Don't mark the tile "Required" to avoid triggering a new network request retainTileFn(tile, TileNecessity::Optional); - renderTiles.emplace_back(previouslyRenderedTile.first, tile); + addRenderTile(previouslyRenderedTile.first, tile); rendered.emplace(previouslyRenderedTile.first); } } @@ -296,7 +296,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered } mapbox::geometry::box<double> box = mapbox::geometry::envelope(queryGeometry); - + // TODO: Find out why we need a special sorting algorithm here. std::vector<std::reference_wrapper<const RenderTile>> sortedTiles{ renderTiles.begin(), renderTiles.end() }; std::sort(sortedTiles.begin(), sortedTiles.end(), [](const RenderTile& a, const RenderTile& b) { @@ -365,4 +365,16 @@ void TilePyramid::dumpDebugLogs() const { } } +void TilePyramid::clearAll() { + tiles.clear(); + renderTiles.clear(); + cache.clear(); +} + +void TilePyramid::addRenderTile(const UnwrappedTileID& tileID, Tile& tile) { + auto it = std::lower_bound(renderTiles.begin(), renderTiles.end(), tileID, + [](const RenderTile& a, const UnwrappedTileID& id) { return a.id < id; }); + renderTiles.emplace(it, tileID, tile); +} + } // namespace mbgl diff --git a/src/mbgl/renderer/tile_pyramid.hpp b/src/mbgl/renderer/tile_pyramid.hpp index 4e5f50fd52..bc2c370780 100644 --- a/src/mbgl/renderer/tile_pyramid.hpp +++ b/src/mbgl/renderer/tile_pyramid.hpp @@ -66,12 +66,16 @@ public: void setObserver(TileObserver*); void dumpDebugLogs() const; - bool enabled = false; + const std::map<OverscaledTileID, std::unique_ptr<Tile>>& getTiles() const { return tiles; } + void clearAll(); + +private: + void addRenderTile(const UnwrappedTileID& tileID, Tile& tile); std::map<OverscaledTileID, std::unique_ptr<Tile>> tiles; TileCache cache; - std::vector<RenderTile> renderTiles; + std::list<RenderTile> renderTiles; TileObserver* observer = nullptr; |