From e9287d83b59baee432aec0341321a25b43bf6a51 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Wed, 10 Aug 2016 09:52:13 -0700 Subject: [PATCH] Fix bug breaking transparency in fill layers with property functions (#2971) * Fix bug breaking transparency in fill layers with property functions fixes #2846 * Fix logic, add test-suite regression test * Fix render_fill * Update test-suite --- js/render/draw_fill.js | 18 +++++++++++++----- package.json | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/render/draw_fill.js b/js/render/draw_fill.js index f28ac0ad6a4..ac83327296b 100644 --- a/js/render/draw_fill.js +++ b/js/render/draw_fill.js @@ -8,13 +8,20 @@ function draw(painter, source, layer, coords) { var gl = painter.gl; gl.enable(gl.STENCIL_TEST); - var color = layer.paint['fill-color']; - var image = layer.paint['fill-pattern']; - var opacity = layer.paint['fill-opacity']; - var isOutlineColorDefined = layer.getPaintProperty('fill-outline-color'); + var isOpaque; + if (layer.paint['fill-pattern']) { + isOpaque = false; + } else { + isOpaque = ( + layer.isPaintValueFeatureConstant('fill-color') && + layer.isPaintValueFeatureConstant('fill-opacity') && + layer.paint['fill-color'][3] === 1 && + layer.paint['fill-opacity'] === 1 + ); + } // Draw fill - if (image ? !painter.isOpaquePass : painter.isOpaquePass === (color[3] === 1 && opacity === 1)) { + if (painter.isOpaquePass === isOpaque) { // Once we switch to earcut drawing we can pull most of the WebGL setup // outside of this coords loop. painter.setDepthSublayer(1); @@ -27,6 +34,7 @@ function draw(painter, source, layer, coords) { painter.lineWidth(2); painter.depthMask(false); + var isOutlineColorDefined = layer.getPaintProperty('fill-outline-color'); if (isOutlineColorDefined || !layer.paint['fill-pattern']) { if (isOutlineColorDefined) { // If we defined a different color for the fill outline, we are diff --git a/package.json b/package.json index 25e5143919c..433d6d41e75 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "istanbul": "^0.4.2", "json-loader": "^0.5.4", "lodash": "^4.13.1", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#dc547418019d542745ca635af38717f560444e58", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#0ed5d988d81072e4b44b02581825979cbcfcf30b", "memory-fs": "^0.3.0", "minifyify": "^7.0.1", "nyc": "6.4.0",