forked from visgl/deck.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9225d45
commit 71e764d
Showing
17 changed files
with
234 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
build/ | ||
dist/ | ||
dist.min.js | ||
*.min.js | ||
node_modules/ | ||
coverage/ | ||
test/**/*-failed.png | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* global deck */ | ||
import {getLoggers} from '../src/debug/loggers'; | ||
|
||
const loggers = getLoggers(deck.log); | ||
deck._registerLoggers(loggers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import deckLog from '../utils/log'; | ||
import {getLoggers} from './loggers'; | ||
|
||
/* debug utility */ | ||
|
||
let loggers; | ||
|
||
// Conditionally load default loggers in development mode | ||
// eslint-disable-next-line | ||
if (process.env.NODE_ENV !== 'production') { | ||
loggers = getLoggers(deckLog); | ||
} | ||
|
||
export function register(handlers) { | ||
loggers = handlers; | ||
} | ||
|
||
export default function debug(eventType) { | ||
if (deckLog.priority > 0 && loggers[eventType]) { | ||
// Not using ...args to defeat perf hit from array construction | ||
loggers[eventType].call(...arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
const logState = { | ||
attributeUpdateMessages: [] | ||
}; | ||
|
||
const PRIORITY_MAJOR_UPDATE = 1; // Events with direct perf impact | ||
const PRIORITY_MINOR_UPDATE = 2; // Events that may affect perf | ||
const PRIORITY_UPDATE_DETAIL = 3; | ||
const PRIORITY_INFO = 4; | ||
const PRIORITY_DRAW = 2; | ||
|
||
export const getLoggers = log => ({ | ||
/* Layer events */ | ||
|
||
'layer.changeFlag': (layer, key, flags) => { | ||
log.log(PRIORITY_UPDATE_DETAIL, `${layer.id} ${key}: `, flags[key])(); | ||
}, | ||
|
||
'layer.initialize': layer => { | ||
log.log(PRIORITY_MAJOR_UPDATE, `Initializing ${layer}`)(); | ||
}, | ||
'layer.update': (layer, needsUpdate) => { | ||
if (needsUpdate) { | ||
const flags = layer.getChangeFlags(); | ||
log.log( | ||
PRIORITY_MINOR_UPDATE, | ||
`Updating ${layer} because: ${Object.keys(flags) | ||
.filter(key => flags[key]) | ||
.join(', ')}` | ||
)(); | ||
} else { | ||
log.log(PRIORITY_INFO, `${layer} does not need update`)(); | ||
} | ||
}, | ||
'layer.matched': (layer, changed) => { | ||
if (changed) { | ||
log.log(PRIORITY_INFO, `Matched ${layer}, state transfered`)(); | ||
} | ||
}, | ||
'layer.finalize': layer => { | ||
log.log(PRIORITY_MAJOR_UPDATE, `Finalizing ${layer}`)(); | ||
}, | ||
|
||
/* CompositeLayer events */ | ||
|
||
'compositeLayer.renderLayers': (layer, updated, subLayers) => { | ||
if (updated) { | ||
log.log( | ||
PRIORITY_MINOR_UPDATE, | ||
`Composite layer rendered new subLayers ${layer}`, | ||
subLayers | ||
)(); | ||
} else { | ||
log.log(PRIORITY_INFO, `Composite layer reused subLayers ${layer}`, subLayers)(); | ||
} | ||
}, | ||
|
||
/* LayerManager events */ | ||
|
||
'layerManager.setLayers': (layerManager, updated, layers) => { | ||
if (updated) { | ||
log.log(PRIORITY_MINOR_UPDATE, `Updating ${layers.length} deck layers`)(); | ||
} | ||
}, | ||
|
||
'layerManager.activateViewport': (layerManager, viewport) => { | ||
log.log(PRIORITY_UPDATE_DETAIL, 'Viewport changed', viewport)(); | ||
}, | ||
|
||
/* AttributeManager events */ | ||
|
||
'attributeManager.invalidate': (attributeManager, trigger, attributeNames) => { | ||
log.log( | ||
PRIORITY_MAJOR_UPDATE, | ||
attributeNames | ||
? `invalidated attributes ${attributeNames} (${trigger}) for ${attributeManager.id}` | ||
: `invalidated all attributes for ${attributeManager.id}` | ||
)(); | ||
}, | ||
|
||
'attributeManager.updateStart': attributeManager => { | ||
logState.attributeUpdateMessages.length = 0; | ||
logState.attributeManagerUpdateStart = Date.now(); | ||
}, | ||
'attributeManager.updateEnd': (attributeManager, numInstances) => { | ||
const timeMs = Math.round(Date.now() - logState.attributeManagerUpdateStart); | ||
log.groupCollapsed( | ||
PRIORITY_MINOR_UPDATE, | ||
`Updated attributes for ${numInstances} instances in ${attributeManager.id} in ${timeMs}ms` | ||
)(); | ||
for (const updateMessage of logState.attributeUpdateMessages) { | ||
log.log(PRIORITY_UPDATE_DETAIL, updateMessage)(); | ||
} | ||
log.groupEnd(PRIORITY_MINOR_UPDATE)(); | ||
}, | ||
|
||
/* Attribute events */ | ||
|
||
'attribute.updateStart': attribute => { | ||
logState.attributeUpdateStart = Date.now(); | ||
}, | ||
'attribute.allocate': (attribute, numInstances) => { | ||
const message = `${attribute.id} allocated ${numInstances}`; | ||
logState.attributeUpdateMessages.push(message); | ||
}, | ||
'attribute.updateEnd': (attribute, numInstances) => { | ||
const timeMs = Math.round(Date.now() - logState.attributeUpdateStart); | ||
const message = `${attribute.id} updated ${numInstances} in ${timeMs}ms`; | ||
logState.attributeUpdateMessages.push(message); | ||
}, | ||
|
||
/* Render events */ | ||
|
||
'deckRenderer.renderLayers': (deckRenderer, renderStats, opts) => { | ||
const {pass, redrawReason, stats} = opts; | ||
for (const status of renderStats) { | ||
const {totalCount, visibleCount, compositeCount, pickableCount} = status; | ||
const primitiveCount = totalCount - compositeCount; | ||
const hiddenCount = primitiveCount - visibleCount; | ||
|
||
log.log( | ||
PRIORITY_DRAW, | ||
`RENDER #${deckRenderer.renderCount} \ | ||
${visibleCount} (of ${totalCount} layers) to ${pass} because ${redrawReason} \ | ||
(${hiddenCount} hidden, ${compositeCount} composite ${pickableCount} pickable)` | ||
)(); | ||
|
||
if (stats) { | ||
stats.get('Redraw Layers').add(visibleCount); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.