From 91395c87b775bec2f12ef5fbfe609e55beec2930 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Mon, 21 Nov 2016 08:51:16 -0800 Subject: [PATCH] Add support for line property functions (#3033) * more rebasing, get tests to pass * fix rebase errors, update package.json * rebase + add device_pixel_ratio to painter * bump shaders * add line multipliers * update shader + test-suite shas * fix line-offset type and multiplier, update test-suite sha * revert weird spacing * update test-suite sha * bump test-suite sha --- js/data/bucket/line_bucket.js | 7 ++++++- js/render/draw_line.js | 11 +---------- js/render/painter.js | 2 +- package.json | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/js/data/bucket/line_bucket.js b/js/data/bucket/line_bucket.js index 0278a002efa..3066a08206f 100644 --- a/js/data/bucket/line_bucket.js +++ b/js/data/bucket/line_bucket.js @@ -45,7 +45,12 @@ const lineInterface = { {name: 'a_data', components: 4, type: 'Uint8'} ]), paintAttributes: [ - {property: 'line-color', type: 'Uint8'} + {property: 'line-color', type: 'Uint8'}, + {property: 'line-blur', multiplier: 10, type: 'Uint8'}, + {property: 'line-opacity', multiplier: 10, type: 'Uint8'}, + {property: 'line-width', multiplier: 10, type: 'Uint8'}, + {property: 'line-gap-width', multiplier: 10, type: 'Uint8', name: 'a_gapwidth'}, + {property: 'line-offset', multiplier: 1, type: 'Int8'}, ], elementArrayType: createElementArrayType() }; diff --git a/js/render/draw_line.js b/js/render/draw_line.js index 1b90a340325..ae67dd40ea7 100644 --- a/js/render/draw_line.js +++ b/js/render/draw_line.js @@ -105,17 +105,8 @@ function drawLineTile(program, painter, tile, buffers, layer, coord, layerData, gl.uniform1f(program.u_fade, image.t); } - // the distance over which the line edge fades out. - // Retina devices need a smaller distance to avoid aliasing. - const antialiasing = 1 / browser.devicePixelRatio; - - gl.uniform1f(program.u_linewidth, layer.paint['line-width'] / 2); - gl.uniform1f(program.u_gapwidth, layer.paint['line-gap-width'] / 2); - gl.uniform1f(program.u_antialiasing, antialiasing / 2); - gl.uniform1f(program.u_blur, layer.paint['line-blur'] + antialiasing); - gl.uniform1f(program.u_opacity, layer.paint['line-opacity']); + gl.uniformMatrix2fv(program.u_antialiasingmatrix, false, painter.transform.lineAntialiasingMatrix); - gl.uniform1f(program.u_offset, -layer.paint['line-offset']); gl.uniform1f(program.u_extra, painter.transform.lineStretch); } diff --git a/js/render/painter.js b/js/render/painter.js index d2d8d7eb457..e1c25b4d706 100644 --- a/js/render/painter.js +++ b/js/render/painter.js @@ -362,7 +362,7 @@ class Painter { const program = gl.createProgram(); const definition = shaders[name]; - let definesSource = '#define MAPBOX_GL_JS;\n'; + let definesSource = `#define MAPBOX_GL_JS\n#define DEVICE_PIXEL_RATIO ${browser.devicePixelRatio.toFixed(1)}\n`; if (this._showOverdrawInspector) { definesSource += '#define OVERDRAW_INSPECTOR;\n'; } diff --git a/package.json b/package.json index fceb12754dd..bde9e3ed57f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "gl-matrix": "^2.3.1", "grid-index": "^1.0.0", "mapbox-gl-function": "mapbox/mapbox-gl-function#41c6724e2bbd7bd1eb5991451bbf118b7d02b525", - "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#5d7b99a4fd286e8b58a219a4247ca446746a462b", + "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#597115a1e1bd982944b068f8accde34eada74fc2", "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#512126c802dbb8f282e9826b181f0d53da00daf2", "mapbox-gl-supported": "^1.2.0", "package-json-versionify": "^1.0.2", @@ -62,7 +62,7 @@ "in-publish": "^2.0.0", "jsdom": "^9.4.2", "lodash.template": "^4.4.0", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#066afa88372ad3882c15ad5ef2435bb526971190", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#5c89044bef42e8b557f60162b515f689e455de75", "minifyify": "^7.0.1", "npm-run-all": "^3.0.0", "nyc": "^8.3.0",