Skip to content

Commit

Permalink
ScreenGridLayer: skip aggregation when data is empty (#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
1chandu committed Aug 7, 2019
1 parent 1fb672d commit beac261
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -114,7 +114,13 @@ export default class ScreenGridLayer extends Layer {
const changeFlags = this._getAggregationChangeFlags(opts);

if (changeFlags) {
this._updateAggregation(changeFlags);
if (changeFlags.cellSizeChanged || changeFlags.viewportChanged) {
this._updateGridParams();
}
const {pointCount} = this.state;
if (pointCount > 0) {
this._updateAggregation(changeFlags);
}
}
}

Expand Down Expand Up @@ -282,7 +288,7 @@ export default class ScreenGridLayer extends Layer {
}
}
weights.color.values = colorWeights;
this.setState({positions});
this.setState({positions, pointCount});
}

// Set a binding point for the aggregation uniform block index
Expand Down Expand Up @@ -316,10 +322,6 @@ export default class ScreenGridLayer extends Layer {

_updateAggregation(changeFlags) {
const attributeManager = this.getAttributeManager();
if (changeFlags.cellSizeChanged || changeFlags.viewportChanged) {
this._updateGridParams();
attributeManager.invalidateAll();
}
const {cellSizePixels, gpuAggregation} = this.props;

const {positions, weights} = this.state;
Expand Down Expand Up @@ -391,6 +393,8 @@ export default class ScreenGridLayer extends Layer {
}

_updateGridParams() {
const attributeManager = this.getAttributeManager();
attributeManager.invalidateAll();
const {width, height} = this.context.viewport;
const {cellSizePixels} = this.props;
const {gl} = this.context;
Expand Down
Expand Up @@ -214,7 +214,7 @@ export default class GPUGridAggregator {
return this.runAggregationOnGPU(aggregationParams);
}
if (useGPU) {
log.info('GPUGridAggregator: GPU Aggregation not supported, falling back to CPU')();
log.warn('GPUGridAggregator: GPU Aggregation not supported, falling back to CPU')();
}
return this.runAggregationOnCPU(aggregationParams);
}
Expand Down

0 comments on commit beac261

Please sign in to comment.