Skip to content

Commit

Permalink
Add support for line property functions (#3033)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lucaswoj authored and mollymerp committed Nov 21, 2016
1 parent c4bb352 commit 91395c8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
7 changes: 6 additions & 1 deletion js/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand Down
11 changes: 1 addition & 10 deletions js/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion js/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 91395c8

Please sign in to comment.