[core] Separate pathway for notifying workers of new images/glyphs

This commit is contained in:
John Firebaugh
2016-11-04 13:00:41 -07:00
parent 1533d28314
commit aa08796767
10 changed files with 75 additions and 13 deletions

View File

@@ -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;