From 426e7150b7deacdf99c6b8db02c3c060eef92efe Mon Sep 17 00:00:00 2001 From: Markus Johnsson Date: Wed, 17 Oct 2018 10:16:15 +0200 Subject: [PATCH 1/4] Set depthMode for 2d custom layers --- src/render/draw_custom.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/render/draw_custom.js b/src/render/draw_custom.js index 6b198f33ef6..ec541b6318a 100644 --- a/src/render/draw_custom.js +++ b/src/render/draw_custom.js @@ -13,6 +13,7 @@ import type CustomStyleLayer from '../style/style_layer/custom_style_layer'; function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) { const context = painter.context; + const gl = context.gl; const implementation = layer.implementation; if (painter.renderPass === 'offscreen') { @@ -46,7 +47,9 @@ function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomSty painter.setCustomLayerDefaults(); context.setStencilMode(StencilMode.disabled); - context.setDepthMode(DepthMode.disabled); + + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadWrite, gl.LESS); + context.setDepthMode(depthMode); implementation.render(context.gl, painter.transform.customLayerMatrix()); From 4a34486a97cfe61e31b7afb24a56d4b7c07c430f Mon Sep 17 00:00:00 2001 From: Markus Johnsson Date: Wed, 17 Oct 2018 11:04:30 +0200 Subject: [PATCH 2/4] Added test for #7422 --- .../custom-layer-js/depth/expected.png | Bin 0 -> 220 bytes .../custom-layer-js/depth/style.json | 66 ++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/integration/render-tests/custom-layer-js/depth/expected.png create mode 100644 test/integration/render-tests/custom-layer-js/depth/style.json diff --git a/test/integration/render-tests/custom-layer-js/depth/expected.png b/test/integration/render-tests/custom-layer-js/depth/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..7a3ed65b8a2afc8a4663eb8bd91f85295fc99ac4 GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Or9=|Ar*{or0OmKc~e2Wrw2C* z9#&vD;IJ^6W%K`rZ+uJ2r>ZTy@IPTQ=VXgc>}bcy(|_;$xx7nE-E+s&i=s;gz#JfGvp$*pqjKnF5-y85}Sb4q9e0NQq7 AWdHyG literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/custom-layer-js/depth/style.json b/test/integration/render-tests/custom-layer-js/depth/style.json new file mode 100644 index 00000000000..17bde5a735e --- /dev/null +++ b/test/integration/render-tests/custom-layer-js/depth/style.json @@ -0,0 +1,66 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64, + "operations": [ + [ + "addCustomLayer", + "null-island", + "fill" + ] + ] + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ + -20, + -10 + ], + [ + -20, + 10 + ], + [ + 0, + 10 + ], + [ + 0, + -10 + ], + [ + -20, + -10 + ] + ] + ] + } + } + }, + "layers": [ + { + "id": "background", + "type": "background", + "paint": { + "background-color": "rgba(0,255,0, 1)" + } + }, + { + "id": "fill", + "type": "fill", + "source": "geojson", + "paint": { + "fill-antialias": false, + "fill-color": "rgba(235, 235,235, 1)" + } + } + ] +} From c91dbda5c71896787312065f1235b02c16b3d4ac Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 17 Oct 2018 20:42:54 +0200 Subject: [PATCH 3/4] Switch to DepthMode.ReadOnly and default depth comparison for 2d custom layers --- src/render/draw_custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/draw_custom.js b/src/render/draw_custom.js index ec541b6318a..c9598b72c46 100644 --- a/src/render/draw_custom.js +++ b/src/render/draw_custom.js @@ -48,7 +48,7 @@ function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomSty context.setStencilMode(StencilMode.disabled); - const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadWrite, gl.LESS); + const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly); context.setDepthMode(depthMode); implementation.render(context.gl, painter.transform.customLayerMatrix()); From e4faee20b9c85ef3254f68bd37fa42799a1eec6a Mon Sep 17 00:00:00 2001 From: Markus Johnsson Date: Wed, 17 Oct 2018 20:47:39 +0200 Subject: [PATCH 4/4] Lint: remove unused local in draw_custom.js --- src/render/draw_custom.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/render/draw_custom.js b/src/render/draw_custom.js index c9598b72c46..03f74ebabde 100644 --- a/src/render/draw_custom.js +++ b/src/render/draw_custom.js @@ -13,7 +13,6 @@ import type CustomStyleLayer from '../style/style_layer/custom_style_layer'; function drawCustom(painter: Painter, sourceCache: SourceCache, layer: CustomStyleLayer) { const context = painter.context; - const gl = context.gl; const implementation = layer.implementation; if (painter.renderPass === 'offscreen') {