diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-06 15:01:34 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-16 12:01:06 -0700 |
commit | 41bbd4e4f7d66465433e370ca024ab0239fcace3 (patch) | |
tree | 8fe15fa31d97aafeb175a808e431b437297af88b /src/mbgl/tile/geometry_tile.hpp | |
parent | 0bd66d40ddf9e75f860fe18e7c80de9c840f48ac (diff) | |
download | qtlocation-mapboxgl-41bbd4e4f7d66465433e370ca024ab0239fcace3.tar.gz |
[core] Use an actor model for tile worker concurrency
Diffstat (limited to 'src/mbgl/tile/geometry_tile.hpp')
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index e0db58325c..a644992376 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -1,9 +1,10 @@ #pragma once #include <mbgl/tile/tile.hpp> -#include <mbgl/tile/tile_worker.hpp> +#include <mbgl/tile/geometry_tile_worker.hpp> #include <mbgl/text/placement_config.hpp> #include <mbgl/util/feature.hpp> +#include <mbgl/actor/actor.hpp> #include <atomic> #include <memory> @@ -12,34 +13,31 @@ namespace mbgl { -class AsyncRequest; class GeometryTileData; class FeatureIndex; +class CollisionTile; namespace style { class Style; class Layer; +class UpdateParameters; } // namespace style class GeometryTile : public Tile { public: GeometryTile(const OverscaledTileID&, std::string sourceID, - style::Style&, - const MapMode); + const style::UpdateParameters&); ~GeometryTile() override; void setError(std::exception_ptr err); void setData(std::unique_ptr<const GeometryTileData>); + void setPlacementConfig(const PlacementConfig&) override; + void redoLayout() override; Bucket* getBucket(const style::Layer&) override; - bool parsePending() override; - - void redoLayout() override; - void redoPlacement(PlacementConfig) override; - void queryRenderedFeatures( std::unordered_map<std::string, std::vector<Feature>>& result, const GeometryCoordinates& queryGeometry, @@ -48,35 +46,40 @@ public: void cancel() override; -private: - std::vector<std::unique_ptr<style::Layer>> cloneStyleLayers() const; - void redoPlacement(); - - void tileLoaded(TileParseResult, PlacementConfig); + class LayoutResult { + public: + std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; + std::unique_ptr<FeatureIndex> featureIndex; + std::unique_ptr<GeometryTileData> tileData; + uint64_t correlationID; + }; + void onLayout(LayoutResult); + + class PlacementResult { + public: + std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; + std::unique_ptr<CollisionTile> collisionTile; + PlacementConfig placedConfig; + uint64_t correlationID; + }; + void onPlacement(PlacementResult); +private: const std::string sourceID; style::Style& style; - Worker& worker; - TileWorker tileWorker; - std::unique_ptr<AsyncRequest> workRequest; + // Used to signal the worker that it should abandon parsing this tile as soon as possible. + std::atomic<bool> obsolete { false }; - // Contains all the Bucket objects for the tile. Buckets are render - // objects and they get added by tile parsing operations. - std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; + std::shared_ptr<Mailbox> mailbox; + Actor<GeometryTileWorker> worker; + + uint64_t correlationID = 0; + optional<PlacementConfig> placedConfig; + std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; std::unique_ptr<FeatureIndex> featureIndex; std::unique_ptr<const GeometryTileData> data; - - // Stores the placement configuration of the text that is currently placed on the screen. - PlacementConfig placedConfig; - - // Stores the placement configuration of how the text should be placed. This isn't necessarily - // the one that is being displayed. - PlacementConfig targetConfig; - - // Used to signal the worker that it should abandon parsing this tile as soon as possible. - std::atomic<bool> obsolete { false }; }; } // namespace mbgl |