Update the tiles via ResourceLoader

This commit is contained in:
Thiago Marcos P. Santos
2015-04-21 16:33:58 +02:00
parent f4baa0ba3e
commit d726613f6f
3 changed files with 31 additions and 5 deletions

View File

@@ -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<TileID>& ids) {

View File

@@ -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> 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();
}

View File

@@ -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<Sprite>, TexturePool&);
// Source::Observer implementation.
void onSourceLoaded() override;
void onTileLoaded() override;