Implement Style::isLoaded
This commit is contained in:
@@ -236,7 +236,7 @@ void MapContext::render() {
|
||||
|
||||
painter->render(*style, data.getTransformState(), data.getAnimationTime());
|
||||
|
||||
if (data.mode == MapMode::Still && data.callback /* && loaded() */) {
|
||||
if (data.mode == MapMode::Still && data.callback && style->isLoaded() && getSprite()->isLoaded()) {
|
||||
auto image = view.readStillImage();
|
||||
|
||||
// We are moving the callback out of the way and empty it in case the callback function
|
||||
|
||||
@@ -118,6 +118,20 @@ Source::Source()
|
||||
|
||||
Source::~Source() {}
|
||||
|
||||
bool Source::isLoaded() const {
|
||||
if (!loaded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& tile : tiles) {
|
||||
if (tile.second->data->state != TileData::State::parsed) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Note: This is a separate function that must be called exactly once after creation
|
||||
// The reason this isn't part of the constructor is that calling shared_from_this() in
|
||||
// the constructor fails.
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
void load(const std::string& accessToken,
|
||||
Environment&,
|
||||
std::function<void()> callback);
|
||||
bool isLoaded() const;
|
||||
|
||||
void load(MapData&, Environment&, std::function<void()> callback);
|
||||
void update(MapData&,
|
||||
|
||||
@@ -86,4 +86,24 @@ void Style::loadJSON(const uint8_t *const data) {
|
||||
glyph_url = parser.getGlyphURL();
|
||||
}
|
||||
|
||||
bool Style::isLoaded() const {
|
||||
// TODO: move loading into Style
|
||||
// if (!loaded) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
for (const auto& source : sources) {
|
||||
if (!source->isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move sprite into Style
|
||||
// if (sprite && !sprite.isLoaded()) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
~Style();
|
||||
|
||||
void loadJSON(const uint8_t *const data);
|
||||
bool isLoaded() const;
|
||||
|
||||
void cascade(const std::vector<std::string>&);
|
||||
void recalculate(float z, TimePoint now);
|
||||
|
||||
Reference in New Issue
Block a user