diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-01-09 13:05:13 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-01-10 10:15:22 -0800 |
commit | e7778509c546f4d1e0dd73e2d1deceb146c90de2 (patch) | |
tree | d8101c341d45a6a011cb37101f486814be7a6259 /src/mbgl | |
parent | ea4c0b77c39926c770b0003097509e36dc26621d (diff) | |
download | qtlocation-mapboxgl-e7778509c546f4d1e0dd73e2d1deceb146c90de2.tar.gz |
[core] Fix flickering caused by regression in #7586
It should be safe to invoke GeometryTileWorker::setData multiple times without invoking GeometryTileWorker::setLayers. Therefore GeometryTileWorker::redoLayout() must not consume the layers.
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/geometry/feature_index.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/geometry/feature_index.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/group_by_layout.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/style/group_by_layout.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.cpp | 13 |
9 files changed, 24 insertions, 22 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index a04d9e0606..5019d888ca 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -151,8 +151,8 @@ optional<GeometryCoordinates> FeatureIndex::translateQueryGeometry( return translated; } -void FeatureIndex::addBucketLayerName(const std::string& bucketName, const std::string& layerID) { - bucketLayerIDs[bucketName].push_back(layerID); +void FeatureIndex::setBucketLayerIDs(const std::string& bucketName, const std::vector<std::string>& layerIDs) { + bucketLayerIDs[bucketName] = layerIDs; } } // namespace mbgl diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp index 662e78aa2c..ca813f4b6b 100644 --- a/src/mbgl/geometry/feature_index.hpp +++ b/src/mbgl/geometry/feature_index.hpp @@ -52,7 +52,7 @@ public: const float bearing, const float pixelsToTileUnits); - void addBucketLayerName(const std::string& bucketName, const std::string& layerName); + void setBucketLayerIDs(const std::string& bucketName, const std::vector<std::string>& layerIDs); private: void addFeature( diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 85e0b19609..eaa0332995 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -27,7 +27,7 @@ namespace mbgl { using namespace style; -SymbolLayout::SymbolLayout(std::vector<std::unique_ptr<Layer>> layers_, +SymbolLayout::SymbolLayout(std::vector<std::string> layerIDs_, std::string sourceLayerName_, uint32_t overscaling_, float zoom_, @@ -37,7 +37,7 @@ SymbolLayout::SymbolLayout(std::vector<std::unique_ptr<Layer>> layers_, style::SymbolLayoutProperties::Evaluated layout_, float textMaxSize_, SpriteAtlas& spriteAtlas_) - : layers(std::move(layers_)), + : layerIDs(std::move(layerIDs_)), sourceLayerName(std::move(sourceLayerName_)), overscaling(overscaling_), zoom(zoom_), @@ -254,7 +254,7 @@ void SymbolLayout::addFeature(const SymbolFeature& feature, ? SymbolPlacementType::Point : layout.get<SymbolPlacement>(); const float textRepeatDistance = symbolSpacing / 2; - IndexedSubfeature indexedFeature = {feature.index, sourceLayerName, layers.at(0)->getID(), symbolInstances.size()}; + IndexedSubfeature indexedFeature = {feature.index, sourceLayerName, layerIDs.at(0), symbolInstances.size()}; auto addSymbolInstance = [&] (const GeometryCoordinates& line, Anchor& anchor) { // https://github.com/mapbox/vector-tile-spec/tree/master/2.1#41-layers diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 63c0a8859d..c89b791ccc 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -28,7 +28,7 @@ struct Anchor; class SymbolLayout { public: - SymbolLayout(std::vector<std::unique_ptr<style::Layer>>, + SymbolLayout(std::vector<std::string> layerIDs_, std::string sourceLayerName_, uint32_t overscaling, float zoom, @@ -56,7 +56,7 @@ public: State state = Pending; - const std::vector<std::unique_ptr<style::Layer>> layers; + const std::vector<std::string> layerIDs; const std::string sourceLayerName; private: diff --git a/src/mbgl/style/group_by_layout.cpp b/src/mbgl/style/group_by_layout.cpp index 52d33827ef..b15fe1ca0d 100644 --- a/src/mbgl/style/group_by_layout.cpp +++ b/src/mbgl/style/group_by_layout.cpp @@ -32,16 +32,15 @@ std::string layoutKey(const Layer& layer) { return s.GetString(); } -std::vector<std::vector<std::unique_ptr<Layer>>> groupByLayout(std::vector<std::unique_ptr<Layer>> layers) { - std::unordered_map<std::string, std::vector<std::unique_ptr<Layer>>> map; +std::vector<std::vector<const Layer*>> groupByLayout(const std::vector<std::unique_ptr<Layer>>& layers) { + std::unordered_map<std::string, std::vector<const Layer*>> map; for (auto& layer : layers) { - auto& vector = map[layoutKey(*layer)]; - vector.push_back(std::move(layer)); + map[layoutKey(*layer)].push_back(layer.get()); } - std::vector<std::vector<std::unique_ptr<Layer>>> result; + std::vector<std::vector<const Layer*>> result; for (auto& pair : map) { - result.push_back(std::move(pair.second)); + result.push_back(pair.second); } return result; diff --git a/src/mbgl/style/group_by_layout.hpp b/src/mbgl/style/group_by_layout.hpp index dd7b5d118a..3a89ac95f3 100644 --- a/src/mbgl/style/group_by_layout.hpp +++ b/src/mbgl/style/group_by_layout.hpp @@ -8,7 +8,7 @@ namespace style { class Layer; -std::vector<std::vector<std::unique_ptr<Layer>>> groupByLayout(std::vector<std::unique_ptr<Layer>>); +std::vector<std::vector<const Layer*>> groupByLayout(const std::vector<std::unique_ptr<Layer>>&); } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index 8fb85513cf..f058598f5f 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -31,7 +31,7 @@ std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&, const std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& parameters, const GeometryTileLayer& layer, - std::vector<std::unique_ptr<Layer>> group) const { + std::vector<std::string> group) const { PropertyEvaluationParameters p(parameters.tileID.overscaledZ); SymbolLayoutProperties::Evaluated evaluated = layout.evaluate(p); diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp index 0d9a7c07e3..db18da07e2 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.hpp +++ b/src/mbgl/style/layers/symbol_layer_impl.hpp @@ -52,7 +52,7 @@ public: std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; std::unique_ptr<SymbolLayout> createLayout(BucketParameters&, const GeometryTileLayer&, - std::vector<std::unique_ptr<Layer>>) const; + std::vector<std::string>) const; SymbolPropertyValues iconPropertyValues(const SymbolLayoutProperties::Evaluated&) const; SymbolPropertyValues textPropertyValues(const SymbolLayoutProperties::Evaluated&) const; diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index 169339f13f..2a86b7feda 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -214,7 +214,7 @@ void GeometryTileWorker::redoLayout() { auto featureIndex = std::make_unique<FeatureIndex>(); BucketParameters parameters { id, obsolete, *featureIndex, mode }; - std::vector<std::vector<std::unique_ptr<Layer>>> groups = groupByLayout(std::move(*layers)); + std::vector<std::vector<const Layer*>> groups = groupByLayout(*layers); for (auto& group : groups) { if (obsolete) { return; @@ -231,13 +231,16 @@ void GeometryTileWorker::redoLayout() { continue; } + std::vector<std::string> layerIDs; for (const auto& layer : group) { - featureIndex->addBucketLayerName(leader.getID(), layer->getID()); + layerIDs.push_back(layer->getID()); } + featureIndex->setBucketLayerIDs(leader.getID(), layerIDs); + if (leader.is<SymbolLayer>()) { symbolLayoutMap.emplace(leader.getID(), - leader.as<SymbolLayer>()->impl->createLayout(parameters, *geometryLayer, std::move(group))); + leader.as<SymbolLayer>()->impl->createLayout(parameters, *geometryLayer, layerIDs)); } else { std::shared_ptr<Bucket> bucket = leader.baseImpl->createBucket(parameters, *geometryLayer); if (!bucket->hasData()) { @@ -321,8 +324,8 @@ void GeometryTileWorker::attemptPlacement() { } std::shared_ptr<Bucket> bucket = symbolLayout->place(*collisionTile); - for (const auto& layer : symbolLayout->layers) { - buckets.emplace(layer->getID(), bucket); + for (const auto& layerID : symbolLayout->layerIDs) { + buckets.emplace(layerID, bucket); } } |