[core] Use an actor model for tile worker concurrency

This commit is contained in:
John Firebaugh
2016-09-06 15:01:34 -07:00
parent 0bd66d40dd
commit 41bbd4e4f7
41 changed files with 1198 additions and 825 deletions

View File

@@ -43,8 +43,7 @@ Style::Style(FileSource& fileSource_, float pixelRatio)
spriteStore(std::make_unique<SpriteStore>(pixelRatio)),
spriteAtlas(std::make_unique<SpriteAtlas>(1024, 1024, pixelRatio, *spriteStore)),
lineAtlas(std::make_unique<LineAtlas>(256, 512)),
observer(&nullObserver),
workers(4) {
observer(&nullObserver) {
glyphStore->setObserver(this);
spriteStore->setObserver(this);
}
@@ -215,19 +214,8 @@ double Style::getDefaultPitch() const {
}
void Style::updateTiles(const UpdateParameters& parameters) {
bool allTilesUpdated = true;
for (const auto& source : sources) {
source->baseImpl->loadTiles(parameters);
if (!source->baseImpl->parseTiles(parameters)) {
allTilesUpdated = false;
}
}
// We can only stop updating "partial" tiles when all of them
// were notified of the arrival of the new resources.
if (allTilesUpdated) {
shouldReparsePartialTiles = false;
source->baseImpl->updateTiles(parameters);
}
}
@@ -235,7 +223,7 @@ void Style::relayout() {
for (const auto& sourceID : updateBatch.sourceIDs) {
Source* source = getSource(sourceID);
if (!source) continue;
source->baseImpl->reload();
source->baseImpl->reloadTiles();
}
updateBatch.sourceIDs.clear();
}
@@ -447,7 +435,6 @@ void Style::setObserver(style::Observer* observer_) {
}
void Style::onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) {
shouldReparsePartialTiles = true;
observer->onGlyphsLoaded(fontStack, glyphRange);
observer->onUpdate(Update::Repaint);
}
@@ -473,12 +460,8 @@ void Style::onSourceError(Source& source, std::exception_ptr error) {
observer->onResourceError(error);
}
void Style::onTileLoaded(Source& source, const OverscaledTileID& tileID, TileLoadState loadState) {
if (loadState == TileLoadState::First) {
shouldReparsePartialTiles = true;
}
observer->onTileLoaded(source, tileID, loadState);
void Style::onTileChanged(Source& source, const OverscaledTileID& tileID) {
observer->onTileChanged(source, tileID);
observer->onUpdate(Update::Repaint);
}
@@ -490,12 +473,7 @@ void Style::onTileError(Source& source, const OverscaledTileID& tileID, std::exc
observer->onResourceError(error);
}
void Style::onTileUpdated(Source&, const OverscaledTileID&) {
observer->onUpdate(Update::Repaint);
}
void Style::onSpriteLoaded() {
shouldReparsePartialTiles = true;
observer->onSpriteLoaded();
observer->onUpdate(Update::Repaint);
}