summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-10 16:25:14 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-13 13:45:48 +0300
commitfc741cdd211c5eb010fa5eb220b13b1f42bf8bde (patch)
tree42f975231e7fde4e017392d860da49b263a658de /src
parent796cc3a4d6ce7fd4d857e0985392efccb388dfb1 (diff)
downloadqtlocation-mapboxgl-fc741cdd211c5eb010fa5eb220b13b1f42bf8bde.tar.gz
[core] Initiate new placement only when a new bucket appeares
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp9
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.cpp19
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.hpp9
3 files changed, 23 insertions, 14 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index eb6963c970..1e2541c4d4 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -360,11 +360,14 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
crossTileSymbolIndex.reset();
}
+ bool symbolBucketsAdded = false;
bool symbolBucketsChanged = false;
for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
- if (crossTileSymbolIndex.addLayer(*it, updateParameters.transformState.getLatLng().longitude())) symbolBucketsChanged = true;
+ auto result = crossTileSymbolIndex.addLayer(*it, updateParameters.transformState.getLatLng().longitude());
+ symbolBucketsAdded = symbolBucketsAdded || (result & CrossTileSymbolIndex::AddLayerResult::BucketsAdded);
+ symbolBucketsChanged = symbolBucketsChanged || (result != CrossTileSymbolIndex::AddLayerResult::NoChanges);
}
- renderTreeParameters->placementChanged = !placement->stillRecent(updateParameters.timePoint, updateParameters.transformState.getZoom()) || symbolBucketsChanged;
+ renderTreeParameters->placementChanged = !placement->stillRecent(updateParameters.timePoint, updateParameters.transformState.getZoom()) || symbolBucketsAdded;
std::set<std::string> usedSymbolLayers;
if (renderTreeParameters->placementChanged) {
@@ -389,7 +392,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
}
for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
- placement->updateLayerBuckets(*it, updateParameters.transformState, renderTreeParameters->placementChanged);
+ placement->updateLayerBuckets(*it, updateParameters.transformState, renderTreeParameters->placementChanged || symbolBucketsChanged);
}
renderTreeParameters->symbolFadeChange = placement->symbolFadeChange(updateParameters.timePoint);
diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp
index 43ed85d957..55ab2cc3c5 100644
--- a/src/mbgl/text/cross_tile_symbol_index.cpp
+++ b/src/mbgl/text/cross_tile_symbol_index.cpp
@@ -163,10 +163,10 @@ bool CrossTileSymbolLayerIndex::removeStaleBuckets(const std::unordered_set<uint
CrossTileSymbolIndex::CrossTileSymbolIndex() = default;
-bool CrossTileSymbolIndex::addLayer(const RenderLayer& layer, float lng) {
+auto CrossTileSymbolIndex::addLayer(const RenderLayer& layer, float lng) -> AddLayerResult {
auto& layerIndex = layerIndexes[layer.getID()];
- bool symbolBucketsChanged = false;
+ AddLayerResult result = AddLayerResult::NoChanges;
std::unordered_set<uint32_t> currentBucketIDs;
layerIndex.handleWrapJump(lng);
@@ -174,16 +174,15 @@ bool CrossTileSymbolIndex::addLayer(const RenderLayer& layer, float lng) {
for (const auto& item : layer.getPlacementData()) {
const RenderTile& renderTile = item.tile;
Bucket& bucket = item.bucket;
- auto result = bucket.registerAtCrossTileIndex(layerIndex, renderTile.getOverscaledTileID(), maxCrossTileID);
- assert(result.first != 0u);
- symbolBucketsChanged = symbolBucketsChanged || result.second;
- currentBucketIDs.insert(result.first);
+ auto pair = bucket.registerAtCrossTileIndex(layerIndex, renderTile.getOverscaledTileID(), maxCrossTileID);
+ assert(pair.first != 0u);
+ if (pair.second) result |= AddLayerResult::BucketsAdded;
+ currentBucketIDs.insert(pair.first);
}
- if (layerIndex.removeStaleBuckets(currentBucketIDs)) {
- symbolBucketsChanged = true;
- }
- return symbolBucketsChanged;
+ if (layerIndex.removeStaleBuckets(currentBucketIDs)) result |= AddLayerResult::BucketsRemoved;
+
+ return result;
}
void CrossTileSymbolIndex::pruneUnusedLayers(const std::set<std::string>& usedLayers) {
diff --git a/src/mbgl/text/cross_tile_symbol_index.hpp b/src/mbgl/text/cross_tile_symbol_index.hpp
index d905aeb569..4e32698b3e 100644
--- a/src/mbgl/text/cross_tile_symbol_index.hpp
+++ b/src/mbgl/text/cross_tile_symbol_index.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/util/bitmask_operations.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/optional.hpp>
@@ -58,7 +59,13 @@ class CrossTileSymbolIndex {
public:
CrossTileSymbolIndex();
- bool addLayer(const RenderLayer& layer, float lng);
+ enum class AddLayerResult : uint8_t {
+ NoChanges = 0,
+ BucketsAdded = 1 << 0,
+ BucketsRemoved = 1 << 1
+ };
+
+ AddLayerResult addLayer(const RenderLayer& layer, float lng);
void pruneUnusedLayers(const std::set<std::string>&);
void reset();