Add partial tile parsing
This change will add a new state to the tile called "partial" which is a state where the tile can be rendered but some information might be missing. For now we skip the SymbolBucket if the Sprites are not loaded (will also do the same for the glyphs in the future). When the Sprites are finally loaded, we trigger another update, this time the Tile will get completely re-rendered and change the state to "parsed".
This commit is contained in:
@@ -12,6 +12,7 @@ TileData::TileData(const TileID& id_, const SourceInfo& source_)
|
||||
: id(id_),
|
||||
name(id),
|
||||
state(State::initial),
|
||||
parsing(ATOMIC_FLAG_INIT),
|
||||
source(source_),
|
||||
env(Environment::Get()),
|
||||
debugBucket(debugFontBuffer) {
|
||||
@@ -60,6 +61,18 @@ void TileData::cancel() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileData::reparse(Worker& worker, std::function<void()> callback) {
|
||||
workRequest = worker.send([this] { parse(); }, callback);
|
||||
bool TileData::mayStartParsing() {
|
||||
return !parsing.test_and_set(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void TileData::endParsing() {
|
||||
parsing.clear(std::memory_order_release);
|
||||
}
|
||||
|
||||
void TileData::reparse(Worker& worker, std::function<void()> callback) {
|
||||
if (!mayStartParsing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
workRequest = worker.send([this] { parse(); endParsing(); }, callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user