summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2018-04-12 14:39:38 +0200
committerŁukasz Paczos <lukas.paczos@gmail.com>2018-04-12 16:10:18 +0200
commitd36ace4cc1405f9e4bb69f8690a34a94a3742d40 (patch)
tree625cebbc8148e4dad879e4d32474ca122a262347
parentff11cb20163caddf5e31ebdaeaafa0e1a9e456ec (diff)
downloadqtlocation-mapboxgl-upstream/lp-js-submodule-bump.tar.gz
[core] update mapbox-gl-js submoduleupstream/lp-js-submodule-bump
m---------mapbox-gl-js0
-rw-r--r--package.json2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java28
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java34
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java28
-rw-r--r--platform/android/src/style/layers/line_layer.cpp9
-rw-r--r--platform/android/src/style/layers/line_layer.hpp2
-rwxr-xr-xscripts/generate-shaders.js4
-rwxr-xr-xscripts/generate-style-code.js3
-rw-r--r--src/mbgl/shaders/line.cpp3
10 files changed, 109 insertions, 4 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject 6b96d69ab54b149db1f6ef06daed37379ac0744
+Subproject 13ea16df5eabc4c8867d69e81da180cdcd6cc6b
diff --git a/package.json b/package.json
index 977cd2b09c..dc99da7fd2 100644
--- a/package.json
+++ b/package.json
@@ -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": {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
index 5e6e6d38e7..0cd518ec53 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java
@@ -437,6 +437,32 @@ public class LineLayer extends Layer {
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();
@@ -501,6 +527,8 @@ public class LineLayer extends Layer {
private native void nativeSetLinePatternTransition(long duration, long delay);
+ private native Object nativeGetLineGradient();
+
@Override
protected native void finalize() throws Throwable;
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..f4823ca2b5 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
@@ -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.
*
* @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.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
@@ -396,6 +396,36 @@ public class PropertyFactory {
}
/**
+ * 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.
*
* @param value a Float value
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
index 40cf0f2927..6a00ea5c00 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
@@ -545,4 +545,32 @@ public class LineLayerTest extends BaseActivityTest {
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);
+ });
+ }
} \ No newline at end of file
diff --git a/platform/android/src/style/layers/line_layer.cpp b/platform/android/src/style/layers/line_layer.cpp
index af4e24523e..f143ecc236 100644
--- a/platform/android/src/style/layers/line_layer.cpp
+++ b/platform/android/src/style/layers/line_layer.cpp
@@ -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;
@@ -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
diff --git a/platform/android/src/style/layers/line_layer.hpp b/platform/android/src/style/layers/line_layer.hpp
index 84ecc77139..9eef1349cb 100644
--- a/platform/android/src/style/layers/line_layer.hpp
+++ b/platform/android/src/style/layers/line_layer.hpp
@@ -74,6 +74,8 @@ public:
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
diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js
index b1eeffb8a0..fc838e9e95 100755
--- a/scripts/generate-shaders.js
+++ b/scripts/generate-shaders.js
@@ -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.
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index 6ddb787f19..2023c8cc41 100755
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -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;
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