From a79d2afe1b43d9fa42e00629c4e07d9463d30d91 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 23 Aug 2016 11:52:12 -0700 Subject: =?UTF-8?q?[core]=20Rename=20data=20=E2=87=A2=20tile;=20use=20Reso?= =?UTF-8?q?urce::Necessity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mbgl/style/source_impl.cpp | 55 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) (limited to 'src/mbgl/style/source_impl.cpp') diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp index 9cdabe847f..6f4772bfac 100644 --- a/src/mbgl/style/source_impl.cpp +++ b/src/mbgl/style/source_impl.cpp @@ -89,7 +89,7 @@ bool Source::Impl::update(const UpdateParameters& parameters) { // Determine the overzooming/underzooming amounts and required tiles. int32_t overscaledZoom = util::coveringZoomLevel(parameters.transformState.getZoom(), type, tileSize); - int32_t dataTileZoom = overscaledZoom; + int32_t tileZoom = overscaledZoom; std::vector idealTiles; if (overscaledZoom >= zoomRange.min) { @@ -97,48 +97,46 @@ bool Source::Impl::update(const UpdateParameters& parameters) { // Make sure we're not reparsing overzoomed raster tiles. if (type == SourceType::Raster) { - dataTileZoom = idealZoom; + tileZoom = idealZoom; } idealTiles = util::tileCover(parameters.transformState, idealZoom); } - // Stores a list of all the data tiles that we're definitely going to retain. There are two + // Stores a list of all the tiles that we're definitely going to retain. There are two // kinds of tiles we need: the ideal tiles determined by the tile cover. They may not yet be in // use because they're still loading. In addition to that, we also need to retain all tiles that // we're actively using, e.g. as a replacement for tile that aren't loaded yet. std::set retain; - auto retainTileFn = [&retain](Tile& tile, bool required) -> void { + auto retainTileFn = [&retain](Tile& tile, Resource::Necessity necessity) -> void { retain.emplace(tile.id); - tile.setNecessity(required ? Tile::Necessity::Required - : Tile::Necessity::Optional); + tile.setNecessity(necessity); }; auto getTileFn = [this](const OverscaledTileID& tileID) -> Tile* { auto it = tiles.find(tileID); return it == tiles.end() ? nullptr : it->second.get(); }; - auto createTileFn = [this, ¶meters](const OverscaledTileID& dataTileID) -> Tile* { - std::unique_ptr data = cache.get(dataTileID); - if (!data) { - data = createTile(dataTileID, parameters); - if (data) { - data->setObserver(this); + auto createTileFn = [this, ¶meters](const OverscaledTileID& tileID) -> Tile* { + std::unique_ptr tile = cache.get(tileID); + if (!tile) { + tile = createTile(tileID, parameters); + if (tile) { + tile->setObserver(this); } } - if (data) { - return tiles.emplace(dataTileID, std::move(data)).first->second.get(); - } else { + if (!tile) { return nullptr; } + return tiles.emplace(tileID, std::move(tile)).first->second.get(); }; - auto renderTileFn = [this](const UnwrappedTileID& renderTileID, Tile& tile) { - renderTiles.emplace(renderTileID, RenderTile{ renderTileID, tile }); + auto renderTileFn = [this](const UnwrappedTileID& tileID, Tile& tile) { + renderTiles.emplace(tileID, RenderTile{ tileID, tile }); }; renderTiles.clear(); algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn, renderTileFn, - idealTiles, zoomRange, dataTileZoom); + idealTiles, zoomRange, tileZoom); if (type != SourceType::Raster && type != SourceType::Annotations && cache.getSize() == 0) { size_t conservativeCacheSize = @@ -149,19 +147,18 @@ bool Source::Impl::update(const UpdateParameters& parameters) { cache.setSize(conservativeCacheSize); } - // Remove stale data tiles from the active set of tiles. - // This goes through the (sorted!) tiles and retain set in lockstep and removes items from - // tiles that don't have the corresponding key in the retain set. - auto dataIt = tiles.begin(); + // Remove stale tiles. This goes through the (sorted!) tiles map and retain set in lockstep + // and removes items from tiles that don't have the corresponding key in the retain set. + auto tilesIt = tiles.begin(); auto retainIt = retain.begin(); - while (dataIt != tiles.end()) { - if (retainIt == retain.end() || dataIt->first < *retainIt) { - dataIt->second->setNecessity(Tile::Necessity::Optional); - cache.add(dataIt->first, std::move(dataIt->second)); - tiles.erase(dataIt++); + while (tilesIt != tiles.end()) { + if (retainIt == retain.end() || tilesIt->first < *retainIt) { + tilesIt->second->setNecessity(Tile::Necessity::Optional); + cache.add(tilesIt->first, std::move(tilesIt->second)); + tiles.erase(tilesIt++); } else { - if (!(*retainIt < dataIt->first)) { - ++dataIt; + if (!(*retainIt < tilesIt->first)) { + ++tilesIt; } ++retainIt; } -- cgit v1.2.1