Skip to content

Commit f06c3e5

Browse files
author
Lucas Wojciechowski
committed
Fix incorrect rendering caused by drawing symbols across edges
fixes #2092
1 parent 29ce455 commit f06c3e5

File tree

9 files changed

+13
-17
lines changed

9 files changed

+13
-17
lines changed

js/render/draw_background.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ function drawBackground(painter, source, layer) {
7474
gl.drawArrays(gl.TRIANGLE_STRIP, 0, painter.tileExtentBuffer.itemCount);
7575
}
7676

77-
gl.enable(gl.STENCIL_TEST);
7877
gl.stencilMask(0x00);
7978
gl.stencilFunc(gl.EQUAL, 0x80, 0x80);
8079
}

js/render/draw_circle.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,4 @@ function drawCircles(painter, source, layer, coords) {
6464
gl.drawElements(gl.TRIANGLES, count, gl.UNSIGNED_SHORT, elementOffset);
6565
}
6666
}
67-
68-
gl.enable(gl.STENCIL_TEST);
6967
}

js/render/draw_collision_debug.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,4 @@ function drawCollisionDebug(painter, source, layer, coords) {
3838
);
3939

4040
}
41-
42-
gl.disable(gl.STENCIL_TEST);
4341
}

js/render/draw_debug.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function drawDebug(painter, source, coords) {
1919
function drawDebugTile(painter, source, coord) {
2020
var gl = painter.gl;
2121

22+
gl.disable(gl.STENCIL_TEST);
2223
gl.lineWidth(1 * browser.devicePixelRatio);
2324

2425
var posMatrix = painter.calculatePosMatrix(coord, source.maxzoom);

js/render/draw_fill.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = draw;
77

88
function draw(painter, source, layer, coords) {
99
var gl = painter.gl;
10+
gl.enable(gl.STENCIL_TEST);
1011

1112
var color = util.premultiply(layer.paint['fill-color'], layer.paint['fill-opacity']);
1213
var image = layer.paint['fill-pattern'];

js/render/draw_line.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = function drawLine(painter, source, layer, coords) {
2525
if (!hasData) return;
2626

2727
var gl = painter.gl;
28+
gl.enable(gl.STENCIL_TEST);
2829

2930
// don't draw zero-width lines
3031
if (layer.paint['line-width'] <= 0) return;

js/render/draw_raster.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ function drawRasterTile(painter, source, layer, coord) {
7272
gl.vertexAttribPointer(shader.a_pos, 2, gl.SHORT, false, 8, 0);
7373
gl.vertexAttribPointer(shader.a_texture_pos, 2, gl.SHORT, false, 8, 4);
7474
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
75-
76-
gl.enable(gl.STENCIL_TEST);
7775
}
7876

7977
function spinWeights(angle) {

js/render/draw_symbol.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ function drawSymbols(painter, source, layer, coords) {
1616

1717
var gl = painter.gl;
1818

19+
// Disable the stencil test so that labels aren't clipped to tile boundaries.
20+
//
21+
// Layers with features that may be drawn overlapping aren't clipped. These
22+
// layers are sorted in the y direction, and to draw the correct ordering near
23+
// tile edges the icons are included in both tiles and clipped when drawing.
1924
if (drawAcrossEdges) {
20-
// Disable the stencil test so that labels aren't clipped to tile boundaries.
21-
//
22-
// Layers with features that may be drawn overlapping aren't clipped. These
23-
// layers are sorted in the y direction, and to draw the correct ordering near
24-
// tile edges the icons are included in both tiles and clipped when drawing.
2525
gl.disable(gl.STENCIL_TEST);
26+
} else {
27+
gl.enable(gl.STENCIL_TEST);
2628
}
2729

2830
painter.setDepthSublayer(0);
@@ -57,12 +59,9 @@ function drawSymbols(painter, source, layer, coords) {
5759
drawSymbol(painter, layer, posMatrix, tile, elementGroups.glyph, 'text', true, false);
5860
}
5961

60-
drawCollisionDebug(painter, source, layer, coords);
61-
62-
if (drawAcrossEdges) {
63-
gl.enable(gl.STENCIL_TEST);
64-
}
6562
gl.enable(gl.DEPTH_TEST);
63+
64+
drawCollisionDebug(painter, source, layer, coords);
6665
}
6766

6867
var defaultSizes = {

js/render/painter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ Painter.prototype._renderTileClippingMasks = function(coords, sourceMaxZoom) {
192192
gl.colorMask(false, false, false, false);
193193
this.depthMask(false);
194194
gl.disable(gl.DEPTH_TEST);
195+
gl.enable(gl.STENCIL_TEST);
195196

196197
// Only write clipping IDs to the last 5 bits. The first three are used for drawing fills.
197198
gl.stencilMask(0xF8);

0 commit comments

Comments
 (0)