diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index 146d7ec4e..50225b429 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -165,11 +165,9 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base) void MapContext::updateTiles() { assert(Environment::currentlyOn(ThreadType::Map)); - if (!style) return; - for (const auto& source : style->sources) { - source->update(data, transformState, *style, *glyphAtlas, *glyphStore, *spriteAtlas, - getSprite(), *texturePool); - } + + resourceLoader->update(data, transformState, *glyphAtlas, *glyphStore, + *spriteAtlas, getSprite(), *texturePool); } void MapContext::updateAnnotationTiles(const std::vector& ids) { diff --git a/src/mbgl/map/resource_loader.cpp b/src/mbgl/map/resource_loader.cpp index 91f183d69..3d4a6ea5b 100644 --- a/src/mbgl/map/resource_loader.cpp +++ b/src/mbgl/map/resource_loader.cpp @@ -41,6 +41,23 @@ void ResourceLoader::setAccessToken(const std::string& accessToken) { accessToken_ = accessToken; } +void ResourceLoader::update(MapData& data, + const TransformState& transform, + GlyphAtlas& glyphAtlas, + GlyphStore& glyphStore, + SpriteAtlas& spriteAtlas, + util::ptr sprite, + TexturePool& texturePool) { + if (!style_) { + return; + } + + for (const auto& source : style_->sources) { + source->update( + data, transform, *style_, glyphAtlas, glyphStore, spriteAtlas, sprite, texturePool); + } +} + void ResourceLoader::onSourceLoaded() { emitTileDataChanged(); } diff --git a/src/mbgl/map/resource_loader.hpp b/src/mbgl/map/resource_loader.hpp index f03ba791d..391c46059 100644 --- a/src/mbgl/map/resource_loader.hpp +++ b/src/mbgl/map/resource_loader.hpp @@ -8,7 +8,13 @@ namespace mbgl { +class GlyphAtlas; +class GlyphStore; +class MapData; +class SpriteAtlas; class Style; +class TexturePool; +class TransformState; // ResourceLoader is responsible for loading and updating the Source(s) owned // by the Style. The Source object currently owns all the tiles, thus this @@ -35,6 +41,11 @@ public: // Set the access token to be used for loading the tile data. void setAccessToken(const std::string& accessToken); + // Fetch the tiles needed by the current viewport and emit a signal when + // a tile is ready so observers can render the tile. + void update(MapData&, const TransformState&, GlyphAtlas&, GlyphStore&, + SpriteAtlas&, util::ptr, TexturePool&); + // Source::Observer implementation. void onSourceLoaded() override; void onTileLoaded() override;