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

Commit

Permalink
Port mapbox/mapbox-gl-js#9266 from gl-js to gl-native
Browse files Browse the repository at this point in the history
  • Loading branch information
karimnaaji committed Feb 19, 2020
1 parent d01c6aa commit 0572a16
Show file tree
Hide file tree
Showing 9 changed files with 516 additions and 495 deletions.
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 50 files
+4 −26 .circleci/config.yml
+0 −2 package.json
+0 −102 src/geo/edge_insets.js
+9 −67 src/geo/transform.js
+0 −50 src/render/draw_debug.js
+1 −6 src/render/painter.js
+5 −2 src/render/program/line_program.js
+14 −15 src/shaders/line_pattern.fragment.glsl
+4 −0 src/shaders/line_pattern.vertex.glsl
+1 −1 src/style-spec/expression/definitions/in.js
+25 −74 src/ui/camera.js
+1 −19 src/ui/map.js
+0 −4 test/README.md
+0 −18 test/browser/README.md
+0 −29 test/browser/drag.test.js
+0 −58 test/browser/fixtures/land.html
+0 −1 test/browser/fixtures/land.json
+0 −118 test/browser/util/browser.js
+0 −30 test/browser/util/doubleclick.js
+0 −45 test/browser/util/mousewheel.js
+0 −21 test/browser/zoom.test.js
+1 −1 test/integration/expression-tests/in/basic-string/test.json
+ test/integration/render-tests/debug/padding/ease-to-btm-distort/expected.png
+0 −112 test/integration/render-tests/debug/padding/ease-to-btm-distort/style.json
+ test/integration/render-tests/debug/padding/ease-to-left-distort/expected.png
+0 −112 test/integration/render-tests/debug/padding/ease-to-left-distort/style.json
+ test/integration/render-tests/debug/padding/ease-to-no-distort/expected.png
+0 −127 test/integration/render-tests/debug/padding/ease-to-no-distort/style.json
+ test/integration/render-tests/debug/padding/ease-to-right-distort/expected.png
+0 −112 test/integration/render-tests/debug/padding/ease-to-right-distort/style.json
+ test/integration/render-tests/debug/padding/ease-to-top-distort/expected.png
+0 −112 test/integration/render-tests/debug/padding/ease-to-top-distort/style.json
+ test/integration/render-tests/debug/padding/set-padding/expected.png
+0 −82 test/integration/render-tests/debug/padding/set-padding/style.json
+ test/integration/render-tests/line-pattern/@2x/expected.png
+ test/integration/render-tests/line-pattern/literal/expected.png
+ test/integration/render-tests/line-pattern/opacity/expected.png
+ test/integration/render-tests/line-pattern/overscaled/expected.png
+ test/integration/render-tests/line-pattern/pitch/expected.png
+ test/integration/render-tests/line-pattern/property-function/expected.png
+ test/integration/render-tests/line-pattern/step-curve/expected.png
+ test/integration/render-tests/line-pattern/with-dasharray/expected.png
+ test/integration/render-tests/line-pattern/zoom-expression/expected.png
+ test/integration/render-tests/regressions/mapbox-gl-js#5978/expected.png
+ test/integration/render-tests/regressions/mapbox-gl-js#8273/expected.png
+ test/integration/render-tests/regressions/mapbox-gl-native#9976/expected.png
+0 −1 test/suite_implementation.js
+0 −99 test/unit/geo/edge_insets.test.js
+0 −39 test/unit/ui/camera.test.js
+3 −60 yarn.lock
50 changes: 34 additions & 16 deletions src/mbgl/programs/gl/line_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<LinePatternProgram> {
static constexpr const char* name = "line_pattern";
static constexpr const uint8_t hash[8] = {0x38, 0x9c, 0x3d, 0xde, 0xb4, 0xe0, 0xd1, 0x61};
static constexpr const uint8_t hash[8] = {0x93, 0x0b, 0xd0, 0x1d, 0x72, 0xcf, 0x8d, 0x9e};
static constexpr const auto vertexOffset = 37858;
static constexpr const auto fragmentOffset = 41252;
static constexpr const auto fragmentOffset = 41590;
};

constexpr const char* ShaderSource<LinePatternProgram>::name;
Expand Down Expand Up @@ -63,6 +63,7 @@ varying vec2 v_normal;
varying vec2 v_width2;
varying float v_linesofar;
varying float v_gamma_scale;
varying float v_width;
#ifndef HAS_UNIFORM_u_blur
Expand Down Expand Up @@ -107,6 +108,14 @@ uniform mediump float u_width;
#endif
#ifndef HAS_UNIFORM_u_floorwidth
uniform lowp float u_floorwidth_t;
attribute lowp vec2 a_floorwidth;
#else
uniform lowp float u_floorwidth;
#endif
#ifndef HAS_UNIFORM_u_pattern_from
uniform lowp float u_pattern_from_t;
attribute lowp vec4 a_pattern_from;
Expand Down Expand Up @@ -162,6 +171,13 @@ void main() {
#endif
#ifndef HAS_UNIFORM_u_floorwidth
lowp float floorwidth = unpack_mix_vec2(a_floorwidth, u_floorwidth_t);
#else
lowp float floorwidth = u_floorwidth;
#endif
#ifndef HAS_UNIFORM_u_pattern_from
pattern_from = a_pattern_from;
#else
Expand Down Expand Up @@ -224,6 +240,7 @@ void main() {
v_linesofar = a_linesofar;
v_width2 = vec2(outset, inset);
v_width = floorwidth;
}
*/
Expand All @@ -241,6 +258,7 @@ varying vec2 v_normal;
varying vec2 v_width2;
varying float v_linesofar;
varying float v_gamma_scale;
varying float v_width;
#ifndef HAS_UNIFORM_u_pattern_from
Expand Down Expand Up @@ -304,12 +322,15 @@ void main() {
float fromScale = u_scale.z;
float toScale = u_scale.w;
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
vec2 display_size_a = (pattern_br_a - pattern_tl_a) / pixelRatio;
vec2 display_size_b = (pattern_br_b - pattern_tl_b) / pixelRatio;
vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y);
vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y);
float aspect_a = display_size_a.y / v_width;
float aspect_b = display_size_b.y / v_width;
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * v_width2.s;
Expand All @@ -319,18 +340,15 @@ void main() {
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
float x_a = mod(v_linesofar / pattern_size_a.x, 1.0);
float x_b = mod(v_linesofar / pattern_size_b.x, 1.0);
// v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge
// we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)
// to ensure we don't sample outside the designated symbol on the sprite sheet.
// 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of
// the texture coordinate
float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (pattern_size_a.y + 2.0) / 2.0) / pattern_size_a.y);
float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (pattern_size_b.y + 2.0) / 2.0) / pattern_size_b.y);
vec2 pos_a = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, vec2(x_a, y_a));
vec2 pos_b = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, vec2(x_b, y_b));
float x_a = mod(v_linesofar / pattern_size_a.x * aspect_a, 1.0);
float x_b = mod(v_linesofar / pattern_size_b.x * aspect_b, 1.0);
float y = 0.5 * v_normal.y + 0.5;
vec2 texel_size = 1.0 / u_texsize;
vec2 pos_a = mix(pattern_tl_a * texel_size - texel_size, pattern_br_a * texel_size + texel_size, vec2(x_a, y));
vec2 pos_b = mix(pattern_tl_b * texel_size - texel_size, pattern_br_b * texel_size + texel_size, vec2(x_b, y));
vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/line_sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<LineSDFProgram> {
static constexpr const char* name = "line_sdf";
static constexpr const uint8_t hash[8] = {0x25, 0x94, 0x7f, 0xad, 0x84, 0xfe, 0x96, 0xad};
static constexpr const auto vertexOffset = 43607;
static constexpr const auto fragmentOffset = 47294;
static constexpr const auto vertexOffset = 43874;
static constexpr const auto fragmentOffset = 47561;
};

constexpr const char* ShaderSource<LineSDFProgram>::name;
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<RasterProgram> {
static constexpr const char* name = "raster";
static constexpr const uint8_t hash[8] = {0x40, 0x3d, 0x6c, 0xf4, 0xd0, 0x41, 0x51, 0x0e};
static constexpr const auto vertexOffset = 48839;
static constexpr const auto fragmentOffset = 49188;
static constexpr const auto vertexOffset = 49106;
static constexpr const auto fragmentOffset = 49455;
};

constexpr const char* ShaderSource<RasterProgram>::name;
Expand Down
Loading

0 comments on commit 0572a16

Please sign in to comment.