From 7cd294c08b82e562d30a873db91565965fe41f43 Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Mon, 24 Oct 2016 13:12:52 -0700 Subject: [PATCH] Use setPaintProperty's optional worker roundtrip to reparse fill-extrude buckets when necessary (fix #3386) --- js/render/painter.js | 5 +---- js/style/style.js | 10 +++++++++- js/style/style_layer/fill_style_layer.js | 10 +++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/js/render/painter.js b/js/render/painter.js index 27d561dc2fa..75f387ad142 100644 --- a/js/render/painter.js +++ b/js/render/painter.js @@ -272,10 +272,7 @@ class Painter { this.id = layer.id; let type = layer.type; - if (type === 'fill' && - (!layer.isPaintValueFeatureConstant('fill-extrude-height') || - !layer.isPaintValueZoomConstant('fill-extrude-height') || - layer.getPaintValue('fill-extrude-height', {zoom: this.transform.zoom}) !== 0)) { + if (type === 'fill' && layer.isExtruded({zoom: this.transform.zoom})) { type = 'extrusion'; } diff --git a/js/style/style.js b/js/style/style.js index 911b742783e..6b858f52614 100644 --- a/js/style/style.js +++ b/js/style/style.js @@ -557,6 +557,7 @@ class Style extends Evented { if (util.deepEqual(layer.getPaintProperty(name, klass), value)) return this; const wasFeatureConstant = layer.isPaintValueFeatureConstant(name); + const wasExtruded = layer.type === 'fill' && layer.isExtruded({ zoom: this.zoom }); layer.setPaintProperty(name, value, klass); const isFeatureConstant = !( @@ -566,7 +567,14 @@ class Style extends Evented { value.property !== undefined ); - if (!isFeatureConstant || !wasFeatureConstant) { + const switchBuckets = ( + layer.type === 'fill' && + name === 'fill-extrude-height' && + (!wasExtruded && value) || + (wasExtruded && value === 0) + ); + + if (!isFeatureConstant || !wasFeatureConstant || switchBuckets) { this._updates.layers[layerId] = true; if (layer.source) { this._updates.sources[layer.source] = true; diff --git a/js/style/style_layer/fill_style_layer.js b/js/style/style_layer/fill_style_layer.js index de97fccca3b..46999829d32 100644 --- a/js/style/style_layer/fill_style_layer.js +++ b/js/style/style_layer/fill_style_layer.js @@ -46,10 +46,14 @@ class FillStyleLayer extends StyleLayer { } } - createBucket(options) { - if (!this.isPaintValueFeatureConstant('fill-extrude-height') || + isExtruded(globalProperties) { + return !this.isPaintValueFeatureConstant('fill-extrude-height') || !this.isPaintValueZoomConstant('fill-extrude-height') || - this.getPaintValue('fill-extrude-height', {zoom: options.zoom}) !== 0) { + this.getPaintValue('fill-extrude-height', globalProperties) !== 0; + } + + createBucket(options) { + if (isExtruded({zoom: options.zoom})) { return new FillExtrusionBucket(options); } return new FillBucket(options);