Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] update mapbox-gl-js submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPaczos committed Apr 12, 2018
1 parent ff11cb2 commit d36ace4
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 69 files
+4 −4 build/generate-style-code.js
+1 −0 debug/canvas.html
+78 −0 debug/line-gradient.html
+32 −0 debug/mobile_scroll.html
+1 −0 docs/documentation.yml
+2 −67 docs/pages/style-spec.js
+4 −10 flow-typed/style-spec.js
+1 −1 package.json
+84 −22 src/data/bucket/line_bucket.js
+14 −1 src/render/draw_line.js
+4 −0 src/shaders/index.js
+3 −0 src/shaders/line.vertex.glsl
+34 −0 src/shaders/line_gradient.fragment.glsl
+84 −0 src/shaders/line_gradient.vertex.glsl
+43 −4 src/source/canvas_source.js
+2 −1 src/source/geojson_source.js
+1 −0 src/source/image_source.js
+7 −6 src/style-spec/error/validation_error.js
+5 −0 src/style-spec/expression/definitions/index.js
+2 −1 src/style-spec/expression/index.js
+1 −1 src/style-spec/expression/parsing_context.js
+39 −37 src/style-spec/reference/v8.json
+1 −1 src/style-spec/validate/validate_function.js
+3 −0 src/style-spec/validate/validate_layer.js
+3 −8 src/style-spec/validate/validate_source.js
+13 −8 src/style/properties.js
+8 −2 src/style/style.js
+1 −1 src/style/style_layer/background_style_layer_properties.js
+1 −1 src/style/style_layer/circle_style_layer_properties.js
+1 −1 src/style/style_layer/fill_extrusion_style_layer_properties.js
+1 −1 src/style/style_layer/fill_style_layer_properties.js
+2 −12 src/style/style_layer/heatmap_style_layer.js
+3 −3 src/style/style_layer/heatmap_style_layer_properties.js
+1 −1 src/style/style_layer/hillshade_style_layer_properties.js
+1 −1 src/style/style_layer/layer_properties.js.ejs
+19 −0 src/style/style_layer/line_style_layer.js
+3 −1 src/style/style_layer/line_style_layer_properties.js
+1 −1 src/style/style_layer/raster_style_layer_properties.js
+1 −1 src/style/style_layer/symbol_style_layer_properties.js
+8 −7 src/style/validate_style.js
+9 −2 src/ui/bind_handlers.js
+2 −1 src/ui/map.js
+28 −0 src/util/color_ramp.js
+2 −0 src/util/evented.js
+ test/integration/render-tests/line-gradient/gradient/expected.png
+82 −0 test/integration/render-tests/line-gradient/gradient/style.json
+ test/integration/render-tests/line-gradient/translucent/expected.png
+83 −0 test/integration/render-tests/line-gradient/translucent/style.json
+ test/integration/render-tests/zoom-visibility/above/expected.png
+46 −0 test/integration/render-tests/zoom-visibility/above/style.json
+ test/integration/render-tests/zoom-visibility/below/expected.png
+46 −0 test/integration/render-tests/zoom-visibility/below/style.json
+ test/integration/render-tests/zoom-visibility/in-range/expected.png
+53 −0 test/integration/render-tests/zoom-visibility/in-range/style.json
+ test/integration/render-tests/zoom-visibility/out-of-range/expected.png
+53 −0 test/integration/render-tests/zoom-visibility/out-of-range/style.json
+ test/integration/render-tests/zoom-visibility/was-above/expected.png
+48 −0 test/integration/render-tests/zoom-visibility/was-above/style.json
+ test/integration/render-tests/zoom-visibility/was-below/expected.png
+48 −0 test/integration/render-tests/zoom-visibility/was-below/style.json
+44 −2 test/unit/source/canvas_source.test.js
+2 −1 test/unit/source/geojson_source.test.js
+51 −0 test/unit/style-spec/fixture/layers.input.json
+26 −18 test/unit/style-spec/fixture/layers.output.json
+1 −1 test/unit/style-spec/fixture/properties.output.json
+7 −0 test/unit/style-spec/fixture/sources.input.json
+6 −2 test/unit/style-spec/fixture/sources.output.json
+49 −0 test/unit/util/color_ramp.test.js
+3 −3 yarn.lock
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "BSD-2-Clause",
"dependencies": {
"nan": "~2.8",
"node-pre-gyp": "^0.6.37",
"node-pre-gyp": "^0.6.39",
"npm-run-all": "^4.0.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,32 @@ public void setLinePatternTransition(TransitionOptions options) {
nativeSetLinePatternTransition(options.getDuration(), options.getDelay());
}

/**
* Get the LineGradient property
*
* @return property wrapper value around String
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getLineGradient() {
return (PropertyValue<String>) new PropertyValue("line-gradient", nativeGetLineGradient());
}

/**
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getLineGradientAsInt() {
PropertyValue<String> value = getLineGradient();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("line-gradient was set as a Function");
}
}

private native Object nativeGetLineCap();

private native Object nativeGetLineJoin();
Expand Down Expand Up @@ -501,6 +527,8 @@ public void setLinePatternTransition(TransitionOptions options) {

private native void nativeSetLinePatternTransition(long duration, long delay);

private native Object nativeGetLineGradient();

@Override
protected native void finalize() throws Throwable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static PropertyValue<Expression> lineBlur(Expression expression) {
}

/**
* 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.
*
* @param value a Float[] value
* @return property wrapper around Float[]
Expand All @@ -366,7 +366,7 @@ public static PropertyValue<Float[]> lineDasharray(Float[] value) {
}

/**
* 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.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
Expand Down Expand Up @@ -395,6 +395,36 @@ public static PropertyValue<Expression> linePattern(Expression expression) {
return new PaintPropertyValue<>("line-pattern", expression);
}

/**
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static PropertyValue<String> lineGradient(@ColorInt int value) {
return new PaintPropertyValue<>("line-gradient", colorToRgbaString(value));
}

/**
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> lineGradient(String value) {
return new PaintPropertyValue<>("line-gradient", value);
}

/**
* Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `"lineMetrics": true`.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> lineGradient(Expression expression) {
return new PaintPropertyValue<>("line-gradient", expression);
}

/**
* The opacity at which the icon will be drawn.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,32 @@ public void testLinePatternAsConstant() {
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
});
}

@Test
public void testLineGradientAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-gradient");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);

// Set and Get
layer.setProperties(lineGradient("rgba(0, 0, 0, 1)"));
assertEquals((String) layer.getLineGradient().getValue(), (String) "rgba(0, 0, 0, 1)");
});
}

@Test
public void testLineGradientAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-gradient");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);

// Set and Get
layer.setProperties(lineGradient(Color.RED));
assertEquals(layer.getLineGradientAsInt(), Color.RED);
});
}
}
9 changes: 8 additions & 1 deletion platform/android/src/style/layers/line_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ namespace android {
layer.as<mbgl::style::LineLayer>()->LineLayer::setLinePatternTransition(options);
}

jni::Object<jni::ObjectTag> LineLayer::getLineGradient(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::LineLayer>()->LineLayer::getLineGradient());
return jni::Object<jni::ObjectTag>(*converted);
}


jni::Class<LineLayer> LineLayer::javaClass;

Expand Down Expand Up @@ -287,7 +293,8 @@ namespace android {
METHOD(&LineLayer::getLineDasharray, "nativeGetLineDasharray"),
METHOD(&LineLayer::getLinePatternTransition, "nativeGetLinePatternTransition"),
METHOD(&LineLayer::setLinePatternTransition, "nativeSetLinePatternTransition"),
METHOD(&LineLayer::getLinePattern, "nativeGetLinePattern"));
METHOD(&LineLayer::getLinePattern, "nativeGetLinePattern"),
METHOD(&LineLayer::getLineGradient, "nativeGetLineGradient"));
}

} // namespace android
Expand Down
2 changes: 2 additions & 0 deletions platform/android/src/style/layers/line_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class LineLayer : public Layer {
jni::Object<jni::ObjectTag> getLinePattern(jni::JNIEnv&);
void setLinePatternTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Object<TransitionOptions> getLinePatternTransition(jni::JNIEnv&);

jni::Object<jni::ObjectTag> getLineGradient(jni::JNIEnv&);
jni::jobject* createJavaPeer(jni::JNIEnv&);

}; // class LineLayer
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate-shaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ for (const key in shaders) {
if (key === 'prelude')
continue;

// Skip line-gradient until it is ported from gl-js
if (key === 'lineGradient')
continue;

const shaderName = key.replace(/[A-Z]+/g, (match) => `_${match.toLowerCase()}`);

writeIfModified(path.join(outputPath, `${shaderName}.hpp`), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate-style-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
}, []);

const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => {
// Skip line-gradient until it is ported from gl-js
if (name === 'line-gradient') return memo;

spec[`paint_${type}`][name].name = name;
memo.push(spec[`paint_${type}`][name]);
return memo;
Expand Down
3 changes: 3 additions & 0 deletions src/mbgl/shaders/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d36ace4

Please sign in to comment.