Keep a pointer to GlyphStore on ResourceLoader
For now, keep a pointer so we can subscribe/unsubscribe to events. In the future, we should move this object completely to ResourceLoader, but we can't do it now because we delete the ResourceLoader when changing the style.
This commit is contained in:
@@ -25,6 +25,10 @@ ResourceLoader::~ResourceLoader() {
|
||||
if (sprite_) {
|
||||
sprite_->setObserver(nullptr);
|
||||
}
|
||||
|
||||
if (glyphStore_) {
|
||||
glyphStore_->setObserver(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceLoader::setObserver(Observer* observer) {
|
||||
@@ -45,6 +49,18 @@ void ResourceLoader::setStyle(Style* style) {
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceLoader::setGlyphStore(GlyphStore* glyphStore) {
|
||||
assert(glyphStore);
|
||||
|
||||
if (glyphStore_) {
|
||||
glyphStore_->setObserver(nullptr);
|
||||
}
|
||||
|
||||
glyphStore_ = glyphStore;
|
||||
glyphStore_->setObserver(this);
|
||||
}
|
||||
|
||||
|
||||
void ResourceLoader::setAccessToken(const std::string& accessToken) {
|
||||
accessToken_ = accessToken;
|
||||
}
|
||||
@@ -52,7 +68,6 @@ void ResourceLoader::setAccessToken(const std::string& accessToken) {
|
||||
void ResourceLoader::update(MapData& data,
|
||||
const TransformState& transform,
|
||||
GlyphAtlas& glyphAtlas,
|
||||
GlyphStore& glyphStore,
|
||||
SpriteAtlas& spriteAtlas,
|
||||
TexturePool& texturePool) {
|
||||
if (!style_) {
|
||||
@@ -69,8 +84,8 @@ void ResourceLoader::update(MapData& data,
|
||||
}
|
||||
|
||||
for (const auto& source : style_->sources) {
|
||||
source->update(
|
||||
data, transform, *style_, glyphAtlas, glyphStore, spriteAtlas, sprite_, texturePool);
|
||||
source->update(data, transform, *style_, glyphAtlas, *glyphStore_,
|
||||
spriteAtlas, sprite_, texturePool);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user