Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix zero-width line rendering #6772

Merged
merged 2 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function drawLine(painter: Painter, sourceCache: SourceCache, lay
if (painter.renderPass !== 'translucent') return;

const opacity = layer.paint.get('line-opacity');
if (opacity.constantOr(1) === 0) return;
const width = layer.paint.get('line-width');
if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return;

const context = painter.context;

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/line.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void main() {
offset = -1.0 * offset;

float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + ANTIALIASING;
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);

// Scale the extrusion vector down to a normal and then up by the line width
// of this vertex.
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,75 @@
{
"version": 8,
"metadata": {
"test": {
"width": 100,
"height": 100,
"diff": 0.00075
}
},
"zoom": 2,
"sources": {
"linesource": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {
"width": 0
},
"geometry": {
"type": "LineString",
"coordinates": [
[
-1,
8
],
[
8,
1
],
[
1,
-8
],
[
-8,
-1
],
[
1,
4
],
[
4,
-1
],
[
-1,
-4
],
[
-2,
0
]
]
}
},
"lineMetrics": true
}
},
"layers": [
{
"id": "line",
"type": "line",
"source": "linesource",
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-width": ["get", "width"],
"line-color": "red"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions test/integration/render-tests/line-width/zero-width/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": 8,
"metadata": {
"test": {
"width": 100,
"height": 100,
"diff": 0.00075
}
},
"zoom": 2,
"sources": {
"linesource": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-1,
8
],
[
8,
1
],
[
1,
-8
],
[
-8,
-1
],
[
1,
4
],
[
4,
-1
],
[
-1,
-4
],
[
-2,
0
]
]
}
},
"lineMetrics": true
}
},
"layers": [
{
"id": "line",
"type": "line",
"source": "linesource",
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-width": 0,
"line-color": "red"
}
}
]
}