diff options
-rwxr-xr-x | scripts/generate-style-code.js | 20 | ||||
-rw-r--r-- | src/mbgl/style/layers/layer_properties.hpp.ejs | 13 | ||||
-rw-r--r-- | src/mbgl/style/layers/line_layer_properties.hpp | 14 |
3 files changed, 27 insertions, 20 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 5145755cec..0bac355071 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -92,6 +92,7 @@ function attributeUniformType(property, type) { 'icon-halo-width': ['halo_width'], 'line-gap-width': ['gapwidth'], 'line-pattern': ['pattern_to', 'pattern_from'], + 'line-floor-width': ['floorwidth'], 'fill-pattern': ['pattern_to', 'pattern_from'], 'fill-extrusion-pattern': ['pattern_to', 'pattern_from'] } @@ -196,6 +197,14 @@ const layerCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer.cpp.ej const propertiesHpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer_properties.hpp.ejs', 'utf8'), {strict: true}); const propertiesCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer_properties.cpp.ejs', 'utf8'), {strict: true}); +// Add this mock property that our SDF line shader needs so that it gets added to the list of +// "data driven" properties. +spec.paint_line['line-floor-width'] = { + "type": "number", + "default": 1, + "property-type": "data-driven" +}; + const layers = Object.keys(spec.layer.type.values).map((type) => { const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => { if (name !== 'visibility') { @@ -224,11 +233,16 @@ const layers = Object.keys(spec.layer.type.values).map((type) => { for (const layer of layers) { 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/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer)); writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer)); + + // Remove our fake property for the external interace. + if (layer.type === 'line') { + layer.paintProperties = layer.paintProperties.filter(property => property.name !== 'line-floor-width'); + } + + writeIfModified(`include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer)); + writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer)); } // Light diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs index 11a1db33c7..277cfd173b 100644 --- a/src/mbgl/style/layers/layer_properties.hpp.ejs +++ b/src/mbgl/style/layers/layer_properties.hpp.ejs @@ -33,19 +33,15 @@ struct <%- camelize(property.name) %> : ColorRampProperty { <% } else { -%> struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %> { static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; } +<% if (property.name === 'line-floor-width') { -%> + using EvaluatorType = DataDrivenPropertyEvaluator<float, true>; +<% } -%> <% if (isOverridable(property)) { -%> static constexpr const char *name() { return "<%- property.name %>"; } static constexpr auto expressionType() { return expression::type::<%- expressionType(property) %>{}; }; template<typename T> static bool hasOverride(const T& t) { return !!t.<%- camelizeWithLeadingLowercase(property.name) %>; }; <% } -%> }; -<% if (property.name === 'line-width') { -%> - -struct LineFloorWidth : DataDrivenPaintProperty<float, attributes::floorwidth, uniforms::floorwidth> { - using EvaluatorType = DataDrivenPropertyEvaluator<float, true>; - static float defaultValue() { return 1.0f; } -}; -<% } -%> <% } -%> <% } -%> @@ -61,9 +57,6 @@ class <%- camelize(type) %>LayoutProperties : public Properties< class <%- camelize(type) %>PaintProperties : public Properties< <% for (const property of paintProperties.slice(0, -1)) { -%> <%- camelize(property.name) %>, -<% if (property.name === 'line-width') { -%> - LineFloorWidth, -<% } -%> <% } -%> <%- camelize(paintProperties.slice(-1)[0].name) %> > {}; diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp index 5fcbecf3be..24a6c13675 100644 --- a/src/mbgl/style/layers/line_layer_properties.hpp +++ b/src/mbgl/style/layers/line_layer_properties.hpp @@ -54,11 +54,6 @@ struct LineWidth : DataDrivenPaintProperty<float, attributes::width, uniforms::w static float defaultValue() { return 1; } }; -struct LineFloorWidth : DataDrivenPaintProperty<float, attributes::floorwidth, uniforms::floorwidth> { - using EvaluatorType = DataDrivenPropertyEvaluator<float, true>; - static float defaultValue() { return 1.0f; } -}; - struct LineGapWidth : DataDrivenPaintProperty<float, attributes::gapwidth, uniforms::gapwidth> { static float defaultValue() { return 0; } }; @@ -82,6 +77,11 @@ struct LinePattern : CrossFadedDataDrivenPaintProperty<std::string, attributes:: struct LineGradient : ColorRampProperty { }; +struct LineFloorWidth : DataDrivenPaintProperty<float, attributes::floorwidth, uniforms::floorwidth> { + static float defaultValue() { return 1; } + using EvaluatorType = DataDrivenPropertyEvaluator<float, true>; +}; + class LineLayoutProperties : public Properties< LineCap, LineJoin, @@ -95,13 +95,13 @@ class LinePaintProperties : public Properties< LineTranslate, LineTranslateAnchor, LineWidth, - LineFloorWidth, LineGapWidth, LineOffset, LineBlur, LineDasharray, LinePattern, - LineGradient + LineGradient, + LineFloorWidth > {}; class LineLayerProperties final : public LayerProperties { |