Skip to content

Commit

Permalink
Use setPaintProperty's optional worker roundtrip to reparse fill-extr…
Browse files Browse the repository at this point in the history
…ude buckets when necessary (fix #3386)
  • Loading branch information
Lauren Budorick committed Oct 26, 2016
1 parent b9d9509 commit 19c12a0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 1 addition & 3 deletions js/data/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ const subclasses = {
Bucket.create = function(options) {
const layer = options.layers[0];
let type = layer.type;
if (type === 'fill' && (!layer.isPaintValueFeatureConstant('fill-extrude-height') ||
!layer.isPaintValueZoomConstant('fill-extrude-height') ||
layer.getPaintValue('fill-extrude-height', {zoom: options.zoom}) !== 0)) {
if (type === 'fill' && layer.isExtruded({ zoom: this.zoom })) {
type = 'fillextrusion';
}
return new subclasses[type](options);
Expand Down
5 changes: 1 addition & 4 deletions js/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
10 changes: 9 additions & 1 deletion js/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = !(
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions js/style/style_layer/fill_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class FillStyleLayer extends StyleLayer {
return super.isPaintValueZoomConstant(name);
}
}

isExtruded(globalProperties) {
return !this.isPaintValueFeatureConstant('fill-extrude-height') ||
!this.isPaintValueZoomConstant('fill-extrude-height') ||
this.getPaintValue('fill-extrude-height', globalProperties) !== 0;
}
}

module.exports = FillStyleLayer;

0 comments on commit 19c12a0

Please sign in to comment.