[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).
This commit is contained in:
@@ -13,7 +13,8 @@ namespace style {
|
||||
class LayerProperties {
|
||||
public:
|
||||
virtual ~LayerProperties() = default;
|
||||
|
||||
// Returns constants mask for the data-driven properties.
|
||||
virtual unsigned long constantsMask() const { return 0u; }
|
||||
Immutable<Layer::Impl> baseImpl;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
BackgroundPaintProperties::PossiblyEvaluated);
|
||||
~BackgroundLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const BackgroundLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
CrossfadeParameters crossfade;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ public:
|
||||
CirclePaintProperties::PossiblyEvaluated);
|
||||
~CircleLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const CircleLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
CirclePaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
FillExtrusionPaintProperties::PossiblyEvaluated);
|
||||
~FillExtrusionLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const FillExtrusionLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
CrossfadeParameters crossfade;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ public:
|
||||
FillPaintProperties::PossiblyEvaluated);
|
||||
~FillLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const FillLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
CrossfadeParameters crossfade;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
HeatmapPaintProperties::PossiblyEvaluated);
|
||||
~HeatmapLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const HeatmapLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
HeatmapPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
HillshadePaintProperties::PossiblyEvaluated);
|
||||
~HillshadeLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const HillshadeLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
HillshadePaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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') { -%>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
LinePaintProperties::PossiblyEvaluated);
|
||||
~LineLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const LineLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
CrossfadeParameters crossfade;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
RasterPaintProperties::PossiblyEvaluated);
|
||||
~RasterLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const RasterLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
RasterPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -341,6 +341,8 @@ public:
|
||||
SymbolPaintProperties::PossiblyEvaluated);
|
||||
~SymbolLayerProperties() override;
|
||||
|
||||
unsigned long constantsMask() const override;
|
||||
|
||||
const SymbolLayer::Impl& layerImpl() const;
|
||||
// Data members.
|
||||
SymbolPaintProperties::PossiblyEvaluated evaluated;
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user