diff options
author | Juha Alanen <juha.alanen@mapbox.com> | 2019-09-17 15:40:01 +0300 |
---|---|---|
committer | Juha Alanen <19551460+jmalanen@users.noreply.github.com> | 2019-09-18 14:29:15 +0300 |
commit | 6b13c42314f28e3b27111367c4f3296c3c3c1248 (patch) | |
tree | 2f91aae637e2c49bb55cfc336f772ac772ab5a2d /src | |
parent | 0042f0b9f5de7151f14300f02a559b6ecb48a507 (diff) | |
download | qtlocation-mapboxgl-6b13c42314f28e3b27111367c4f3296c3c3c1248.tar.gz |
[build] Fix clang format and tidy checks
Diffstat (limited to 'src')
45 files changed, 348 insertions, 491 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index 571ff172f8..20026dd117 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -1,14 +1,14 @@ #include <mbgl/geometry/feature_index.hpp> -#include <mbgl/renderer/render_layer.hpp> -#include <mbgl/renderer/query.hpp> +#include <mbgl/math/minmax.hpp> #include <mbgl/renderer/layers/render_symbol_layer.hpp> +#include <mbgl/renderer/query.hpp> +#include <mbgl/renderer/render_layer.hpp> +#include <mbgl/renderer/source_state.hpp> +#include <mbgl/style/filter.hpp> #include <mbgl/text/collision_index.hpp> +#include <mbgl/tile/tile_id.hpp> #include <mbgl/util/constants.hpp> #include <mbgl/util/math.hpp> -#include <mbgl/math/minmax.hpp> -#include <mbgl/style/filter.hpp> -#include <mbgl/tile/tile_id.hpp> -#include <mbgl/renderer/source_state.hpp> #include <mapbox/geometry/envelope.hpp> @@ -39,19 +39,12 @@ void FeatureIndex::insert(const GeometryCollection& geometries, } } -void FeatureIndex::query( - std::unordered_map<std::string, std::vector<Feature>>& result, - const GeometryCoordinates& queryGeometry, - const TransformState& transformState, - const mat4& posMatrix, - const double tileSize, - const double scale, - const RenderedQueryOptions& queryOptions, - const UnwrappedTileID& tileID, - const std::unordered_map<std::string, const RenderLayer*>& layers, - const float additionalQueryPadding, - const SourceFeatureState& sourceFeatureState) const { - +void FeatureIndex::query(std::unordered_map<std::string, std::vector<Feature>>& result, + const GeometryCoordinates& queryGeometry, const TransformState& transformState, + const mat4& posMatrix, const double tileSize, const double scale, + const RenderedQueryOptions& queryOptions, const UnwrappedTileID& tileID, + const std::unordered_map<std::string, const RenderLayer*>& layers, + const float additionalQueryPadding, const SourceFeatureState& sourceFeatureState) const { if (!tileData) { return; } @@ -76,10 +69,11 @@ void FeatureIndex::query( if (indexedFeature.sortIndex == previousSortIndex) continue; previousSortIndex = indexedFeature.sortIndex; - addFeature(result, indexedFeature, queryOptions, tileID.canonical, layers, queryGeometry, transformState, pixelsToTileUnits, posMatrix, &sourceFeatureState); + addFeature(result, indexedFeature, queryOptions, tileID.canonical, layers, queryGeometry, transformState, + pixelsToTileUnits, posMatrix, &sourceFeatureState); } } - + std::unordered_map<std::string, std::vector<Feature>> FeatureIndex::lookupSymbolFeatures(const std::vector<IndexedSubfeature>& symbolFeatures, const RenderedQueryOptions& queryOptions, @@ -115,23 +109,19 @@ FeatureIndex::lookupSymbolFeatures(const std::vector<IndexedSubfeature>& symbolF for (const auto& symbolFeature : sortedFeatures) { mat4 unusedMatrix; - addFeature(result, symbolFeature, queryOptions, tileID.canonical, layers, GeometryCoordinates(), {}, 0, unusedMatrix, nullptr); + addFeature(result, symbolFeature, queryOptions, tileID.canonical, layers, GeometryCoordinates(), {}, 0, + unusedMatrix, nullptr); } return result; } -void FeatureIndex::addFeature( - std::unordered_map<std::string, std::vector<Feature>>& result, - const IndexedSubfeature& indexedFeature, - const RenderedQueryOptions& options, - const CanonicalTileID& tileID, - const std::unordered_map<std::string, const RenderLayer*>& layers, - const GeometryCoordinates& queryGeometry, - const TransformState& transformState, - const float pixelsToTileUnits, - const mat4& posMatrix, - const SourceFeatureState* sourceFeatureState) const { - +void FeatureIndex::addFeature(std::unordered_map<std::string, std::vector<Feature>>& result, + const IndexedSubfeature& indexedFeature, const RenderedQueryOptions& options, + const CanonicalTileID& tileID, + const std::unordered_map<std::string, const RenderLayer*>& layers, + const GeometryCoordinates& queryGeometry, const TransformState& transformState, + const float pixelsToTileUnits, const mat4& posMatrix, + const SourceFeatureState* sourceFeatureState) const { // Lazily calculated. std::unique_ptr<GeometryTileLayer> sourceLayer; std::unique_ptr<GeometryTileFeature> geometryTileFeature; @@ -152,7 +142,7 @@ void FeatureIndex::addFeature( assert(geometryTileFeature); } FeatureState state; - if (sourceFeatureState) { + if (sourceFeatureState != nullptr) { optional<std::string> idStr = featureIDtoString(geometryTileFeature->getID()); if (idStr) { sourceFeatureState->getState(state, sourceLayer->getName(), *idStr); @@ -161,7 +151,8 @@ void FeatureIndex::addFeature( bool needsCrossTileIndex = renderLayer->baseImpl->getTypeInfo()->crossTileIndex == style::LayerTypeInfo::CrossTileIndex::Required; if (!needsCrossTileIndex && - !renderLayer->queryIntersectsFeature(queryGeometry, *geometryTileFeature, tileID.z, transformState, pixelsToTileUnits, posMatrix, state)) { + !renderLayer->queryIntersectsFeature(queryGeometry, *geometryTileFeature, tileID.z, transformState, + pixelsToTileUnits, posMatrix, state)) { continue; } diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp index ab0cfea7db..5a006a51bc 100644 --- a/src/mbgl/geometry/feature_index.hpp +++ b/src/mbgl/geometry/feature_index.hpp @@ -59,18 +59,11 @@ public: void insert(const GeometryCollection&, std::size_t index, const std::string& sourceLayerName, const std::string& bucketLeaderID); - void query( - std::unordered_map<std::string, std::vector<Feature>>& result, - const GeometryCoordinates& queryGeometry, - const TransformState&, - const mat4& posMatrix, - const double tileSize, - const double scale, - const RenderedQueryOptions& options, - const UnwrappedTileID&, - const std::unordered_map<std::string, const RenderLayer*>&, - const float additionalQueryPadding, - const SourceFeatureState& sourceFeatureState) const; + void query(std::unordered_map<std::string, std::vector<Feature>>& result, const GeometryCoordinates& queryGeometry, + const TransformState&, const mat4& posMatrix, const double tileSize, const double scale, + const RenderedQueryOptions& options, const UnwrappedTileID&, + const std::unordered_map<std::string, const RenderLayer*>&, const float additionalQueryPadding, + const SourceFeatureState& sourceFeatureState) const; static optional<GeometryCoordinates> translateQueryGeometry( const GeometryCoordinates& queryGeometry, @@ -89,17 +82,12 @@ public: const std::shared_ptr<std::vector<size_t>>& featureSortOrder) const; private: - void addFeature( - std::unordered_map<std::string, std::vector<Feature>>& result, - const IndexedSubfeature&, - const RenderedQueryOptions& options, - const CanonicalTileID&, - const std::unordered_map<std::string, const RenderLayer*>&, - const GeometryCoordinates& queryGeometry, - const TransformState& transformState, - const float pixelsToTileUnits, - const mat4& posMatrix, - const SourceFeatureState* sourceFeatureState) const; + void addFeature(std::unordered_map<std::string, std::vector<Feature>>& result, const IndexedSubfeature&, + const RenderedQueryOptions& options, const CanonicalTileID&, + const std::unordered_map<std::string, const RenderLayer*>&, + const GeometryCoordinates& queryGeometry, const TransformState& transformState, + const float pixelsToTileUnits, const mat4& posMatrix, + const SourceFeatureState* sourceFeatureState) const; GridIndex<IndexedSubfeature> grid; unsigned int sortIndex = 0; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 71724cad5f..81d1d9a5b6 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -713,7 +713,8 @@ void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIn } for (auto& pair : bucket->paintProperties) { - pair.second.iconBinders.populateVertexVectors(feature, iconBuffer.vertices.elements(), symbolInstance.dataFeatureIndex, {}, {}); + pair.second.iconBinders.populateVertexVectors(feature, iconBuffer.vertices.elements(), + symbolInstance.dataFeatureIndex, {}, {}); } } @@ -765,7 +766,8 @@ void SymbolLayout::updatePaintPropertiesForSection(SymbolBucket& bucket, std::size_t sectionIndex) { const auto& formattedSection = sectionOptionsToValue((*feature.formattedText).sectionAt(sectionIndex)); for (auto& pair : bucket.paintProperties) { - pair.second.textBinders.populateVertexVectors(feature, bucket.text.vertices.elements(), feature.index, {}, {}, formattedSection); + pair.second.textBinders.populateVertexVectors(feature, bucket.text.vertices.elements(), feature.index, {}, {}, + formattedSection); } } diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp index 98c2200ce9..6c74b8309f 100644 --- a/src/mbgl/renderer/bucket.hpp +++ b/src/mbgl/renderer/bucket.hpp @@ -32,15 +32,11 @@ public: // Feature geometries are also used to populate the feature index. // Obtaining these is a costly operation, so we do it only once, and // pass-by-const-ref the geometries as a second parameter. - virtual void addFeature(const GeometryTileFeature&, - const GeometryCollection&, - const ImagePositions&, - const PatternLayerMap&, - std::size_t) {}; + virtual void addFeature(const GeometryTileFeature&, const GeometryCollection&, const ImagePositions&, + const PatternLayerMap&, std::size_t){}; virtual void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) {} - // As long as this bucket has a Prepare render pass, this function is getting called. Typically, // this only happens once when the bucket is being rendered for the first time. virtual void upload(gfx::UploadPass&) = 0; diff --git a/src/mbgl/renderer/buckets/circle_bucket.cpp b/src/mbgl/renderer/buckets/circle_bucket.cpp index ffa6f59128..560a74781a 100644 --- a/src/mbgl/renderer/buckets/circle_bucket.cpp +++ b/src/mbgl/renderer/buckets/circle_bucket.cpp @@ -41,11 +41,8 @@ bool CircleBucket::hasData() const { return !segments.empty(); } -void CircleBucket::addFeature(const GeometryTileFeature& feature, - const GeometryCollection& geometry, - const ImagePositions&, - const PatternLayerMap&, - std::size_t featureIndex) { +void CircleBucket::addFeature(const GeometryTileFeature& feature, const GeometryCollection& geometry, + const ImagePositions&, const PatternLayerMap&, std::size_t featureIndex) { constexpr const uint16_t vertexLength = 4; for (auto& circle : geometry) { @@ -115,7 +112,8 @@ float CircleBucket::getQueryRadius(const RenderLayer& layer) const { return radius + stroke + util::length(translate[0], translate[1]); } -void CircleBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, const ImagePositions& imagePositions) { +void CircleBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, + const ImagePositions& imagePositions) { auto it = paintPropertyBinders.find(layerID); if (it != paintPropertyBinders.end()) { it->second.updateVertexVectors(states, layer, imagePositions); diff --git a/src/mbgl/renderer/buckets/circle_bucket.hpp b/src/mbgl/renderer/buckets/circle_bucket.hpp index 9fee45ad79..e514f8a5f2 100644 --- a/src/mbgl/renderer/buckets/circle_bucket.hpp +++ b/src/mbgl/renderer/buckets/circle_bucket.hpp @@ -18,11 +18,8 @@ public: CircleBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&); ~CircleBucket() override; - void addFeature(const GeometryTileFeature&, - const GeometryCollection&, - const ImagePositions&, - const PatternLayerMap&, - std::size_t) override; + void addFeature(const GeometryTileFeature&, const GeometryCollection&, const ImagePositions&, + const PatternLayerMap&, std::size_t) override; bool hasData() const override; diff --git a/src/mbgl/renderer/buckets/fill_bucket.cpp b/src/mbgl/renderer/buckets/fill_bucket.cpp index ea79a1e687..6660934f8d 100644 --- a/src/mbgl/renderer/buckets/fill_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_bucket.cpp @@ -44,10 +44,8 @@ FillBucket::FillBucket(const FillBucket::PossiblyEvaluatedLayoutProperties, FillBucket::~FillBucket() = default; -void FillBucket::addFeature(const GeometryTileFeature& feature, - const GeometryCollection& geometry, - const ImagePositions& patternPositions, - const PatternLayerMap& patternDependencies, +void FillBucket::addFeature(const GeometryTileFeature& feature, const GeometryCollection& geometry, + const ImagePositions& patternPositions, const PatternLayerMap& patternDependencies, std::size_t index) { for (auto& polygon : classifyRings(geometry)) { // Optimize polygons with many interior rings for earcut tesselation. @@ -126,7 +124,8 @@ void FillBucket::upload(gfx::UploadPass& uploadPass) { if (!uploaded) { vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices)); lineIndexBuffer = uploadPass.createIndexBuffer(std::move(lines)); - triangleIndexBuffer = triangles.empty() ? optional<gfx::IndexBuffer> {} : uploadPass.createIndexBuffer(std::move(triangles)); + triangleIndexBuffer = + triangles.empty() ? optional<gfx::IndexBuffer>{} : uploadPass.createIndexBuffer(std::move(triangles)); } for (auto& pair : paintPropertyBinders) { @@ -146,7 +145,8 @@ float FillBucket::getQueryRadius(const RenderLayer& layer) const { return util::length(translate[0], translate[1]); } -void FillBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, const ImagePositions& imagePositions) { +void FillBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, + const ImagePositions& imagePositions) { auto it = paintPropertyBinders.find(layerID); if (it != paintPropertyBinders.end()) { it->second.updateVertexVectors(states, layer, imagePositions); diff --git a/src/mbgl/renderer/buckets/fill_bucket.hpp b/src/mbgl/renderer/buckets/fill_bucket.hpp index eee421f938..9f65e774ca 100644 --- a/src/mbgl/renderer/buckets/fill_bucket.hpp +++ b/src/mbgl/renderer/buckets/fill_bucket.hpp @@ -26,11 +26,8 @@ public: const float zoom, const uint32_t overscaling); - void addFeature(const GeometryTileFeature&, - const GeometryCollection&, - const mbgl::ImagePositions&, - const PatternLayerMap&, - std::size_t) override; + void addFeature(const GeometryTileFeature&, const GeometryCollection&, const mbgl::ImagePositions&, + const PatternLayerMap&, std::size_t) override; bool hasData() const override; diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp index 6a25349c22..698895fdcf 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp @@ -50,10 +50,8 @@ FillExtrusionBucket::FillExtrusionBucket(const FillExtrusionBucket::PossiblyEval FillExtrusionBucket::~FillExtrusionBucket() = default; -void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, - const GeometryCollection& geometry, - const ImagePositions& patternPositions, - const PatternLayerMap& patternDependencies, +void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, const GeometryCollection& geometry, + const ImagePositions& patternPositions, const PatternLayerMap& patternDependencies, std::size_t index) { for (auto& polygon : classifyRings(geometry)) { // Optimize polygons with many interior rings for earcut tesselation. @@ -189,7 +187,8 @@ float FillExtrusionBucket::getQueryRadius(const RenderLayer& layer) const { return util::length(translate[0], translate[1]); } -void FillExtrusionBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, const ImagePositions& imagePositions) { +void FillExtrusionBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, + const std::string& layerID, const ImagePositions& imagePositions) { auto it = paintPropertyBinders.find(layerID); if (it != paintPropertyBinders.end()) { it->second.updateVertexVectors(states, layer, imagePositions); diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp index 582480bf41..8535f99b70 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp @@ -24,11 +24,8 @@ public: const float, const uint32_t); - void addFeature(const GeometryTileFeature&, - const GeometryCollection&, - const mbgl::ImagePositions&, - const PatternLayerMap&, - std::size_t) override; + void addFeature(const GeometryTileFeature&, const GeometryCollection&, const mbgl::ImagePositions&, + const PatternLayerMap&, std::size_t) override; bool hasData() const override; diff --git a/src/mbgl/renderer/buckets/heatmap_bucket.cpp b/src/mbgl/renderer/buckets/heatmap_bucket.cpp index 0ea645a9a0..78c4fb7507 100644 --- a/src/mbgl/renderer/buckets/heatmap_bucket.cpp +++ b/src/mbgl/renderer/buckets/heatmap_bucket.cpp @@ -39,11 +39,8 @@ bool HeatmapBucket::hasData() const { return !segments.empty(); } -void HeatmapBucket::addFeature(const GeometryTileFeature& feature, - const GeometryCollection& geometry, - const ImagePositions&, - const PatternLayerMap&, - std::size_t featureIndex) { +void HeatmapBucket::addFeature(const GeometryTileFeature& feature, const GeometryCollection& geometry, + const ImagePositions&, const PatternLayerMap&, std::size_t featureIndex) { constexpr const uint16_t vertexLength = 4; for (auto& points : geometry) { diff --git a/src/mbgl/renderer/buckets/heatmap_bucket.hpp b/src/mbgl/renderer/buckets/heatmap_bucket.hpp index 3f9d1cb5c3..04d4170b50 100644 --- a/src/mbgl/renderer/buckets/heatmap_bucket.hpp +++ b/src/mbgl/renderer/buckets/heatmap_bucket.hpp @@ -18,11 +18,8 @@ public: HeatmapBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&); ~HeatmapBucket() override; - void addFeature(const GeometryTileFeature&, - const GeometryCollection&, - const ImagePositions&, - const PatternLayerMap&, - std::size_t) override; + void addFeature(const GeometryTileFeature&, const GeometryCollection&, const ImagePositions&, + const PatternLayerMap&, std::size_t) override; bool hasData() const override; void upload(gfx::UploadPass&) override; diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp index 318af99b0f..f65c239968 100644 --- a/src/mbgl/renderer/buckets/line_bucket.cpp +++ b/src/mbgl/renderer/buckets/line_bucket.cpp @@ -30,10 +30,8 @@ LineBucket::LineBucket(const style::LineLayoutProperties::PossiblyEvaluated layo LineBucket::~LineBucket() = default; -void LineBucket::addFeature(const GeometryTileFeature& feature, - const GeometryCollection& geometryCollection, - const ImagePositions& patternPositions, - const PatternLayerMap& patternDependencies, +void LineBucket::addFeature(const GeometryTileFeature& feature, const GeometryCollection& geometryCollection, + const ImagePositions& patternPositions, const PatternLayerMap& patternDependencies, std::size_t index) { for (auto& line : geometryCollection) { addGeometry(line, feature); @@ -49,7 +47,6 @@ void LineBucket::addFeature(const GeometryTileFeature& feature, } } - /* * Sharp corners cause dashed lines to tilt because the distance along the line * is the same at both the inner and outer corners. To improve the appearance of @@ -557,7 +554,8 @@ float LineBucket::getQueryRadius(const RenderLayer& layer) const { return lineWidth / 2.0f + std::abs(offset) + util::length(translate[0], translate[1]); } -void LineBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, const ImagePositions& imagePositions) { +void LineBucket::update(const FeatureStates& states, const GeometryTileLayer& layer, const std::string& layerID, + const ImagePositions& imagePositions) { auto it = paintPropertyBinders.find(layerID); if (it != paintPropertyBinders.end()) { it->second.updateVertexVectors(states, layer, imagePositions); diff --git a/src/mbgl/renderer/buckets/line_bucket.hpp b/src/mbgl/renderer/buckets/line_bucket.hpp index 6be35593d9..6343aab2be 100644 --- a/src/mbgl/renderer/buckets/line_bucket.hpp +++ b/src/mbgl/renderer/buckets/line_bucket.hpp @@ -26,11 +26,8 @@ public: const uint32_t overscaling); ~LineBucket() override; - void addFeature(const GeometryTileFeature&, - const GeometryCollection&, - const mbgl::ImagePositions& patternPositions, - const PatternLayerMap&, - std::size_t) override; + void addFeature(const GeometryTileFeature&, const GeometryCollection&, const mbgl::ImagePositions& patternPositions, + const PatternLayerMap&, std::size_t) override; bool hasData() const override; diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index 76dadd80bf..b88a026e11 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -141,14 +141,10 @@ GeometryCoordinates projectQueryGeometry(const GeometryCoordinates& queryGeometr return projectedGeometry; } -bool RenderCircleLayer::queryIntersectsFeature( - const GeometryCoordinates& queryGeometry, - const GeometryTileFeature& feature, - const float zoom, - const TransformState& transformState, - const float pixelsToTileUnits, - const mat4& posMatrix, - const FeatureState& featureState) const { +bool RenderCircleLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, + const GeometryTileFeature& feature, const float zoom, + const TransformState& transformState, const float pixelsToTileUnits, + const mat4& posMatrix, const FeatureState& featureState) const { const auto& evaluated = static_cast<const CircleLayerProperties&>(*evaluatedProperties).evaluated; // Translate query geometry const GeometryCoordinates& translatedQueryGeometry = FeatureIndex::translateQueryGeometry( diff --git a/src/mbgl/renderer/layers/render_circle_layer.hpp b/src/mbgl/renderer/layers/render_circle_layer.hpp index ee0318da7c..70af20f0cf 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.hpp +++ b/src/mbgl/renderer/layers/render_circle_layer.hpp @@ -18,14 +18,8 @@ private: bool hasCrossfade() const override; void render(PaintParameters&) override; - bool queryIntersectsFeature( - const GeometryCoordinates&, - const GeometryTileFeature&, - const float, - const TransformState&, - const float, - const mat4&, - const FeatureState&) const override; + bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, const float, + const TransformState&, const float, const mat4&, const FeatureState&) const override; // Paint properties style::CirclePaintProperties::Unevaluated unevaluated; diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index b6ffa3f8f9..fc830e462c 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -224,14 +224,11 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) { } } -bool RenderFillExtrusionLayer::queryIntersectsFeature( - const GeometryCoordinates& queryGeometry, - const GeometryTileFeature& feature, - const float, - const TransformState& transformState, - const float pixelsToTileUnits, - const mat4&, - const FeatureState&) const { +bool RenderFillExtrusionLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, + const GeometryTileFeature& feature, const float, + const TransformState& transformState, + const float pixelsToTileUnits, const mat4&, + const FeatureState&) const { const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated; auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry( queryGeometry, diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp index bad2c26122..0e6a747c71 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp @@ -20,14 +20,8 @@ private: bool is3D() const override; void render(PaintParameters&) override; - bool queryIntersectsFeature( - const GeometryCoordinates&, - const GeometryTileFeature&, - const float, - const TransformState&, - const float, - const mat4&, - const FeatureState&) const override; + bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, const float, + const TransformState&, const float, const mat4&, const FeatureState&) const override; // Paint properties style::FillExtrusionPaintProperties::Unevaluated unevaluated; diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 40b3c289f2..e855866eea 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -249,14 +249,10 @@ void RenderFillLayer::render(PaintParameters& parameters) { } } -bool RenderFillLayer::queryIntersectsFeature( - const GeometryCoordinates& queryGeometry, - const GeometryTileFeature& feature, - const float, - const TransformState& transformState, - const float pixelsToTileUnits, - const mat4&, - const FeatureState&) const { +bool RenderFillLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, + const GeometryTileFeature& feature, const float, + const TransformState& transformState, const float pixelsToTileUnits, + const mat4&, const FeatureState&) const { const auto& evaluated = getEvaluated<FillLayerProperties>(evaluatedProperties); auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry( queryGeometry, @@ -268,5 +264,4 @@ bool RenderFillLayer::queryIntersectsFeature( return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), feature.getGeometries()); } - } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_fill_layer.hpp b/src/mbgl/renderer/layers/render_fill_layer.hpp index 182e0c544c..12484dbfb1 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_layer.hpp @@ -21,14 +21,8 @@ private: bool hasCrossfade() const override; void render(PaintParameters&) override; - bool queryIntersectsFeature( - const GeometryCoordinates&, - const GeometryTileFeature&, - const float, - const TransformState&, - const float, - const mat4&, - const FeatureState&) const override; + bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, const float, + const TransformState&, const float, const mat4&, const FeatureState&) const override; // Paint properties style::FillPaintProperties::Unevaluated unevaluated; diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index 777269f9db..797aedd297 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -219,14 +219,10 @@ void RenderHeatmapLayer::updateColorRamp() { } } -bool RenderHeatmapLayer::queryIntersectsFeature( - const GeometryCoordinates& queryGeometry, - const GeometryTileFeature& feature, - const float zoom, - const TransformState&, - const float pixelsToTileUnits, - const mat4&, - const FeatureState&) const { +bool RenderHeatmapLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, + const GeometryTileFeature& feature, const float zoom, + const TransformState&, const float pixelsToTileUnits, const mat4&, + const FeatureState&) const { (void) queryGeometry; (void) feature; (void) zoom; diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.hpp b/src/mbgl/renderer/layers/render_heatmap_layer.hpp index 1c1eb67ad5..1e9b1063ae 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.hpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.hpp @@ -22,14 +22,8 @@ private: void upload(gfx::UploadPass&) override; void render(PaintParameters&) override; - bool queryIntersectsFeature( - const GeometryCoordinates&, - const GeometryTileFeature&, - const float, - const TransformState&, - const float, - const mat4&, - const FeatureState&) const override; + bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, const float, + const TransformState&, const float, const mat4&, const FeatureState&) const override; // Paint properties style::HeatmapPaintProperties::Unevaluated unevaluated; diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index fe3ca00f06..36665c1db4 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -257,14 +257,10 @@ GeometryCollection offsetLine(const GeometryCollection& rings, double offset) { } // namespace -bool RenderLineLayer::queryIntersectsFeature( - const GeometryCoordinates& queryGeometry, - const GeometryTileFeature& feature, - const float zoom, - const TransformState& transformState, - const float pixelsToTileUnits, - const mat4&, - const FeatureState& featureState) const { +bool RenderLineLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, + const GeometryTileFeature& feature, const float zoom, + const TransformState& transformState, const float pixelsToTileUnits, + const mat4&, const FeatureState& featureState) const { const auto& evaluated = static_cast<const LineLayerProperties&>(*evaluatedProperties).evaluated; // Translate query geometry auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry( @@ -275,10 +271,11 @@ bool RenderLineLayer::queryIntersectsFeature( pixelsToTileUnits); // Evaluate function - auto offset = evaluated.get<style::LineOffset>() - .evaluate(feature, zoom, featureState, style::LineOffset::defaultValue()) * pixelsToTileUnits; + auto offset = + evaluated.get<style::LineOffset>().evaluate(feature, zoom, featureState, style::LineOffset::defaultValue()) * + pixelsToTileUnits; // Test intersection - const float halfWidth = getLineWidth(feature, zoom, featureState) / 2.0 * pixelsToTileUnits; + const auto halfWidth = static_cast<float>(getLineWidth(feature, zoom, featureState) / 2.0 * pixelsToTileUnits); // Apply offset to geometry if (offset != 0.0f && !feature.getGeometries().empty()) { @@ -315,12 +312,13 @@ void RenderLineLayer::updateColorRamp() { } } -float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature, const float zoom, const FeatureState& featureState) const { +float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature, const float zoom, + const FeatureState& featureState) const { const auto& evaluated = static_cast<const LineLayerProperties&>(*evaluatedProperties).evaluated; - float lineWidth = evaluated.get<style::LineWidth>() - .evaluate(feature, zoom, featureState, style::LineWidth::defaultValue()); - float gapWidth = evaluated.get<style::LineGapWidth>() - .evaluate(feature, zoom, featureState, style::LineGapWidth::defaultValue()); + float lineWidth = + evaluated.get<style::LineWidth>().evaluate(feature, zoom, featureState, style::LineWidth::defaultValue()); + float gapWidth = + evaluated.get<style::LineGapWidth>().evaluate(feature, zoom, featureState, style::LineGapWidth::defaultValue()); if (gapWidth) { return gapWidth + 2 * lineWidth; } else { diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp index d4d84eb34e..1914a82b77 100644 --- a/src/mbgl/renderer/layers/render_line_layer.hpp +++ b/src/mbgl/renderer/layers/render_line_layer.hpp @@ -24,14 +24,8 @@ private: void upload(gfx::UploadPass&) override; void render(PaintParameters&) override; - bool queryIntersectsFeature( - const GeometryCoordinates&, - const GeometryTileFeature&, - const float, - const TransformState&, - const float, - const mat4&, - const FeatureState&) const override; + bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, const float, + const TransformState&, const float, const mat4&, const FeatureState&) const override; // Paint properties style::LinePaintProperties::Unevaluated unevaluated; diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index fdfbc99642..1a36f8a2e5 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -105,15 +105,11 @@ public: virtual ~PaintPropertyBinder() = default; - virtual void populateVertexVector(const GeometryTileFeature& feature, - std::size_t length, std::size_t index, - const ImagePositions&, - const optional<PatternDependency>&, + virtual void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, std::size_t index, + const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value&) = 0; - virtual void updateVertexVectors(const FeatureStates&, - const GeometryTileLayer&, - const ImagePositions&) {} + virtual void updateVertexVectors(const FeatureStates&, const GeometryTileLayer&, const ImagePositions&) {} virtual void updateVertexVector(std::size_t, std::size_t, const GeometryTileFeature&, const FeatureState&) = 0; @@ -135,7 +131,8 @@ public: : constant(std::move(constant_)) { } - void populateVertexVector(const GeometryTileFeature&, std::size_t, std::size_t, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value&) override {} + void populateVertexVector(const GeometryTileFeature&, std::size_t, std::size_t, const ImagePositions&, + const optional<PatternDependency>&, const style::expression::Value&) override {} void updateVertexVector(std::size_t, std::size_t, const GeometryTileFeature&, const FeatureState&) override {} void upload(gfx::UploadPass&) override {} void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, const CrossfadeParameters&) override {}; @@ -163,7 +160,8 @@ public: : constant(std::move(constant_)), constantPatternPositions({}) { } - void populateVertexVector(const GeometryTileFeature&, std::size_t, std::size_t, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value&) override {} + void populateVertexVector(const GeometryTileFeature&, std::size_t, std::size_t, const ImagePositions&, + const optional<PatternDependency>&, const style::expression::Value&) override {} void updateVertexVector(std::size_t, std::size_t, const GeometryTileFeature&, const FeatureState&) override {} void upload(gfx::UploadPass&) override {} @@ -206,7 +204,9 @@ public: defaultValue(std::move(defaultValue_)) { } void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, const CrossfadeParameters&) override {}; - void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, std::size_t index, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value& formattedSection) override { + void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, std::size_t index, + const ImagePositions&, const optional<PatternDependency>&, + const style::expression::Value& formattedSection) override { using style::expression::EvaluationContext; auto evaluated = expression.evaluate(EvaluationContext(&feature).withFormattedSection(&formattedSection), defaultValue); this->statistics.add(evaluated); @@ -217,11 +217,12 @@ public: } optional<std::string> idStr = featureIDtoString(feature.getID()); if (idStr) { - featureMap[*idStr].emplace_back(FeatureVertexRange { index, elements, length }); + featureMap[*idStr].emplace_back(FeatureVertexRange{index, elements, length}); } } - void updateVertexVectors(const FeatureStates& states, const GeometryTileLayer& layer, const ImagePositions&) override { + void updateVertexVectors(const FeatureStates& states, const GeometryTileLayer& layer, + const ImagePositions&) override { for (const auto& it : states) { const auto positions = featureMap.find(it.first); if (positions == featureMap.end()) { @@ -237,14 +238,15 @@ public: } } - void updateVertexVector(std::size_t start, std::size_t end, const GeometryTileFeature& feature, const FeatureState& state) override { + void updateVertexVector(std::size_t start, std::size_t end, const GeometryTileFeature& feature, + const FeatureState& state) override { using style::expression::EvaluationContext; auto evaluated = expression.evaluate(EvaluationContext(&feature).withFeatureState(&state), defaultValue); this->statistics.add(evaluated); auto value = attributeValue(evaluated); for (std::size_t i = start; i < end; ++i) { - vertexVector.at(i) = BaseVertex { value }; + vertexVector.at(i) = BaseVertex{value}; } } @@ -297,7 +299,9 @@ public: zoomRange({zoom, zoom + 1}) { } void setPatternParameters(const optional<ImagePosition>&, const optional<ImagePosition>&, const CrossfadeParameters&) override {}; - void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, std::size_t index, const ImagePositions&, const optional<PatternDependency>&, const style::expression::Value& formattedSection) override { + void populateVertexVector(const GeometryTileFeature& feature, std::size_t length, std::size_t index, + const ImagePositions&, const optional<PatternDependency>&, + const style::expression::Value& formattedSection) override { using style::expression::EvaluationContext; Range<T> range = { expression.evaluate(EvaluationContext(zoomRange.min, &feature).withFormattedSection(&formattedSection), defaultValue), @@ -314,11 +318,12 @@ public: } optional<std::string> idStr = featureIDtoString(feature.getID()); if (idStr) { - featureMap[*idStr].emplace_back(FeatureVertexRange { index, elements, length }); + featureMap[*idStr].emplace_back(FeatureVertexRange{index, elements, length}); } } - void updateVertexVectors(const FeatureStates& states, const GeometryTileLayer& layer, const ImagePositions&) override { + void updateVertexVectors(const FeatureStates& states, const GeometryTileLayer& layer, + const ImagePositions&) override { for (const auto& it : states) { const auto positions = featureMap.find(it.first); if (positions == featureMap.end()) { @@ -334,20 +339,19 @@ public: } } - void updateVertexVector(std::size_t start, std::size_t end, const GeometryTileFeature& feature, const FeatureState& state) override { + void updateVertexVector(std::size_t start, std::size_t end, const GeometryTileFeature& feature, + const FeatureState& state) override { using style::expression::EvaluationContext; Range<T> range = { - expression.evaluate(EvaluationContext(zoomRange.min, &feature, &state), defaultValue), - expression.evaluate(EvaluationContext(zoomRange.max, &feature, &state), defaultValue), + expression.evaluate(EvaluationContext(zoomRange.min, &feature, &state), defaultValue), + expression.evaluate(EvaluationContext(zoomRange.max, &feature, &state), defaultValue), }; this->statistics.add(range.min); this->statistics.add(range.max); - AttributeValue value = zoomInterpolatedAttributeValue( - attributeValue(range.min), - attributeValue(range.max)); + AttributeValue value = zoomInterpolatedAttributeValue(attributeValue(range.min), attributeValue(range.max)); for (std::size_t i = start; i < end; ++i) { - vertexVector.at(i) = Vertex { value }; + vertexVector.at(i) = Vertex{value}; } } @@ -413,8 +417,10 @@ public: crossfade = crossfade_; }; - void populateVertexVector(const GeometryTileFeature&, std::size_t length, std::size_t /* index */, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies, const style::expression::Value&) override { - + void populateVertexVector(const GeometryTileFeature&, std::size_t length, std::size_t /* index */, + const ImagePositions& patternPositions, + const optional<PatternDependency>& patternDependencies, + const style::expression::Value&) override { if (!patternDependencies || patternDependencies->mid.empty()) { // Unlike other propperties with expressions that evaluate to null, the default value for `*-pattern` properties is an empty // string and will not have a valid entry in patternPositions. We still need to populate the attribute buffers to avoid crashes @@ -584,16 +590,18 @@ public: PaintPropertyBinders(PaintPropertyBinders&&) = default; PaintPropertyBinders(const PaintPropertyBinders&) = delete; - void populateVertexVectors(const GeometryTileFeature& feature, std::size_t length, std::size_t index, const ImagePositions& patternPositions, const optional<PatternDependency>& patternDependencies, const style::expression::Value& formattedSection = {}) { - util::ignore({ - (binders.template get<Ps>()->populateVertexVector(feature, length, index, patternPositions, patternDependencies, formattedSection), 0)... - }); + void populateVertexVectors(const GeometryTileFeature& feature, std::size_t length, std::size_t index, + const ImagePositions& patternPositions, + const optional<PatternDependency>& patternDependencies, + const style::expression::Value& formattedSection = {}) { + util::ignore({(binders.template get<Ps>()->populateVertexVector(feature, length, index, patternPositions, + patternDependencies, formattedSection), + 0)...}); } - void updateVertexVectors(const FeatureStates& states, const GeometryTileLayer& layer, const ImagePositions& imagePositions) { - util::ignore({ - (binders.template get<Ps>()->updateVertexVectors(states, layer, imagePositions), 0)... - }); + void updateVertexVectors(const FeatureStates& states, const GeometryTileLayer& layer, + const ImagePositions& imagePositions) { + util::ignore({(binders.template get<Ps>()->updateVertexVectors(states, layer, imagePositions), 0)...}); } void setPatternParameters(const optional<ImagePosition>& posA, const optional<ImagePosition>& posB, const CrossfadeParameters& crossfade) const { diff --git a/src/mbgl/renderer/possibly_evaluated_property_value.hpp b/src/mbgl/renderer/possibly_evaluated_property_value.hpp index 2e47e6c854..1198e43aae 100644 --- a/src/mbgl/renderer/possibly_evaluated_property_value.hpp +++ b/src/mbgl/renderer/possibly_evaluated_property_value.hpp @@ -52,12 +52,10 @@ public: template <class Feature> T evaluate(const Feature& feature, float zoom, const FeatureState& featureState, T defaultValue) const { - return this->match( - [&] (const T& constant_) { return constant_; }, - [&] (const style::PropertyExpression<T>& expression) { - return expression.evaluate(zoom, feature, featureState, defaultValue); - } - ); + return this->match([&](const T& constant_) { return constant_; }, + [&](const style::PropertyExpression<T>& expression) { + return expression.evaluate(zoom, feature, featureState, defaultValue); + }); } }; diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index 2b65d069ae..ba3c638f88 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -88,14 +88,10 @@ public: // Check wether the given geometry intersects // with the feature - virtual bool queryIntersectsFeature( - const GeometryCoordinates&, - const GeometryTileFeature&, - const float, - const TransformState&, - const float, - const mat4&, - const FeatureState&) const { return false; }; + virtual bool queryIntersectsFeature(const GeometryCoordinates&, const GeometryTileFeature&, const float, + const TransformState&, const float, const mat4&, const FeatureState&) const { + return false; + }; virtual void prepare(const LayerPrepareParameters&); diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index 6bccee7798..a1280331b1 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -562,17 +562,14 @@ FeatureExtensionValue RenderOrchestrator::queryFeatureExtensions(const std::stri return {}; } -void RenderOrchestrator::setFeatureState(const std::string& sourceID, - const optional<std::string>& sourceLayerID, - const std::string& featureID, - const FeatureState& state) { +void RenderOrchestrator::setFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID, + const std::string& featureID, const FeatureState& state) { if (RenderSource* renderSource = getRenderSource(sourceID)) { renderSource->setFeatureState(sourceLayerID, featureID, state); } } -void RenderOrchestrator::getFeatureState(FeatureState& state, - const std::string& sourceID, +void RenderOrchestrator::getFeatureState(FeatureState& state, const std::string& sourceID, const optional<std::string>& sourceLayerID, const std::string& featureID) const { if (RenderSource* renderSource = getRenderSource(sourceID)) { @@ -580,8 +577,7 @@ void RenderOrchestrator::getFeatureState(FeatureState& state, } } -void RenderOrchestrator::removeFeatureState(const std::string& sourceID, - const optional<std::string>& sourceLayerID, +void RenderOrchestrator::removeFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID, const optional<std::string>& featureID, const optional<std::string>& stateKey) { if (RenderSource* renderSource = getRenderSource(sourceID)) { diff --git a/src/mbgl/renderer/render_orchestrator.hpp b/src/mbgl/renderer/render_orchestrator.hpp index f42a40ec33..34b623348f 100644 --- a/src/mbgl/renderer/render_orchestrator.hpp +++ b/src/mbgl/renderer/render_orchestrator.hpp @@ -64,20 +64,14 @@ public: const std::string& extensionField, const optional<std::map<std::string, Value>>& args) const; - void setFeatureState(const std::string& sourceID, - const optional<std::string>& layerID, - const std::string& featureID, - const FeatureState& state); - - void getFeatureState(FeatureState& state, - const std::string& sourceID, - const optional<std::string>& layerID, + void setFeatureState(const std::string& sourceID, const optional<std::string>& layerID, + const std::string& featureID, const FeatureState& state); + + void getFeatureState(FeatureState& state, const std::string& sourceID, const optional<std::string>& layerID, const std::string& featureID) const; - void removeFeatureState(const std::string& sourceID, - const optional<std::string>& sourceLayerID, - const optional<std::string>& featureID, - const optional<std::string>& stateKey); + void removeFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID, + const optional<std::string>& featureID, const optional<std::string>& stateKey); void reduceMemoryUse(); void dumpDebugLogs(); diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp index 39ca97d563..ee90e1c4d0 100644 --- a/src/mbgl/renderer/render_source.hpp +++ b/src/mbgl/renderer/render_source.hpp @@ -93,16 +93,11 @@ public: return {}; } - virtual void setFeatureState(const optional<std::string>&, - const std::string&, - const FeatureState&) {} + virtual void setFeatureState(const optional<std::string>&, const std::string&, const FeatureState&) {} - virtual void getFeatureState(FeatureState&, - const optional<std::string>&, - const std::string&) const {} + virtual void getFeatureState(FeatureState&, const optional<std::string>&, const std::string&) const {} - virtual void removeFeatureState(const optional<std::string>&, - const optional<std::string>&, + virtual void removeFeatureState(const optional<std::string>&, const optional<std::string>&, const optional<std::string>&) {} virtual void reduceMemoryUse() = 0; diff --git a/src/mbgl/renderer/renderer.cpp b/src/mbgl/renderer/renderer.cpp index a91a0098ca..cf4072036c 100644 --- a/src/mbgl/renderer/renderer.cpp +++ b/src/mbgl/renderer/renderer.cpp @@ -109,24 +109,18 @@ FeatureExtensionValue Renderer::queryFeatureExtensions(const std::string& source return impl->orchestrator.queryFeatureExtensions(sourceID, feature, extension, extensionField, args); } -void Renderer::setFeatureState(const std::string& sourceID, - const optional<std::string>& sourceLayerID, - const std::string& featureID, - const FeatureState& state) { +void Renderer::setFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID, + const std::string& featureID, const FeatureState& state) { impl->orchestrator.setFeatureState(sourceID, sourceLayerID, featureID, state); } -void Renderer::getFeatureState(FeatureState& state, - const std::string& sourceID, - const optional<std::string>& sourceLayerID, - const std::string& featureID) const { +void Renderer::getFeatureState(FeatureState& state, const std::string& sourceID, + const optional<std::string>& sourceLayerID, const std::string& featureID) const { impl->orchestrator.getFeatureState(state, sourceID, sourceLayerID, featureID); } -void Renderer::removeFeatureState(const std::string& sourceID, - const optional<std::string>& sourceLayerID, - const optional<std::string>& featureID, - const optional<std::string>& stateKey) { +void Renderer::removeFeatureState(const std::string& sourceID, const optional<std::string>& sourceLayerID, + const optional<std::string>& featureID, const optional<std::string>& stateKey) { impl->orchestrator.removeFeatureState(sourceID, sourceLayerID, featureID, stateKey); } diff --git a/src/mbgl/renderer/source_state.cpp b/src/mbgl/renderer/source_state.cpp index c1b95aca68..d057c211b5 100644 --- a/src/mbgl/renderer/source_state.cpp +++ b/src/mbgl/renderer/source_state.cpp @@ -1,11 +1,12 @@ +#include <mbgl/renderer/render_tile.hpp> #include <mbgl/renderer/source_state.hpp> #include <mbgl/style/conversion_impl.hpp> -#include <mbgl/renderer/render_tile.hpp> #include <mbgl/util/logging.hpp> namespace mbgl { -void SourceFeatureState::updateState(const optional<std::string>& sourceLayerID, const std::string& featureID, const FeatureState& newState) { +void SourceFeatureState::updateState(const optional<std::string>& sourceLayerID, const std::string& featureID, + const FeatureState& newState) { std::string sourceLayer = sourceLayerID.value_or(std::string()); for (const auto& state : newState) { auto& layerStates = stateChanges[sourceLayer]; @@ -14,9 +15,11 @@ void SourceFeatureState::updateState(const optional<std::string>& sourceLayerID, } } -void SourceFeatureState::getState(FeatureState& result, const optional<std::string>& sourceLayerID, const std::string& featureID) const { +void SourceFeatureState::getState(FeatureState& result, const optional<std::string>& sourceLayerID, + const std::string& featureID) const { std::string sourceLayer = sourceLayerID.value_or(std::string()); - FeatureState current, changes; + FeatureState current; + FeatureState changes; auto layerStates = currentStates.find(sourceLayer); if (layerStates != currentStates.end()) { const auto currentStateEntry = layerStates->second.find(featureID); @@ -61,7 +64,7 @@ void SourceFeatureState::coalesceChanges(std::vector<RenderTile>& tiles) { for (const auto& layerStatesEntry : deletedStates) { const auto& sourceLayer = layerStatesEntry.first; - FeatureStates layerStates = { {}, {} }; + FeatureStates layerStates = {{}, {}}; if (deletedStates[sourceLayer].empty()) { for (const auto& featureStatesEntry : currentStates[sourceLayer]) { @@ -89,25 +92,31 @@ void SourceFeatureState::coalesceChanges(std::vector<RenderTile>& tiles) { stateChanges.clear(); deletedStates.clear(); - if (changes.empty()) return; + if (changes.empty()) { + return; + } for (auto& tile : tiles) { tile.setFeatureState(changes); } } -void SourceFeatureState::removeState(const optional<std::string>& sourceLayerID, const optional<std::string>& featureID, const optional<std::string>& stateKey) { +void SourceFeatureState::removeState(const optional<std::string>& sourceLayerID, const optional<std::string>& featureID, + const optional<std::string>& stateKey) { std::string sourceLayer = sourceLayerID.value_or(std::string()); bool sourceLayerDeleted = (deletedStates.count(sourceLayer) > 0) && deletedStates[sourceLayer].empty(); - if (sourceLayerDeleted) return; + if (sourceLayerDeleted) { + return; + } if (stateKey && featureID) { if ((deletedStates.count(sourceLayer) == 0) && (deletedStates[sourceLayer].count(*featureID)) == 0) { deletedStates[sourceLayer][*featureID][*stateKey] = {}; } } else if (featureID) { - bool updateInQueue = stateChanges.count(sourceLayer) && stateChanges[sourceLayer].count(*featureID); + bool updateInQueue = + (stateChanges.count(sourceLayer) != 0U) && (stateChanges[sourceLayer].count(*featureID) != 0U); if (updateInQueue) { for (const auto& changeEntry : stateChanges[sourceLayer][*featureID]) { deletedStates[sourceLayer][*featureID][changeEntry.first] = {}; diff --git a/src/mbgl/renderer/source_state.hpp b/src/mbgl/renderer/source_state.hpp index 61546aff62..7217302630 100644 --- a/src/mbgl/renderer/source_state.hpp +++ b/src/mbgl/renderer/source_state.hpp @@ -6,16 +6,17 @@ namespace mbgl { class RenderTile; -using namespace style::conversion; class SourceFeatureState { public: SourceFeatureState() = default; ~SourceFeatureState() = default; - void updateState(const optional<std::string>& sourceLayerID, const std::string& featureID, const FeatureState& newState); + void updateState(const optional<std::string>& sourceLayerID, const std::string& featureID, + const FeatureState& newState); void getState(FeatureState& result, const optional<std::string>& sourceLayerID, const std::string& featureID) const; - void removeState(const optional<std::string>& sourceLayerID, const optional<std::string>& featureID, const optional<std::string>& stateKey); + void removeState(const optional<std::string>& sourceLayerID, const optional<std::string>& featureID, + const optional<std::string>& stateKey); void coalesceChanges(std::vector<RenderTile>& tiles); diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp index 3c6eff0855..221f976c50 100644 --- a/src/mbgl/renderer/sources/render_tile_source.cpp +++ b/src/mbgl/renderer/sources/render_tile_source.cpp @@ -134,14 +134,12 @@ std::vector<Feature> RenderTileSource::querySourceFeatures(const SourceQueryOpti return tilePyramid.querySourceFeatures(options); } -void RenderTileSource::setFeatureState(const optional<std::string>& sourceLayerID, - const std::string& featureID, +void RenderTileSource::setFeatureState(const optional<std::string>& sourceLayerID, const std::string& featureID, const FeatureState& state) { featureState.updateState(sourceLayerID, featureID, state); } -void RenderTileSource::getFeatureState(FeatureState& state, - const optional<std::string>& sourceLayerID, +void RenderTileSource::getFeatureState(FeatureState& state, const optional<std::string>& sourceLayerID, const std::string& featureID) const { featureState.getState(state, sourceLayerID, featureID); } diff --git a/src/mbgl/renderer/sources/render_tile_source.hpp b/src/mbgl/renderer/sources/render_tile_source.hpp index 48eea8558c..7756bd8ed0 100644 --- a/src/mbgl/renderer/sources/render_tile_source.hpp +++ b/src/mbgl/renderer/sources/render_tile_source.hpp @@ -1,9 +1,9 @@ #pragma once #include <mbgl/renderer/render_source.hpp> +#include <mbgl/renderer/source_state.hpp> #include <mbgl/renderer/tile_pyramid.hpp> #include <mbgl/style/sources/vector_source_impl.hpp> -#include <mbgl/renderer/source_state.hpp> namespace mbgl { @@ -35,17 +35,12 @@ public: std::vector<Feature> querySourceFeatures(const SourceQueryOptions&) const override; - virtual void setFeatureState(const optional<std::string>&, - const std::string&, - const FeatureState&) override; + void setFeatureState(const optional<std::string>&, const std::string&, const FeatureState&) override; - virtual void getFeatureState(FeatureState& state, - const optional<std::string>&, - const std::string&) const override; + void getFeatureState(FeatureState& state, const optional<std::string>&, const std::string&) const override; - virtual void removeFeatureState(const optional<std::string>&, - const optional<std::string>&, - const optional<std::string>&) override; + void removeFeatureState(const optional<std::string>&, const optional<std::string>&, + const optional<std::string>&) override; void reduceMemoryUse() override; void dumpDebugLogs() const override; @@ -56,7 +51,9 @@ protected: Immutable<std::vector<RenderTile>> renderTiles; mutable RenderTiles filteredRenderTiles; mutable RenderTiles renderTilesSortedByY; - float bearing = 0.0f; + +private: + float bearing = 0.0F; SourceFeatureState featureState; }; diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp index db3e731605..2bf6e2e1a9 100644 --- a/src/mbgl/renderer/tile_pyramid.cpp +++ b/src/mbgl/renderer/tile_pyramid.cpp @@ -278,13 +278,10 @@ void TilePyramid::handleWrapJump(float lng) { } } - -std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRenderedFeatures(const ScreenLineString& geometry, - const TransformState& transformState, - const std::unordered_map<std::string, const RenderLayer*>& layers, - const RenderedQueryOptions& options, - const mat4& projMatrix, - const SourceFeatureState& featureState) const { +std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRenderedFeatures( + const ScreenLineString& geometry, const TransformState& transformState, + const std::unordered_map<std::string, const RenderLayer*>& layers, const RenderedQueryOptions& options, + const mat4& projMatrix, const SourceFeatureState& featureState) const { std::unordered_map<std::string, std::vector<Feature>> result; if (renderedTiles.empty() || geometry.empty()) { return result; @@ -332,12 +329,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered tileSpaceQueryGeometry.push_back(TileCoordinate::toGeometryCoordinate(id, c)); } - tile.queryRenderedFeatures(result, - tileSpaceQueryGeometry, - transformState, - layers, - options, - projMatrix, + tile.queryRenderedFeatures(result, tileSpaceQueryGeometry, transformState, layers, options, projMatrix, featureState); } diff --git a/src/mbgl/renderer/tile_pyramid.hpp b/src/mbgl/renderer/tile_pyramid.hpp index bb0b7e9f67..3b5cab5d6c 100644 --- a/src/mbgl/renderer/tile_pyramid.hpp +++ b/src/mbgl/renderer/tile_pyramid.hpp @@ -49,13 +49,10 @@ public: void handleWrapJump(float lng); - std::unordered_map<std::string, std::vector<Feature>> - queryRenderedFeatures(const ScreenLineString& geometry, - const TransformState& transformState, - const std::unordered_map<std::string, const RenderLayer*>&, - const RenderedQueryOptions& options, - const mat4& projMatrix, - const mbgl::SourceFeatureState& featureState) const; + std::unordered_map<std::string, std::vector<Feature>> queryRenderedFeatures( + const ScreenLineString& geometry, const TransformState& transformState, + const std::unordered_map<std::string, const RenderLayer*>&, const RenderedQueryOptions& options, + const mat4& projMatrix, const mbgl::SourceFeatureState& featureState) const; std::vector<Feature> querySourceFeatures(const SourceQueryOptions&) const; diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 8bd21bdad7..c2bc511e41 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -676,16 +676,17 @@ const auto& errorCompoundExpression() { } const auto& featureStateCompoundExpression() { - static auto signature = detail::makeSignature("feature-state", [](const EvaluationContext& params, const std::string& key) -> Result<Value> { - mbgl::Value state; - if (params.featureState) { - auto it = params.featureState->find(key); - if (it != params.featureState->end()) { - state = mbgl::Value(it->second); + static auto signature = detail::makeSignature( + "feature-state", [](const EvaluationContext& params, const std::string& key) -> Result<Value> { + mbgl::Value state; + if (params.featureState != nullptr) { + auto it = params.featureState->find(key); + if (it != params.featureState->end()) { + state = mbgl::Value(it->second); + } } - } - return toExpressionValue(state); - }); + return toExpressionValue(state); + }); return signature; } @@ -886,82 +887,83 @@ const auto& filterInCompoundExpression() { } using ParseCompoundFunction = const std::unique_ptr<detail::SignatureBase>& (*)(); -MAPBOX_ETERNAL_CONSTEXPR const auto compoundExpressionRegistry = mapbox::eternal::hash_map<mapbox::eternal::string, ParseCompoundFunction>({ - { "e", eCompoundExpression }, - { "pi", piCompoundExpression }, - { "ln2", ln2CompoundExpression }, - { "typeof", typeofCompoundExpression }, - { "to-rgba", toRgbaCompoundExpression }, - { "rgba", rgbaCompoundExpression }, - { "rgb", rgbCompoundExpression }, - { "zoom", zoomCompoundExpression }, - { "heatmap-density", heatmapDensityCompoundExpression }, - { "line-progress", lineProgressCompoundExpression }, - { "accumulated", accumulatedCompoundExpression }, - { "has", hasContextCompoundExpression }, - { "has", hasObjectCompoundExpression }, - { "get", getContextCompoundExpression }, - { "get", getObjectCompoundExpression }, - { "properties", propertiesCompoundExpression }, - { "geometry-type", geometryTypeCompoundExpression }, - { "id", idCompoundExpression }, - { "+", plusCompoundExpression }, - { "-", minusCompoundExpression }, - { "-", negateCompoundExpression }, - { "*", multiplyCompoundExpression }, - { "/", divideCompoundExpression }, - { "%", modCompoundExpression }, - { "^", powCompoundExpression }, - { "sqrt", sqrtCompoundExpression }, - { "log10", log10CompoundExpression }, - { "ln", lnCompoundExpression }, - { "log2", log2CompoundExpression }, - { "sin", sinCompoundExpression }, - { "cos", cosCompoundExpression }, - { "tan", tanCompoundExpression }, - { "asin", asinCompoundExpression }, - { "acos", acosCompoundExpression }, - { "atan", atanCompoundExpression }, - { "min", minCompoundExpression }, - { "max", maxCompoundExpression }, - { "round", roundCompoundExpression }, - { "floor", floorCompoundExpression }, - { "ceil", ceilCompoundExpression }, - { "abs", absCompoundExpression }, - { "!", notCompoundExpression }, - { "is-supported-script", isSupportedScriptCompoundExpression }, - { "upcase", upcaseCompoundExpression }, - { "downcase", downcaseCompoundExpression }, - { "concat", concatCompoundExpression }, - { "resolved-locale", resolvedLocaleCompoundExpression }, - { "error", errorCompoundExpression }, - { "feature-state", featureStateCompoundExpression }, - // Legacy Filters - { "filter-==", filterEqualsCompoundExpression }, - { "filter-id-==", filterIdEqualsCompoundExpression }, - { "filter-type-==", filterTypeEqualsCompoundExpression }, - { "filter-<", filterLessThanNumberCompoundExpression }, - { "filter-<", filterLessThanStringCompoundExpression }, - { "filter-id-<", filterIdLessThanNumberCompoundExpression }, - { "filter-id-<", filterIdLessThanStringCompoundExpression }, - { "filter->", filterMoreThanNumberCompoundExpression }, - { "filter->", filterMoreThanStringCompoundExpression }, - { "filter-id->", filterIdMoreThanNumberCompoundExpression }, - { "filter-id->", filterIdMoreThanStringCompoundExpression }, - { "filter-<=", filterLessOrEqualThanNumberCompoundExpression }, - { "filter-<=", filterLessOrEqualThanStringCompoundExpression }, - { "filter-id-<=", filterIdLessOrEqualThanNumberCompoundExpression }, - { "filter-id-<=", filterIdLessOrEqualThanStringCompoundExpression }, - { "filter->=", filterGreaterOrEqualThanNumberCompoundExpression }, - { "filter->=", filterGreaterOrEqualThanStringCompoundExpression }, - { "filter-id->=", filterIdGreaterOrEqualThanNumberCompoundExpression }, - { "filter-id->=", filterIdGreaterOrEqualThanStringCompoundExpression }, - { "filter-has", filterHasCompoundExpression }, - { "filter-has-id", filterHasIdCompoundExpression }, - { "filter-type-in", filterTypeInCompoundExpression }, - { "filter-id-in", filterIdInCompoundExpression }, - { "filter-in", filterInCompoundExpression }, -}); +MAPBOX_ETERNAL_CONSTEXPR const auto compoundExpressionRegistry = + mapbox::eternal::hash_map<mapbox::eternal::string, ParseCompoundFunction>({ + {"e", eCompoundExpression}, + {"pi", piCompoundExpression}, + {"ln2", ln2CompoundExpression}, + {"typeof", typeofCompoundExpression}, + {"to-rgba", toRgbaCompoundExpression}, + {"rgba", rgbaCompoundExpression}, + {"rgb", rgbCompoundExpression}, + {"zoom", zoomCompoundExpression}, + {"heatmap-density", heatmapDensityCompoundExpression}, + {"line-progress", lineProgressCompoundExpression}, + {"accumulated", accumulatedCompoundExpression}, + {"has", hasContextCompoundExpression}, + {"has", hasObjectCompoundExpression}, + {"get", getContextCompoundExpression}, + {"get", getObjectCompoundExpression}, + {"properties", propertiesCompoundExpression}, + {"geometry-type", geometryTypeCompoundExpression}, + {"id", idCompoundExpression}, + {"+", plusCompoundExpression}, + {"-", minusCompoundExpression}, + {"-", negateCompoundExpression}, + {"*", multiplyCompoundExpression}, + {"/", divideCompoundExpression}, + {"%", modCompoundExpression}, + {"^", powCompoundExpression}, + {"sqrt", sqrtCompoundExpression}, + {"log10", log10CompoundExpression}, + {"ln", lnCompoundExpression}, + {"log2", log2CompoundExpression}, + {"sin", sinCompoundExpression}, + {"cos", cosCompoundExpression}, + {"tan", tanCompoundExpression}, + {"asin", asinCompoundExpression}, + {"acos", acosCompoundExpression}, + {"atan", atanCompoundExpression}, + {"min", minCompoundExpression}, + {"max", maxCompoundExpression}, + {"round", roundCompoundExpression}, + {"floor", floorCompoundExpression}, + {"ceil", ceilCompoundExpression}, + {"abs", absCompoundExpression}, + {"!", notCompoundExpression}, + {"is-supported-script", isSupportedScriptCompoundExpression}, + {"upcase", upcaseCompoundExpression}, + {"downcase", downcaseCompoundExpression}, + {"concat", concatCompoundExpression}, + {"resolved-locale", resolvedLocaleCompoundExpression}, + {"error", errorCompoundExpression}, + {"feature-state", featureStateCompoundExpression}, + // Legacy Filters + {"filter-==", filterEqualsCompoundExpression}, + {"filter-id-==", filterIdEqualsCompoundExpression}, + {"filter-type-==", filterTypeEqualsCompoundExpression}, + {"filter-<", filterLessThanNumberCompoundExpression}, + {"filter-<", filterLessThanStringCompoundExpression}, + {"filter-id-<", filterIdLessThanNumberCompoundExpression}, + {"filter-id-<", filterIdLessThanStringCompoundExpression}, + {"filter->", filterMoreThanNumberCompoundExpression}, + {"filter->", filterMoreThanStringCompoundExpression}, + {"filter-id->", filterIdMoreThanNumberCompoundExpression}, + {"filter-id->", filterIdMoreThanStringCompoundExpression}, + {"filter-<=", filterLessOrEqualThanNumberCompoundExpression}, + {"filter-<=", filterLessOrEqualThanStringCompoundExpression}, + {"filter-id-<=", filterIdLessOrEqualThanNumberCompoundExpression}, + {"filter-id-<=", filterIdLessOrEqualThanStringCompoundExpression}, + {"filter->=", filterGreaterOrEqualThanNumberCompoundExpression}, + {"filter->=", filterGreaterOrEqualThanStringCompoundExpression}, + {"filter-id->=", filterIdGreaterOrEqualThanNumberCompoundExpression}, + {"filter-id->=", filterIdGreaterOrEqualThanStringCompoundExpression}, + {"filter-has", filterHasCompoundExpression}, + {"filter-has-id", filterHasIdCompoundExpression}, + {"filter-type-in", filterTypeInCompoundExpression}, + {"filter-id-in", filterIdInCompoundExpression}, + {"filter-in", filterInCompoundExpression}, + }); using namespace mbgl::style::conversion; diff --git a/src/mbgl/style/expression/is_constant.cpp b/src/mbgl/style/expression/is_constant.cpp index 5f8215c55f..4c4684c86a 100644 --- a/src/mbgl/style/expression/is_constant.cpp +++ b/src/mbgl/style/expression/is_constant.cpp @@ -17,12 +17,7 @@ bool isFeatureConstant(const Expression& expression) { return false; } else if (name == "has" && parameterCount && *parameterCount == 1) { return false; - } else if ( - name == "properties" || - name == "geometry-type" || - name == "id" || - name == "feature-state" - ) { + } else if (name == "properties" || name == "geometry-type" || name == "id" || name == "feature-state") { return false; } else if (0u == name.rfind(filter, 0u)) { // Legacy filters begin with "filter-" and are never constant. diff --git a/src/mbgl/style/properties.hpp b/src/mbgl/style/properties.hpp index b07456a96d..db0e54330c 100644 --- a/src/mbgl/style/properties.hpp +++ b/src/mbgl/style/properties.hpp @@ -183,13 +183,8 @@ public: template <class T> static T evaluate(float z, const GeometryTileFeature& feature, const FeatureState& state, const PossiblyEvaluatedPropertyValue<T>& v, const T& defaultValue) { - return v.match( - [&] (const T& t) { - return t; - }, - [&] (const PropertyExpression<T>& t) { - return t.evaluate(z, feature, state, defaultValue); - }); + return v.match([&](const T& t) { return t; }, + [&](const PropertyExpression<T>& t) { return t.evaluate(z, feature, state, defaultValue); }); } template <class P> diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 2076c73337..9f9c41d229 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -302,15 +302,11 @@ float GeometryTile::getQueryPadding(const std::unordered_map<std::string, const return queryPadding; } -void GeometryTile::queryRenderedFeatures( - std::unordered_map<std::string, std::vector<Feature>>& result, - const GeometryCoordinates& queryGeometry, - const TransformState& transformState, - const std::unordered_map<std::string, const RenderLayer*>& layers, - const RenderedQueryOptions& options, - const mat4& projMatrix, - const SourceFeatureState& featureState) { - +void GeometryTile::queryRenderedFeatures(std::unordered_map<std::string, std::vector<Feature>>& result, + const GeometryCoordinates& queryGeometry, const TransformState& transformState, + const std::unordered_map<std::string, const RenderLayer*>& layers, + const RenderedQueryOptions& options, const mat4& projMatrix, + const SourceFeatureState& featureState) { if (!getData()) return; const float queryPadding = getQueryPadding(layers); @@ -319,17 +315,10 @@ void GeometryTile::queryRenderedFeatures( transformState.matrixFor(posMatrix, id.toUnwrapped()); matrix::multiply(posMatrix, projMatrix, posMatrix); - layoutResult->featureIndex->query(result, - queryGeometry, - transformState, - posMatrix, - util::tileSize * id.overscaleFactor(), - std::pow(2, transformState.getZoom() - id.overscaledZ), - options, - id.toUnwrapped(), - layers, - queryPadding * transformState.maxPitchScaleFactor(), - featureState); + layoutResult->featureIndex->query(result, queryGeometry, transformState, posMatrix, + util::tileSize * id.overscaleFactor(), + std::pow(2, transformState.getZoom() - id.overscaledZ), options, id.toUnwrapped(), + layers, queryPadding * transformState.maxPitchScaleFactor(), featureState); } void GeometryTile::querySourceFeatures( @@ -391,7 +380,9 @@ void GeometryTile::performedFadePlacement() { void GeometryTile::setFeatureState(const LayerFeatureStates& states) { auto layers = getData(); - if (!layers || states.empty() || !layoutResult) return; + if ((layers == nullptr) || states.empty() || !layoutResult) { + return; + } auto& layerIdToLayerRenderData = layoutResult->layerRenderData; for (auto& layer : layerIdToLayerRenderData) { @@ -400,9 +391,13 @@ void GeometryTile::setFeatureState(const LayerFeatureStates& states) { if (sourceLayer) { const auto& sourceLayerID = sourceLayer->getName(); auto entry = states.find(sourceLayerID); - if (entry == states.end()) continue; + if (entry == states.end()) { + continue; + } const auto& featureStates = entry->second; - if (featureStates.empty()) continue; + if (featureStates.empty()) { + continue; + } auto bucket = layer.second.bucket; if (bucket && bucket->hasData()) { diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index 4415e0a1fa..566b359547 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -48,14 +48,11 @@ public: bool layerPropertiesUpdated(const Immutable<style::LayerProperties>&) override; - void queryRenderedFeatures( - std::unordered_map<std::string, std::vector<Feature>>& result, - const GeometryCoordinates& queryGeometry, - const TransformState&, - const std::unordered_map<std::string, const RenderLayer*>& layers, - const RenderedQueryOptions& options, - const mat4& projMatrix, - const SourceFeatureState& featureState) override; + void queryRenderedFeatures(std::unordered_map<std::string, std::vector<Feature>>& result, + const GeometryCoordinates& queryGeometry, const TransformState&, + const std::unordered_map<std::string, const RenderLayer*>& layers, + const RenderedQueryOptions& options, const mat4& projMatrix, + const SourceFeatureState& featureState) override; void querySourceFeatures( std::vector<Feature>& result, @@ -94,7 +91,7 @@ public: const std::shared_ptr<FeatureIndex> getFeatureIndex() const; const std::string sourceID; - + void setFeatureState(const LayerFeatureStates&) override; protected: diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index ce883ad93f..f6af61eb3c 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -384,7 +384,7 @@ void GeometryTileWorker::parse() { continue; const GeometryCollection& geometries = feature->getGeometries(); - bucket->addFeature(*feature, geometries, {}, PatternLayerMap (), i); + bucket->addFeature(*feature, geometries, {}, PatternLayerMap(), i); featureIndex->insert(geometries, i, sourceLayerID, leaderImpl.id); } diff --git a/src/mbgl/tile/tile.cpp b/src/mbgl/tile/tile.cpp index 87223c7933..2ebbf76c2a 100644 --- a/src/mbgl/tile/tile.cpp +++ b/src/mbgl/tile/tile.cpp @@ -39,14 +39,9 @@ void Tile::dumpDebugLogs() const { Log::Info(Event::General, "Tile::complete: %s", isComplete() ? "yes" : "no"); } -void Tile::queryRenderedFeatures( - std::unordered_map<std::string, std::vector<Feature>>&, - const GeometryCoordinates&, - const TransformState&, - const std::unordered_map<std::string, const RenderLayer*>&, - const RenderedQueryOptions&, - const mat4&, - const SourceFeatureState&) {} +void Tile::queryRenderedFeatures(std::unordered_map<std::string, std::vector<Feature>>&, const GeometryCoordinates&, + const TransformState&, const std::unordered_map<std::string, const RenderLayer*>&, + const RenderedQueryOptions&, const mat4&, const SourceFeatureState&) {} float Tile::getQueryPadding(const std::unordered_map<std::string, const RenderLayer*>&) { return 0; diff --git a/src/mbgl/tile/tile.hpp b/src/mbgl/tile/tile.hpp index eda4667027..b73383f989 100644 --- a/src/mbgl/tile/tile.hpp +++ b/src/mbgl/tile/tile.hpp @@ -68,14 +68,11 @@ public: virtual void setLayers(const std::vector<Immutable<style::LayerProperties>>&) {} virtual void setMask(TileMask&&) {} - virtual void queryRenderedFeatures( - std::unordered_map<std::string, std::vector<Feature>>& result, - const GeometryCoordinates& queryGeometry, - const TransformState&, - const std::unordered_map<std::string, const RenderLayer*>&, - const RenderedQueryOptions& options, - const mat4& projMatrix, - const SourceFeatureState& featureState); + virtual void queryRenderedFeatures(std::unordered_map<std::string, std::vector<Feature>>& result, + const GeometryCoordinates& queryGeometry, const TransformState&, + const std::unordered_map<std::string, const RenderLayer*>&, + const RenderedQueryOptions& options, const mat4& projMatrix, + const SourceFeatureState& featureState); virtual void querySourceFeatures( std::vector<Feature>& result, |