-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Extract SymbolLayout from SymbolBucket #6298
Conversation
@jfirebaugh, thanks for your PR! By analyzing this pull request, we identified @ansis, @yhahn and @tmpsantos to be potential reviewers. |
86dee78
to
03dd84e
Compare
I'd like to merge this today, so I can continue progress on fixing #6263. Reviews appreciated! |
03dd84e
to
738774d
Compare
Moving most of the code + changes in one commit makes this really hard to review. |
Really liking this separation. While reviewing, I didn't spot any logic errors. I think this is good to go. |
Here's a suggestion for reducing the number of `SymbolBuckets that are gratuitously created, then discarded: diff --git a/src/mbgl/tile/tile_worker.cpp b/src/mbgl/tile/tile_worker.cpp
index f079847..53f6acb 100644
--- a/src/mbgl/tile/tile_worker.cpp
+++ b/src/mbgl/tile/tile_worker.cpp
@@ -164,9 +164,9 @@ TilePlacementResult TileWorker::redoPlacement(const PlacementConfig& config) {
for (auto& symbolLayout : symbolLayouts) {
symbolLayout->state = SymbolLayout::Placed;
- std::unique_ptr<Bucket> bucket = symbolLayout->place(*result.collisionTile);
- if (bucket->hasData() || symbolLayout->hasSymbolInstances()) {
- result.buckets.emplace(symbolLayout->bucketName, std::move(bucket));
+ if (symbolLayout->hasSymbolInstances()) {
+ result.buckets.emplace(symbolLayout->bucketName,
+ symbolLayout->place(*result.collisionTile));
}
}
|
738774d
to
a7f12ff
Compare
Sorry for the poor diff. Here is a diff between symbol_bucket.cpp before and symbol_layout.cpp after, so you can see what changed in the moved code:
|
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.
a7f12ff
to
a9f5224
Compare
@@ -40,7 +40,8 @@ void SymbolBucket::render(Painter& painter, | |||
} | |||
|
|||
bool SymbolBucket::hasData() const { | |||
return hasTextData() || hasIconData(); | |||
assert(false); // Should be calling SymbolLayout::hasSymbolInstances() instead. | |||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could move hasSymbolInstances()
to this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
@jfirebaugh nice! Does it make sense to split the two in GL JS as well? |
I still need to debug this, but I want to get @ansis and @kkaefer 👀 on it as soon as possible.
This PR splits
SymbolBucket
in two. The new classSymbolLayout
lives on the worker thread only 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 duringTileWorker::redoPlacement
.SymbolBucket::swapRenderData
is no longer necessary.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.The related
SymbolLayout
methods reflect this terminology, which fixes #2884.In
TileWorker
, allSymbolLayouts
are now stored in a single vector. EachSymbolLayout
knows what state it is in, andTileWorker
can more straightforwardly determine how much progress it can make toward a final result. I think the advancement of a tile through the stages of processing is clearer now, making further progress towards #2851.