Skip to content

Commit

Permalink
Fix bug breaking transparency in fill layers with property functions (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
lucaswoj authored Aug 10, 2016
1 parent abf49ff commit e9287d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions js/render/draw_fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e9287d8

Please sign in to comment.