summaryrefslogtreecommitdiff
path: root/scripts/generate-style-code.js
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-05-02 15:16:09 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-05-02 17:44:18 +0200
commita48152a9811a856e467eff3e396a76a059558fb1 (patch)
tree6217f11a8ea4804ddac4e843793c91b7dd33aeb2 /scripts/generate-style-code.js
parent989bf69c3b1cd34e2636b2b8ed5a095308640eb0 (diff)
downloadqtlocation-mapboxgl-a48152a9811a856e467eff3e396a76a059558fb1.tar.gz
[build] change special casing for LineFloorWidth in shader generation
Diffstat (limited to 'scripts/generate-style-code.js')
-rwxr-xr-xscripts/generate-style-code.js20
1 files changed, 17 insertions, 3 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