Skip to content

Commit

Permalink
Merge 066216a into 89aa08d
Browse files Browse the repository at this point in the history
  • Loading branch information
1chandu committed Nov 12, 2019
2 parents 89aa08d + 066216a commit 3eb2a32
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 34 deletions.
37 changes: 13 additions & 24 deletions modules/aggregation-layers/src/aggregation-layer.js
Expand Up @@ -18,26 +18,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import {CompositeLayer, AttributeManager, experimental} from '@deck.gl/core';
import {CompositeLayer, AttributeManager, experimental, Layer} from '@deck.gl/core';
import {cssToDeviceRatio, log} from '@luma.gl/core';
const {compareProps} = experimental;

// props when changed results in new uniforms that requires re-aggregation
const UNIFORM_PROPS = [
// DATA-FILTER extension
'filterEnabled',
'filterRange',
'filterSoftRange',
'filterTransformSize',
'filterTransformColor'
];

export default class AggregationLayer extends CompositeLayer {
initializeState(aggregationProps = []) {
initializeState(ignoreProps = {}) {
super.initializeState();
this.setState({
aggregationProps: aggregationProps.concat(UNIFORM_PROPS)
});
this.setState({ignoreProps: Object.assign({}, ignoreProps, Layer.defaultProps)});
}

updateState(opts) {
Expand Down Expand Up @@ -87,16 +75,17 @@ export default class AggregationLayer extends CompositeLayer {
if (this.state.dataChanged) {
return true;
}
const {aggregationProps} = this.state;
const oldProps = {};
const props = {};
for (const propName of aggregationProps) {
oldProps[propName] = opts.oldProps[propName];
props[propName] = opts.props[propName];
if (
compareProps({
oldProps: opts.oldProps,
newProps: opts.props,
ignoreProps: this.state.ignoreProps,
propTypes: this.constructor._propTypes
})
) {
return true;
}
return Boolean(
compareProps({oldProps, newProps: props, propTypes: this.constructor._propTypes})
);
return false;
}

_updateShaders(shaders) {
Expand Down
13 changes: 10 additions & 3 deletions modules/aggregation-layers/src/contour-layer/contour-layer.js
Expand Up @@ -45,12 +45,19 @@ const defaultProps = {
zOffset: 0.005
};

// props , when changed requires re-aggregation
const AGGREGATION_PROPS = ['gpuAggregation'];
const AGGREGATION_PROPS = ['cellSize', 'gpuAggregation'];

// props , when changed doesn't require updating aggregation
const ignoreProps = Object.keys(defaultProps).reduce((accu, cur) => {
if (!AGGREGATION_PROPS.includes(cur)) {
accu[cur] = defaultProps[cur];
}
return accu;
}, {});

export default class ContourLayer extends GridAggregationLayer {
initializeState() {
super.initializeState(AGGREGATION_PROPS);
super.initializeState(ignoreProps);
this.setState({
contourData: {},
colorTrigger: 0,
Expand Down
18 changes: 15 additions & 3 deletions modules/aggregation-layers/src/gpu-grid-layer/gpu-grid-layer.js
Expand Up @@ -59,8 +59,20 @@ const defaultProps = {
gpuAggregation: true
};

// props , when changed requires re-aggregation
const AGGREGATION_PROPS = ['gpuAggregation', 'colorAggregation', 'elevationAggregation'];
const AGGREGATION_PROPS = [
'gpuAggregation',
'colorAggregation',
'elevationAggregation',
'cellSize'
];

// props , when changed doesn't require updating aggregation
const ignoreProps = Object.keys(defaultProps).reduce((accu, cur) => {
if (!AGGREGATION_PROPS.includes(cur)) {
accu[cur] = defaultProps[cur];
}
return accu;
}, {});

export default class GPUGridLayer extends GridAggregationLayer {
initializeState() {
Expand All @@ -69,7 +81,7 @@ export default class GPUGridLayer extends GridAggregationLayer {
if (!isSupported) {
log.error('GPUGridLayer is not supported on this browser, use GridLayer instead')();
}
super.initializeState(AGGREGATION_PROPS);
super.initializeState(ignoreProps);
this.setState({isSupported});
const attributeManager = this.getAttributeManager();
attributeManager.add({
Expand Down
11 changes: 9 additions & 2 deletions modules/aggregation-layers/src/heatmap-layer/heatmap-layer.js
Expand Up @@ -76,9 +76,16 @@ const REQUIRED_FEATURES = [
// FEATURES.FLOAT_BLEND, // implictly supported when TEXTURE_FLOAT is supported
];

// props , when changed requires re-aggregation
const AGGREGATION_PROPS = ['radiusPixels'];

// props , when changed doesn't require updating aggregation
const ignoreProps = Object.keys(defaultProps).reduce((accu, cur) => {
if (!AGGREGATION_PROPS.includes(cur)) {
accu[cur] = defaultProps[cur];
}
return accu;
}, {});

export default class HeatmapLayer extends AggregationLayer {
initializeState() {
const {gl} = this.context;
Expand All @@ -87,7 +94,7 @@ export default class HeatmapLayer extends AggregationLayer {
log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();
return;
}
super.initializeState(AGGREGATION_PROPS);
super.initializeState(ignoreProps);
this.setState({supported: true});
this._setupTextureParams();
this._setupAttributes();
Expand Down
Expand Up @@ -35,9 +35,16 @@ const defaultProps = Object.assign({}, ScreenGridCellLayer.defaultProps, {
aggregation: 'SUM'
});

// props , when changed requires re-aggregation
const AGGREGATION_PROPS = ['gpuAggregation'];

// props , when changed doesn't require updating aggregation
const ignoreProps = Object.keys(defaultProps).reduce((accu, cur) => {
if (!AGGREGATION_PROPS.includes(cur)) {
accu[cur] = defaultProps[cur] || ScreenGridCellLayer.defaultProps[cur];
}
return accu;
}, {});

export default class ScreenGridLayer extends GridAggregationLayer {
initializeState() {
const {gl} = this.context;
Expand All @@ -47,7 +54,7 @@ export default class ScreenGridLayer extends GridAggregationLayer {
log.error(`ScreenGridLayer: ${this.id} is not supported on this browser`)();
return;
}
super.initializeState(AGGREGATION_PROPS);
super.initializeState(ignoreProps);
const weights = {
color: {
size: 1,
Expand Down

0 comments on commit 3eb2a32

Please sign in to comment.