diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-20 16:31:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-12-21 08:45:08 -0800 |
commit | f6985cf6ffe0557d4b8a9360ef351d1668c8974c (patch) | |
tree | de923320280f8c1f2957db94820ce298630b412a | |
parent | 77db372123920ca6c3233c0b2c7393703db66635 (diff) | |
download | qtlocation-mapboxgl-f6985cf6ffe0557d4b8a9360ef351d1668c8974c.tar.gz |
[core] Convert BucketParameters#layer to a separate parameter
This parameter varies between Buckets, while the others are constant. It makes more sense as an individual parameter.
20 files changed, 36 insertions, 39 deletions
diff --git a/src/mbgl/style/bucket_parameters.cpp b/src/mbgl/style/bucket_parameters.cpp index 64f53babcd..e641120c5e 100644 --- a/src/mbgl/style/bucket_parameters.cpp +++ b/src/mbgl/style/bucket_parameters.cpp @@ -6,7 +6,8 @@ namespace mbgl { namespace style { void BucketParameters::eachFilteredFeature(const Filter& filter, - std::function<void (const GeometryTileFeature&, std::size_t index, const std::string& layerName)> function) { + const GeometryTileLayer& layer, + std::function<void (const GeometryTileFeature&, std::size_t index, const std::string& layerName)> function) { auto name = layer.getName(); for (std::size_t i = 0; !cancelled() && i < layer.featureCount(); i++) { auto feature = layer.getFeature(i); diff --git a/src/mbgl/style/bucket_parameters.hpp b/src/mbgl/style/bucket_parameters.hpp index 9aad35dcad..2b16db7625 100644 --- a/src/mbgl/style/bucket_parameters.hpp +++ b/src/mbgl/style/bucket_parameters.hpp @@ -21,14 +21,12 @@ namespace style { class BucketParameters { public: BucketParameters(const OverscaledTileID& tileID_, - const GeometryTileLayer& layer_, const std::atomic<bool>& obsolete_, uintptr_t tileUID_, GlyphAtlas& glyphAtlas_, FeatureIndex& featureIndex_, const MapMode mode_) : tileID(tileID_), - layer(layer_), obsolete(obsolete_), tileUID(tileUID_), glyphAtlas(glyphAtlas_), @@ -39,10 +37,9 @@ public: return obsolete; } - void eachFilteredFeature(const Filter&, std::function<void (const GeometryTileFeature&, std::size_t index, const std::string& layerName)>); + void eachFilteredFeature(const Filter&, const GeometryTileLayer&, std::function<void (const GeometryTileFeature&, std::size_t index, const std::string& layerName)>); const OverscaledTileID& tileID; - const GeometryTileLayer& layer; const std::atomic<bool>& obsolete; uintptr_t tileUID; GlyphAtlas& glyphAtlas; diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp index 38ac32e1de..7e2c55c2e6 100644 --- a/src/mbgl/style/layer_impl.hpp +++ b/src/mbgl/style/layer_impl.hpp @@ -59,7 +59,7 @@ public: // Returns true if any paint properties have active transitions. virtual bool evaluate(const PropertyEvaluationParameters&) = 0; - virtual std::unique_ptr<Bucket> createBucket(BucketParameters&) const = 0; + virtual std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const = 0; // Checks whether this layer needs to be rendered in the given render pass. bool hasRenderPass(RenderPass) const; diff --git a/src/mbgl/style/layers/background_layer_impl.cpp b/src/mbgl/style/layers/background_layer_impl.cpp index 9a7db9416e..4a8fe39c9a 100644 --- a/src/mbgl/style/layers/background_layer_impl.cpp +++ b/src/mbgl/style/layers/background_layer_impl.cpp @@ -16,7 +16,7 @@ bool BackgroundLayer::Impl::evaluate(const PropertyEvaluationParameters& paramet return paint.hasTransition(); } -std::unique_ptr<Bucket> BackgroundLayer::Impl::createBucket(BucketParameters&) const { +std::unique_ptr<Bucket> BackgroundLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { return nullptr; } diff --git a/src/mbgl/style/layers/background_layer_impl.hpp b/src/mbgl/style/layers/background_layer_impl.hpp index 6ede1b7d97..d3d50e21cd 100644 --- a/src/mbgl/style/layers/background_layer_impl.hpp +++ b/src/mbgl/style/layers/background_layer_impl.hpp @@ -15,7 +15,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; BackgroundPaintProperties paint; }; diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp index 6599126702..614f637b3b 100644 --- a/src/mbgl/style/layers/circle_layer_impl.cpp +++ b/src/mbgl/style/layers/circle_layer_impl.cpp @@ -21,11 +21,11 @@ bool CircleLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) return paint.hasTransition(); } -std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(BucketParameters& parameters) const { +std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const { auto bucket = std::make_unique<CircleBucket>(parameters.mode); auto& name = bucketName(); - parameters.eachFilteredFeature(filter, [&] (const auto& feature, std::size_t index, const std::string& layerName) { + parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) { auto geometries = feature.getGeometries(); bucket->addGeometry(geometries); parameters.featureIndex.insert(geometries, index, layerName, name); diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp index df3b34cc1a..f0db58be24 100644 --- a/src/mbgl/style/layers/circle_layer_impl.hpp +++ b/src/mbgl/style/layers/circle_layer_impl.hpp @@ -15,7 +15,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; float getQueryRadius() const override; bool queryIntersectsGeometry( diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp index 50dcc0dda9..3f11943478 100644 --- a/src/mbgl/style/layers/custom_layer_impl.cpp +++ b/src/mbgl/style/layers/custom_layer_impl.cpp @@ -67,7 +67,7 @@ bool CustomLayer::Impl::evaluate(const PropertyEvaluationParameters&) { return false; } -std::unique_ptr<Bucket> CustomLayer::Impl::createBucket(BucketParameters&) const { +std::unique_ptr<Bucket> CustomLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { return nullptr; } diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp index 56e3f3146c..3e365faacf 100644 --- a/src/mbgl/style/layers/custom_layer_impl.hpp +++ b/src/mbgl/style/layers/custom_layer_impl.hpp @@ -31,7 +31,7 @@ private: void cascade(const CascadeParameters&) final {} bool evaluate(const PropertyEvaluationParameters&) final; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const final; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const final; CustomLayerInitializeFunction initializeFn = nullptr; CustomLayerRenderFunction renderFn = nullptr; diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp index 239f7754d0..ebe9009312 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp @@ -11,7 +11,7 @@ bool FillExtrusionLayer::Impl::evaluate(const PropertyEvaluationParameters&) { return false; } -std::unique_ptr<Bucket> FillExtrusionLayer::Impl::createBucket(BucketParameters&) const { +std::unique_ptr<Bucket> FillExtrusionLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { return nullptr; } diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp index 79ae02dd5b..52b9d327f2 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp @@ -15,7 +15,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; FillExtrusionPaintProperties paint; }; diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp index 6a690ba447..59d6a22432 100644 --- a/src/mbgl/style/layers/fill_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_layer_impl.cpp @@ -30,11 +30,11 @@ bool FillLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { return paint.hasTransition(); } -std::unique_ptr<Bucket> FillLayer::Impl::createBucket(BucketParameters& parameters) const { +std::unique_ptr<Bucket> FillLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const { auto bucket = std::make_unique<FillBucket>(); auto& name = bucketName(); - parameters.eachFilteredFeature(filter, [&] (const auto& feature, std::size_t index, const std::string& layerName) { + parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) { auto geometries = feature.getGeometries(); bucket->addGeometry(geometries); parameters.featureIndex.insert(geometries, index, layerName, name); diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp index 53276d744a..bebea4ffab 100644 --- a/src/mbgl/style/layers/fill_layer_impl.hpp +++ b/src/mbgl/style/layers/fill_layer_impl.hpp @@ -15,7 +15,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; float getQueryRadius() const override; bool queryIntersectsGeometry( diff --git a/src/mbgl/style/layers/line_layer_impl.cpp b/src/mbgl/style/layers/line_layer_impl.cpp index e6ec21a659..24b2b097b1 100644 --- a/src/mbgl/style/layers/line_layer_impl.cpp +++ b/src/mbgl/style/layers/line_layer_impl.cpp @@ -26,13 +26,13 @@ bool LineLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) { return paint.hasTransition(); } -std::unique_ptr<Bucket> LineLayer::Impl::createBucket(BucketParameters& parameters) const { +std::unique_ptr<Bucket> LineLayer::Impl::createBucket(BucketParameters& parameters, const GeometryTileLayer& layer) const { auto bucket = std::make_unique<LineBucket>(parameters.tileID.overscaleFactor()); bucket->layout = layout.evaluate(PropertyEvaluationParameters(parameters.tileID.overscaledZ)); auto& name = bucketName(); - parameters.eachFilteredFeature(filter, [&] (const auto& feature, std::size_t index, const std::string& layerName) { + parameters.eachFilteredFeature(filter, layer, [&] (const auto& feature, std::size_t index, const std::string& layerName) { auto geometries = feature.getGeometries(); bucket->addGeometry(geometries); parameters.featureIndex.insert(geometries, index, layerName, name); diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp index 3387db07f0..8c8c7d053b 100644 --- a/src/mbgl/style/layers/line_layer_impl.hpp +++ b/src/mbgl/style/layers/line_layer_impl.hpp @@ -15,7 +15,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; float getQueryRadius() const override; bool queryIntersectsGeometry( diff --git a/src/mbgl/style/layers/raster_layer_impl.cpp b/src/mbgl/style/layers/raster_layer_impl.cpp index 3be4bb4fbd..a78614aee9 100644 --- a/src/mbgl/style/layers/raster_layer_impl.cpp +++ b/src/mbgl/style/layers/raster_layer_impl.cpp @@ -16,7 +16,7 @@ bool RasterLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) return paint.hasTransition(); } -std::unique_ptr<Bucket> RasterLayer::Impl::createBucket(BucketParameters&) const { +std::unique_ptr<Bucket> RasterLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { return nullptr; } diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp index df5d388bdf..b7c926f623 100644 --- a/src/mbgl/style/layers/raster_layer_impl.hpp +++ b/src/mbgl/style/layers/raster_layer_impl.hpp @@ -15,7 +15,7 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; RasterPaintProperties paint; }; diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index 957bc1993e..64968f51e4 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -24,12 +24,12 @@ bool SymbolLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) return paint.hasTransition(); } -std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&) const { +std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const { assert(false); // Should be calling createLayout() instead. return nullptr; } -std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& parameters) const { +std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& parameters, const GeometryTileLayer& layer) const { PropertyEvaluationParameters p(parameters.tileID.overscaledZ); SymbolLayoutProperties::Evaluated evaluated = layout.evaluate(p); @@ -60,11 +60,11 @@ std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& evaluated.get<TextSize>() = layout.evaluate<TextSize>(PropertyEvaluationParameters(p.z + 1)); return std::make_unique<SymbolLayout>(id, - parameters.layer.getName(), + layer.getName(), parameters.tileID.overscaleFactor(), parameters.tileID.overscaledZ, parameters.mode, - parameters.layer, + layer, filter, evaluated, textMaxSize, diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp index 46ed75b231..4377630491 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.hpp +++ b/src/mbgl/style/layers/symbol_layer_impl.hpp @@ -49,8 +49,8 @@ public: void cascade(const CascadeParameters&) override; bool evaluate(const PropertyEvaluationParameters&) override; - std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; - std::unique_ptr<SymbolLayout> createLayout(BucketParameters&) const; + std::unique_ptr<Bucket> createBucket(BucketParameters&, const GeometryTileLayer&) const override; + std::unique_ptr<SymbolLayout> createLayout(BucketParameters&, const GeometryTileLayer&) 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 738c78572d..e6aaf05d1a 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -210,6 +210,13 @@ void GeometryTileWorker::redoLayout() { std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; auto featureIndex = std::make_unique<FeatureIndex>(); + BucketParameters parameters(id, + obsolete, + reinterpret_cast<uintptr_t>(this), + glyphAtlas, + *featureIndex, + mode); + for (auto i = layers->rbegin(); i != layers->rend(); i++) { if (obsolete) { return; @@ -235,18 +242,10 @@ void GeometryTileWorker::redoLayout() { continue; } - BucketParameters parameters(id, - *geometryLayer, - obsolete, - reinterpret_cast<uintptr_t>(this), - glyphAtlas, - *featureIndex, - mode); - if (layer->is<SymbolLayer>()) { - symbolLayouts.push_back(layer->as<SymbolLayer>()->impl->createLayout(parameters)); + symbolLayouts.push_back(layer->as<SymbolLayer>()->impl->createLayout(parameters, *geometryLayer)); } else { - std::unique_ptr<Bucket> bucket = layer->baseImpl->createBucket(parameters); + std::unique_ptr<Bucket> bucket = layer->baseImpl->createBucket(parameters, *geometryLayer); if (bucket->hasData()) { buckets.emplace(layer->baseImpl->bucketName(), std::move(bucket)); } |