[core] Forward ImageManagerObserver::onRemoveUnusedStyleImages to MapObserver interface
This commit is contained in:
@@ -48,6 +48,9 @@ public:
|
||||
virtual void onSourceChanged(style::Source&) {}
|
||||
virtual void onDidBecomeIdle() {}
|
||||
virtual void onStyleImageMissing(const std::string&) {}
|
||||
// This method should return true if unused image can be removed,
|
||||
// false otherwise. By default, unused image will be removed.
|
||||
virtual bool onCanRemoveUnusedStyleImage(const std::string&) { return true; }
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
// Style is missing an image
|
||||
using StyleImageMissingCallback = std::function<void()>;
|
||||
virtual void onStyleImageMissing(const std::string&, StyleImageMissingCallback done) { done(); }
|
||||
virtual void onRemoveUnusedStyleImages(const std::vector<std::string>&) {}
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -179,4 +179,12 @@ void Map::Impl::onStyleImageMissing(const std::string& id, std::function<void()>
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
void Map::Impl::onRemoveUnusedStyleImages(const std::vector<std::string>& unusedImageIDs) {
|
||||
for (const auto& unusedImageID : unusedImageIDs) {
|
||||
if (observer.onCanRemoveUnusedStyleImage(unusedImageID)) {
|
||||
style->removeImage(unusedImageID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
void onWillStartRenderingMap() final;
|
||||
void onDidFinishRenderingMap() final;
|
||||
void onStyleImageMissing(const std::string&, std::function<void()>) final;
|
||||
void onRemoveUnusedStyleImages(const std::vector<std::string>&) final;
|
||||
|
||||
// Map
|
||||
void jumpTo(const CameraOptions&);
|
||||
|
||||
@@ -762,4 +762,8 @@ void Renderer::Impl::onStyleImageMissing(const std::string& id, std::function<vo
|
||||
observer->onStyleImageMissing(id, std::move(done));
|
||||
}
|
||||
|
||||
void Renderer::Impl::onRemoveUnusedStyleImages(const std::vector<std::string>& unusedImageIDs) {
|
||||
observer->onRemoveUnusedStyleImages(unusedImageIDs);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -91,6 +91,7 @@ private:
|
||||
|
||||
// ImageManagerObserver implementation
|
||||
void onStyleImageMissing(const std::string&, std::function<void()>) override;
|
||||
void onRemoveUnusedStyleImages(const std::vector<std::string>&) final;
|
||||
|
||||
void updateFadingTiles();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user