[core] Extract SymbolLayout from SymbolBucket

SymbolLayout lives on the worker thread and contains the persistent data needed for repeated placement. SymbolBucket contains the data generated during placement, and is transferred to the main thread for rendering.

This eliminates the risky sharing of GeometryTile::buckets between the main thread and worker thread during TileWorker::redoPlacement.

While here, rationalize the names of states a SymbolLayout may be in:

* Pending: Waiting for the necessary glyphs or icons to be available.
* Prepared: The potential positions of text and icons have been determined.
* Placed: The final positions have been determined, taking into account prior layers.

In TileWorker, all SymbolLayouts are stored in a single vector. Each SymbolLayout knows what state it is in, and TileWorker can easily determine how much progress it can make toward a final result.
This commit is contained in:
John Firebaugh
2016-09-08 12:31:36 -07:00
parent 0bdd968d2b
commit c8217a8739
17 changed files with 913 additions and 876 deletions

View File

@@ -63,10 +63,9 @@ public:
}
void redoPlacement(TileWorker* worker,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>* buckets,
PlacementConfig config,
std::function<void(std::unique_ptr<CollisionTile>)> callback) {
callback(worker->redoPlacement(buckets, config));
std::function<void(TilePlacementResult)> callback) {
callback(worker->redoPlacement(config));
}
};
@@ -120,12 +119,11 @@ Worker::redoLayout(TileWorker& worker,
std::unique_ptr<AsyncRequest>
Worker::redoPlacement(TileWorker& worker,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>& buckets,
PlacementConfig config,
std::function<void(std::unique_ptr<CollisionTile>)> callback) {
std::function<void(TilePlacementResult)> callback) {
current = (current + 1) % threads.size();
return threads[current]->invokeWithCallback(&Worker::Impl::redoPlacement, &worker,
&buckets, config, callback);
config, callback);
}
} // end namespace mbgl