Skip to content

Commit

Permalink
Prefer line-pattern over line-dasharray in accordance with documentat…
Browse files Browse the repository at this point in the history
…ion (mapbox#9189)
  • Loading branch information
kkaefer committed Jan 15, 2020
1 parent e1980e3 commit b2c4b04
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default function drawLine(painter: Painter, sourceCache: SourceCache, lay
const crossfade = layer.getCrossfadeParameters();

const programId =
dasharray ? 'lineSDF' :
image ? 'linePattern' :
dasharray ? 'lineSDF' :
gradient ? 'lineGradient' : 'line';

const context = painter.context;
Expand Down Expand Up @@ -73,18 +73,18 @@ export default function drawLine(painter: Painter, sourceCache: SourceCache, lay
if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);
}

const uniformValues = dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade) :
image ? linePatternUniformValues(painter, tile, layer, crossfade) :
const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade) :
dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade) :
gradient ? lineGradientUniformValues(painter, tile, layer) :
lineUniformValues(painter, tile, layer);

if (dasharray && (programChanged || painter.lineAtlas.dirty)) {
context.activeTexture.set(gl.TEXTURE0);
painter.lineAtlas.bind(context);
} else if (image) {
if (image) {
context.activeTexture.set(gl.TEXTURE0);
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
programConfiguration.updatePatternPaintBuffers(crossfade);
} else if (dasharray && (programChanged || painter.lineAtlas.dirty)) {
context.activeTexture.set(gl.TEXTURE0);
painter.lineAtlas.bind(context);
}

program.draw(context, gl.TRIANGLES, depthMode,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64
}
},
"sources": {
"a": {
"type": "geojson",
"data": {
"type": "LineString",
"coordinates": [
[
-10,
-10
],
[
10,
-10
]
]
}
},
"b": {
"type": "geojson",
"data": {
"type": "LineString",
"coordinates": [
[
-10,
0
],
[
10,
0
]
]
}
},
"c": {
"type": "geojson",
"data": {
"type": "LineString",
"coordinates": [
[
-10,
10
],
[
10,
10
]
]
}
}
},
"sprite": "local://sprites/emerald",
"layers": [
{
"id": "a",
"type": "line",
"source": "a",
"paint": {
"line-width": 2,
"line-dasharray": [2, 4],
"line-pattern": "generic_icon"
}
},
{
"id": "b",
"type": "line",
"source": "b",
"paint": {
"line-width": 4,
"line-dasharray": [2, 4],
"line-pattern": "generic_icon"
}
},
{
"id": "c",
"type": "line",
"source": "c",
"paint": {
"line-width": 8,
"line-dasharray": [2, 4],
"line-pattern": "generic_icon"
}
}
]
}

0 comments on commit b2c4b04

Please sign in to comment.