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 27, 2016
1 parent 52b67c5 commit 7cd294c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
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
10 changes: 7 additions & 3 deletions js/style/style_layer/fill_style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7cd294c

Please sign in to comment.