Do not process partial tiles if no new resources have arrived

Partial tiles are now only processed again when there is a new resource
available. If we don't have new resources - like new glyphs - the end result
of the reparsing is the same, because no new SymbolBuckets would are created.

In my tests debugging with PowerTOP, this patch drops the CPU utilization
during the sampling period from 100ms/s to 40ms/s. The improvements on
slow connections (i.e. more time waiting for resources) are even more
noticeable.
This commit is contained in:
Thiago Marcos P. Santos
2015-05-07 16:09:15 +03:00
parent 41dc5e836a
commit 3f445e8578
4 changed files with 15 additions and 4 deletions

View File

@@ -85,11 +85,15 @@ void ResourceLoader::update(MapData& data,
for (const auto& source : style_->sources) {
source->update(data, transform, *style_, glyphAtlas, *glyphStore_,
spriteAtlas, sprite_, texturePool);
spriteAtlas, sprite_, texturePool, shouldReparsePartialTiles_);
}
shouldReparsePartialTiles_ = false;
}
void ResourceLoader::onGlyphRangeLoaded() {
shouldReparsePartialTiles_ = true;
emitTileDataChanged();
}
@@ -102,6 +106,8 @@ void ResourceLoader::onTileLoaded() {
}
void ResourceLoader::onSpriteLoaded() {
shouldReparsePartialTiles_ = true;
emitTileDataChanged();
}

View File

@@ -73,6 +73,8 @@ public:
private:
void emitTileDataChanged();
bool shouldReparsePartialTiles_ = false;
std::string accessToken_;
util::ptr<Sprite> sprite_;

View File

@@ -384,7 +384,8 @@ void Source::update(MapData& data,
GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas,
util::ptr<Sprite> sprite,
TexturePool& texturePool) {
TexturePool& texturePool,
bool shouldReparsePartialTiles) {
if (!loaded || data.getAnimationTime() <= updated) {
return;
}
@@ -407,7 +408,8 @@ void Source::update(MapData& data,
switch (state) {
case TileData::State::partial:
handlePartialTile(id, style.workers);
if (shouldReparsePartialTiles)
handlePartialTile(id, style.workers);
break;
case TileData::State::invalid:
state = addTile(data, transformState, style, glyphAtlas, glyphStore,

View File

@@ -75,7 +75,8 @@ public:
GlyphStore&,
SpriteAtlas&,
util::ptr<Sprite>,
TexturePool&);
TexturePool&,
bool shouldReparsePartialTiles);
void invalidateTiles(const std::vector<TileID>&);