[core] Separate pathway for notifying workers of new images/glyphs
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
"lodash": "^4.16.4",
|
||||
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#98a56d538b11fb331aa67a6d632d6ecd6821b007",
|
||||
"mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#7f62a4fc9f21e619824d68abbc4b03cbc1685572",
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#d27aab1c74f0f0462e19d4aa5700fb2127567f87",
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#10a135f01b56989aa03686de94cc67c3efa6139d",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-cmake": "^1.2.1",
|
||||
"request": "^2.72.0",
|
||||
|
||||
@@ -184,6 +184,12 @@ void Source::Impl::removeTiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void Source::Impl::updateSymbolDependentTiles() {
|
||||
for (auto& pair : tiles) {
|
||||
pair.second->symbolDependenciesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Source::Impl::reloadTiles() {
|
||||
cache.clear();
|
||||
|
||||
|
||||
@@ -43,11 +43,14 @@ public:
|
||||
virtual void loadDescription(FileSource&) = 0;
|
||||
bool isLoaded() const;
|
||||
|
||||
// Called when the camera has changed or icons or glyphs are loaded. May load new
|
||||
// tiles, unload obsolete tiles, and trigger further parsing of incomplete tiles or
|
||||
// re-placement of existing complete tiles.
|
||||
// Called when the camera has changed. May load new tiles, unload obsolete tiles, or
|
||||
// trigger re-placement of existing complete tiles.
|
||||
void updateTiles(const UpdateParameters&);
|
||||
|
||||
// Called when icons or glyphs are loaded. Triggers further processing of tiles which
|
||||
// were waiting on such dependencies.
|
||||
void updateSymbolDependentTiles();
|
||||
|
||||
// Removes all tiles (by putting them into the cache).
|
||||
void removeTiles();
|
||||
|
||||
|
||||
@@ -220,6 +220,12 @@ void Style::updateTiles(const UpdateParameters& parameters) {
|
||||
}
|
||||
}
|
||||
|
||||
void Style::updateSymbolDependentTiles() {
|
||||
for (const auto& source : sources) {
|
||||
source->baseImpl->updateSymbolDependentTiles();
|
||||
}
|
||||
}
|
||||
|
||||
void Style::relayout() {
|
||||
for (const auto& sourceID : updateBatch.sourceIDs) {
|
||||
Source* source = getSource(sourceID);
|
||||
@@ -475,7 +481,7 @@ void Style::setObserver(style::Observer* observer_) {
|
||||
|
||||
void Style::onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) {
|
||||
observer->onGlyphsLoaded(fontStack, glyphRange);
|
||||
observer->onUpdate(Update::Repaint);
|
||||
updateSymbolDependentTiles();
|
||||
}
|
||||
|
||||
void Style::onGlyphsError(const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) {
|
||||
@@ -525,7 +531,8 @@ void Style::onTileError(Source& source, const OverscaledTileID& tileID, std::exc
|
||||
|
||||
void Style::onSpriteLoaded() {
|
||||
observer->onSpriteLoaded();
|
||||
observer->onUpdate(Update::Repaint);
|
||||
observer->onUpdate(Update::Repaint); // For *-pattern properties.
|
||||
updateSymbolDependentTiles();
|
||||
}
|
||||
|
||||
void Style::onSpriteError(std::exception_ptr error) {
|
||||
|
||||
@@ -121,6 +121,7 @@ private:
|
||||
|
||||
std::vector<std::unique_ptr<Layer>>::const_iterator findLayer(const std::string& layerID) const;
|
||||
void reloadLayerSource(Layer&);
|
||||
void updateSymbolDependentTiles();
|
||||
|
||||
// GlyphStoreObserver implementation.
|
||||
void onGlyphsLoaded(const FontStack&, const GlyphRange&) override;
|
||||
|
||||
@@ -65,6 +65,10 @@ void GeometryTile::setPlacementConfig(const PlacementConfig& desiredConfig) {
|
||||
worker.invoke(&GeometryTileWorker::setPlacementConfig, desiredConfig, correlationID);
|
||||
}
|
||||
|
||||
void GeometryTile::symbolDependenciesChanged() {
|
||||
worker.invoke(&GeometryTileWorker::symbolDependenciesChanged);
|
||||
}
|
||||
|
||||
void GeometryTile::redoLayout() {
|
||||
// Mark the tile as pending again if it was complete before to prevent signaling a complete
|
||||
// state despite pending parse operations.
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
void setData(std::unique_ptr<const GeometryTileData>);
|
||||
|
||||
void setPlacementConfig(const PlacementConfig&) override;
|
||||
void symbolDependenciesChanged() override;
|
||||
void redoLayout() override;
|
||||
|
||||
Bucket* getBucket(const style::Layer&) override;
|
||||
|
||||
@@ -42,13 +42,13 @@ GeometryTileWorker::~GeometryTileWorker() {
|
||||
States are indicated by [state], lines are transitions triggered by
|
||||
messages, (parentheses) are actions taken on transition.
|
||||
|
||||
[idle] <------------------.
|
||||
| |
|
||||
set{Data,Layers,Placement} |
|
||||
| |
|
||||
(do layout/placement; self-send "coalesced") |
|
||||
v |
|
||||
[coalescing] --- coalesced --.
|
||||
[idle] <----------------------------.
|
||||
| |
|
||||
set{Data,Layers,Placement}, symbolDependenciesChanged |
|
||||
| |
|
||||
(do layout/placement; self-send "coalesced") |
|
||||
v |
|
||||
[coalescing] --- coalesced ------------.
|
||||
| |
|
||||
.-----------------. .---------------.
|
||||
| |
|
||||
@@ -140,6 +140,31 @@ void GeometryTileWorker::setPlacementConfig(PlacementConfig placementConfig_, ui
|
||||
}
|
||||
}
|
||||
|
||||
void GeometryTileWorker::symbolDependenciesChanged() {
|
||||
try {
|
||||
switch (state) {
|
||||
case Idle:
|
||||
if (hasPendingSymbolDependencies()) {
|
||||
attemptPlacement();
|
||||
coalesce();
|
||||
}
|
||||
break;
|
||||
|
||||
case Coalescing:
|
||||
if (hasPendingSymbolDependencies()) {
|
||||
state = NeedPlacement;
|
||||
}
|
||||
break;
|
||||
|
||||
case NeedPlacement:
|
||||
case NeedLayout:
|
||||
break;
|
||||
}
|
||||
} catch (...) {
|
||||
parent.invoke(&GeometryTile::onError, std::current_exception());
|
||||
}
|
||||
}
|
||||
|
||||
void GeometryTileWorker::coalesced() {
|
||||
try {
|
||||
switch (state) {
|
||||
@@ -238,6 +263,18 @@ void GeometryTileWorker::redoLayout() {
|
||||
attemptPlacement();
|
||||
}
|
||||
|
||||
bool GeometryTileWorker::hasPendingSymbolDependencies() const {
|
||||
bool result = false;
|
||||
|
||||
for (const auto& symbolLayout : symbolLayouts) {
|
||||
if (symbolLayout->state == SymbolLayout::Pending) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void GeometryTileWorker::attemptPlacement() {
|
||||
if (!data || !layers || !placementConfig) {
|
||||
return;
|
||||
|
||||
@@ -34,12 +34,14 @@ public:
|
||||
void setLayers(std::vector<std::unique_ptr<style::Layer>>, uint64_t correlationID);
|
||||
void setData(std::unique_ptr<const GeometryTileData>, uint64_t correlationID);
|
||||
void setPlacementConfig(PlacementConfig, uint64_t correlationID);
|
||||
void symbolDependenciesChanged();
|
||||
|
||||
private:
|
||||
void coalesce();
|
||||
void coalesced();
|
||||
void redoLayout();
|
||||
void attemptPlacement();
|
||||
bool hasPendingSymbolDependencies() const;
|
||||
|
||||
ActorRef<GeometryTileWorker> self;
|
||||
ActorRef<GeometryTile> parent;
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
virtual Bucket* getBucket(const style::Layer&) = 0;
|
||||
|
||||
virtual void setPlacementConfig(const PlacementConfig&) {}
|
||||
virtual void symbolDependenciesChanged() {};
|
||||
virtual void redoLayout() {}
|
||||
|
||||
virtual void queryRenderedFeatures(
|
||||
|
||||
Reference in New Issue
Block a user