diff options
author | Lauren Budorick <lauren@mapbox.com> | 2018-04-16 17:38:53 -0700 |
---|---|---|
committer | Lauren Budorick <lauren@mapbox.com> | 2018-04-17 14:50:09 -0700 |
commit | 24b113983aad64692dc257582e4c4584af47557f (patch) | |
tree | e9a906b4befda306cc68f1b40705af716cf6733e | |
parent | 4c1ed22efaa6cf6db9fe8a1e98e173ef99f601a5 (diff) | |
download | qtlocation-mapboxgl-upstream/lb-release-boba-gljs-pin.tar.gz |
Bump gl-js pin: ignore line-gradient properties + shaders, use new expression style-spec taxonomyupstream/lb-release-boba-gljs-pin
m--------- | mapbox-gl-js | 0 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java | 20 | ||||
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs | 2 | ||||
-rwxr-xr-x | platform/android/scripts/generate-style-code.js | 13 | ||||
-rwxr-xr-x | platform/darwin/scripts/generate-style-code.js | 11 | ||||
-rw-r--r-- | platform/darwin/src/MGLFillStyleLayer.h | 3 | ||||
-rw-r--r-- | platform/darwin/src/MGLLineStyleLayer.h | 5 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 4 | ||||
-rw-r--r-- | platform/darwin/test/MGLStyleLayerTests.mm.ejs | 10 | ||||
-rwxr-xr-x | scripts/generate-shaders.js | 2 | ||||
-rwxr-xr-x | scripts/generate-style-code.js | 5 | ||||
-rw-r--r-- | src/mbgl/shaders/line.cpp | 3 | ||||
-rw-r--r-- | test/style/expression/expression.test.cpp | 7 |
13 files changed, 56 insertions, 29 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js -Subproject 6b96d69ab54b149db1f6ef06daed37379ac0744 +Subproject cd3241fa2f82bf6512ff54e7a03f4bbf2bdfb06 diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java index 4289deeda3..1dd8eddab9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java @@ -166,7 +166,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param value a String value * @return property wrapper around String @@ -176,7 +176,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param expression an expression statement * @return property wrapper around an expression statement @@ -356,7 +356,7 @@ public class PropertyFactory { } /** - * Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to density-independent pixels, multiply the length by the current line width. + * Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to density-independent pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param value a Float[] value * @return property wrapper around Float[] @@ -366,7 +366,7 @@ public class PropertyFactory { } /** - * Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to density-independent pixels, multiply the length by the current line width. + * Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to density-independent pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param expression an expression statement * @return property wrapper around an expression statement @@ -376,7 +376,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param value a String value * @return property wrapper around String @@ -386,7 +386,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param expression an expression statement * @return property wrapper around an expression statement @@ -1156,7 +1156,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param value a String value * @return property wrapper around String @@ -1166,7 +1166,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param expression an expression statement * @return property wrapper around an expression statement @@ -1536,7 +1536,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param value a String value * @return property wrapper around String @@ -1546,7 +1546,7 @@ public class PropertyFactory { } /** - * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). + * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels. * * @param expression an expression statement * @return property wrapper around an expression statement diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs index 935813899f..5f9bc26b82 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs @@ -188,4 +188,4 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest { <% } -%> <% } -%> <% } -%> -}
\ No newline at end of file +} diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js index 3b0363cc19..fd0f316157 100755 --- a/platform/android/scripts/generate-style-code.js +++ b/platform/android/scripts/generate-style-code.js @@ -29,6 +29,9 @@ var layers = Object.keys(spec.layer.type.values).map((type) => { }, []); const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => { + // not yet implemented + if (name === 'line-gradient') return memo; + spec[`paint_${type}`][name].name = name; memo.push(spec[`paint_${type}`][name]); return memo; @@ -268,9 +271,13 @@ global.propertyValueDoc = function (property, value) { }; global.isDataDriven = function (property) { - return property['property-function'] === true; + return property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven'; }; +global.isInterpolable = function(property) { + return property.expression && property.expression.interpolated; +} + global.isLightProperty = function (property) { return property['light-property'] === true; }; @@ -318,11 +325,11 @@ global.evaluatedType = function (property) { }; global.supportsZoomFunction = function (property) { - return property['zoom-function'] === true; + return property.expression && property.expression.parameters.indexOf('zoom') > -1; }; global.supportsPropertyFunction = function (property) { - return property['property-function'] === true; + return property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven'; }; // Template processing // diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 9ea5dd3e80..caa4028071 100755 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -319,9 +319,9 @@ global.propertyDoc = function (propertyName, property, layerType, kind) { '* Conditional expressions\n' + '* Variable assignments and references to assigned variables\n'; const inputVariable = property.name === 'heatmap-color' ? '$heatmapDensity' : '$zoomLevel'; - if (property["property-function"]) { + if (isDataDriven(property)) { doc += `* Interpolation and step functions applied to the \`${inputVariable}\` variable and/or feature attributes\n`; - } else if (property.function === "interpolated") { + } else if (property.expression && property.expression.interpolated) { doc += `* Interpolation and step functions applied to the \`${inputVariable}\` variable\n\n` + 'This property does not support applying interpolation or step functions to feature attributes.'; } else { @@ -332,6 +332,10 @@ global.propertyDoc = function (propertyName, property, layerType, kind) { return doc; }; +global.isDataDriven = function (property) { + return property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven'; +}; + global.propertyReqs = function (property, propertiesByName, type) { return 'This property is only applied to the style if ' + property.requires.map(function (req) { if (typeof req === 'string') { @@ -647,6 +651,9 @@ const layers = _(spec.layer.type.values).map((value, layerType) => { }, []); const paintProperties = Object.keys(spec[`paint_${layerType}`]).reduce((memo, name) => { + // not yet implemented + if (name === 'line-gradient') return memo; + spec[`paint_${layerType}`][name].name = name; memo.push(spec[`paint_${layerType}`][name]); return memo; diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index a159a924e6..90740223eb 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -218,7 +218,8 @@ MGL_EXPORT /** Name of image in sprite to use for drawing image fills. For seamless patterns, - image width and height must be a factor of two (2, 4, 8, ..., 512). + image width and height must be a factor of two (2, 4, 8, ..., 512). Note that + zoom-dependent expressions will be evaluated only at integer zoom levels. You can set this property to an expression containing any of the following: diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index a7510142fc..32c8ece6c5 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -302,7 +302,10 @@ MGL_EXPORT /** Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash - length to points, multiply the length by the current line width. + length to points, multiply the length by the current line width. Note that + GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to + the expected scale. Also note that zoom-dependent expressions will be evaluated + only at integer zoom levels. This property is measured in line widths. diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 42940083b5..3792906a53 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -121,7 +121,7 @@ namespace mbgl { - (void)set<%- camelize(property.name) %>:(NSExpression *)<%- objCName(property) %> { MGLAssertStyleLayerIsValid(); -<% if (property["property-function"]) { -%> +<% if (isDataDriven(property)) { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue<mbgl::style::DataDrivenPropertyValue<<%- valueTransformerArguments(property)[0] %>>>(<%- objCName(property) %>); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue<mbgl::style::PropertyValue<<%- valueTransformerArguments(property)[0] %>>>(<%- objCName(property) %>); @@ -164,7 +164,7 @@ namespace mbgl { <% if (property.name === 'heatmap-color') { -%> auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::HeatmapColorPropertyValue>(heatmapColor); -<% } else if (property["property-function"]) { -%> +<% } else if (isDataDriven(property)) { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue<mbgl::style::DataDrivenPropertyValue<<%- valueTransformerArguments(property)[0] %>>>(<%- objCName(property) %>); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue<mbgl::style::PropertyValue<<%- valueTransformerArguments(property)[0] %>>>(<%- objCName(property) %>); diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs index f70f0bba23..0266a033ee 100644 --- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs +++ b/platform/darwin/test/MGLStyleLayerTests.mm.ejs @@ -69,7 +69,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, type, true, 3) %>]; layer.<%- objCName(property) %> = constantExpression; -<% if (property["property-function"]) { -%> +<% if (isDataDriven(property)) { -%> mbgl::style::DataDrivenPropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> }; <% } else { -%> mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> }; @@ -88,13 +88,13 @@ { 18, <%- mbglTestValue(property, type) %> }, }}; propertyValue = mbgl::style::CameraFunction<<%- mbglType(property) %>> { intervalStops }; - + XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue, @"Setting <%- objCName(property) %> to a camera expression should update <%- originalPropertyName(property) %>."); XCTAssertEqualObjects(layer.<%- objCName(property) %>, functionExpression, @"<%- objCName(property) %> should round-trip camera expressions."); -<% if (property["property-function"] && isInterpolatable(property)) { -%> +<% if (isDataDriven(property) && isInterpolatable(property)) { -%> functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; layer.<%- objCName(property) %> = functionExpression; @@ -120,7 +120,7 @@ pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; XCTAssertEqualObjects(layer.<%- objCName(property) %>, pedanticFunctionExpression, @"<%- objCName(property) %> should round-trip camera-data expressions."); -<% } -%> +<% } -%> <% if (!property.required) { -%> layer.<%- objCName(property) %> = nil; @@ -129,7 +129,7 @@ XCTAssertEqualObjects(layer.<%- objCName(property) %>, defaultExpression, @"<%- objCName(property) %> should return the default value after being unset."); <% } -%> -<% if (!property["property-function"]) { -%> +<% if (!isDataDriven(property)) { -%> functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; XCTAssertThrowsSpecificNamed(layer.<%- objCName(property) %> = functionExpression, NSException, NSInvalidArgumentException, @"MGL<%- camelize(type) %>Layer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js index b1eeffb8a0..dbc8cdb302 100755 --- a/scripts/generate-shaders.js +++ b/scripts/generate-shaders.js @@ -42,7 +42,7 @@ ${shaders.prelude.fragmentSource} `); for (const key in shaders) { - if (key === 'prelude') + if (key === 'prelude' || key === 'lineGradient') continue; const shaderName = key.replace(/[A-Z]+/g, (match) => `_${match.toLowerCase()}`); diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 6ddb787f19..3cd5166ce5 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -16,7 +16,7 @@ function parseCSSColor(str) { } global.isDataDriven = function (property) { - return property['property-function'] === true; + return property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven'; }; global.isLightProperty = function (property) { @@ -168,6 +168,9 @@ const layers = Object.keys(spec.layer.type.values).map((type) => { }, []); const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => { + // not yet implemented + if (name === 'line-gradient') return memo; + spec[`paint_${type}`][name].name = name; memo.push(spec[`paint_${type}`][name]); return memo; diff --git a/src/mbgl/shaders/line.cpp b/src/mbgl/shaders/line.cpp index c700295a15..68d2dcc468 100644 --- a/src/mbgl/shaders/line.cpp +++ b/src/mbgl/shaders/line.cpp @@ -31,6 +31,7 @@ uniform vec2 u_gl_units_to_pixels; varying vec2 v_normal; varying vec2 v_width2; varying float v_gamma_scale; +varying highp float v_linesofar; #ifndef HAS_UNIFORM_u_color @@ -131,6 +132,8 @@ void main() { vec2 a_extrude = a_data.xy - 128.0; float a_direction = mod(a_data.z, 4.0) - 1.0; + v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0; + vec2 pos = a_pos_normal.xy; // x is 1 if it's a round cap, 0 otherwise diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp index fe5c261be1..2b3c8b038c 100644 --- a/test/style/expression/expression.test.cpp +++ b/test/style/expression/expression.test.cpp @@ -24,11 +24,14 @@ TEST(Expression, IsExpression) { spec["expression_name"].IsObject() && spec["expression_name"].HasMember("values") && spec["expression_name"]["values"].IsObject()); - + const auto& allExpressions = spec["expression_name"]["values"]; - + for(auto& entry : allExpressions.GetObject()) { const std::string name { entry.name.GetString(), entry.name.GetStringLength() }; + if (name == "line-progress") continue; + if (name == "collator") continue; + if (name == "resolved-locale") continue; JSDocument document; document.Parse<0>(R"([")" + name + R"("])"); |