From cf85873f365e5baee73de0fb33113cd7bb134a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Sun, 4 Jun 2017 23:17:59 +0200 Subject: [PATCH] [core] add uniforms to DataDrivenPaintPropertys --- src/mbgl/programs/uniforms.hpp | 14 ++++++++++++- .../style/layers/circle_layer_properties.hpp | 15 ++++++------- .../fill_extrusion_layer_properties.hpp | 7 ++++--- .../style/layers/fill_layer_properties.hpp | 7 ++++--- .../style/layers/line_layer_properties.hpp | 11 +++++----- .../style/layers/symbol_layer_properties.hpp | 21 ++++++++++--------- src/mbgl/style/paint_property.hpp | 3 ++- 7 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/mbgl/programs/uniforms.hpp b/src/mbgl/programs/uniforms.hpp index 972405d5a..60a50a7cb 100644 --- a/src/mbgl/programs/uniforms.hpp +++ b/src/mbgl/programs/uniforms.hpp @@ -16,7 +16,19 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_blur); MBGL_DEFINE_UNIFORM_SCALAR(float, u_zoom); MBGL_DEFINE_UNIFORM_SCALAR(float, u_pitch); MBGL_DEFINE_UNIFORM_SCALAR(float, u_bearing); - +MBGL_DEFINE_UNIFORM_SCALAR(float, u_radius); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_stroke_width); +MBGL_DEFINE_UNIFORM_SCALAR(Color, u_stroke_color); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_stroke_opacity); +MBGL_DEFINE_UNIFORM_SCALAR(Color, u_fill_color); +MBGL_DEFINE_UNIFORM_SCALAR(Color, u_halo_color); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_halo_width); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_halo_blur); +MBGL_DEFINE_UNIFORM_SCALAR(Color, u_outline_color); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_height); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_base); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_gap_width); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_offset); MBGL_DEFINE_UNIFORM_SCALAR(Size, u_world); MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_extrude_scale); diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp index 1cb4f5a63..58206c61d 100644 --- a/src/mbgl/style/layers/circle_layer_properties.hpp +++ b/src/mbgl/style/layers/circle_layer_properties.hpp @@ -6,23 +6,24 @@ #include #include #include +#include namespace mbgl { namespace style { -struct CircleRadius : DataDrivenPaintProperty { +struct CircleRadius : DataDrivenPaintProperty { static float defaultValue() { return 5; } }; -struct CircleColor : DataDrivenPaintProperty { +struct CircleColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; -struct CircleBlur : DataDrivenPaintProperty { +struct CircleBlur : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; -struct CircleOpacity : DataDrivenPaintProperty { +struct CircleOpacity : DataDrivenPaintProperty { static float defaultValue() { return 1; } }; @@ -38,15 +39,15 @@ struct CirclePitchScale : PaintProperty { static CirclePitchScaleType defaultValue() { return CirclePitchScaleType::Map; } }; -struct CircleStrokeWidth : DataDrivenPaintProperty { +struct CircleStrokeWidth : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; -struct CircleStrokeColor : DataDrivenPaintProperty { +struct CircleStrokeColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; -struct CircleStrokeOpacity : DataDrivenPaintProperty { +struct CircleStrokeOpacity : DataDrivenPaintProperty { static float defaultValue() { return 1; } }; diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp index c1dd3b079..f41ce68b9 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -14,7 +15,7 @@ struct FillExtrusionOpacity : PaintProperty { static float defaultValue() { return 1; } }; -struct FillExtrusionColor : DataDrivenPaintProperty { +struct FillExtrusionColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; @@ -30,11 +31,11 @@ struct FillExtrusionPattern : CrossFadedPaintProperty { static std::string defaultValue() { return ""; } }; -struct FillExtrusionHeight : DataDrivenPaintProperty { +struct FillExtrusionHeight : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; -struct FillExtrusionBase : DataDrivenPaintProperty { +struct FillExtrusionBase : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp index f44a18d0e..ee1e5158c 100644 --- a/src/mbgl/style/layers/fill_layer_properties.hpp +++ b/src/mbgl/style/layers/fill_layer_properties.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -14,15 +15,15 @@ struct FillAntialias : PaintProperty { static bool defaultValue() { return true; } }; -struct FillOpacity : DataDrivenPaintProperty { +struct FillOpacity : DataDrivenPaintProperty { static float defaultValue() { return 1; } }; -struct FillColor : DataDrivenPaintProperty { +struct FillColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; -struct FillOutlineColor : DataDrivenPaintProperty { +struct FillOutlineColor : DataDrivenPaintProperty { static Color defaultValue() { return {}; } }; diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp index 724026e3a..0b234921a 100644 --- a/src/mbgl/style/layers/line_layer_properties.hpp +++ b/src/mbgl/style/layers/line_layer_properties.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -30,11 +31,11 @@ struct LineRoundLimit : LayoutProperty { static float defaultValue() { return 1; } }; -struct LineOpacity : DataDrivenPaintProperty { +struct LineOpacity : DataDrivenPaintProperty { static float defaultValue() { return 1; } }; -struct LineColor : DataDrivenPaintProperty { +struct LineColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; @@ -50,15 +51,15 @@ struct LineWidth : PaintProperty { static float defaultValue() { return 1; } }; -struct LineGapWidth : DataDrivenPaintProperty { +struct LineGapWidth : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; -struct LineOffset : DataDrivenPaintProperty> { +struct LineOffset : DataDrivenPaintProperty, uniforms::u_offset> { static float defaultValue() { return 0; } }; -struct LineBlur : DataDrivenPaintProperty { +struct LineBlur : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index 42f593890..5b5717578 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -180,23 +181,23 @@ struct TextOptional : LayoutProperty { static bool defaultValue() { return false; } }; -struct IconOpacity : DataDrivenPaintProperty { +struct IconOpacity : DataDrivenPaintProperty { static float defaultValue() { return 1; } }; -struct IconColor : DataDrivenPaintProperty { +struct IconColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; -struct IconHaloColor : DataDrivenPaintProperty { +struct IconHaloColor : DataDrivenPaintProperty { static Color defaultValue() { return {}; } }; -struct IconHaloWidth : DataDrivenPaintProperty { +struct IconHaloWidth : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; -struct IconHaloBlur : DataDrivenPaintProperty { +struct IconHaloBlur : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; @@ -208,23 +209,23 @@ struct IconTranslateAnchor : PaintProperty { static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; } }; -struct TextOpacity : DataDrivenPaintProperty { +struct TextOpacity : DataDrivenPaintProperty { static float defaultValue() { return 1; } }; -struct TextColor : DataDrivenPaintProperty { +struct TextColor : DataDrivenPaintProperty { static Color defaultValue() { return Color::black(); } }; -struct TextHaloColor : DataDrivenPaintProperty { +struct TextHaloColor : DataDrivenPaintProperty { static Color defaultValue() { return {}; } }; -struct TextHaloWidth : DataDrivenPaintProperty { +struct TextHaloWidth : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; -struct TextHaloBlur : DataDrivenPaintProperty { +struct TextHaloBlur : DataDrivenPaintProperty { static float defaultValue() { return 0; } }; diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index f1752e69d..c203083c4 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -92,7 +92,7 @@ public: static constexpr bool IsDataDriven = false; }; -template +template class DataDrivenPaintProperty { public: using ValueType = DataDrivenPropertyValue; @@ -104,6 +104,7 @@ public: using Type = T; using Attribute = A; + using Uniform = U; }; template