diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-06-27 17:06:49 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-07-02 16:05:09 +0300 |
commit | c1445913220023fdaf8ec5960eb6cba27c348864 (patch) | |
tree | 4958d023e640e630525760d80431606794c10f78 /src | |
parent | 21f75229675a07093689d542f116066c7af59ce4 (diff) | |
download | qtlocation-mapboxgl-c1445913220023fdaf8ec5960eb6cba27c348864.tar.gz |
[core] Introduce LayerProperties::constantsMask()
Constants mask for data-driven paint properties is a reliable
criteria of whether the given updated properties can still be used
with the existing bucket (and the gl program instance).
Diffstat (limited to 'src')
21 files changed, 82 insertions, 0 deletions
diff --git a/src/mbgl/style/layers/background_layer_properties.cpp b/src/mbgl/style/layers/background_layer_properties.cpp index f0da811379..63f6a7be68 100644 --- a/src/mbgl/style/layers/background_layer_properties.cpp +++ b/src/mbgl/style/layers/background_layer_properties.cpp @@ -21,6 +21,10 @@ BackgroundLayerProperties::BackgroundLayerProperties( BackgroundLayerProperties::~BackgroundLayerProperties() = default; +unsigned long BackgroundLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const BackgroundLayer::Impl& BackgroundLayerProperties::layerImpl() const { return static_cast<const BackgroundLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/background_layer_properties.hpp b/src/mbgl/style/layers/background_layer_properties.hpp index 371e8639f1..56db696533 100644 --- a/src/mbgl/style/layers/background_layer_properties.hpp +++ b/src/mbgl/style/layers/background_layer_properties.hpp @@ -41,6 +41,8 @@ public: BackgroundPaintProperties::PossiblyEvaluated); ~BackgroundLayerProperties() override; + unsigned long constantsMask() const override; + const BackgroundLayer::Impl& layerImpl() const; // Data members. CrossfadeParameters crossfade; diff --git a/src/mbgl/style/layers/circle_layer_properties.cpp b/src/mbgl/style/layers/circle_layer_properties.cpp index fbb4aeabd4..03a4a8f56e 100644 --- a/src/mbgl/style/layers/circle_layer_properties.cpp +++ b/src/mbgl/style/layers/circle_layer_properties.cpp @@ -19,6 +19,10 @@ CircleLayerProperties::CircleLayerProperties( CircleLayerProperties::~CircleLayerProperties() = default; +unsigned long CircleLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const CircleLayer::Impl& CircleLayerProperties::layerImpl() const { return static_cast<const CircleLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp index 17727c79eb..1aaa3bb3e3 100644 --- a/src/mbgl/style/layers/circle_layer_properties.hpp +++ b/src/mbgl/style/layers/circle_layer_properties.hpp @@ -80,6 +80,8 @@ public: CirclePaintProperties::PossiblyEvaluated); ~CircleLayerProperties() override; + unsigned long constantsMask() const override; + const CircleLayer::Impl& layerImpl() const; // Data members. CirclePaintProperties::PossiblyEvaluated evaluated; diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp index 7986c40923..ddfe9c8468 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp @@ -21,6 +21,10 @@ FillExtrusionLayerProperties::FillExtrusionLayerProperties( FillExtrusionLayerProperties::~FillExtrusionLayerProperties() = default; +unsigned long FillExtrusionLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const FillExtrusionLayer::Impl& FillExtrusionLayerProperties::layerImpl() const { return static_cast<const FillExtrusionLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp index f5aeaf5c73..69b8a0bcb8 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp @@ -66,6 +66,8 @@ public: FillExtrusionPaintProperties::PossiblyEvaluated); ~FillExtrusionLayerProperties() override; + unsigned long constantsMask() const override; + const FillExtrusionLayer::Impl& layerImpl() const; // Data members. CrossfadeParameters crossfade; diff --git a/src/mbgl/style/layers/fill_layer_properties.cpp b/src/mbgl/style/layers/fill_layer_properties.cpp index 55e5a58cce..de917177f6 100644 --- a/src/mbgl/style/layers/fill_layer_properties.cpp +++ b/src/mbgl/style/layers/fill_layer_properties.cpp @@ -21,6 +21,10 @@ FillLayerProperties::FillLayerProperties( FillLayerProperties::~FillLayerProperties() = default; +unsigned long FillLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const FillLayer::Impl& FillLayerProperties::layerImpl() const { return static_cast<const FillLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp index 376852d254..4e1b6970fe 100644 --- a/src/mbgl/style/layers/fill_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_layer_properties.hpp @@ -61,6 +61,8 @@ public: FillPaintProperties::PossiblyEvaluated); ~FillLayerProperties() override; + unsigned long constantsMask() const override; + const FillLayer::Impl& layerImpl() const; // Data members. CrossfadeParameters crossfade; diff --git a/src/mbgl/style/layers/heatmap_layer_properties.cpp b/src/mbgl/style/layers/heatmap_layer_properties.cpp index 03a73be103..cc50073651 100644 --- a/src/mbgl/style/layers/heatmap_layer_properties.cpp +++ b/src/mbgl/style/layers/heatmap_layer_properties.cpp @@ -19,6 +19,10 @@ HeatmapLayerProperties::HeatmapLayerProperties( HeatmapLayerProperties::~HeatmapLayerProperties() = default; +unsigned long HeatmapLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const HeatmapLayer::Impl& HeatmapLayerProperties::layerImpl() const { return static_cast<const HeatmapLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/heatmap_layer_properties.hpp b/src/mbgl/style/layers/heatmap_layer_properties.hpp index dda9808e77..634cbef1ed 100644 --- a/src/mbgl/style/layers/heatmap_layer_properties.hpp +++ b/src/mbgl/style/layers/heatmap_layer_properties.hpp @@ -49,6 +49,8 @@ public: HeatmapPaintProperties::PossiblyEvaluated); ~HeatmapLayerProperties() override; + unsigned long constantsMask() const override; + const HeatmapLayer::Impl& layerImpl() const; // Data members. HeatmapPaintProperties::PossiblyEvaluated evaluated; diff --git a/src/mbgl/style/layers/hillshade_layer_properties.cpp b/src/mbgl/style/layers/hillshade_layer_properties.cpp index 407acb6fc0..72acc235e2 100644 --- a/src/mbgl/style/layers/hillshade_layer_properties.cpp +++ b/src/mbgl/style/layers/hillshade_layer_properties.cpp @@ -19,6 +19,10 @@ HillshadeLayerProperties::HillshadeLayerProperties( HillshadeLayerProperties::~HillshadeLayerProperties() = default; +unsigned long HillshadeLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const HillshadeLayer::Impl& HillshadeLayerProperties::layerImpl() const { return static_cast<const HillshadeLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/hillshade_layer_properties.hpp b/src/mbgl/style/layers/hillshade_layer_properties.hpp index 85ef8b967c..e38e5bb5b3 100644 --- a/src/mbgl/style/layers/hillshade_layer_properties.hpp +++ b/src/mbgl/style/layers/hillshade_layer_properties.hpp @@ -55,6 +55,8 @@ public: HillshadePaintProperties::PossiblyEvaluated); ~HillshadeLayerProperties() override; + unsigned long constantsMask() const override; + const HillshadeLayer::Impl& layerImpl() const; // Data members. HillshadePaintProperties::PossiblyEvaluated evaluated; diff --git a/src/mbgl/style/layers/layer_properties.cpp.ejs b/src/mbgl/style/layers/layer_properties.cpp.ejs index 2c8e1ce9a0..fcdcfda7be 100644 --- a/src/mbgl/style/layers/layer_properties.cpp.ejs +++ b/src/mbgl/style/layers/layer_properties.cpp.ejs @@ -30,6 +30,10 @@ namespace style { <%- camelize(type) %>LayerProperties::~<%- camelize(type) %>LayerProperties() = default; +unsigned long <%- camelize(type) %>LayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const <%- camelize(type) %>Layer::Impl& <%- camelize(type) %>LayerProperties::layerImpl() const { return static_cast<const <%- camelize(type) %>Layer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs index 277cfd173b..4513146d6d 100644 --- a/src/mbgl/style/layers/layer_properties.hpp.ejs +++ b/src/mbgl/style/layers/layer_properties.hpp.ejs @@ -72,6 +72,8 @@ public: <%- camelize(type) %>PaintProperties::PossiblyEvaluated); ~<%- camelize(type) %>LayerProperties() override; + unsigned long constantsMask() const override; + const <%- camelize(type) %>Layer::Impl& layerImpl() const; // Data members. <% if (type === 'background' || type === 'fill' || type === 'line' || type === 'fill-extrusion') { -%> diff --git a/src/mbgl/style/layers/line_layer_properties.cpp b/src/mbgl/style/layers/line_layer_properties.cpp index 09fb6ff80c..46b220661c 100644 --- a/src/mbgl/style/layers/line_layer_properties.cpp +++ b/src/mbgl/style/layers/line_layer_properties.cpp @@ -21,6 +21,10 @@ LineLayerProperties::LineLayerProperties( LineLayerProperties::~LineLayerProperties() = default; +unsigned long LineLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const LineLayer::Impl& LineLayerProperties::layerImpl() const { return static_cast<const LineLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp index 7463d94393..dac6cebae0 100644 --- a/src/mbgl/style/layers/line_layer_properties.hpp +++ b/src/mbgl/style/layers/line_layer_properties.hpp @@ -113,6 +113,8 @@ public: LinePaintProperties::PossiblyEvaluated); ~LineLayerProperties() override; + unsigned long constantsMask() const override; + const LineLayer::Impl& layerImpl() const; // Data members. CrossfadeParameters crossfade; diff --git a/src/mbgl/style/layers/raster_layer_properties.cpp b/src/mbgl/style/layers/raster_layer_properties.cpp index 4d9245a218..77bdb62b8d 100644 --- a/src/mbgl/style/layers/raster_layer_properties.cpp +++ b/src/mbgl/style/layers/raster_layer_properties.cpp @@ -19,6 +19,10 @@ RasterLayerProperties::RasterLayerProperties( RasterLayerProperties::~RasterLayerProperties() = default; +unsigned long RasterLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const RasterLayer::Impl& RasterLayerProperties::layerImpl() const { return static_cast<const RasterLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp index 61aa32de2d..9ddd6cc790 100644 --- a/src/mbgl/style/layers/raster_layer_properties.hpp +++ b/src/mbgl/style/layers/raster_layer_properties.hpp @@ -65,6 +65,8 @@ public: RasterPaintProperties::PossiblyEvaluated); ~RasterLayerProperties() override; + unsigned long constantsMask() const override; + const RasterLayer::Impl& layerImpl() const; // Data members. RasterPaintProperties::PossiblyEvaluated evaluated; diff --git a/src/mbgl/style/layers/symbol_layer_properties.cpp b/src/mbgl/style/layers/symbol_layer_properties.cpp index aeca39b419..5e50535377 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.cpp +++ b/src/mbgl/style/layers/symbol_layer_properties.cpp @@ -19,6 +19,10 @@ SymbolLayerProperties::SymbolLayerProperties( SymbolLayerProperties::~SymbolLayerProperties() = default; +unsigned long SymbolLayerProperties::constantsMask() const { + return evaluated.constantsMask(); +} + const SymbolLayer::Impl& SymbolLayerProperties::layerImpl() const { return static_cast<const SymbolLayer::Impl&>(*baseImpl); } diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index 7b630a1ca3..0c2bcd2661 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -341,6 +341,8 @@ public: SymbolPaintProperties::PossiblyEvaluated); ~SymbolLayerProperties() override; + unsigned long constantsMask() const override; + const SymbolLayer::Impl& layerImpl() const; // Data members. SymbolPaintProperties::PossiblyEvaluated evaluated; diff --git a/src/mbgl/style/properties.hpp b/src/mbgl/style/properties.hpp index 7f58ff223d..9d66f850de 100644 --- a/src/mbgl/style/properties.hpp +++ b/src/mbgl/style/properties.hpp @@ -9,6 +9,8 @@ #include <mbgl/util/indexed_tuple.hpp> #include <mbgl/util/ignore.hpp> +#include <bitset> + namespace mbgl { class GeometryTileFeature; @@ -102,6 +104,22 @@ struct IsDataDriven : std::integral_constant<bool, P::IsDataDriven> {}; template <class P> struct IsOverridable : std::integral_constant<bool, P::IsOverridable> {}; +template <class Ps> +struct ConstantsMask; + +template <class... Ps> +struct ConstantsMask<TypeList<Ps...>> { + template <class Properties> + static unsigned long getMask(const Properties& properties) { + std::bitset<sizeof... (Ps)> result; + util::ignore({ + result.set(TypeIndex<Ps, Ps...>::value, + properties.template get<Ps>().isConstant())... + }); + return result.to_ulong(); + } +}; + template <class... Ps> class Properties { public: @@ -172,6 +190,10 @@ public: evaluate<Ps>(z, feature)... }; } + + unsigned long constantsMask() const { + return ConstantsMask<DataDrivenProperties>::getMask(*this); + } }; class Unevaluated : public Tuple<UnevaluatedTypes> { |