summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-10 11:34:00 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-15 09:45:55 -0700
commitda4d735e2c465195e0fb9531ce9d4d7c5c9e6503 (patch)
treed7145d5f884420703d0a1bb03a0492eebf05b160
parent2690a65f8dc9e920c16af3264864321295f7daa8 (diff)
downloadqtlocation-mapboxgl-da4d735e2c465195e0fb9531ce9d4d7c5c9e6503.tar.gz
[core] Unify {Paint,Layout,Light}Properties
-rw-r--r--cmake/core-files.cmake3
-rw-r--r--cmake/test-files.cmake2
-rw-r--r--include/mbgl/style/data_driven_property_value.hpp2
-rw-r--r--include/mbgl/style/property_value.hpp2
-rw-r--r--src/mbgl/layout/symbol_layout.cpp4
-rw-r--r--src/mbgl/layout/symbol_layout.hpp2
-rw-r--r--src/mbgl/programs/collision_box_program.hpp3
-rw-r--r--src/mbgl/programs/debug_program.hpp3
-rw-r--r--src/mbgl/programs/extrusion_texture_program.hpp3
-rw-r--r--src/mbgl/programs/line_program.cpp8
-rw-r--r--src/mbgl/programs/line_program.hpp6
-rw-r--r--src/mbgl/programs/program.hpp2
-rw-r--r--src/mbgl/programs/symbol_program.hpp2
-rw-r--r--src/mbgl/renderer/buckets/line_bucket.cpp2
-rw-r--r--src/mbgl/renderer/buckets/line_bucket.hpp2
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.cpp3
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_background_layer.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_circle_layer.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.hpp2
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp8
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.hpp10
-rw-r--r--src/mbgl/renderer/paint_property_binder.hpp1
-rw-r--r--src/mbgl/renderer/painter.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_background.cpp4
-rw-r--r--src/mbgl/renderer/painters/painter_circle.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_clipping.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_debug.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_fill.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_fill_extrusion.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_line.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_raster.cpp2
-rw-r--r--src/mbgl/renderer/painters/painter_symbol.cpp2
-rw-r--r--src/mbgl/renderer/render_light.cpp4
-rw-r--r--src/mbgl/renderer/render_light.hpp70
-rw-r--r--src/mbgl/renderer/transitioning_property.hpp75
-rw-r--r--src/mbgl/style/conversion/stringify.hpp9
-rw-r--r--src/mbgl/style/layers/background_layer.cpp1
-rw-r--r--src/mbgl/style/layers/background_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp1
-rw-r--r--src/mbgl/style/layers/circle_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp1
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp1
-rw-r--r--src/mbgl/style/layers/fill_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs7
-rw-r--r--src/mbgl/style/layers/layer_properties.hpp.ejs5
-rw-r--r--src/mbgl/style/layers/line_layer.cpp19
-rw-r--r--src/mbgl/style/layers/line_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/line_layer_properties.hpp5
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp1
-rw-r--r--src/mbgl/style/layers/raster_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp139
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp5
-rw-r--r--src/mbgl/style/layout_property.hpp95
-rw-r--r--src/mbgl/style/light_impl.hpp16
-rw-r--r--src/mbgl/style/paint_property.hpp161
-rw-r--r--src/mbgl/style/properties.hpp268
-rw-r--r--src/mbgl/style/style.cpp2
-rw-r--r--test/style/conversion/stringify.test.cpp17
-rw-r--r--test/style/properties.test.cpp (renamed from test/style/paint_property.test.cpp)43
-rw-r--r--test/tile/vector_tile.test.cpp2
66 files changed, 494 insertions, 576 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index a191061354..f066f28e13 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -192,7 +192,6 @@ set(MBGL_CORE_FILES
src/mbgl/renderer/tile_parameters.hpp
src/mbgl/renderer/tile_pyramid.cpp
src/mbgl/renderer/tile_pyramid.hpp
- src/mbgl/renderer/transitioning_property.hpp
src/mbgl/renderer/update_parameters.hpp
# renderer/buckets
@@ -343,11 +342,11 @@ set(MBGL_CORE_FILES
src/mbgl/style/light_impl.cpp
src/mbgl/style/light_impl.hpp
src/mbgl/style/light_observer.hpp
- src/mbgl/style/light_properties.hpp
src/mbgl/style/observer.hpp
src/mbgl/style/paint_property.hpp
src/mbgl/style/parser.cpp
src/mbgl/style/parser.hpp
+ src/mbgl/style/properties.hpp
src/mbgl/style/rapidjson_conversion.hpp
src/mbgl/style/source.cpp
src/mbgl/style/source_impl.cpp
diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake
index 5eb9d8d9f8..9415add573 100644
--- a/cmake/test-files.cmake
+++ b/cmake/test-files.cmake
@@ -97,7 +97,7 @@ set(MBGL_TEST_FILES
test/style/function/source_function.test.cpp
# style
- test/style/paint_property.test.cpp
+ test/style/properties.test.cpp
test/style/source.test.cpp
test/style/style.test.cpp
test/style/style_image.test.cpp
diff --git a/include/mbgl/style/data_driven_property_value.hpp b/include/mbgl/style/data_driven_property_value.hpp
index 5acf800840..12a369abb1 100644
--- a/include/mbgl/style/data_driven_property_value.hpp
+++ b/include/mbgl/style/data_driven_property_value.hpp
@@ -56,7 +56,7 @@ public:
}
template <typename Evaluator>
- auto evaluate(const Evaluator& evaluator) const {
+ auto evaluate(const Evaluator& evaluator, TimePoint = {}) const {
return Value::visit(value, evaluator);
}
};
diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp
index 8bec7388e5..5259eecf2a 100644
--- a/include/mbgl/style/property_value.hpp
+++ b/include/mbgl/style/property_value.hpp
@@ -35,7 +35,7 @@ public:
const CameraFunction<T>& asCameraFunction() const { return value.template get<CameraFunction<T>>(); }
template <typename Evaluator>
- auto evaluate(const Evaluator& evaluator) const {
+ auto evaluate(const Evaluator& evaluator, TimePoint = {}) const {
return Value::visit(value, evaluator);
}
};
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 5142584c91..0e8b2fa636 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -50,8 +50,8 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
mode(parameters.mode),
tileSize(util::tileSize * overscaling),
tilePixelRatio(float(util::EXTENT) / tileSize),
- textSize(layers.at(0)->as<RenderSymbolLayer>()->impl().layout.unevaluated.get<TextSize>()),
- iconSize(layers.at(0)->as<RenderSymbolLayer>()->impl().layout.unevaluated.get<IconSize>())
+ textSize(layers.at(0)->as<RenderSymbolLayer>()->impl().layout.get<TextSize>()),
+ iconSize(layers.at(0)->as<RenderSymbolLayer>()->impl().layout.get<IconSize>())
{
const SymbolLayer::Impl& leader = layers.at(0)->as<RenderSymbolLayer>()->impl();
diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp
index 7d19aba671..7bdcf52f91 100644
--- a/src/mbgl/layout/symbol_layout.hpp
+++ b/src/mbgl/layout/symbol_layout.hpp
@@ -47,7 +47,7 @@ public:
State state = Pending;
std::map<std::string,
- std::pair<style::IconPaintProperties::Evaluated, style::TextPaintProperties::Evaluated>> layerPaintProperties;
+ std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>> layerPaintProperties;
private:
void addFeature(const size_t,
diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp
index 89b69484fd..160fd42814 100644
--- a/src/mbgl/programs/collision_box_program.hpp
+++ b/src/mbgl/programs/collision_box_program.hpp
@@ -4,6 +4,7 @@
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/shaders/collision_box.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/util/geometry.hpp>
#include <cmath>
@@ -29,7 +30,7 @@ class CollisionBoxProgram : public Program<
uniforms::u_scale,
uniforms::u_zoom,
uniforms::u_maxzoom>,
- style::PaintProperties<>>
+ style::Properties<>>
{
public:
using Program::Program;
diff --git a/src/mbgl/programs/debug_program.hpp b/src/mbgl/programs/debug_program.hpp
index de1666b4a8..7a6d075cdb 100644
--- a/src/mbgl/programs/debug_program.hpp
+++ b/src/mbgl/programs/debug_program.hpp
@@ -4,6 +4,7 @@
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/shaders/debug.hpp>
+#include <mbgl/style/properties.hpp>
namespace mbgl {
@@ -15,7 +16,7 @@ class DebugProgram : public Program<
gl::Uniforms<
uniforms::u_matrix,
uniforms::u_color>,
- style::PaintProperties<>>
+ style::Properties<>>
{
public:
using Program::Program;
diff --git a/src/mbgl/programs/extrusion_texture_program.hpp b/src/mbgl/programs/extrusion_texture_program.hpp
index 1519aa095d..bd82208885 100644
--- a/src/mbgl/programs/extrusion_texture_program.hpp
+++ b/src/mbgl/programs/extrusion_texture_program.hpp
@@ -4,6 +4,7 @@
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/shaders/extrusion_texture.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/util/geometry.hpp>
namespace mbgl {
@@ -17,7 +18,7 @@ class ExtrusionTextureProgram : public Program<
uniforms::u_world,
uniforms::u_image,
uniforms::u_opacity>,
- style::PaintProperties<>> {
+ style::Properties<>> {
public:
using Program::Program;
diff --git a/src/mbgl/programs/line_program.cpp b/src/mbgl/programs/line_program.cpp
index d9778ba7ce..e7e5c58e47 100644
--- a/src/mbgl/programs/line_program.cpp
+++ b/src/mbgl/programs/line_program.cpp
@@ -13,7 +13,7 @@ using namespace style;
static_assert(sizeof(LineLayoutVertex) == 8, "expected LineLayoutVertex size");
template <class Values, class...Args>
-Values makeValues(const LinePaintProperties::Evaluated& properties,
+Values makeValues(const LinePaintProperties::PossiblyEvaluated& properties,
const RenderTile& tile,
const TransformState& state,
const std::array<float, 2>& pixelsToGLUnits,
@@ -33,7 +33,7 @@ Values makeValues(const LinePaintProperties::Evaluated& properties,
}
LineProgram::UniformValues
-LineProgram::uniformValues(const LinePaintProperties::Evaluated& properties,
+LineProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated& properties,
const RenderTile& tile,
const TransformState& state,
const std::array<float, 2>& pixelsToGLUnits) {
@@ -46,7 +46,7 @@ LineProgram::uniformValues(const LinePaintProperties::Evaluated& properties,
}
LineSDFProgram::UniformValues
-LineSDFProgram::uniformValues(const LinePaintProperties::Evaluated& properties,
+LineSDFProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated& properties,
float pixelRatio,
const RenderTile& tile,
const TransformState& state,
@@ -84,7 +84,7 @@ LineSDFProgram::uniformValues(const LinePaintProperties::Evaluated& properties,
}
LinePatternProgram::UniformValues
-LinePatternProgram::uniformValues(const LinePaintProperties::Evaluated& properties,
+LinePatternProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated& properties,
const RenderTile& tile,
const TransformState& state,
const std::array<float, 2>& pixelsToGLUnits,
diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp
index b2e55a4f3b..9ad3882e72 100644
--- a/src/mbgl/programs/line_program.hpp
+++ b/src/mbgl/programs/line_program.hpp
@@ -91,7 +91,7 @@ public:
*/
static const int8_t extrudeScale = 63;
- static UniformValues uniformValues(const style::LinePaintProperties::Evaluated&,
+ static UniformValues uniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
const RenderTile&,
const TransformState&,
const std::array<float, 2>& pixelsToGLUnits);
@@ -119,7 +119,7 @@ class LinePatternProgram : public Program<
public:
using Program::Program;
- static UniformValues uniformValues(const style::LinePaintProperties::Evaluated&,
+ static UniformValues uniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
const RenderTile&,
const TransformState&,
const std::array<float, 2>& pixelsToGLUnits,
@@ -148,7 +148,7 @@ class LineSDFProgram : public Program<
public:
using Program::Program;
- static UniformValues uniformValues(const style::LinePaintProperties::Evaluated&,
+ static UniformValues uniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
float pixelRatio,
const RenderTile&,
const TransformState&,
diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp
index 7eec15e755..a5db5cf8dc 100644
--- a/src/mbgl/programs/program.hpp
+++ b/src/mbgl/programs/program.hpp
@@ -53,7 +53,7 @@ public:
const gl::IndexBuffer<DrawMode>& indexBuffer,
const gl::SegmentVector<Attributes>& segments,
const PaintPropertyBinders& paintPropertyBinders,
- const typename PaintProperties::Evaluated& currentProperties,
+ const typename PaintProperties::PossiblyEvaluated& currentProperties,
float currentZoom) {
program.draw(
context,
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index ec68dc2098..9eaa140955 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -365,7 +365,7 @@ public:
const gl::IndexBuffer<DrawMode>& indexBuffer,
const gl::SegmentVector<Attributes>& segments,
const PaintPropertyBinders& paintPropertyBinders,
- const typename PaintProperties::Evaluated& currentProperties,
+ const typename PaintProperties::PossiblyEvaluated& currentProperties,
float currentZoom) {
program.draw(
context,
diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp
index 3c5fa6bc67..ab9cfe9376 100644
--- a/src/mbgl/renderer/buckets/line_bucket.cpp
+++ b/src/mbgl/renderer/buckets/line_bucket.cpp
@@ -14,7 +14,7 @@ using namespace style;
LineBucket::LineBucket(const BucketParameters& parameters,
const std::vector<const RenderLayer*>& layers,
- const style::LineLayoutProperties& layout_)
+ const style::LineLayoutProperties::Unevaluated& layout_)
: layout(layout_.evaluate(PropertyEvaluationParameters(parameters.tileID.overscaledZ))),
overscaling(parameters.tileID.overscaleFactor()) {
for (const auto& layer : layers) {
diff --git a/src/mbgl/renderer/buckets/line_bucket.hpp b/src/mbgl/renderer/buckets/line_bucket.hpp
index c319548714..34d8935953 100644
--- a/src/mbgl/renderer/buckets/line_bucket.hpp
+++ b/src/mbgl/renderer/buckets/line_bucket.hpp
@@ -19,7 +19,7 @@ class LineBucket : public Bucket {
public:
LineBucket(const BucketParameters&,
const std::vector<const RenderLayer*>&,
- const style::LineLayoutProperties&);
+ const style::LineLayoutProperties::Unevaluated&);
void addFeature(const GeometryTileFeature&,
const GeometryCollection&) override;
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp
index 423161f24c..bc4e5f57cb 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.cpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp
@@ -10,7 +10,8 @@ using namespace style;
SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layout_,
const std::map<std::string, std::pair<
- style::IconPaintProperties::Evaluated, style::TextPaintProperties::Evaluated>>& layerPaintProperties,
+ style::IconPaintProperties::PossiblyEvaluated,
+ style::TextPaintProperties::PossiblyEvaluated>>& layerPaintProperties,
const style::DataDrivenPropertyValue<float>& textSize,
const style::DataDrivenPropertyValue<float>& iconSize,
float zoom,
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp
index f7e4bcfa20..f30c9cf10e 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.hpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp
@@ -18,7 +18,7 @@ namespace mbgl {
class SymbolBucket : public Bucket {
public:
SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated,
- const std::map<std::string, std::pair<style::IconPaintProperties::Evaluated, style::TextPaintProperties::Evaluated>>&,
+ const std::map<std::string, std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>>&,
const style::DataDrivenPropertyValue<float>& textSize,
const style::DataDrivenPropertyValue<float>& iconSize,
float zoom,
diff --git a/src/mbgl/renderer/layers/render_background_layer.hpp b/src/mbgl/renderer/layers/render_background_layer.hpp
index 7eabf47345..c2dfc27364 100644
--- a/src/mbgl/renderer/layers/render_background_layer.hpp
+++ b/src/mbgl/renderer/layers/render_background_layer.hpp
@@ -19,7 +19,7 @@ public:
// Paint properties
style::BackgroundPaintProperties::Unevaluated unevaluated;
- style::BackgroundPaintProperties::Evaluated evaluated;
+ style::BackgroundPaintProperties::PossiblyEvaluated evaluated;
const style::BackgroundLayer::Impl& impl() const;
};
diff --git a/src/mbgl/renderer/layers/render_circle_layer.hpp b/src/mbgl/renderer/layers/render_circle_layer.hpp
index 2b517912c9..64322487f0 100644
--- a/src/mbgl/renderer/layers/render_circle_layer.hpp
+++ b/src/mbgl/renderer/layers/render_circle_layer.hpp
@@ -26,7 +26,7 @@ public:
// Paint properties
style::CirclePaintProperties::Unevaluated unevaluated;
- style::CirclePaintProperties::Evaluated evaluated;
+ style::CirclePaintProperties::PossiblyEvaluated evaluated;
const style::CircleLayer::Impl& impl() const;
};
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
index f6166495c6..8bacd3e935 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
@@ -26,7 +26,7 @@ public:
// Paint properties
style::FillExtrusionPaintProperties::Unevaluated unevaluated;
- style::FillExtrusionPaintProperties::Evaluated evaluated;
+ style::FillExtrusionPaintProperties::PossiblyEvaluated evaluated;
const style::FillExtrusionLayer::Impl& impl() const;
};
diff --git a/src/mbgl/renderer/layers/render_fill_layer.hpp b/src/mbgl/renderer/layers/render_fill_layer.hpp
index d26ca10b44..238cb06aa8 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.hpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.hpp
@@ -26,7 +26,7 @@ public:
// Paint properties
style::FillPaintProperties::Unevaluated unevaluated;
- style::FillPaintProperties::Evaluated evaluated;
+ style::FillPaintProperties::PossiblyEvaluated evaluated;
const style::FillLayer::Impl& impl() const;
};
diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp
index 0276e6a6d9..23a78a3673 100644
--- a/src/mbgl/renderer/layers/render_line_layer.hpp
+++ b/src/mbgl/renderer/layers/render_line_layer.hpp
@@ -26,7 +26,7 @@ public:
// Paint properties
style::LinePaintProperties::Unevaluated unevaluated;
- style::LinePaintProperties::Evaluated evaluated;
+ style::LinePaintProperties::PossiblyEvaluated evaluated;
const style::LineLayer::Impl& impl() const;
diff --git a/src/mbgl/renderer/layers/render_raster_layer.hpp b/src/mbgl/renderer/layers/render_raster_layer.hpp
index 50c213aa26..8cf62fa0d5 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.hpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.hpp
@@ -19,7 +19,7 @@ public:
// Paint properties
style::RasterPaintProperties::Unevaluated unevaluated;
- style::RasterPaintProperties::Evaluated evaluated;
+ style::RasterPaintProperties::PossiblyEvaluated evaluated;
const style::RasterLayer::Impl& impl() const;
};
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 7d6b1cc039..af8917a75b 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -54,8 +54,8 @@ bool RenderSymbolLayer::hasTransition() const {
return unevaluated.hasTransition();
}
-style::IconPaintProperties::Evaluated RenderSymbolLayer::iconPaintProperties() const {
- return style::IconPaintProperties::Evaluated {
+style::IconPaintProperties::PossiblyEvaluated RenderSymbolLayer::iconPaintProperties() const {
+ return style::IconPaintProperties::PossiblyEvaluated {
evaluated.get<style::IconOpacity>(),
evaluated.get<style::IconColor>(),
evaluated.get<style::IconHaloColor>(),
@@ -66,8 +66,8 @@ style::IconPaintProperties::Evaluated RenderSymbolLayer::iconPaintProperties() c
};
}
-style::TextPaintProperties::Evaluated RenderSymbolLayer::textPaintProperties() const {
- return style::TextPaintProperties::Evaluated {
+style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProperties() const {
+ return style::TextPaintProperties::PossiblyEvaluated {
evaluated.get<style::TextOpacity>(),
evaluated.get<style::TextColor>(),
evaluated.get<style::TextHaloColor>(),
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp
index ba1b047663..4308761ee8 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.hpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp
@@ -13,7 +13,7 @@ namespace style {
// {icon,text}-specific paint-property packs for use in the symbol Programs.
// Since each program deals either with icons or text, using a smaller property set
// lets us avoid unnecessarily binding attributes for properties the program wouldn't use.
-class IconPaintProperties : public PaintProperties<
+class IconPaintProperties : public Properties<
IconOpacity,
IconColor,
IconHaloColor,
@@ -23,7 +23,7 @@ class IconPaintProperties : public PaintProperties<
IconTranslateAnchor
> {};
-class TextPaintProperties : public PaintProperties<
+class TextPaintProperties : public Properties<
TextOpacity,
TextColor,
TextHaloColor,
@@ -68,8 +68,8 @@ public:
void evaluate(const PropertyEvaluationParameters&) override;
bool hasTransition() const override;
- style::IconPaintProperties::Evaluated iconPaintProperties() const;
- style::TextPaintProperties::Evaluated textPaintProperties() const;
+ style::IconPaintProperties::PossiblyEvaluated iconPaintProperties() const;
+ style::TextPaintProperties::PossiblyEvaluated textPaintProperties() const;
style::SymbolPropertyValues iconPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated&) const;
style::SymbolPropertyValues textPropertyValues(const style::SymbolLayoutProperties::PossiblyEvaluated&) const;
@@ -80,7 +80,7 @@ public:
// Paint properties
style::SymbolPaintProperties::Unevaluated unevaluated;
- style::SymbolPaintProperties::Evaluated evaluated;
+ style::SymbolPaintProperties::PossiblyEvaluated evaluated;
float iconSize = 1.0f;
float textSize = 16.0f;
diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp
index 3e53bcc884..14934fb6bd 100644
--- a/src/mbgl/renderer/paint_property_binder.hpp
+++ b/src/mbgl/renderer/paint_property_binder.hpp
@@ -4,6 +4,7 @@
#include <mbgl/gl/attribute.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/type_list.hpp>
+#include <mbgl/renderer/possibly_evaluated_property_value.hpp>
#include <mbgl/renderer/paint_property_statistics.hpp>
namespace mbgl {
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 0c5e0e764a..7649f86ca6 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -350,7 +350,7 @@ void Painter::renderPass(PaintParameters& parameters,
mat4 viewportMat;
matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1);
- const PaintProperties<>::Evaluated properties{};
+ const Properties<>::PossiblyEvaluated properties{};
parameters.programs.extrusionTexture.draw(
context, gl::Triangles(), gl::DepthMode::disabled(), gl::StencilMode::disabled(),
diff --git a/src/mbgl/renderer/painters/painter_background.cpp b/src/mbgl/renderer/painters/painter_background.cpp
index fbd44b4480..783880fe86 100644
--- a/src/mbgl/renderer/painters/painter_background.cpp
+++ b/src/mbgl/renderer/painters/painter_background.cpp
@@ -14,9 +14,9 @@ using namespace style;
void Painter::renderBackground(PaintParameters& parameters, const RenderBackgroundLayer& layer) {
// Note that for bottommost layers without a pattern, the background color is drawn with
// glClear rather than this method.
- const BackgroundPaintProperties::Evaluated& background = layer.evaluated;
+ const BackgroundPaintProperties::PossiblyEvaluated& background = layer.evaluated;
- style::FillPaintProperties::Evaluated properties;
+ style::FillPaintProperties::PossiblyEvaluated properties;
properties.get<FillPattern>() = background.get<BackgroundPattern>();
properties.get<FillOpacity>() = { background.get<BackgroundOpacity>() };
properties.get<FillColor>() = { background.get<BackgroundColor>() };
diff --git a/src/mbgl/renderer/painters/painter_circle.cpp b/src/mbgl/renderer/painters/painter_circle.cpp
index 0bca8ee94f..367dd57bc7 100644
--- a/src/mbgl/renderer/painters/painter_circle.cpp
+++ b/src/mbgl/renderer/painters/painter_circle.cpp
@@ -20,7 +20,7 @@ void Painter::renderCircle(PaintParameters& parameters,
return;
}
- const CirclePaintProperties::Evaluated& properties = layer.evaluated;
+ const CirclePaintProperties::PossiblyEvaluated& properties = layer.evaluated;
const bool scaleWithMap = properties.get<CirclePitchScale>() == CirclePitchScaleType::Map;
parameters.programs.circle.draw(
diff --git a/src/mbgl/renderer/painters/painter_clipping.cpp b/src/mbgl/renderer/painters/painter_clipping.cpp
index 0d3b5f1504..31e2b700b0 100644
--- a/src/mbgl/renderer/painters/painter_clipping.cpp
+++ b/src/mbgl/renderer/painters/painter_clipping.cpp
@@ -6,7 +6,7 @@
namespace mbgl {
void Painter::renderClippingMask(const UnwrappedTileID& tileID, const ClipID& clip) {
- static const style::FillPaintProperties::Evaluated properties {};
+ static const style::FillPaintProperties::PossiblyEvaluated properties {};
static const FillProgram::PaintPropertyBinders paintAttibuteData(properties, 0);
programs->fill.draw(
context,
diff --git a/src/mbgl/renderer/painters/painter_debug.cpp b/src/mbgl/renderer/painters/painter_debug.cpp
index a108cd2d00..4794d79d45 100644
--- a/src/mbgl/renderer/painters/painter_debug.cpp
+++ b/src/mbgl/renderer/painters/painter_debug.cpp
@@ -20,7 +20,7 @@ void Painter::renderTileDebug(const RenderTile& renderTile) {
MBGL_DEBUG_GROUP(context, std::string { "debug " } + util::toString(renderTile.id));
- static const style::PaintProperties<>::Evaluated properties {};
+ static const style::Properties<>::PossiblyEvaluated properties {};
static const DebugProgram::PaintPropertyBinders paintAttibuteData(properties, 0);
auto draw = [&] (Color color, const auto& vertexBuffer, const auto& indexBuffer, const auto& segments, auto drawMode) {
diff --git a/src/mbgl/renderer/painters/painter_fill.cpp b/src/mbgl/renderer/painters/painter_fill.cpp
index 782fba3d42..0b77474efe 100644
--- a/src/mbgl/renderer/painters/painter_fill.cpp
+++ b/src/mbgl/renderer/painters/painter_fill.cpp
@@ -17,7 +17,7 @@ void Painter::renderFill(PaintParameters& parameters,
FillBucket& bucket,
const RenderFillLayer& layer,
const RenderTile& tile) {
- const FillPaintProperties::Evaluated& properties = layer.evaluated;
+ const FillPaintProperties::PossiblyEvaluated& properties = layer.evaluated;
if (!properties.get<FillPattern>().from.empty()) {
if (pass != RenderPass::Translucent) {
diff --git a/src/mbgl/renderer/painters/painter_fill_extrusion.cpp b/src/mbgl/renderer/painters/painter_fill_extrusion.cpp
index c00597ab40..8e10cd7369 100644
--- a/src/mbgl/renderer/painters/painter_fill_extrusion.cpp
+++ b/src/mbgl/renderer/painters/painter_fill_extrusion.cpp
@@ -18,7 +18,7 @@ void Painter::renderFillExtrusion(PaintParameters& parameters,
FillExtrusionBucket& bucket,
const RenderFillExtrusionLayer& layer,
const RenderTile& tile) {
- const FillExtrusionPaintProperties::Evaluated& properties = layer.evaluated;
+ const FillExtrusionPaintProperties::PossiblyEvaluated& properties = layer.evaluated;
if (pass == RenderPass::Opaque) {
return;
diff --git a/src/mbgl/renderer/painters/painter_line.cpp b/src/mbgl/renderer/painters/painter_line.cpp
index 20a16750d2..dc99ef9aff 100644
--- a/src/mbgl/renderer/painters/painter_line.cpp
+++ b/src/mbgl/renderer/painters/painter_line.cpp
@@ -21,7 +21,7 @@ void Painter::renderLine(PaintParameters& parameters,
return;
}
- const LinePaintProperties::Evaluated& properties = layer.evaluated;
+ const LinePaintProperties::PossiblyEvaluated& properties = layer.evaluated;
auto draw = [&] (auto& program, auto&& uniformValues) {
program.draw(
diff --git a/src/mbgl/renderer/painters/painter_raster.cpp b/src/mbgl/renderer/painters/painter_raster.cpp
index 5d98fcf860..1f0d72be40 100644
--- a/src/mbgl/renderer/painters/painter_raster.cpp
+++ b/src/mbgl/renderer/painters/painter_raster.cpp
@@ -48,7 +48,7 @@ void Painter::renderRaster(PaintParameters& parameters,
if (!bucket.hasData())
return;
- const RasterPaintProperties::Evaluated& properties = layer.evaluated;
+ const RasterPaintProperties::PossiblyEvaluated& properties = layer.evaluated;
const RasterProgram::PaintPropertyBinders paintAttributeData(properties, 0);
assert(bucket.texture);
diff --git a/src/mbgl/renderer/painters/painter_symbol.cpp b/src/mbgl/renderer/painters/painter_symbol.cpp
index 8147a933bc..45094777c6 100644
--- a/src/mbgl/renderer/painters/painter_symbol.cpp
+++ b/src/mbgl/renderer/painters/painter_symbol.cpp
@@ -137,7 +137,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
}
if (bucket.hasCollisionBoxData()) {
- static const style::PaintProperties<>::Evaluated properties {};
+ static const style::Properties<>::PossiblyEvaluated properties {};
static const CollisionBoxProgram::PaintPropertyBinders paintAttributeData(properties, 0);
programs->collisionBox.draw(
diff --git a/src/mbgl/renderer/render_light.cpp b/src/mbgl/renderer/render_light.cpp
index 1fc346fd26..23b7ecb9b4 100644
--- a/src/mbgl/renderer/render_light.cpp
+++ b/src/mbgl/renderer/render_light.cpp
@@ -7,11 +7,11 @@ RenderLight::RenderLight(Immutable<style::Light::Impl> impl_)
}
void RenderLight::transition(const CascadeParameters& parameters) {
- transitioning = TransitioningLight(impl->properties, std::move(transitioning), parameters);
+ transitioning = impl->properties.cascade(parameters, std::move(transitioning));
}
void RenderLight::evaluate(const PropertyEvaluationParameters& parameters) {
- evaluated = EvaluatedLight(transitioning, parameters);
+ evaluated = transitioning.evaluate(parameters);
}
bool RenderLight::hasTransition() const {
diff --git a/src/mbgl/renderer/render_light.hpp b/src/mbgl/renderer/render_light.hpp
index 7e0662105f..ce83616bbe 100644
--- a/src/mbgl/renderer/render_light.hpp
+++ b/src/mbgl/renderer/render_light.hpp
@@ -1,75 +1,15 @@
#pragma once
#include <mbgl/style/light_impl.hpp>
-#include <mbgl/renderer/transitioning_property.hpp>
-#include <mbgl/renderer/cascade_parameters.hpp>
-#include <mbgl/renderer/property_evaluator.hpp>
-#include <mbgl/renderer/property_evaluation_parameters.hpp>
-#include <mbgl/util/ignore.hpp>
-
-#include <memory>
+#include <mbgl/util/immutable.hpp>
namespace mbgl {
-template <class TypeList>
-class Transitioning;
-
-template <class... Ps>
-class Transitioning<TypeList<Ps...>> : public IndexedTuple<
- TypeList<Ps...>,
- TypeList<TransitioningProperty<typename Ps::ValueType>...>>
-{
-private:
- using Properties = TypeList<Ps...>;
- using Raw = IndexedTuple<Properties, Properties>;
- using Super = IndexedTuple<
- TypeList<Ps...>,
- TypeList<TransitioningProperty<typename Ps::ValueType>...>>;
-
-public:
- Transitioning() = default;
- Transitioning(const Raw& raw, Transitioning&& prior, const CascadeParameters& params)
- : Super {
- TransitioningProperty<typename Ps::ValueType>(
- raw.template get<Ps>().value,
- std::move(prior.template get<Ps>()),
- raw.template get<Ps>().transition.reverseMerge(params.transition),
- params.now)...
- } {}
-
- bool hasTransition() const {
- bool result = false;
- util::ignore({ result |= this->template get<Ps>().hasTransition()... });
- return result;
- }
-};
-
-template <class TypeList>
-class Evaluated;
-
-template <class... Ps>
-class Evaluated<TypeList<Ps...>> : public IndexedTuple<
- TypeList<Ps...>,
- TypeList<typename Ps::Type...>>
-{
-private:
- using Properties = TypeList<Ps...>;
- using TransitioningPs = Transitioning<Properties>;
- using Super = IndexedTuple<
- TypeList<Ps...>,
- TypeList<typename Ps::Type...>>;
-
-public:
- Evaluated() = default;
- Evaluated(TransitioningPs& transitioning, const PropertyEvaluationParameters& params)
- : Super {
- transitioning.template get<Ps>()
- .evaluate(PropertyEvaluator<typename Ps::Type>(params, Ps::defaultValue()), params.now)...
- } {}
-};
+class CascadeParameters;
+class PropertyEvaluationParameters;
-using TransitioningLight = Transitioning<style::LightProperties>;
-using EvaluatedLight = Evaluated<style::LightProperties>;
+using TransitioningLight = style::LightProperties::Unevaluated;
+using EvaluatedLight = style::LightProperties::PossiblyEvaluated;
class RenderLight {
public:
diff --git a/src/mbgl/renderer/transitioning_property.hpp b/src/mbgl/renderer/transitioning_property.hpp
deleted file mode 100644
index c211ccf116..0000000000
--- a/src/mbgl/renderer/transitioning_property.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#pragma once
-
-#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
-#include <mbgl/style/transition_options.hpp>
-#include <mbgl/util/interpolate.hpp>
-
-#include <utility>
-
-namespace mbgl {
-
-template <class Value>
-class TransitioningProperty {
-public:
- TransitioningProperty() = default;
-
- TransitioningProperty(Value value_,
- TransitioningProperty<Value> prior_,
- style::TransitionOptions transition,
- TimePoint now)
- : begin(now + transition.delay.value_or(Duration::zero())),
- end(begin + transition.duration.value_or(Duration::zero())),
- value(std::move(value_)) {
- if (transition.isDefined()) {
- prior = { std::move(prior_) };
- }
- }
-
- template <class Evaluator>
- auto evaluate(const Evaluator& evaluator, TimePoint now) {
- auto finalValue = value.evaluate(evaluator);
- if (!prior) {
- // No prior value.
- return finalValue;
- } else if (now >= end) {
- // Transition from prior value is now complete.
- prior = {};
- return finalValue;
- } else if (value.isDataDriven()) {
- // Transitions to data-driven properties are not supported.
- // We snap immediately to the data-driven value so that, when we perform layout,
- // we see the data-driven function and can use it to populate vertex buffers.
- prior = {};
- return finalValue;
- } else if (now < begin) {
- // Transition hasn't started yet.
- return prior->get().evaluate(evaluator, now);
- } else {
- // Interpolate between recursively-calculated prior value and final.
- float t = std::chrono::duration<float>(now - begin) / (end - begin);
- return util::interpolate(prior->get().evaluate(evaluator, now), finalValue,
- util::DEFAULT_TRANSITION_EASE.solve(t, 0.001));
- }
- }
-
- bool hasTransition() const {
- return bool(prior);
- }
-
- bool isUndefined() const {
- return value.isUndefined();
- }
-
- const Value& getValue() const {
- return value;
- }
-
-private:
- optional<mapbox::util::recursive_wrapper<TransitioningProperty<Value>>> prior;
- TimePoint begin;
- TimePoint end;
- Value value;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/style/conversion/stringify.hpp b/src/mbgl/style/conversion/stringify.hpp
index 4afbf198e5..6ae6fede42 100644
--- a/src/mbgl/style/conversion/stringify.hpp
+++ b/src/mbgl/style/conversion/stringify.hpp
@@ -2,7 +2,7 @@
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/layout_property.hpp>
+#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/enum.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/feature.hpp>
@@ -446,13 +446,6 @@ void stringify(Writer& writer, const DataDrivenPropertyValue<T>& value) {
}
}
-template <class Writer, class... Ps>
-void stringify(Writer& writer, const LayoutProperties<Ps...>& ps) {
- writer.StartObject();
- util::ignore({ (stringify<Ps>(writer, ps.unevaluated.template get<Ps>()), 0)... });
- writer.EndObject();
-}
-
} // namespace conversion
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index 2aa15a779c..1c5b6c3a66 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/background_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
diff --git a/src/mbgl/style/layers/background_layer_properties.hpp b/src/mbgl/style/layers/background_layer_properties.hpp
index fae6c26a4b..f9a67b214d 100644
--- a/src/mbgl/style/layers/background_layer_properties.hpp
+++ b/src/mbgl/style/layers/background_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -22,7 +23,7 @@ struct BackgroundOpacity : PaintProperty<float> {
static float defaultValue() { return 1; }
};
-class BackgroundPaintProperties : public PaintProperties<
+class BackgroundPaintProperties : public Properties<
BackgroundColor,
BackgroundPattern,
BackgroundOpacity
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index ea812748d0..e874f00ff7 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/circle_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp
index 1cb4f5a635..734dab109c 100644
--- a/src/mbgl/style/layers/circle_layer_properties.hpp
+++ b/src/mbgl/style/layers/circle_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -50,7 +51,7 @@ struct CircleStrokeOpacity : DataDrivenPaintProperty<float, attributes::a_stroke
static float defaultValue() { return 1; }
};
-class CirclePaintProperties : public PaintProperties<
+class CirclePaintProperties : public Properties<
CircleRadius,
CircleColor,
CircleBlur,
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index 9a2ec36e15..cff0c59df2 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
#include <mbgl/style/layers/fill_extrusion_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
index c1dd3b079d..1819f98ae6 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -38,7 +39,7 @@ struct FillExtrusionBase : DataDrivenPaintProperty<float, attributes::a_base> {
static float defaultValue() { return 0; }
};
-class FillExtrusionPaintProperties : public PaintProperties<
+class FillExtrusionPaintProperties : public Properties<
FillExtrusionOpacity,
FillExtrusionColor,
FillExtrusionTranslate,
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 0031972842..d38b027740 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/style/layers/fill_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp
index f44a18d0e0..67c2ae1fa4 100644
--- a/src/mbgl/style/layers/fill_layer_properties.hpp
+++ b/src/mbgl/style/layers/fill_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -38,7 +39,7 @@ struct FillPattern : CrossFadedPaintProperty<std::string> {
static std::string defaultValue() { return ""; }
};
-class FillPaintProperties : public PaintProperties<
+class FillPaintProperties : public Properties<
FillAntialias,
FillOpacity,
FillColor,
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index b07f7db307..738165e668 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -7,7 +7,6 @@
#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
@@ -46,7 +45,7 @@ std::unique_ptr<Layer> <%- camelize(type) %>Layer::cloneRef(const std::string& i
<% if (layoutProperties.length) { -%>
void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>& writer) const {
- conversion::stringify(writer, layout);
+ layout.stringify(writer);
}
<% } else { -%>
void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
@@ -119,14 +118,14 @@ void <%- camelize(type) %>Layer::setMaxZoom(float maxZoom) {
}
<%- propertyValueType(property) %> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const {
- return impl().layout.unevaluated.get<<%- camelize(property.name) %>>();
+ return impl().layout.get<<%- camelize(property.name) %>>();
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> value) {
if (value == get<%- camelize(property.name) %>())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<<%- camelize(property.name) %>>() = value;
+ impl_->layout.get<<%- camelize(property.name) %>>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "<%- property.name %>");
}
diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs
index 2a736ca388..a271a27e8d 100644
--- a/src/mbgl/style/layers/layer_properties.hpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.hpp.ejs
@@ -10,6 +10,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -29,7 +30,7 @@ struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %>
<% } -%>
<% if (layoutProperties.length) { -%>
-class <%- camelize(type) %>LayoutProperties : public LayoutProperties<
+class <%- camelize(type) %>LayoutProperties : public Properties<
<% for (const property of layoutProperties.slice(0, -1)) { -%>
<%- camelize(property.name) %>,
<% } -%>
@@ -37,7 +38,7 @@ class <%- camelize(type) %>LayoutProperties : public LayoutProperties<
> {};
<% } -%>
-class <%- camelize(type) %>PaintProperties : public PaintProperties<
+class <%- camelize(type) %>PaintProperties : public Properties<
<% for (const property of paintProperties.slice(0, -1)) { -%>
<%- camelize(property.name) %>,
<% } -%>
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index 359078f913..c8684ec6f5 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/line_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
@@ -34,7 +33,7 @@ std::unique_ptr<Layer> LineLayer::cloneRef(const std::string& id_) const {
}
void LineLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>& writer) const {
- conversion::stringify(writer, layout);
+ layout.stringify(writer);
}
// Source
@@ -98,14 +97,14 @@ PropertyValue<LineCapType> LineLayer::getDefaultLineCap() {
}
PropertyValue<LineCapType> LineLayer::getLineCap() const {
- return impl().layout.unevaluated.get<LineCap>();
+ return impl().layout.get<LineCap>();
}
void LineLayer::setLineCap(PropertyValue<LineCapType> value) {
if (value == getLineCap())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<LineCap>() = value;
+ impl_->layout.get<LineCap>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "line-cap");
}
@@ -114,14 +113,14 @@ PropertyValue<LineJoinType> LineLayer::getDefaultLineJoin() {
}
PropertyValue<LineJoinType> LineLayer::getLineJoin() const {
- return impl().layout.unevaluated.get<LineJoin>();
+ return impl().layout.get<LineJoin>();
}
void LineLayer::setLineJoin(PropertyValue<LineJoinType> value) {
if (value == getLineJoin())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<LineJoin>() = value;
+ impl_->layout.get<LineJoin>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "line-join");
}
@@ -130,14 +129,14 @@ PropertyValue<float> LineLayer::getDefaultLineMiterLimit() {
}
PropertyValue<float> LineLayer::getLineMiterLimit() const {
- return impl().layout.unevaluated.get<LineMiterLimit>();
+ return impl().layout.get<LineMiterLimit>();
}
void LineLayer::setLineMiterLimit(PropertyValue<float> value) {
if (value == getLineMiterLimit())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<LineMiterLimit>() = value;
+ impl_->layout.get<LineMiterLimit>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "line-miter-limit");
}
@@ -146,14 +145,14 @@ PropertyValue<float> LineLayer::getDefaultLineRoundLimit() {
}
PropertyValue<float> LineLayer::getLineRoundLimit() const {
- return impl().layout.unevaluated.get<LineRoundLimit>();
+ return impl().layout.get<LineRoundLimit>();
}
void LineLayer::setLineRoundLimit(PropertyValue<float> value) {
if (value == getLineRoundLimit())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<LineRoundLimit>() = value;
+ impl_->layout.get<LineRoundLimit>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "line-round-limit");
}
diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp
index 8328378a1f..2eab19a612 100644
--- a/src/mbgl/style/layers/line_layer_impl.hpp
+++ b/src/mbgl/style/layers/line_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- LineLayoutProperties layout;
+ LineLayoutProperties::Unevaluated layout;
LinePaintProperties::Cascading paint;
};
diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp
index 724026e3a6..62acad295b 100644
--- a/src/mbgl/style/layers/line_layer_properties.hpp
+++ b/src/mbgl/style/layers/line_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -70,14 +71,14 @@ struct LinePattern : CrossFadedPaintProperty<std::string> {
static std::string defaultValue() { return ""; }
};
-class LineLayoutProperties : public LayoutProperties<
+class LineLayoutProperties : public Properties<
LineCap,
LineJoin,
LineMiterLimit,
LineRoundLimit
> {};
-class LinePaintProperties : public PaintProperties<
+class LinePaintProperties : public Properties<
LineOpacity,
LineColor,
LineTranslate,
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index fb31d97657..a17e34dd8a 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/raster_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp
index 219fe34d8c..732f5b2aff 100644
--- a/src/mbgl/style/layers/raster_layer_properties.hpp
+++ b/src/mbgl/style/layers/raster_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -38,7 +39,7 @@ struct RasterFadeDuration : PaintProperty<float> {
static float defaultValue() { return 300; }
};
-class RasterPaintProperties : public PaintProperties<
+class RasterPaintProperties : public Properties<
RasterOpacity,
RasterHueRotate,
RasterBrightnessMin,
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 75de1bb36b..4a3ad2ffcc 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>
-#include <mbgl/style/conversion/stringify.hpp>
#include <mbgl/style/layer_observer.hpp>
namespace mbgl {
@@ -34,7 +33,7 @@ std::unique_ptr<Layer> SymbolLayer::cloneRef(const std::string& id_) const {
}
void SymbolLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>& writer) const {
- conversion::stringify(writer, layout);
+ layout.stringify(writer);
}
// Source
@@ -98,14 +97,14 @@ PropertyValue<SymbolPlacementType> SymbolLayer::getDefaultSymbolPlacement() {
}
PropertyValue<SymbolPlacementType> SymbolLayer::getSymbolPlacement() const {
- return impl().layout.unevaluated.get<SymbolPlacement>();
+ return impl().layout.get<SymbolPlacement>();
}
void SymbolLayer::setSymbolPlacement(PropertyValue<SymbolPlacementType> value) {
if (value == getSymbolPlacement())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<SymbolPlacement>() = value;
+ impl_->layout.get<SymbolPlacement>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "symbol-placement");
}
@@ -114,14 +113,14 @@ PropertyValue<float> SymbolLayer::getDefaultSymbolSpacing() {
}
PropertyValue<float> SymbolLayer::getSymbolSpacing() const {
- return impl().layout.unevaluated.get<SymbolSpacing>();
+ return impl().layout.get<SymbolSpacing>();
}
void SymbolLayer::setSymbolSpacing(PropertyValue<float> value) {
if (value == getSymbolSpacing())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<SymbolSpacing>() = value;
+ impl_->layout.get<SymbolSpacing>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "symbol-spacing");
}
@@ -130,14 +129,14 @@ PropertyValue<bool> SymbolLayer::getDefaultSymbolAvoidEdges() {
}
PropertyValue<bool> SymbolLayer::getSymbolAvoidEdges() const {
- return impl().layout.unevaluated.get<SymbolAvoidEdges>();
+ return impl().layout.get<SymbolAvoidEdges>();
}
void SymbolLayer::setSymbolAvoidEdges(PropertyValue<bool> value) {
if (value == getSymbolAvoidEdges())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<SymbolAvoidEdges>() = value;
+ impl_->layout.get<SymbolAvoidEdges>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "symbol-avoid-edges");
}
@@ -146,14 +145,14 @@ PropertyValue<bool> SymbolLayer::getDefaultIconAllowOverlap() {
}
PropertyValue<bool> SymbolLayer::getIconAllowOverlap() const {
- return impl().layout.unevaluated.get<IconAllowOverlap>();
+ return impl().layout.get<IconAllowOverlap>();
}
void SymbolLayer::setIconAllowOverlap(PropertyValue<bool> value) {
if (value == getIconAllowOverlap())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconAllowOverlap>() = value;
+ impl_->layout.get<IconAllowOverlap>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-allow-overlap");
}
@@ -162,14 +161,14 @@ PropertyValue<bool> SymbolLayer::getDefaultIconIgnorePlacement() {
}
PropertyValue<bool> SymbolLayer::getIconIgnorePlacement() const {
- return impl().layout.unevaluated.get<IconIgnorePlacement>();
+ return impl().layout.get<IconIgnorePlacement>();
}
void SymbolLayer::setIconIgnorePlacement(PropertyValue<bool> value) {
if (value == getIconIgnorePlacement())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconIgnorePlacement>() = value;
+ impl_->layout.get<IconIgnorePlacement>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-ignore-placement");
}
@@ -178,14 +177,14 @@ PropertyValue<bool> SymbolLayer::getDefaultIconOptional() {
}
PropertyValue<bool> SymbolLayer::getIconOptional() const {
- return impl().layout.unevaluated.get<IconOptional>();
+ return impl().layout.get<IconOptional>();
}
void SymbolLayer::setIconOptional(PropertyValue<bool> value) {
if (value == getIconOptional())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconOptional>() = value;
+ impl_->layout.get<IconOptional>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-optional");
}
@@ -194,14 +193,14 @@ PropertyValue<AlignmentType> SymbolLayer::getDefaultIconRotationAlignment() {
}
PropertyValue<AlignmentType> SymbolLayer::getIconRotationAlignment() const {
- return impl().layout.unevaluated.get<IconRotationAlignment>();
+ return impl().layout.get<IconRotationAlignment>();
}
void SymbolLayer::setIconRotationAlignment(PropertyValue<AlignmentType> value) {
if (value == getIconRotationAlignment())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconRotationAlignment>() = value;
+ impl_->layout.get<IconRotationAlignment>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-rotation-alignment");
}
@@ -210,14 +209,14 @@ DataDrivenPropertyValue<float> SymbolLayer::getDefaultIconSize() {
}
DataDrivenPropertyValue<float> SymbolLayer::getIconSize() const {
- return impl().layout.unevaluated.get<IconSize>();
+ return impl().layout.get<IconSize>();
}
void SymbolLayer::setIconSize(DataDrivenPropertyValue<float> value) {
if (value == getIconSize())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconSize>() = value;
+ impl_->layout.get<IconSize>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-size");
}
@@ -226,14 +225,14 @@ PropertyValue<IconTextFitType> SymbolLayer::getDefaultIconTextFit() {
}
PropertyValue<IconTextFitType> SymbolLayer::getIconTextFit() const {
- return impl().layout.unevaluated.get<IconTextFit>();
+ return impl().layout.get<IconTextFit>();
}
void SymbolLayer::setIconTextFit(PropertyValue<IconTextFitType> value) {
if (value == getIconTextFit())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconTextFit>() = value;
+ impl_->layout.get<IconTextFit>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-text-fit");
}
@@ -242,14 +241,14 @@ PropertyValue<std::array<float, 4>> SymbolLayer::getDefaultIconTextFitPadding()
}
PropertyValue<std::array<float, 4>> SymbolLayer::getIconTextFitPadding() const {
- return impl().layout.unevaluated.get<IconTextFitPadding>();
+ return impl().layout.get<IconTextFitPadding>();
}
void SymbolLayer::setIconTextFitPadding(PropertyValue<std::array<float, 4>> value) {
if (value == getIconTextFitPadding())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconTextFitPadding>() = value;
+ impl_->layout.get<IconTextFitPadding>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-text-fit-padding");
}
@@ -258,14 +257,14 @@ DataDrivenPropertyValue<std::string> SymbolLayer::getDefaultIconImage() {
}
DataDrivenPropertyValue<std::string> SymbolLayer::getIconImage() const {
- return impl().layout.unevaluated.get<IconImage>();
+ return impl().layout.get<IconImage>();
}
void SymbolLayer::setIconImage(DataDrivenPropertyValue<std::string> value) {
if (value == getIconImage())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconImage>() = value;
+ impl_->layout.get<IconImage>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-image");
}
@@ -274,14 +273,14 @@ DataDrivenPropertyValue<float> SymbolLayer::getDefaultIconRotate() {
}
DataDrivenPropertyValue<float> SymbolLayer::getIconRotate() const {
- return impl().layout.unevaluated.get<IconRotate>();
+ return impl().layout.get<IconRotate>();
}
void SymbolLayer::setIconRotate(DataDrivenPropertyValue<float> value) {
if (value == getIconRotate())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconRotate>() = value;
+ impl_->layout.get<IconRotate>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-rotate");
}
@@ -290,14 +289,14 @@ PropertyValue<float> SymbolLayer::getDefaultIconPadding() {
}
PropertyValue<float> SymbolLayer::getIconPadding() const {
- return impl().layout.unevaluated.get<IconPadding>();
+ return impl().layout.get<IconPadding>();
}
void SymbolLayer::setIconPadding(PropertyValue<float> value) {
if (value == getIconPadding())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconPadding>() = value;
+ impl_->layout.get<IconPadding>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-padding");
}
@@ -306,14 +305,14 @@ PropertyValue<bool> SymbolLayer::getDefaultIconKeepUpright() {
}
PropertyValue<bool> SymbolLayer::getIconKeepUpright() const {
- return impl().layout.unevaluated.get<IconKeepUpright>();
+ return impl().layout.get<IconKeepUpright>();
}
void SymbolLayer::setIconKeepUpright(PropertyValue<bool> value) {
if (value == getIconKeepUpright())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconKeepUpright>() = value;
+ impl_->layout.get<IconKeepUpright>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-keep-upright");
}
@@ -322,14 +321,14 @@ DataDrivenPropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconOffset(
}
DataDrivenPropertyValue<std::array<float, 2>> SymbolLayer::getIconOffset() const {
- return impl().layout.unevaluated.get<IconOffset>();
+ return impl().layout.get<IconOffset>();
}
void SymbolLayer::setIconOffset(DataDrivenPropertyValue<std::array<float, 2>> value) {
if (value == getIconOffset())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<IconOffset>() = value;
+ impl_->layout.get<IconOffset>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "icon-offset");
}
@@ -338,14 +337,14 @@ PropertyValue<AlignmentType> SymbolLayer::getDefaultTextPitchAlignment() {
}
PropertyValue<AlignmentType> SymbolLayer::getTextPitchAlignment() const {
- return impl().layout.unevaluated.get<TextPitchAlignment>();
+ return impl().layout.get<TextPitchAlignment>();
}
void SymbolLayer::setTextPitchAlignment(PropertyValue<AlignmentType> value) {
if (value == getTextPitchAlignment())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextPitchAlignment>() = value;
+ impl_->layout.get<TextPitchAlignment>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-pitch-alignment");
}
@@ -354,14 +353,14 @@ PropertyValue<AlignmentType> SymbolLayer::getDefaultTextRotationAlignment() {
}
PropertyValue<AlignmentType> SymbolLayer::getTextRotationAlignment() const {
- return impl().layout.unevaluated.get<TextRotationAlignment>();
+ return impl().layout.get<TextRotationAlignment>();
}
void SymbolLayer::setTextRotationAlignment(PropertyValue<AlignmentType> value) {
if (value == getTextRotationAlignment())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextRotationAlignment>() = value;
+ impl_->layout.get<TextRotationAlignment>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-rotation-alignment");
}
@@ -370,14 +369,14 @@ DataDrivenPropertyValue<std::string> SymbolLayer::getDefaultTextField() {
}
DataDrivenPropertyValue<std::string> SymbolLayer::getTextField() const {
- return impl().layout.unevaluated.get<TextField>();
+ return impl().layout.get<TextField>();
}
void SymbolLayer::setTextField(DataDrivenPropertyValue<std::string> value) {
if (value == getTextField())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextField>() = value;
+ impl_->layout.get<TextField>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-field");
}
@@ -386,14 +385,14 @@ PropertyValue<std::vector<std::string>> SymbolLayer::getDefaultTextFont() {
}
PropertyValue<std::vector<std::string>> SymbolLayer::getTextFont() const {
- return impl().layout.unevaluated.get<TextFont>();
+ return impl().layout.get<TextFont>();
}
void SymbolLayer::setTextFont(PropertyValue<std::vector<std::string>> value) {
if (value == getTextFont())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextFont>() = value;
+ impl_->layout.get<TextFont>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-font");
}
@@ -402,14 +401,14 @@ DataDrivenPropertyValue<float> SymbolLayer::getDefaultTextSize() {
}
DataDrivenPropertyValue<float> SymbolLayer::getTextSize() const {
- return impl().layout.unevaluated.get<TextSize>();
+ return impl().layout.get<TextSize>();
}
void SymbolLayer::setTextSize(DataDrivenPropertyValue<float> value) {
if (value == getTextSize())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextSize>() = value;
+ impl_->layout.get<TextSize>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-size");
}
@@ -418,14 +417,14 @@ PropertyValue<float> SymbolLayer::getDefaultTextMaxWidth() {
}
PropertyValue<float> SymbolLayer::getTextMaxWidth() const {
- return impl().layout.unevaluated.get<TextMaxWidth>();
+ return impl().layout.get<TextMaxWidth>();
}
void SymbolLayer::setTextMaxWidth(PropertyValue<float> value) {
if (value == getTextMaxWidth())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextMaxWidth>() = value;
+ impl_->layout.get<TextMaxWidth>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-max-width");
}
@@ -434,14 +433,14 @@ PropertyValue<float> SymbolLayer::getDefaultTextLineHeight() {
}
PropertyValue<float> SymbolLayer::getTextLineHeight() const {
- return impl().layout.unevaluated.get<TextLineHeight>();
+ return impl().layout.get<TextLineHeight>();
}
void SymbolLayer::setTextLineHeight(PropertyValue<float> value) {
if (value == getTextLineHeight())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextLineHeight>() = value;
+ impl_->layout.get<TextLineHeight>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-line-height");
}
@@ -450,14 +449,14 @@ PropertyValue<float> SymbolLayer::getDefaultTextLetterSpacing() {
}
PropertyValue<float> SymbolLayer::getTextLetterSpacing() const {
- return impl().layout.unevaluated.get<TextLetterSpacing>();
+ return impl().layout.get<TextLetterSpacing>();
}
void SymbolLayer::setTextLetterSpacing(PropertyValue<float> value) {
if (value == getTextLetterSpacing())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextLetterSpacing>() = value;
+ impl_->layout.get<TextLetterSpacing>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-letter-spacing");
}
@@ -466,14 +465,14 @@ PropertyValue<TextJustifyType> SymbolLayer::getDefaultTextJustify() {
}
PropertyValue<TextJustifyType> SymbolLayer::getTextJustify() const {
- return impl().layout.unevaluated.get<TextJustify>();
+ return impl().layout.get<TextJustify>();
}
void SymbolLayer::setTextJustify(PropertyValue<TextJustifyType> value) {
if (value == getTextJustify())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextJustify>() = value;
+ impl_->layout.get<TextJustify>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-justify");
}
@@ -482,14 +481,14 @@ PropertyValue<TextAnchorType> SymbolLayer::getDefaultTextAnchor() {
}
PropertyValue<TextAnchorType> SymbolLayer::getTextAnchor() const {
- return impl().layout.unevaluated.get<TextAnchor>();
+ return impl().layout.get<TextAnchor>();
}
void SymbolLayer::setTextAnchor(PropertyValue<TextAnchorType> value) {
if (value == getTextAnchor())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextAnchor>() = value;
+ impl_->layout.get<TextAnchor>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-anchor");
}
@@ -498,14 +497,14 @@ PropertyValue<float> SymbolLayer::getDefaultTextMaxAngle() {
}
PropertyValue<float> SymbolLayer::getTextMaxAngle() const {
- return impl().layout.unevaluated.get<TextMaxAngle>();
+ return impl().layout.get<TextMaxAngle>();
}
void SymbolLayer::setTextMaxAngle(PropertyValue<float> value) {
if (value == getTextMaxAngle())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextMaxAngle>() = value;
+ impl_->layout.get<TextMaxAngle>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-max-angle");
}
@@ -514,14 +513,14 @@ DataDrivenPropertyValue<float> SymbolLayer::getDefaultTextRotate() {
}
DataDrivenPropertyValue<float> SymbolLayer::getTextRotate() const {
- return impl().layout.unevaluated.get<TextRotate>();
+ return impl().layout.get<TextRotate>();
}
void SymbolLayer::setTextRotate(DataDrivenPropertyValue<float> value) {
if (value == getTextRotate())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextRotate>() = value;
+ impl_->layout.get<TextRotate>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-rotate");
}
@@ -530,14 +529,14 @@ PropertyValue<float> SymbolLayer::getDefaultTextPadding() {
}
PropertyValue<float> SymbolLayer::getTextPadding() const {
- return impl().layout.unevaluated.get<TextPadding>();
+ return impl().layout.get<TextPadding>();
}
void SymbolLayer::setTextPadding(PropertyValue<float> value) {
if (value == getTextPadding())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextPadding>() = value;
+ impl_->layout.get<TextPadding>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-padding");
}
@@ -546,14 +545,14 @@ PropertyValue<bool> SymbolLayer::getDefaultTextKeepUpright() {
}
PropertyValue<bool> SymbolLayer::getTextKeepUpright() const {
- return impl().layout.unevaluated.get<TextKeepUpright>();
+ return impl().layout.get<TextKeepUpright>();
}
void SymbolLayer::setTextKeepUpright(PropertyValue<bool> value) {
if (value == getTextKeepUpright())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextKeepUpright>() = value;
+ impl_->layout.get<TextKeepUpright>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-keep-upright");
}
@@ -562,14 +561,14 @@ DataDrivenPropertyValue<TextTransformType> SymbolLayer::getDefaultTextTransform(
}
DataDrivenPropertyValue<TextTransformType> SymbolLayer::getTextTransform() const {
- return impl().layout.unevaluated.get<TextTransform>();
+ return impl().layout.get<TextTransform>();
}
void SymbolLayer::setTextTransform(DataDrivenPropertyValue<TextTransformType> value) {
if (value == getTextTransform())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextTransform>() = value;
+ impl_->layout.get<TextTransform>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-transform");
}
@@ -578,14 +577,14 @@ DataDrivenPropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextOffset(
}
DataDrivenPropertyValue<std::array<float, 2>> SymbolLayer::getTextOffset() const {
- return impl().layout.unevaluated.get<TextOffset>();
+ return impl().layout.get<TextOffset>();
}
void SymbolLayer::setTextOffset(DataDrivenPropertyValue<std::array<float, 2>> value) {
if (value == getTextOffset())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextOffset>() = value;
+ impl_->layout.get<TextOffset>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-offset");
}
@@ -594,14 +593,14 @@ PropertyValue<bool> SymbolLayer::getDefaultTextAllowOverlap() {
}
PropertyValue<bool> SymbolLayer::getTextAllowOverlap() const {
- return impl().layout.unevaluated.get<TextAllowOverlap>();
+ return impl().layout.get<TextAllowOverlap>();
}
void SymbolLayer::setTextAllowOverlap(PropertyValue<bool> value) {
if (value == getTextAllowOverlap())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextAllowOverlap>() = value;
+ impl_->layout.get<TextAllowOverlap>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-allow-overlap");
}
@@ -610,14 +609,14 @@ PropertyValue<bool> SymbolLayer::getDefaultTextIgnorePlacement() {
}
PropertyValue<bool> SymbolLayer::getTextIgnorePlacement() const {
- return impl().layout.unevaluated.get<TextIgnorePlacement>();
+ return impl().layout.get<TextIgnorePlacement>();
}
void SymbolLayer::setTextIgnorePlacement(PropertyValue<bool> value) {
if (value == getTextIgnorePlacement())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextIgnorePlacement>() = value;
+ impl_->layout.get<TextIgnorePlacement>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-ignore-placement");
}
@@ -626,14 +625,14 @@ PropertyValue<bool> SymbolLayer::getDefaultTextOptional() {
}
PropertyValue<bool> SymbolLayer::getTextOptional() const {
- return impl().layout.unevaluated.get<TextOptional>();
+ return impl().layout.get<TextOptional>();
}
void SymbolLayer::setTextOptional(PropertyValue<bool> value) {
if (value == getTextOptional())
return;
auto impl_ = mutableImpl();
- impl_->layout.unevaluated.get<TextOptional>() = value;
+ impl_->layout.get<TextOptional>() = value;
baseImpl = std::move(impl_);
observer->onLayerLayoutPropertyChanged(*this, "text-optional");
}
diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp
index d961dbb0b9..28760e1f74 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.hpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- SymbolLayoutProperties layout;
+ SymbolLayoutProperties::Unevaluated layout;
SymbolPaintProperties::Cascading paint;
};
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index 42f593890b..d484d699d7 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/programs/attributes.hpp>
namespace mbgl {
@@ -236,7 +237,7 @@ struct TextTranslateAnchor : PaintProperty<TranslateAnchorType> {
static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; }
};
-class SymbolLayoutProperties : public LayoutProperties<
+class SymbolLayoutProperties : public Properties<
SymbolPlacement,
SymbolSpacing,
SymbolAvoidEdges,
@@ -273,7 +274,7 @@ class SymbolLayoutProperties : public LayoutProperties<
TextOptional
> {};
-class SymbolPaintProperties : public PaintProperties<
+class SymbolPaintProperties : public Properties<
IconOpacity,
IconColor,
IconHaloColor,
diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp
index 3b9d6114c0..82a19e6a80 100644
--- a/src/mbgl/style/layout_property.hpp
+++ b/src/mbgl/style/layout_property.hpp
@@ -4,117 +4,30 @@
#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/renderer/property_evaluator.hpp>
#include <mbgl/renderer/data_driven_property_evaluator.hpp>
-#include <mbgl/util/indexed_tuple.hpp>
namespace mbgl {
-
-class PropertyEvaluationParameters;
-
namespace style {
template <class T>
class LayoutProperty {
public:
+ using CascadingType = std::nullptr_t;
using UnevaluatedType = PropertyValue<T>;
using EvaluatorType = PropertyEvaluator<T>;
using PossiblyEvaluatedType = T;
using Type = T;
+ static constexpr bool IsDataDriven = false;
};
template <class T>
class DataDrivenLayoutProperty {
public:
+ using CascadingType = std::nullptr_t;
using UnevaluatedType = DataDrivenPropertyValue<T>;
using EvaluatorType = DataDrivenPropertyEvaluator<T>;
using PossiblyEvaluatedType = PossiblyEvaluatedPropertyValue<T>;
using Type = T;
-};
-
-template <class... Ps>
-class LayoutProperties {
-public:
- using Properties = TypeList<Ps...>;
-
- template <class TypeList>
- using Tuple = IndexedTuple<Properties, TypeList>;
-
- /*
- For layout properties we implement a two step evaluation process: if you have a zoom level,
- you can evaluate a set of unevaluated property values, producing a set of possibly evaluated
- values, where undefined, constant, or camera function values have been fully evaluated, and
- source or composite function values have not.
-
- Once you also have a particular feature, you can evaluate that set of possibly evaluated values
- fully, producing a set of fully evaluated values.
-
- This is in theory maximally efficient in terms of avoiding repeated evaluation of camera
- functions, though it's more of a historical accident than a purposeful optimization.
- */
-
- using UnevaluatedTypes = TypeList<typename Ps::UnevaluatedType...>;
- using PossiblyEvaluatedTypes = TypeList<typename Ps::PossiblyEvaluatedType...>;
- using EvaluatedTypes = TypeList<typename Ps::Type...>;
-
- class Evaluated : public Tuple<EvaluatedTypes> {
- public:
- using Tuple<EvaluatedTypes>::Tuple;
- };
-
- class PossiblyEvaluated : public Tuple<PossiblyEvaluatedTypes> {
- public:
- using Tuple<PossiblyEvaluatedTypes>::Tuple;
-
- template <class T>
- static T evaluate(float, const GeometryTileFeature&, const T& t, const T&) {
- return t;
- }
-
- template <class T>
- static T evaluate(float z, const GeometryTileFeature& feature,
- const PossiblyEvaluatedPropertyValue<T>& v, const T& defaultValue) {
- return v.match(
- [&] (const T& t) {
- return t;
- },
- [&] (const SourceFunction<T>& t) {
- return t.evaluate(feature, defaultValue);
- },
- [&] (const CompositeFunction<T>& t) {
- return t.evaluate(z, feature, defaultValue);
- });
- }
-
- template <class P>
- auto evaluate(float z, const GeometryTileFeature& feature) const {
- return evaluate(z, feature, this->template get<P>(), P::defaultValue());
- }
-
- Evaluated evaluate(float z, const GeometryTileFeature& feature) const {
- return Evaluated {
- evaluate<Ps>(z, feature)...
- };
- }
- };
-
- class Unevaluated : public Tuple<UnevaluatedTypes> {
- public:
- using Tuple<UnevaluatedTypes>::Tuple;
- };
-
- template <class P>
- auto evaluate(const PropertyEvaluationParameters& parameters) const {
- using Evaluator = typename P::EvaluatorType;
- return unevaluated.template get<P>()
- .evaluate(Evaluator(parameters, P::defaultValue()));
- }
-
- PossiblyEvaluated evaluate(const PropertyEvaluationParameters& parameters) const {
- return PossiblyEvaluated {
- evaluate<Ps>(parameters)...
- };
- }
-
- Unevaluated unevaluated;
+ static constexpr bool IsDataDriven = true;
};
} // namespace style
diff --git a/src/mbgl/style/light_impl.hpp b/src/mbgl/style/light_impl.hpp
index 4179c2b276..7cf160f439 100644
--- a/src/mbgl/style/light_impl.hpp
+++ b/src/mbgl/style/light_impl.hpp
@@ -2,9 +2,10 @@
#include <mbgl/style/light.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/style/position.hpp>
+#include <mbgl/style/properties.hpp>
+#include <mbgl/renderer/property_evaluator.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/indexed_tuple.hpp>
@@ -14,11 +15,12 @@ namespace style {
template <class T>
class LightProperty {
public:
+ using CascadingType = Transitionable<PropertyValue<T>>;
+ using UnevaluatedType = Transitioning<PropertyValue<T>>;
+ using EvaluatorType = PropertyEvaluator<T>;
+ using PossiblyEvaluatedType = T;
using Type = T;
- using ValueType = PropertyValue<T>;
-
- PropertyValue<T> value;
- TransitionOptions transition;
+ static constexpr bool IsDataDriven = false;
};
struct LightAnchor : LightProperty<LightAnchorType> {
@@ -46,11 +48,11 @@ struct LightIntensity : LightProperty<float> {
}
};
-using LightProperties = TypeList<LightAnchor, LightPosition, LightColor, LightIntensity>;
+using LightProperties = Properties<LightAnchor, LightPosition, LightColor, LightIntensity>;
class Light::Impl {
public:
- IndexedTuple<LightProperties, LightProperties> properties;
+ LightProperties::Cascading properties;
};
} // namespace style
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index f1752e69d9..b0dc5641fb 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -1,186 +1,51 @@
#pragma once
-#include <mbgl/style/class_dictionary.hpp>
+#include <mbgl/style/properties.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/data_driven_property_value.hpp>
-#include <mbgl/style/transition_options.hpp>
#include <mbgl/renderer/property_evaluator.hpp>
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
#include <mbgl/renderer/data_driven_property_evaluator.hpp>
-#include <mbgl/renderer/property_evaluation_parameters.hpp>
-#include <mbgl/renderer/cascade_parameters.hpp>
-#include <mbgl/renderer/transitioning_property.hpp>
-#include <mbgl/renderer/paint_property_binder.hpp>
-#include <mbgl/util/constants.hpp>
-#include <mbgl/util/interpolate.hpp>
-#include <mbgl/util/indexed_tuple.hpp>
-#include <mbgl/util/ignore.hpp>
#include <utility>
namespace mbgl {
-
-class GeometryTileFeature;
-
namespace style {
-template <class Value>
-class CascadingPaintProperty {
-public:
- bool isUndefined() const {
- return values.find(ClassID::Default) == values.end();
- }
-
- const Value& get(const optional<std::string>& klass) const {
- static const Value staticValue{};
- const auto it = values.find(klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default);
- return it == values.end() ? staticValue : it->second;
- }
-
- void set(const Value& value_, const optional<std::string>& klass) {
- values[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = value_;
- }
-
- const TransitionOptions& getTransition(const optional<std::string>& klass) const {
- static const TransitionOptions staticValue{};
- const auto it = transitions.find(klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default);
- return it == transitions.end() ? staticValue : it->second;
- }
-
- void setTransition(const TransitionOptions& transition, const optional<std::string>& klass) {
- transitions[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = transition;
- }
-
- template <class TransitioningProperty>
- TransitioningProperty cascade(const CascadeParameters& params, TransitioningProperty prior) const {
- TransitionOptions transition;
- Value value;
-
- for (const auto classID : params.classes) {
- if (values.find(classID) != values.end()) {
- value = values.at(classID);
- break;
- }
- }
-
- for (const auto classID : params.classes) {
- if (transitions.find(classID) != transitions.end()) {
- transition = transitions.at(classID).reverseMerge(transition);
- break;
- }
- }
-
- return TransitioningProperty(std::move(value),
- std::move(prior),
- transition.reverseMerge(params.transition),
- params.now);
- }
-
-private:
- std::map<ClassID, Value> values;
- std::map<ClassID, TransitionOptions> transitions;
-};
-
template <class T>
class PaintProperty {
public:
- using ValueType = PropertyValue<T>;
- using CascadingType = CascadingPaintProperty<ValueType>;
- using UnevaluatedType = TransitioningProperty<ValueType>;
+ using CascadingType = Cascading<PropertyValue<T>>;
+ using UnevaluatedType = Transitioning<PropertyValue<T>>;
using EvaluatorType = PropertyEvaluator<T>;
- using EvaluatedType = T;
+ using PossiblyEvaluatedType = T;
+ using Type = T;
static constexpr bool IsDataDriven = false;
};
template <class T, class A>
class DataDrivenPaintProperty {
public:
- using ValueType = DataDrivenPropertyValue<T>;
- using CascadingType = CascadingPaintProperty<ValueType>;
- using UnevaluatedType = TransitioningProperty<ValueType>;
+ using CascadingType = Cascading<DataDrivenPropertyValue<T>>;
+ using UnevaluatedType = Transitioning<DataDrivenPropertyValue<T>>;
using EvaluatorType = DataDrivenPropertyEvaluator<T>;
- using EvaluatedType = PossiblyEvaluatedPropertyValue<T>;
+ using PossiblyEvaluatedType = PossiblyEvaluatedPropertyValue<T>;
+ using Type = T;
static constexpr bool IsDataDriven = true;
- using Type = T;
using Attribute = A;
};
template <class T>
class CrossFadedPaintProperty {
public:
- using ValueType = PropertyValue<T>;
- using CascadingType = CascadingPaintProperty<ValueType>;
- using UnevaluatedType = TransitioningProperty<ValueType>;
+ using CascadingType = Cascading<PropertyValue<T>>;
+ using UnevaluatedType = Transitioning<PropertyValue<T>>;
using EvaluatorType = CrossFadedPropertyEvaluator<T>;
- using EvaluatedType = Faded<T>;
+ using PossiblyEvaluatedType = Faded<T>;
+ using Type = T;
static constexpr bool IsDataDriven = false;
};
-template <class P>
-struct IsDataDriven : std::integral_constant<bool, P::IsDataDriven> {};
-
-template <class... Ps>
-class PaintProperties {
-public:
- using Properties = TypeList<Ps...>;
- using DataDrivenProperties = FilteredTypeList<Properties, IsDataDriven>;
- using Binders = PaintPropertyBinders<DataDrivenProperties>;
-
- using EvaluatedTypes = TypeList<typename Ps::EvaluatedType...>;
- using UnevaluatedTypes = TypeList<typename Ps::UnevaluatedType...>;
- using CascadingTypes = TypeList<typename Ps::CascadingType...>;
-
- template <class TypeList>
- using Tuple = IndexedTuple<Properties, TypeList>;
-
- class Evaluated : public Tuple<EvaluatedTypes> {
- public:
- using Tuple<EvaluatedTypes>::Tuple;
- };
-
- class Unevaluated : public Tuple<UnevaluatedTypes> {
- public:
- using Tuple<UnevaluatedTypes>::Tuple;
-
- bool hasTransition() const {
- bool result = false;
- util::ignore({ result |= this->template get<Ps>().hasTransition()... });
- return result;
- }
-
- template <class P>
- auto evaluate(const PropertyEvaluationParameters& parameters) {
- using Evaluator = typename P::EvaluatorType;
-
- return this->template get<P>().evaluate(
- Evaluator(parameters, P::defaultValue()),
- parameters.now
- );
- }
-
- Evaluated evaluate(const PropertyEvaluationParameters& parameters) {
- return Evaluated {
- evaluate<Ps>(parameters)...
- };
- }
-
- };
-
- class Cascading : public Tuple<CascadingTypes> {
- public:
- using Tuple<CascadingTypes>::Tuple;
-
- Unevaluated cascade(const CascadeParameters& parameters, Unevaluated&& prior) const {
- return Unevaluated {
- this->template get<Ps>().cascade(
- parameters,
- std::move(prior.template get<Ps>())
- )...
- };
- }
- };
-};
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/properties.hpp b/src/mbgl/style/properties.hpp
new file mode 100644
index 0000000000..c808554c93
--- /dev/null
+++ b/src/mbgl/style/properties.hpp
@@ -0,0 +1,268 @@
+#pragma once
+
+#include <mbgl/style/transition_options.hpp>
+#include <mbgl/style/conversion/stringify.hpp>
+#include <mbgl/renderer/cascade_parameters.hpp>
+#include <mbgl/renderer/paint_property_binder.hpp>
+#include <mbgl/renderer/property_evaluation_parameters.hpp>
+#include <mbgl/renderer/cascade_parameters.hpp>
+#include <mbgl/util/indexed_tuple.hpp>
+#include <mbgl/util/ignore.hpp>
+
+namespace mbgl {
+
+class GeometryTileFeature;
+
+namespace style {
+
+template <class Value>
+class Transitioning {
+public:
+ Transitioning() = default;
+
+ Transitioning(Value value_,
+ Transitioning<Value> prior_,
+ TransitionOptions transition,
+ TimePoint now)
+ : begin(now + transition.delay.value_or(Duration::zero())),
+ end(begin + transition.duration.value_or(Duration::zero())),
+ value(std::move(value_)) {
+ if (transition.isDefined()) {
+ prior = { std::move(prior_) };
+ }
+ }
+
+ template <class Evaluator>
+ auto evaluate(const Evaluator& evaluator, TimePoint now) const {
+ auto finalValue = value.evaluate(evaluator);
+ if (!prior) {
+ // No prior value.
+ return finalValue;
+ } else if (now >= end) {
+ // Transition from prior value is now complete.
+ prior = {};
+ return finalValue;
+ } else if (value.isDataDriven()) {
+ // Transitions to data-driven properties are not supported.
+ // We snap immediately to the data-driven value so that, when we perform layout,
+ // we see the data-driven function and can use it to populate vertex buffers.
+ prior = {};
+ return finalValue;
+ } else if (now < begin) {
+ // Transition hasn't started yet.
+ return prior->get().evaluate(evaluator, now);
+ } else {
+ // Interpolate between recursively-calculated prior value and final.
+ float t = std::chrono::duration<float>(now - begin) / (end - begin);
+ return util::interpolate(prior->get().evaluate(evaluator, now), finalValue,
+ util::DEFAULT_TRANSITION_EASE.solve(t, 0.001));
+ }
+ }
+
+ bool hasTransition() const {
+ return bool(prior);
+ }
+
+ bool isUndefined() const {
+ return value.isUndefined();
+ }
+
+ const Value& getValue() const {
+ return value;
+ }
+
+private:
+ mutable optional<mapbox::util::recursive_wrapper<Transitioning<Value>>> prior;
+ TimePoint begin;
+ TimePoint end;
+ Value value;
+};
+
+template <class Value>
+class Transitionable {
+public:
+ Value value;
+ TransitionOptions transition;
+
+ Transitioning<Value> cascade(const CascadeParameters& params, Transitioning<Value> prior) const {
+ return Transitioning<Value>(value,
+ std::move(prior),
+ transition.reverseMerge(params.transition),
+ params.now);
+ }
+};
+template <class Value>
+class Cascading {
+public:
+ bool isUndefined() const {
+ return values.find(ClassID::Default) == values.end();
+ }
+
+ const Value& get(const optional<std::string>& klass) const {
+ static const Value staticValue{};
+ const auto it = values.find(klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default);
+ return it == values.end() ? staticValue : it->second;
+ }
+
+ void set(const Value& value_, const optional<std::string>& klass) {
+ values[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = value_;
+ }
+
+ const TransitionOptions& getTransition(const optional<std::string>& klass) const {
+ static const TransitionOptions staticValue{};
+ const auto it = transitions.find(klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default);
+ return it == transitions.end() ? staticValue : it->second;
+ }
+
+ void setTransition(const TransitionOptions& transition, const optional<std::string>& klass) {
+ transitions[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = transition;
+ }
+
+ Transitioning<Value> cascade(const CascadeParameters& params, Transitioning<Value> prior) const {
+ TransitionOptions transition;
+ Value value;
+
+ for (const auto classID : params.classes) {
+ if (values.find(classID) != values.end()) {
+ value = values.at(classID);
+ break;
+ }
+ }
+
+ for (const auto classID : params.classes) {
+ if (transitions.find(classID) != transitions.end()) {
+ transition = transitions.at(classID).reverseMerge(transition);
+ break;
+ }
+ }
+
+ return Transitioning<Value>(std::move(value),
+ std::move(prior),
+ transition.reverseMerge(params.transition),
+ params.now);
+ }
+
+private:
+ std::map<ClassID, Value> values;
+ std::map<ClassID, TransitionOptions> transitions;
+};
+
+
+template <class P>
+struct IsDataDriven : std::integral_constant<bool, P::IsDataDriven> {};
+
+template <class... Ps>
+class Properties {
+public:
+ /*
+ For style properties we implement a two step evaluation process: if you have a zoom level,
+ you can evaluate a set of unevaluated property values, producing a set of possibly evaluated
+ values, where undefined, constant, or camera function values have been fully evaluated, and
+ source or composite function values have not.
+
+ Once you also have a particular feature, you can evaluate that set of possibly evaluated values
+ fully, producing a set of fully evaluated values.
+
+ This is in theory maximally efficient in terms of avoiding repeated evaluation of camera
+ functions, though it's more of a historical accident than a purposeful optimization.
+ */
+
+ using PropertyTypes = TypeList<Ps...>;
+ using CascadingTypes = TypeList<typename Ps::CascadingType...>;
+ using UnevaluatedTypes = TypeList<typename Ps::UnevaluatedType...>;
+ using PossiblyEvaluatedTypes = TypeList<typename Ps::PossiblyEvaluatedType...>;
+ using EvaluatedTypes = TypeList<typename Ps::Type...>;
+
+ using DataDrivenProperties = FilteredTypeList<PropertyTypes, IsDataDriven>;
+ using Binders = PaintPropertyBinders<DataDrivenProperties>;
+
+ template <class TypeList>
+ using Tuple = IndexedTuple<PropertyTypes, TypeList>;
+
+ class Evaluated : public Tuple<EvaluatedTypes> {
+ public:
+ using Tuple<EvaluatedTypes>::Tuple;
+ };
+
+ class PossiblyEvaluated : public Tuple<PossiblyEvaluatedTypes> {
+ public:
+ using Tuple<PossiblyEvaluatedTypes>::Tuple;
+
+ template <class T>
+ static T evaluate(float, const GeometryTileFeature&, const T& t, const T&) {
+ return t;
+ }
+
+ template <class T>
+ static T evaluate(float z, const GeometryTileFeature& feature,
+ const PossiblyEvaluatedPropertyValue<T>& v, const T& defaultValue) {
+ return v.match(
+ [&] (const T& t) {
+ return t;
+ },
+ [&] (const SourceFunction<T>& t) {
+ return t.evaluate(feature, defaultValue);
+ },
+ [&] (const CompositeFunction<T>& t) {
+ return t.evaluate(z, feature, defaultValue);
+ });
+ }
+
+ template <class P>
+ auto evaluate(float z, const GeometryTileFeature& feature) const {
+ return evaluate(z, feature, this->template get<P>(), P::defaultValue());
+ }
+
+ Evaluated evaluate(float z, const GeometryTileFeature& feature) const {
+ return Evaluated {
+ evaluate<Ps>(z, feature)...
+ };
+ }
+ };
+
+ class Unevaluated : public Tuple<UnevaluatedTypes> {
+ public:
+ using Tuple<UnevaluatedTypes>::Tuple;
+
+ bool hasTransition() const {
+ bool result = false;
+ util::ignore({ result |= this->template get<Ps>().hasTransition()... });
+ return result;
+ }
+
+ template <class P>
+ auto evaluate(const PropertyEvaluationParameters& parameters) const {
+ using Evaluator = typename P::EvaluatorType;
+ return this->template get<P>()
+ .evaluate(Evaluator(parameters, P::defaultValue()), parameters.now);
+ }
+
+ PossiblyEvaluated evaluate(const PropertyEvaluationParameters& parameters) const {
+ return PossiblyEvaluated {
+ evaluate<Ps>(parameters)...
+ };
+ }
+
+ template <class Writer>
+ void stringify(Writer& writer) const {
+ writer.StartObject();
+ util::ignore({ (conversion::stringify<Ps>(writer, this->template get<Ps>()), 0)... });
+ writer.EndObject();
+ }
+ };
+
+ class Cascading : public Tuple<CascadingTypes> {
+ public:
+ using Tuple<CascadingTypes>::Tuple;
+
+ Unevaluated cascade(const CascadeParameters& parameters, Unevaluated&& prior) const {
+ return Unevaluated {
+ this->template get<Ps>()
+ .cascade(parameters, std::move(prior.template get<Ps>()))...
+ };
+ }
+ };
+};
+
+} // namespace style
+} // namespace mbgl
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 256949af3b..7a76d289cf 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -584,7 +584,7 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions, float angle) const
result.order.emplace_back(*layer);
continue;
}
- const BackgroundPaintProperties::Evaluated& paint = background->evaluated;
+ const BackgroundPaintProperties::PossiblyEvaluated& paint = background->evaluated;
if (layerImpl.get() == layerImpls[0].get() && paint.get<BackgroundPattern>().from.empty()) {
// This is a solid background. We can use glClear().
result.backgroundColor = paint.get<BackgroundColor>() * paint.get<BackgroundOpacity>();
diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp
index 1dae20b26b..0b2940a0e0 100644
--- a/test/style/conversion/stringify.test.cpp
+++ b/test/style/conversion/stringify.test.cpp
@@ -121,10 +121,17 @@ TEST(Stringify, PropertyValue) {
}
TEST(Stringify, Layout) {
- ASSERT_EQ(stringify(SymbolLayoutProperties()), "{}");
-
- SymbolLayoutProperties layout;
- layout.unevaluated.get<SymbolAvoidEdges>() = true;
- layout.unevaluated.get<IconPadding>() = 2.0;
+ auto stringify = [] (const SymbolLayoutProperties::Unevaluated& layout) {
+ rapidjson::StringBuffer s;
+ rapidjson::Writer<rapidjson::StringBuffer> writer(s);
+ layout.stringify(writer);
+ return std::string(s.GetString());
+ };
+
+ ASSERT_EQ(stringify(SymbolLayoutProperties::Unevaluated()), "{}");
+
+ SymbolLayoutProperties::Unevaluated layout;
+ layout.get<SymbolAvoidEdges>() = true;
+ layout.get<IconPadding>() = 2.0;
ASSERT_EQ(stringify(layout), "{\"symbol-avoid-edges\":true,\"icon-padding\":2.0}");
}
diff --git a/test/style/paint_property.test.cpp b/test/style/properties.test.cpp
index fcca05f3bd..279fadb8c2 100644
--- a/test/style/paint_property.test.cpp
+++ b/test/style/properties.test.cpp
@@ -1,13 +1,14 @@
#include <mbgl/test/util.hpp>
-#include <mbgl/style/paint_property.hpp>
-#include <mbgl/renderer/transitioning_property.hpp>
+#include <mbgl/style/properties.hpp>
+#include <mbgl/renderer/property_evaluator.hpp>
+#include <mbgl/renderer/data_driven_property_evaluator.hpp>
using namespace mbgl;
using namespace mbgl::style;
using namespace std::literals::chrono_literals;
-float evaluate(TransitioningProperty<PropertyValue<float>>& property, Duration delta = Duration::zero()) {
+float evaluate(Transitioning<PropertyValue<float>>& property, Duration delta = Duration::zero()) {
ZoomHistory zoomHistory;
zoomHistory.update(0, TimePoint::min() + delta);
@@ -25,7 +26,7 @@ float evaluate(TransitioningProperty<PropertyValue<float>>& property, Duration d
return property.evaluate(evaluator, parameters.now);
}
-PossiblyEvaluatedPropertyValue<float> evaluate(TransitioningProperty<DataDrivenPropertyValue<float>>& property, Duration delta = Duration::zero()) {
+PossiblyEvaluatedPropertyValue<float> evaluate(Transitioning<DataDrivenPropertyValue<float>>& property, Duration delta = Duration::zero()) {
ZoomHistory zoomHistory;
zoomHistory.update(0, TimePoint::min() + delta);
@@ -43,15 +44,15 @@ PossiblyEvaluatedPropertyValue<float> evaluate(TransitioningProperty<DataDrivenP
return property.evaluate(evaluator, parameters.now);
}
-TEST(TransitioningProperty, EvaluateDefaultValue) {
- TransitioningProperty<PropertyValue<float>> property;
+TEST(TransitioningPropertyValue, EvaluateDefaultValue) {
+ Transitioning<PropertyValue<float>> property;
ASSERT_EQ(0.0f, evaluate(property));
}
-TEST(TransitioningProperty, EvaluateUntransitionedConstant) {
- TransitioningProperty<PropertyValue<float>> property {
+TEST(TransitioningPropertyValue, EvaluateUntransitionedConstant) {
+ Transitioning<PropertyValue<float>> property {
PropertyValue<float>(1.0f),
- TransitioningProperty<PropertyValue<float>>(),
+ Transitioning<PropertyValue<float>>(),
TransitionOptions(),
TimePoint::min()
};
@@ -59,18 +60,18 @@ TEST(TransitioningProperty, EvaluateUntransitionedConstant) {
ASSERT_EQ(1.0f, evaluate(property));
}
-TEST(TransitioningProperty, EvaluateTransitionedConstantWithoutDelay) {
+TEST(TransitioningPropertyValue, EvaluateTransitionedConstantWithoutDelay) {
TransitionOptions transition;
transition.duration = { 1000ms };
- TransitioningProperty<PropertyValue<float>> t0 {
+ Transitioning<PropertyValue<float>> t0 {
PropertyValue<float>(0.0f),
- TransitioningProperty<PropertyValue<float>>(),
+ Transitioning<PropertyValue<float>>(),
TransitionOptions(),
TimePoint::min()
};
- TransitioningProperty<PropertyValue<float>> t1 {
+ Transitioning<PropertyValue<float>> t1 {
PropertyValue<float>(1.0f),
t0,
transition,
@@ -82,19 +83,19 @@ TEST(TransitioningProperty, EvaluateTransitionedConstantWithoutDelay) {
ASSERT_FLOAT_EQ(1.0f, evaluate(t1, 1500ms));
}
-TEST(TransitioningProperty, EvaluateTransitionedConstantWithDelay) {
+TEST(TransitioningPropertyValue, EvaluateTransitionedConstantWithDelay) {
TransitionOptions transition;
transition.delay = { 1000ms };
transition.duration = { 1000ms };
- TransitioningProperty<PropertyValue<float>> t0 {
+ Transitioning<PropertyValue<float>> t0 {
PropertyValue<float>(0.0f),
- TransitioningProperty<PropertyValue<float>>(),
+ Transitioning<PropertyValue<float>>(),
TransitionOptions(),
TimePoint::min()
};
- TransitioningProperty<PropertyValue<float>> t1 {
+ Transitioning<PropertyValue<float>> t1 {
PropertyValue<float>(1.0f),
t0,
transition,
@@ -108,14 +109,14 @@ TEST(TransitioningProperty, EvaluateTransitionedConstantWithDelay) {
ASSERT_FLOAT_EQ(1.0f, evaluate(t1, 2500ms));
}
-TEST(TransitioningProperty, EvaluateDataDrivenValue) {
+TEST(TransitioningDataDrivenPropertyValue, Evaluate) {
TransitionOptions transition;
transition.delay = { 1000ms };
transition.duration = { 1000ms };
- TransitioningProperty<DataDrivenPropertyValue<float>> t0 {
+ Transitioning<DataDrivenPropertyValue<float>> t0 {
DataDrivenPropertyValue<float>(0.0f),
- TransitioningProperty<DataDrivenPropertyValue<float>>(),
+ Transitioning<DataDrivenPropertyValue<float>>(),
TransitionOptions(),
TimePoint::min()
};
@@ -125,7 +126,7 @@ TEST(TransitioningProperty, EvaluateDataDrivenValue) {
IdentityStops<float>()
};
- TransitioningProperty<DataDrivenPropertyValue<float>> t1 {
+ Transitioning<DataDrivenPropertyValue<float>> t1 {
DataDrivenPropertyValue<float>(sourceFunction),
t0,
transition,
diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp
index 2eafa4699e..03896199f4 100644
--- a/test/tile/vector_tile.test.cpp
+++ b/test/tile/vector_tile.test.cpp
@@ -68,7 +68,7 @@ TEST(VectorTile, Issue7615) {
style::SymbolLayoutProperties::PossiblyEvaluated(),
std::map<
std::string,
- std::pair<style::IconPaintProperties::Evaluated, style::TextPaintProperties::Evaluated>>(),
+ std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>>(),
16.0f, 1.0f, 0.0f, false, false);
// Simulate placement of a symbol layer.