diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-03-31 14:53:18 -0700 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2017-04-04 11:33:12 -0700 |
commit | 5cdf838a387cae446dba500ac49a1c5524bf7949 (patch) | |
tree | 3b438034a7842c36a7804096785fca1a6ad6fa80 /src/mbgl/tile/geometry_tile.cpp | |
parent | 64beba3accb0f2088b2e01fad710f915c81d99c7 (diff) | |
download | qtlocation-mapboxgl-5cdf838a387cae446dba500ac49a1c5524bf7949.tar.gz |
[core] De-mutex GlyphAtlas and SpriteAtlas
- Expose glyph and icon information to workers via message interface.
- Glyph/SpriteAtlas track which tiles have outstanding requests
and send messages to them when glyphs/icons become available.
- Remove obsolete "updateSymbolDependentTiles" pathway
- Symbol preparation for a tile now depends on all glyphs becoming
available before it can start.
- Start tracking individual icons needed for a tile, although we don't
do anything with the information yet.
- Introduce typedef for GlyphID
Diffstat (limited to 'src/mbgl/tile/geometry_tile.cpp')
-rw-r--r-- | src/mbgl/tile/geometry_tile.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 5ccc037ce0..4e67144082 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -18,6 +18,8 @@ #include <mbgl/style/query.hpp> #include <mbgl/util/logging.hpp> +#include <iostream> + namespace mbgl { using namespace style; @@ -32,12 +34,16 @@ GeometryTile::GeometryTile(const OverscaledTileID& id_, worker(parameters.workerScheduler, ActorRef<GeometryTile>(*this, mailbox), id_, - *parameters.style.glyphAtlas, obsolete, - parameters.mode) { + parameters.mode), + glyphAtlas(*parameters.style.glyphAtlas) { } GeometryTile::~GeometryTile() { + glyphAtlas.removeGlyphs(*this); + for (auto spriteAtlas : pendingSpriteAtlases) { + spriteAtlas->removeRequestor(*this); + } cancel(); } @@ -77,10 +83,6 @@ void GeometryTile::setPlacementConfig(const PlacementConfig& desiredConfig) { worker.invoke(&GeometryTileWorker::setPlacementConfig, desiredConfig, correlationID); } -void GeometryTile::symbolDependenciesChanged() { - worker.invoke(&GeometryTileWorker::symbolDependenciesChanged); -} - void GeometryTile::redoLayout() { // Mark the tile as pending again if it was complete before to prevent signaling a complete // state despite pending parse operations. @@ -130,6 +132,31 @@ void GeometryTile::onError(std::exception_ptr err) { availableData = DataAvailability::All; observer->onTileError(*this, err); } + +void GeometryTile::onGlyphsAvailable(GlyphPositionMap glyphPositions, GlyphRangeSet loadedRanges) { + worker.invoke(&GeometryTileWorker::onGlyphsAvailable, std::move(glyphPositions), std::move(loadedRanges)); +} + +void GeometryTile::getGlyphs(GlyphDependencies glyphDependencies) { + glyphAtlas.getGlyphs(*this, std::move(glyphDependencies)); +} + +void GeometryTile::onIconsAvailable(SpriteAtlas* spriteAtlas, IconMap icons) { + iconAtlasMap[(uintptr_t)spriteAtlas] = icons; + pendingSpriteAtlases.erase(spriteAtlas); + if (pendingSpriteAtlases.empty()) { + worker.invoke(&GeometryTileWorker::onIconsAvailable, std::move(iconAtlasMap)); + } +} + +// TODO: If there's any value to be gained by it, we can narrow our request to just the sprites +// we need, but SpriteAtlases are just "loaded" or "not loaded" +void GeometryTile::getIcons(IconDependencyMap iconDependencyMap) { + for (auto dependency : iconDependencyMap) { + pendingSpriteAtlases.insert(dependency.first); + dependency.first->getIcons(*this); + } +} Bucket* GeometryTile::getBucket(const Layer& layer) { const auto& buckets = layer.is<SymbolLayer>() ? symbolBuckets : nonSymbolBuckets; |