Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Dec 5, 2019
1 parent 69b30be commit 17d8c3f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 40 deletions.
26 changes: 13 additions & 13 deletions modules/core/src/lib/attribute/attribute-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import debug from '../../debug';

import AttributeTransitionManager from './attribute-transition-manager';

const EVENT_INVALIDATE = 'attributeManager.invalidate';
const EVENT_UPDATE_START = 'attributeManager.updateStart';
const EVENT_UPDATE_END = 'attributeManager.updateEnd';
const EVENT_ATTRIBUTE_UPDATE_START = 'attribute.updateStart';
const EVENT_ATTRIBUTE_ALLOCATE = 'attribute.allocate';
const EVENT_ATTRIBUTE_UPDATE_END = 'attribute.updateEnd';
const TRACE_INVALIDATE = 'attributeManager.invalidate';
const TRACE_UPDATE_START = 'attributeManager.updateStart';
const TRACE_UPDATE_END = 'attributeManager.updateEnd';
const TRACE_ATTRIBUTE_UPDATE_START = 'attribute.updateStart';
const TRACE_ATTRIBUTE_ALLOCATE = 'attribute.allocate';
const TRACE_ATTRIBUTE_UPDATE_END = 'attribute.updateEnd';

export default class AttributeManager {
/**
Expand Down Expand Up @@ -139,15 +139,15 @@ export default class AttributeManager {
invalidate(triggerName, dataRange) {
const invalidatedAttributes = this._invalidateTrigger(triggerName, dataRange);
// For performance tuning
debug(EVENT_INVALIDATE, this, triggerName, invalidatedAttributes);
debug(TRACE_INVALIDATE, this, triggerName, invalidatedAttributes);
}

invalidateAll(dataRange) {
for (const attributeName in this.attributes) {
this.attributes[attributeName].setNeedsUpdate(attributeName, dataRange);
}
// For performance tuning
debug(EVENT_INVALIDATE, this, 'all');
debug(TRACE_INVALIDATE, this, 'all');
}

// Ensure all attribute buffers are updated from props or data.
Expand All @@ -163,7 +163,7 @@ export default class AttributeManager {
// keep track of whether some attributes are updated
let updated = false;

debug(EVENT_UPDATE_START, this);
debug(TRACE_UPDATE_START, this);
if (this.stats) {
this.stats.get('Update Attributes').timeStart();
}
Expand Down Expand Up @@ -202,7 +202,7 @@ export default class AttributeManager {

if (updated) {
// Only initiate alloc/update (and logging) if actually needed
debug(EVENT_UPDATE_END, this, numInstances);
debug(TRACE_UPDATE_END, this, numInstances);
}

if (this.stats) {
Expand Down Expand Up @@ -349,17 +349,17 @@ export default class AttributeManager {

_updateAttribute(opts) {
const {attribute, numInstances} = opts;
debug(EVENT_ATTRIBUTE_UPDATE_START, attribute);
debug(TRACE_ATTRIBUTE_UPDATE_START, attribute);

if (attribute.allocate(numInstances)) {
debug(EVENT_ATTRIBUTE_ALLOCATE, attribute, numInstances);
debug(TRACE_ATTRIBUTE_ALLOCATE, attribute, numInstances);
}

// Calls update on any buffers that need update
const updated = attribute.updateBuffer(opts);
if (updated) {
this.needsRedraw = true;
debug(EVENT_ATTRIBUTE_UPDATE_END, attribute, numInstances);
debug(TRACE_ATTRIBUTE_UPDATE_END, attribute, numInstances);
}
}
}
4 changes: 2 additions & 2 deletions modules/core/src/lib/composite-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Layer from './layer';
import debug from '../debug';
import {flatten} from '../utils/flatten';

const EVENT_RENDER_LAYERS = 'compositeLayer.renderLayers';
const TRACE_RENDER_LAYERS = 'compositeLayer.renderLayers';

export default class CompositeLayer extends Layer {
get isComposite() {
Expand Down Expand Up @@ -217,7 +217,7 @@ export default class CompositeLayer extends Layer {
subLayers = flatten(subLayers, {filter: Boolean});
this.internalState.subLayers = subLayers;
}
debug(EVENT_RENDER_LAYERS, this, shouldUpdate, subLayers);
debug(TRACE_RENDER_LAYERS, this, shouldUpdate, subLayers);

// populate reference to parent layer (this layer)
// NOTE: needs to be done even when reusing layers as the parent may have changed
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/lib/deck-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import DrawLayersPass from '../passes/draw-layers-pass';
import PickLayersPass from '../passes/pick-layers-pass';
import {Framebuffer} from '@luma.gl/core';

const EVENT_RENDER_LAYERS = 'deckRenderer.renderLayers';
const TRACE_RENDER_LAYERS = 'deckRenderer.renderLayers';

export default class DeckRenderer {
constructor(gl) {
Expand Down Expand Up @@ -58,7 +58,7 @@ export default class DeckRenderer {

this.renderCount++;

debug(EVENT_RENDER_LAYERS, this, renderStats, opts);
debug(TRACE_RENDER_LAYERS, this, renderStats, opts);
}

needsRedraw(opts = {clearRedrawFlags: false}) {
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/lib/layer-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {Stats} from 'probe.gl';
import Viewport from '../viewports/viewport';
import {createProgramManager} from '../shaderlib';

const EVENT_SET_LAYERS = 'layerManager.setLayers';
const EVENT_ACTIVATE_VIEWPORT = 'layerManager.activateViewport';
const TRACE_SET_LAYERS = 'layerManager.setLayers';
const TRACE_ACTIVATE_VIEWPORT = 'layerManager.activateViewport';

// CONTEXT IS EXPOSED TO LAYERS
const INITIAL_CONTEXT = Object.seal({
Expand Down Expand Up @@ -148,7 +148,7 @@ export default class LayerManager {
setLayers(newLayers, forceUpdate = false) {
// TODO - something is generating state updates that cause rerender of the same
const shouldUpdate = forceUpdate || newLayers !== this.lastRenderedLayers;
debug(EVENT_SET_LAYERS, this, shouldUpdate, newLayers);
debug(TRACE_SET_LAYERS, this, shouldUpdate, newLayers);

if (!shouldUpdate) {
return this;
Expand Down Expand Up @@ -215,7 +215,7 @@ export default class LayerManager {
const viewportChanged = !oldViewport || !viewport.equals(oldViewport);

if (viewportChanged) {
debug(EVENT_ACTIVATE_VIEWPORT, this, viewport);
debug(TRACE_ACTIVATE_VIEWPORT, this, viewport);

this.context.viewport = viewport;

Expand Down
31 changes: 15 additions & 16 deletions modules/core/src/lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import AttributeManager from './attribute/attribute-manager';
import UniformTransitionManager from './uniform-transition-manager';
import {diffProps, validateProps} from '../lifecycle/props';
import {count} from '../utils/count';
import log from '../utils/log';
import debug from '../debug';
import GL from '@luma.gl/constants';
import {withParameters, setParameters} from '@luma.gl/core';
Expand All @@ -39,11 +38,11 @@ import {worldToPixels} from '@math.gl/web-mercator';

import {load} from '@loaders.gl/core';

const EVENT_CHANGE_FLAG = 'layer.changeFlag';
const EVENT_INITIALIZE = 'layer.initialize';
const EVENT_UPDATE = 'layer.update';
const EVENT_FINALIZE = 'layer.finalize';
const EVENT_MATCHED = 'layer.matched';
const TRACE_CHANGE_FLAG = 'layer.changeFlag';
const TRACE_INITIALIZE = 'layer.initialize';
const TRACE_UPDATE = 'layer.update';
const TRACE_FINALIZE = 'layer.finalize';
const TRACE_MATCHED = 'layer.matched';

const EMPTY_ARRAY = Object.freeze([]);

Expand Down Expand Up @@ -541,7 +540,7 @@ export default class Layer extends Component {
// Called by layer manager when a new layer is found
/* eslint-disable max-statements */
_initialize() {
debug(EVENT_INITIALIZE, this);
debug(TRACE_INITIALIZE, this);

this._initState();

Expand Down Expand Up @@ -570,7 +569,7 @@ export default class Layer extends Component {
// Call subclass lifecycle method
const stateNeedsUpdate = this.needsUpdate();
// End lifecycle method
debug(EVENT_UPDATE, this, stateNeedsUpdate);
debug(TRACE_UPDATE, this, stateNeedsUpdate);

if (stateNeedsUpdate) {
this._updateState();
Expand Down Expand Up @@ -627,7 +626,7 @@ export default class Layer extends Component {
// Called by manager when layer is about to be disposed
// Note: not guaranteed to be called on application shutdown
_finalize() {
debug(EVENT_FINALIZE, this);
debug(TRACE_FINALIZE, this);
assert(this.internalState && this.state);

// Call subclass lifecycle method
Expand Down Expand Up @@ -686,30 +685,30 @@ export default class Layer extends Component {
// Update primary flags
if (flags.dataChanged && !changeFlags.dataChanged) {
changeFlags.dataChanged = flags.dataChanged;
debug(EVENT_CHANGE_FLAG, this, 'dataChanged', flags);
debug(TRACE_CHANGE_FLAG, this, 'dataChanged', flags);
}
if (flags.updateTriggersChanged && !changeFlags.updateTriggersChanged) {
changeFlags.updateTriggersChanged =
changeFlags.updateTriggersChanged && flags.updateTriggersChanged
? Object.assign({}, flags.updateTriggersChanged, changeFlags.updateTriggersChanged)
: flags.updateTriggersChanged || changeFlags.updateTriggersChanged;
debug(EVENT_CHANGE_FLAG, this, 'updateTriggersChanged', flags);
debug(TRACE_CHANGE_FLAG, this, 'updateTriggersChanged', flags);
}
if (flags.propsChanged && !changeFlags.propsChanged) {
changeFlags.propsChanged = flags.propsChanged;
debug(EVENT_CHANGE_FLAG, this, 'propsChanged', flags);
debug(TRACE_CHANGE_FLAG, this, 'propsChanged', flags);
}
if (flags.extensionsChanged && !changeFlags.extensionsChanged) {
changeFlags.extensionsChanged = flags.extensionsChanged;
debug(EVENT_CHANGE_FLAG, this, 'extensionsChanged', flags);
debug(TRACE_CHANGE_FLAG, this, 'extensionsChanged', flags);
}
if (flags.viewportChanged && !changeFlags.viewportChanged) {
changeFlags.viewportChanged = flags.viewportChanged;
debug(EVENT_CHANGE_FLAG, this, 'viewportChanged', flags);
debug(TRACE_CHANGE_FLAG, this, 'viewportChanged', flags);
}
if (flags.stateChanged && !changeFlags.stateChanged) {
changeFlags.stateChanged = flags.stateChanged;
debug(EVENT_CHANGE_FLAG, this, 'stateChanged', flags);
debug(TRACE_CHANGE_FLAG, this, 'stateChanged', flags);
}

// Update composite flags
Expand Down Expand Up @@ -882,7 +881,7 @@ ${flags.viewportChanged ? 'viewport' : ''}\

// Called by layer manager to transfer state from an old layer
_transferState(oldLayer) {
debug(EVENT_MATCHED, this, this === oldLayer);
debug(TRACE_MATCHED, this, this === oldLayer);

const {state, internalState} = oldLayer;
assert(state && internalState);
Expand Down
3 changes: 0 additions & 3 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ canvas.width = gl.drawingBufferWidth;
canvas.height = gl.drawingBufferHeight;
gl.canvas = canvas;

const debug = require('@deck.gl/core/debug');
debug.enable();

require('./modules');

0 comments on commit 17d8c3f

Please sign in to comment.