diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-12-08 12:09:21 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-12-09 09:35:21 -0800 |
commit | 3b2a4216a2e3929a557dbddd0d239758641c285f (patch) | |
tree | fc30966e6d1253e040b6092f1c53eb2fd22632e7 | |
parent | 4a2f53e6e51b4759cacd89790db99783bf211343 (diff) | |
download | qtlocation-mapboxgl-3b2a4216a2e3929a557dbddd0d239758641c285f.tar.gz |
[core] Implement circle-stroke properties
Also includes stubs for fill-extrusion layer, because most of the code was auto-generated.
21 files changed, 471 insertions, 18 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 6a87be8b5f..c9e581737f 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -265,6 +265,7 @@ set(MBGL_CORE_FILES include/mbgl/style/layers/background_layer.hpp include/mbgl/style/layers/circle_layer.hpp include/mbgl/style/layers/custom_layer.hpp + include/mbgl/style/layers/fill_extrusion_layer.hpp include/mbgl/style/layers/fill_layer.hpp include/mbgl/style/layers/line_layer.hpp include/mbgl/style/layers/raster_layer.hpp @@ -282,6 +283,11 @@ set(MBGL_CORE_FILES src/mbgl/style/layers/custom_layer.cpp src/mbgl/style/layers/custom_layer_impl.cpp src/mbgl/style/layers/custom_layer_impl.hpp + src/mbgl/style/layers/fill_extrusion_layer.cpp + src/mbgl/style/layers/fill_extrusion_layer_impl.cpp + src/mbgl/style/layers/fill_extrusion_layer_impl.hpp + src/mbgl/style/layers/fill_extrusion_layer_properties.cpp + src/mbgl/style/layers/fill_extrusion_layer_properties.hpp src/mbgl/style/layers/fill_layer.cpp src/mbgl/style/layers/fill_layer_impl.cpp src/mbgl/style/layers/fill_layer_impl.hpp diff --git a/include/mbgl/style/conversion/make_property_setters.hpp b/include/mbgl/style/conversion/make_property_setters.hpp index a3ba5e5d5a..e30359937e 100644 --- a/include/mbgl/style/conversion/make_property_setters.hpp +++ b/include/mbgl/style/conversion/make_property_setters.hpp @@ -8,6 +8,7 @@ #include <mbgl/style/layers/line_layer.hpp> #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/style/layers/circle_layer.hpp> +#include <mbgl/style/layers/fill_extrusion_layer.hpp> #include <mbgl/style/layers/raster_layer.hpp> #include <mbgl/style/layers/background_layer.hpp> @@ -67,6 +68,7 @@ auto makeLayoutPropertySetters() { + return result; } @@ -115,6 +117,17 @@ auto makePaintPropertySetters() { result["circle-translate"] = makePropertySetter<V>(&CircleLayer::setCircleTranslate); result["circle-translate-anchor"] = makePropertySetter<V>(&CircleLayer::setCircleTranslateAnchor); result["circle-pitch-scale"] = makePropertySetter<V>(&CircleLayer::setCirclePitchScale); + result["circle-stroke-width"] = makePropertySetter<V>(&CircleLayer::setCircleStrokeWidth); + result["circle-stroke-color"] = makePropertySetter<V>(&CircleLayer::setCircleStrokeColor); + result["circle-stroke-opacity"] = makePropertySetter<V>(&CircleLayer::setCircleStrokeOpacity); + + result["fill-extrusion-opacity"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionOpacity); + result["fill-extrusion-color"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionColor); + result["fill-extrusion-translate"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionTranslate); + result["fill-extrusion-translate-anchor"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionTranslateAnchor); + result["fill-extrusion-pattern"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionPattern); + result["fill-extrusion-height"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionHeight); + result["fill-extrusion-base"] = makePropertySetter<V>(&FillExtrusionLayer::setFillExtrusionBase); result["raster-opacity"] = makePropertySetter<V>(&RasterLayer::setRasterOpacity); result["raster-hue-rotate"] = makePropertySetter<V>(&RasterLayer::setRasterHueRotate); diff --git a/include/mbgl/style/conversion/make_property_setters.hpp.ejs b/include/mbgl/style/conversion/make_property_setters.hpp.ejs index 54e3958180..ed8f6e891c 100644 --- a/include/mbgl/style/conversion/make_property_setters.hpp.ejs +++ b/include/mbgl/style/conversion/make_property_setters.hpp.ejs @@ -5,7 +5,7 @@ #include <mbgl/style/conversion/property_setter.hpp> <% for (const layer of locals.layers) { -%> -#include <mbgl/style/layers/<%- layer.type %>_layer.hpp> +#include <mbgl/style/layers/<%- layer.type.replace('-', '_') %>_layer.hpp> <% } -%> #include <unordered_map> diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 925629a349..dc02cb09b2 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -15,6 +15,7 @@ class SymbolLayer; class RasterLayer; class BackgroundLayer; class CustomLayer; +class FillExtrusionLayer; /** * The runtime representation of a [layer](https://www.mapbox.com/mapbox-gl-style-spec/#layers) from the Mapbox Style @@ -42,6 +43,7 @@ protected: Raster, Background, Custom, + FillExtrusion, }; class Impl; @@ -95,6 +97,8 @@ public: return visitor(*as<BackgroundLayer>()); case Type::Custom: return visitor(*as<CustomLayer>()); + case Type::FillExtrusion: + return visitor(*as<FillExtrusionLayer>()); } } diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp index 587f0023e3..5562126c2f 100644 --- a/include/mbgl/style/layers/circle_layer.hpp +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -54,6 +54,18 @@ public: PropertyValue<CirclePitchScaleType> getCirclePitchScale(const optional<std::string>& klass = {}) const; void setCirclePitchScale(PropertyValue<CirclePitchScaleType>, const optional<std::string>& klass = {}); + static PropertyValue<float> getDefaultCircleStrokeWidth(); + PropertyValue<float> getCircleStrokeWidth(const optional<std::string>& klass = {}) const; + void setCircleStrokeWidth(PropertyValue<float>, const optional<std::string>& klass = {}); + + static PropertyValue<Color> getDefaultCircleStrokeColor(); + PropertyValue<Color> getCircleStrokeColor(const optional<std::string>& klass = {}) const; + void setCircleStrokeColor(PropertyValue<Color>, const optional<std::string>& klass = {}); + + static PropertyValue<float> getDefaultCircleStrokeOpacity(); + PropertyValue<float> getCircleStrokeOpacity(const optional<std::string>& klass = {}) const; + void setCircleStrokeOpacity(PropertyValue<float>, const optional<std::string>& klass = {}); + // Private implementation class Impl; diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp new file mode 100644 index 0000000000..08728af309 --- /dev/null +++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp @@ -0,0 +1,72 @@ +// This file is generated. Do not edit. + +#pragma once + +#include <mbgl/style/layer.hpp> +#include <mbgl/style/filter.hpp> +#include <mbgl/style/property_value.hpp> + +#include <mbgl/util/color.hpp> + +namespace mbgl { +namespace style { + +class FillExtrusionLayer : public Layer { +public: + FillExtrusionLayer(const std::string& layerID, const std::string& sourceID); + ~FillExtrusionLayer() final; + + // Source + const std::string& getSourceID() const; + const std::string& getSourceLayer() const; + void setSourceLayer(const std::string& sourceLayer); + + void setFilter(const Filter&); + const Filter& getFilter() const; + + // Paint properties + + static PropertyValue<float> getDefaultFillExtrusionOpacity(); + PropertyValue<float> getFillExtrusionOpacity(const optional<std::string>& klass = {}) const; + void setFillExtrusionOpacity(PropertyValue<float>, const optional<std::string>& klass = {}); + + static PropertyValue<Color> getDefaultFillExtrusionColor(); + PropertyValue<Color> getFillExtrusionColor(const optional<std::string>& klass = {}) const; + void setFillExtrusionColor(PropertyValue<Color>, const optional<std::string>& klass = {}); + + static PropertyValue<std::array<float, 2>> getDefaultFillExtrusionTranslate(); + PropertyValue<std::array<float, 2>> getFillExtrusionTranslate(const optional<std::string>& klass = {}) const; + void setFillExtrusionTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {}); + + static PropertyValue<TranslateAnchorType> getDefaultFillExtrusionTranslateAnchor(); + PropertyValue<TranslateAnchorType> getFillExtrusionTranslateAnchor(const optional<std::string>& klass = {}) const; + void setFillExtrusionTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {}); + + static PropertyValue<std::string> getDefaultFillExtrusionPattern(); + PropertyValue<std::string> getFillExtrusionPattern(const optional<std::string>& klass = {}) const; + void setFillExtrusionPattern(PropertyValue<std::string>, const optional<std::string>& klass = {}); + + static PropertyValue<float> getDefaultFillExtrusionHeight(); + PropertyValue<float> getFillExtrusionHeight(const optional<std::string>& klass = {}) const; + void setFillExtrusionHeight(PropertyValue<float>, const optional<std::string>& klass = {}); + + static PropertyValue<float> getDefaultFillExtrusionBase(); + PropertyValue<float> getFillExtrusionBase(const optional<std::string>& klass = {}) const; + void setFillExtrusionBase(PropertyValue<float>, const optional<std::string>& klass = {}); + + // Private implementation + + class Impl; + Impl* const impl; + + FillExtrusionLayer(const Impl&); + FillExtrusionLayer(const FillExtrusionLayer&) = delete; +}; + +template <> +inline bool Layer::is<FillExtrusionLayer>() const { + return type == Type::FillExtrusion; +} + +} // namespace style +} // namespace mbgl diff --git a/package.json b/package.json index 8c7700d385..4037efe631 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "ejs": "^2.4.1", "express": "^4.11.1", "lodash": "^4.16.4", - "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#597115a1e1bd982944b068f8accde34eada74fc2", - "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#7f62a4fc9f21e619824d68abbc4b03cbc1685572", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#0c6f3e00193248474349cd730e232eb5ffcd9bf4", + "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#b51b85ffb8c512e228c36c5405293ce51d123519", + "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#deb30918f8637e7675a00731b799a5caec894b17", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#9252ffc5108131704b5acf52d78258ac05687871", "mkdirp": "^0.5.1", "node-cmake": "^1.2.1", "request": "^2.72.0", diff --git a/platform/android/src/style/layers/layer.cpp.ejs b/platform/android/src/style/layers/layer.cpp.ejs index e802fb6bd2..500c76ea7a 100644 --- a/platform/android/src/style/layers/layer.cpp.ejs +++ b/platform/android/src/style/layers/layer.cpp.ejs @@ -4,7 +4,7 @@ -%> // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. -#include "<%- type %>_layer.hpp" +#include "<%- type.replace('-', '_') %>_layer.hpp" #include <string> diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 005bc022df..f2acb12a2a 100644 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -3,12 +3,12 @@ const fs = require('fs'); const ejs = require('ejs'); const spec = require('mapbox-gl-style-spec').latest; -var colorParser = require('csscolorparser'); +const colorParser = require('csscolorparser'); require('./style-code'); function parseCSSColor(str) { - var color = colorParser.parseCSSColor(str); + const color = colorParser.parseCSSColor(str); return [ color[0] / 255 * color[3], color[1] / 255 * color[3], color[2] / 255 * color[3], color[3] ]; @@ -40,7 +40,7 @@ global.propertyType = function (property) { } default: throw new Error(`unknown type for ${property.name}`) } -} +}; global.defaultValue = function (property) { // https://github.com/mapbox/mapbox-gl-native/issues/5258 @@ -64,7 +64,7 @@ global.defaultValue = function (property) { return `${propertyType(property)}::${camelize(property.default)}`; } case 'color': - var color = parseCSSColor(property.default).join(', '); + const color = parseCSSColor(property.default).join(', '); switch (color) { case '0, 0, 0, 0': return '{}'; @@ -85,7 +85,7 @@ global.defaultValue = function (property) { default: return property.default; } -} +}; const layerHpp = ejs.compile(fs.readFileSync('include/mbgl/style/layers/layer.hpp.ejs', 'utf8'), {strict: true}); const layerCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer.cpp.ejs', 'utf8'), {strict: true}); @@ -118,11 +118,13 @@ const layers = Object.keys(spec.layer.type.values).map((type) => { }); for (const layer of layers) { - writeIfModified(`include/mbgl/style/layers/${layer.type}_layer.hpp`, layerHpp(layer)); - writeIfModified(`src/mbgl/style/layers/${layer.type}_layer.cpp`, layerCpp(layer)); + const layerFileName = layer.type.replace('-', '_'); + + writeIfModified(`include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer)); + writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer)); - writeIfModified(`src/mbgl/style/layers/${layer.type}_layer_properties.hpp`, propertiesHpp(layer)); - writeIfModified(`src/mbgl/style/layers/${layer.type}_layer_properties.cpp`, propertiesCpp(layer)); + writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer)); + writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer)); } const propertySettersHpp = ejs.compile(fs.readFileSync('include/mbgl/style/conversion/make_property_setters.hpp.ejs', 'utf8'), {strict: true}); diff --git a/src/mbgl/programs/circle_program.hpp b/src/mbgl/programs/circle_program.hpp index 6b713bb41c..c9aea1d137 100644 --- a/src/mbgl/programs/circle_program.hpp +++ b/src/mbgl/programs/circle_program.hpp @@ -10,6 +10,9 @@ namespace mbgl { namespace uniforms { MBGL_DEFINE_UNIFORM_SCALAR(float, u_radius); +MBGL_DEFINE_UNIFORM_SCALAR(Color, u_stroke_color); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_stroke_width); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_stroke_opacity); MBGL_DEFINE_UNIFORM_SCALAR(bool, u_scale_with_map); } // namespace uniforms @@ -26,6 +29,9 @@ class CircleProgram : public Program< uniforms::u_color, uniforms::u_radius, uniforms::u_blur, + uniforms::u_stroke_color, + uniforms::u_stroke_width, + uniforms::u_stroke_opacity, uniforms::u_scale_with_map, uniforms::u_extrude_scale>> { diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp index 0767a50943..9385b7b1a3 100644 --- a/src/mbgl/renderer/painter_circle.cpp +++ b/src/mbgl/renderer/painter_circle.cpp @@ -41,6 +41,9 @@ void Painter::renderCircle(PaintParameters& parameters, uniforms::u_color::Value{ properties.get<CircleColor>() }, uniforms::u_radius::Value{ properties.get<CircleRadius>() }, uniforms::u_blur::Value{ properties.get<CircleBlur>() }, + uniforms::u_stroke_color::Value{ properties.get<CircleStrokeColor>() }, + uniforms::u_stroke_width::Value{ properties.get<CircleStrokeWidth>() }, + uniforms::u_stroke_opacity::Value{ properties.get<CircleStrokeOpacity>() }, uniforms::u_scale_with_map::Value{ scaleWithMap }, uniforms::u_extrude_scale::Value{ scaleWithMap ? std::array<float, 2> {{ diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index ce01a12ff2..e3a506e895 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -167,5 +167,50 @@ void CircleLayer::setCirclePitchScale(PropertyValue<CirclePitchScaleType> value, impl->observer->onLayerPaintPropertyChanged(*this); } +PropertyValue<float> CircleLayer::getDefaultCircleStrokeWidth() { + return { 0 }; +} + +PropertyValue<float> CircleLayer::getCircleStrokeWidth(const optional<std::string>& klass) const { + return impl->paint.get<CircleStrokeWidth>(klass); +} + +void CircleLayer::setCircleStrokeWidth(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getCircleStrokeWidth(klass)) + return; + impl->paint.set<CircleStrokeWidth>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<Color> CircleLayer::getDefaultCircleStrokeColor() { + return { Color::black() }; +} + +PropertyValue<Color> CircleLayer::getCircleStrokeColor(const optional<std::string>& klass) const { + return impl->paint.get<CircleStrokeColor>(klass); +} + +void CircleLayer::setCircleStrokeColor(PropertyValue<Color> value, const optional<std::string>& klass) { + if (value == getCircleStrokeColor(klass)) + return; + impl->paint.set<CircleStrokeColor>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<float> CircleLayer::getDefaultCircleStrokeOpacity() { + return { 1 }; +} + +PropertyValue<float> CircleLayer::getCircleStrokeOpacity(const optional<std::string>& klass) const { + return impl->paint.get<CircleStrokeOpacity>(klass); +} + +void CircleLayer::setCircleStrokeOpacity(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getCircleStrokeOpacity(klass)) + return; + impl->paint.set<CircleStrokeOpacity>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp index b7f279de4b..ea36b31949 100644 --- a/src/mbgl/style/layers/circle_layer_properties.hpp +++ b/src/mbgl/style/layers/circle_layer_properties.hpp @@ -37,6 +37,18 @@ struct CirclePitchScale : PaintProperty<CirclePitchScaleType> { static CirclePitchScaleType defaultValue() { return CirclePitchScaleType::Map; } }; +struct CircleStrokeWidth : PaintProperty<float> { + static float defaultValue() { return 0; } +}; + +struct CircleStrokeColor : PaintProperty<Color> { + static Color defaultValue() { return Color::black(); } +}; + +struct CircleStrokeOpacity : PaintProperty<float> { + static float defaultValue() { return 1; } +}; + class CirclePaintProperties : public PaintProperties< CircleRadius, CircleColor, @@ -44,7 +56,10 @@ class CirclePaintProperties : public PaintProperties< CircleOpacity, CircleTranslate, CircleTranslateAnchor, - CirclePitchScale + CirclePitchScale, + CircleStrokeWidth, + CircleStrokeColor, + CircleStrokeOpacity > {}; } // namespace style diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp new file mode 100644 index 0000000000..64efb1dd6a --- /dev/null +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -0,0 +1,171 @@ +// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. + +#include <mbgl/style/layers/fill_extrusion_layer.hpp> +#include <mbgl/style/layers/fill_extrusion_layer_impl.hpp> + +namespace mbgl { +namespace style { + +FillExtrusionLayer::FillExtrusionLayer(const std::string& layerID, const std::string& sourceID) + : Layer(Type::FillExtrusion, std::make_unique<Impl>()) + , impl(static_cast<Impl*>(baseImpl.get())) { + impl->id = layerID; + impl->source = sourceID; +} + +FillExtrusionLayer::FillExtrusionLayer(const Impl& other) + : Layer(Type::FillExtrusion, std::make_unique<Impl>(other)) + , impl(static_cast<Impl*>(baseImpl.get())) { +} + +FillExtrusionLayer::~FillExtrusionLayer() = default; + +std::unique_ptr<Layer> FillExtrusionLayer::Impl::clone() const { + return std::make_unique<FillExtrusionLayer>(*this); +} + +std::unique_ptr<Layer> FillExtrusionLayer::Impl::cloneRef(const std::string& id_) const { + auto result = std::make_unique<FillExtrusionLayer>(*this); + result->impl->id = id_; + result->impl->ref = this->id; + result->impl->paint = FillExtrusionPaintProperties(); + return std::move(result); +} + +// Source + +const std::string& FillExtrusionLayer::getSourceID() const { + return impl->source; +} + +void FillExtrusionLayer::setSourceLayer(const std::string& sourceLayer) { + impl->sourceLayer = sourceLayer; +} + +const std::string& FillExtrusionLayer::getSourceLayer() const { + return impl->sourceLayer; +} + +// Filter + +void FillExtrusionLayer::setFilter(const Filter& filter) { + impl->filter = filter; + impl->observer->onLayerFilterChanged(*this); +} + +const Filter& FillExtrusionLayer::getFilter() const { + return impl->filter; +} + +// Layout properties + + +// Paint properties + +PropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionOpacity() { + return { 1 }; +} + +PropertyValue<float> FillExtrusionLayer::getFillExtrusionOpacity(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionOpacity>(klass); +} + +void FillExtrusionLayer::setFillExtrusionOpacity(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getFillExtrusionOpacity(klass)) + return; + impl->paint.set<FillExtrusionOpacity>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<Color> FillExtrusionLayer::getDefaultFillExtrusionColor() { + return { Color::black() }; +} + +PropertyValue<Color> FillExtrusionLayer::getFillExtrusionColor(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionColor>(klass); +} + +void FillExtrusionLayer::setFillExtrusionColor(PropertyValue<Color> value, const optional<std::string>& klass) { + if (value == getFillExtrusionColor(klass)) + return; + impl->paint.set<FillExtrusionColor>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<std::array<float, 2>> FillExtrusionLayer::getDefaultFillExtrusionTranslate() { + return { {{ 0, 0 }} }; +} + +PropertyValue<std::array<float, 2>> FillExtrusionLayer::getFillExtrusionTranslate(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionTranslate>(klass); +} + +void FillExtrusionLayer::setFillExtrusionTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) { + if (value == getFillExtrusionTranslate(klass)) + return; + impl->paint.set<FillExtrusionTranslate>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<TranslateAnchorType> FillExtrusionLayer::getDefaultFillExtrusionTranslateAnchor() { + return { TranslateAnchorType::Map }; +} + +PropertyValue<TranslateAnchorType> FillExtrusionLayer::getFillExtrusionTranslateAnchor(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionTranslateAnchor>(klass); +} + +void FillExtrusionLayer::setFillExtrusionTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) { + if (value == getFillExtrusionTranslateAnchor(klass)) + return; + impl->paint.set<FillExtrusionTranslateAnchor>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<std::string> FillExtrusionLayer::getDefaultFillExtrusionPattern() { + return { "" }; +} + +PropertyValue<std::string> FillExtrusionLayer::getFillExtrusionPattern(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionPattern>(klass); +} + +void FillExtrusionLayer::setFillExtrusionPattern(PropertyValue<std::string> value, const optional<std::string>& klass) { + if (value == getFillExtrusionPattern(klass)) + return; + impl->paint.set<FillExtrusionPattern>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionHeight() { + return { 0 }; +} + +PropertyValue<float> FillExtrusionLayer::getFillExtrusionHeight(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionHeight>(klass); +} + +void FillExtrusionLayer::setFillExtrusionHeight(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getFillExtrusionHeight(klass)) + return; + impl->paint.set<FillExtrusionHeight>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +PropertyValue<float> FillExtrusionLayer::getDefaultFillExtrusionBase() { + return { 0 }; +} + +PropertyValue<float> FillExtrusionLayer::getFillExtrusionBase(const optional<std::string>& klass) const { + return impl->paint.get<FillExtrusionBase>(klass); +} + +void FillExtrusionLayer::setFillExtrusionBase(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getFillExtrusionBase(klass)) + return; + impl->paint.set<FillExtrusionBase>(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); +} + +} // namespace style +} // namespace mbgl diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp new file mode 100644 index 0000000000..239f7754d0 --- /dev/null +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp @@ -0,0 +1,19 @@ +#include <mbgl/style/layers/fill_extrusion_layer_impl.hpp> +#include <mbgl/renderer/bucket.hpp> + +namespace mbgl { +namespace style { + +void FillExtrusionLayer::Impl::cascade(const CascadeParameters&) { +} + +bool FillExtrusionLayer::Impl::evaluate(const PropertyEvaluationParameters&) { + return false; +} + +std::unique_ptr<Bucket> FillExtrusionLayer::Impl::createBucket(BucketParameters&) const { + return nullptr; +} + +} // namespace style +} // namespace mbgl diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp new file mode 100644 index 0000000000..79ae02dd5b --- /dev/null +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include <mbgl/style/layer_impl.hpp> +#include <mbgl/style/layers/fill_extrusion_layer.hpp> +#include <mbgl/style/layers/fill_extrusion_layer_properties.hpp> + +namespace mbgl { +namespace style { + +class FillExtrusionLayer::Impl : public Layer::Impl { +public: + std::unique_ptr<Layer> clone() const override; + std::unique_ptr<Layer> cloneRef(const std::string& id) const override; + + void cascade(const CascadeParameters&) override; + bool evaluate(const PropertyEvaluationParameters&) override; + + std::unique_ptr<Bucket> createBucket(BucketParameters&) const override; + + FillExtrusionPaintProperties paint; +}; + +} // namespace style +} // namespace mbgl diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp new file mode 100644 index 0000000000..59572bd3ab --- /dev/null +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.cpp @@ -0,0 +1,9 @@ +// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. + +#include <mbgl/style/layers/fill_extrusion_layer_properties.hpp> + +namespace mbgl { +namespace style { + +} // namespace style +} // namespace mbgl diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp new file mode 100644 index 0000000000..a2d01199a5 --- /dev/null +++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp @@ -0,0 +1,51 @@ +// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. + +#pragma once + +#include <mbgl/style/types.hpp> +#include <mbgl/style/layout_property.hpp> +#include <mbgl/style/paint_property.hpp> + +namespace mbgl { +namespace style { + +struct FillExtrusionOpacity : PaintProperty<float> { + static float defaultValue() { return 1; } +}; + +struct FillExtrusionColor : PaintProperty<Color> { + static Color defaultValue() { return Color::black(); } +}; + +struct FillExtrusionTranslate : PaintProperty<std::array<float, 2>> { + static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; } +}; + +struct FillExtrusionTranslateAnchor : PaintProperty<TranslateAnchorType> { + static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; } +}; + +struct FillExtrusionPattern : CrossFadedPaintProperty<std::string> { + static std::string defaultValue() { return ""; } +}; + +struct FillExtrusionHeight : PaintProperty<float> { + static float defaultValue() { return 0; } +}; + +struct FillExtrusionBase : PaintProperty<float> { + static float defaultValue() { return 0; } +}; + +class FillExtrusionPaintProperties : public PaintProperties< + FillExtrusionOpacity, + FillExtrusionColor, + FillExtrusionTranslate, + FillExtrusionTranslateAnchor, + FillExtrusionPattern, + FillExtrusionHeight, + FillExtrusionBase +> {}; + +} // namespace style +} // namespace mbgl diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index dcc78bafe5..5fe78519ec 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -5,8 +5,8 @@ -%> // This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. -#include <mbgl/style/layers/<%- type %>_layer.hpp> -#include <mbgl/style/layers/<%- type %>_layer_impl.hpp> +#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp> +#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer_impl.hpp> namespace mbgl { namespace style { diff --git a/src/mbgl/style/layers/layer_properties.cpp.ejs b/src/mbgl/style/layers/layer_properties.cpp.ejs index 3b287decc0..e5523e5439 100644 --- a/src/mbgl/style/layers/layer_properties.cpp.ejs +++ b/src/mbgl/style/layers/layer_properties.cpp.ejs @@ -5,7 +5,7 @@ -%> // This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. -#include <mbgl/style/layers/<%- type %>_layer_properties.hpp> +#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer_properties.hpp> namespace mbgl { namespace style { diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index f16e8f1856..b1cf174bdb 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -8,6 +8,7 @@ #include <mbgl/style/layers/background_layer.hpp> #include <mbgl/style/layers/background_layer_impl.hpp> #include <mbgl/style/layers/fill_layer.hpp> +#include <mbgl/style/layers/fill_extrusion_layer.hpp> #include <mbgl/style/layers/line_layer.hpp> #include <mbgl/style/layers/circle_layer.hpp> #include <mbgl/style/layers/raster_layer.hpp> |