[core] Correctly track sprite loaded state through smart setStyle
This commit is contained in:
Submodule mapbox-gl-js updated: f27666813d...31444a72c2
@@ -4,12 +4,23 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
void ImageManager::onSpriteLoaded() {
|
||||
loaded = true;
|
||||
for (const auto& entry : requestors) {
|
||||
notify(*entry.first, entry.second);
|
||||
void ImageManager::setLoaded(bool loaded_) {
|
||||
if (loaded == loaded_) {
|
||||
return;
|
||||
}
|
||||
requestors.clear();
|
||||
|
||||
loaded = loaded_;
|
||||
|
||||
if (loaded) {
|
||||
for (const auto& entry : requestors) {
|
||||
notify(*entry.first, entry.second);
|
||||
}
|
||||
requestors.clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageManager::isLoaded() const {
|
||||
return loaded;
|
||||
}
|
||||
|
||||
void ImageManager::addImage(Immutable<style::Image::Impl> image_) {
|
||||
|
||||
@@ -39,11 +39,8 @@ public:
|
||||
ImageManager();
|
||||
~ImageManager();
|
||||
|
||||
void onSpriteLoaded();
|
||||
|
||||
bool isLoaded() const {
|
||||
return loaded;
|
||||
}
|
||||
void setLoaded(bool);
|
||||
bool isLoaded() const;
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
|
||||
@@ -143,9 +143,7 @@ void RenderStyle::update(const UpdateParameters& parameters) {
|
||||
imageManager->updateImage(entry.second.after);
|
||||
}
|
||||
|
||||
if (parameters.spriteLoaded && !imageManager->isLoaded()) {
|
||||
imageManager->onSpriteLoaded();
|
||||
}
|
||||
imageManager->setLoaded(parameters.spriteLoaded);
|
||||
|
||||
|
||||
const LayerDifference layerDiff = diffLayers(layerImpls, parameters.layers);
|
||||
|
||||
@@ -111,6 +111,7 @@ void Style::Impl::parse(const std::string& json_) {
|
||||
defaultPitch = parser.pitch;
|
||||
setLight(std::make_unique<Light>(parser.light));
|
||||
|
||||
spriteLoaded = false;
|
||||
spriteLoader->load(parser.spriteURL, scheduler, fileSource);
|
||||
glyphURL = parser.glyphURL;
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ TEST(ImageManager, NotifiesRequestorWhenSpriteIsLoaded) {
|
||||
imageManager.getImages(requestor, {"one"});
|
||||
ASSERT_FALSE(notified);
|
||||
|
||||
imageManager.onSpriteLoaded();
|
||||
imageManager.setLoaded(true);
|
||||
ASSERT_TRUE(notified);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user