From 17d8c3fe60a5c7ef0941e67ba84e1fe170c83d27 Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Thu, 5 Dec 2019 10:12:16 -0800 Subject: [PATCH] fix tests --- .../src/lib/attribute/attribute-manager.js | 26 ++++++++-------- modules/core/src/lib/composite-layer.js | 4 +-- modules/core/src/lib/deck-renderer.js | 4 +-- modules/core/src/lib/layer-manager.js | 8 ++--- modules/core/src/lib/layer.js | 31 +++++++++---------- test/node.js | 3 -- 6 files changed, 36 insertions(+), 40 deletions(-) diff --git a/modules/core/src/lib/attribute/attribute-manager.js b/modules/core/src/lib/attribute/attribute-manager.js index 0de9be5cf8b..6a3f5998501 100644 --- a/modules/core/src/lib/attribute/attribute-manager.js +++ b/modules/core/src/lib/attribute/attribute-manager.js @@ -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 { /** @@ -139,7 +139,7 @@ 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) { @@ -147,7 +147,7 @@ export default class AttributeManager { 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. @@ -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(); } @@ -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) { @@ -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); } } } diff --git a/modules/core/src/lib/composite-layer.js b/modules/core/src/lib/composite-layer.js index 47ca54eb9e8..79c5288717f 100644 --- a/modules/core/src/lib/composite-layer.js +++ b/modules/core/src/lib/composite-layer.js @@ -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() { @@ -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 diff --git a/modules/core/src/lib/deck-renderer.js b/modules/core/src/lib/deck-renderer.js index 56218562b3a..b2e0f93e8a0 100644 --- a/modules/core/src/lib/deck-renderer.js +++ b/modules/core/src/lib/deck-renderer.js @@ -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) { @@ -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}) { diff --git a/modules/core/src/lib/layer-manager.js b/modules/core/src/lib/layer-manager.js index 9783f636a0a..eaae693357b 100644 --- a/modules/core/src/lib/layer-manager.js +++ b/modules/core/src/lib/layer-manager.js @@ -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({ @@ -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; @@ -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; diff --git a/modules/core/src/lib/layer.js b/modules/core/src/lib/layer.js index 59ff531f27b..ddf98d20a72 100644 --- a/modules/core/src/lib/layer.js +++ b/modules/core/src/lib/layer.js @@ -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'; @@ -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([]); @@ -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(); @@ -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(); @@ -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 @@ -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 @@ -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); diff --git a/test/node.js b/test/node.js index 11bb7ed1c6c..e9b29a8a8a5 100644 --- a/test/node.js +++ b/test/node.js @@ -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');