diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-04 13:00:41 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-07 10:16:35 -0800 |
commit | aa087967675cd337961ebea78bd04836600d8aed (patch) | |
tree | fc15ac2fc7c4ae3fe6016771bb2582d519f295e4 /src/mbgl/tile | |
parent | 1533d28314fe869ad3f1772872e99516eab76e36 (diff) | |
download | qtlocation-mapboxgl-aa087967675cd337961ebea78bd04836600d8aed.tar.gz |
[core] Separate pathway for notifying workers of new images/glyphs
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r-- | src/mbgl/tile/geometry_tile.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.cpp | 51 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/tile.hpp | 1 |
5 files changed, 52 insertions, 7 deletions
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 46e2b414fe..c77467ebc1 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -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. diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index bcc71480af..cb3ca54633 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -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; diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index b6f166be56..6ff3c67793 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -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; diff --git a/src/mbgl/tile/geometry_tile_worker.hpp b/src/mbgl/tile/geometry_tile_worker.hpp index d55b29702c..58b5e23cfd 100644 --- a/src/mbgl/tile/geometry_tile_worker.hpp +++ b/src/mbgl/tile/geometry_tile_worker.hpp @@ -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; diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp index 949bc0e334..eea89bd634 100644 --- a/src/mbgl/tile/tile.hpp +++ b/src/mbgl/tile/tile.hpp @@ -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( |