From c9a7f2695b55f89cc64ad86c6d5db118c18b8669 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 11 May 2015 07:57:02 -0500 Subject: [PATCH] Adds options to disable scratch canvases logging --- examples/inspector/js/inspector.js | 13 ++++++++----- examples/inspector/js/inspectorGfx.js | 16 ++++++++++++++-- examples/inspector/js/inspectorSettings.js | 2 ++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/examples/inspector/js/inspector.js b/examples/inspector/js/inspector.js index e4ae65e9c..f74000632 100644 --- a/examples/inspector/js/inspector.js +++ b/examples/inspector/js/inspector.js @@ -200,12 +200,11 @@ Promise.all([gfxReady, playerReady]).then(function () { createOptionsGUI(); - gfxWindow.assetListContainer = document.getElementById("assetList"); - gfxWindow.scratchCanvasContainer = document.getElementById("scratchCanvasContainer"); - setRelease(state.release); gfxWindow.resizeEaselContainer(state.width, state.height); - gfxWindow.setLogAssets(state.logAssets); + gfxWindow.setLogAssets(state.logAssets, document.getElementById("assetList")); + gfxWindow.setLogScratchCanvases(state.logScratchCanvases, + document.getElementById("scratchCanvasContainer")); if (state.profileStartup && state.profileStartupDuration > 0) { profiler.start(performance.now(), state.profileStartupDuration, false); @@ -231,7 +230,11 @@ document.addEventListener('inspectorOptionsChanged', function (e) { setRelease(state.release); break; case 'logAssets': - gfxWindow.setLogAssets(state.logAssets); + gfxWindow.setLogAssets(state.logAssets, document.getElementById("assetList")); + break; + case 'logScratchCanvases': + gfxWindow.setLogScratchCanvases(state.logScratchCanvases, + document.getElementById("scratchCanvasContainer")); break; case 'overlayFlash': gfxWindow.setFlashOverlayState(state.overlayFlash); diff --git a/examples/inspector/js/inspectorGfx.js b/examples/inspector/js/inspectorGfx.js index 3e2a54b65..a94f86dfc 100644 --- a/examples/inspector/js/inspectorGfx.js +++ b/examples/inspector/js/inspectorGfx.js @@ -38,8 +38,15 @@ function setProfile(enabled) { } var logAssets = false; -function setLogAssets(enabled) { +function setLogAssets(enabled, assetListContainer_) { logAssets = enabled; + assetListContainer = assetListContainer_; +} + +var logScratchCanvases = false; +function setLogScratchCanvases(enabled, scratchCanvasContainer_) { + logScratchCanvases = enabled; + scratchCanvasContainer = scratchCanvasContainer_; } function resizeEaselContainer(width, height) { @@ -168,8 +175,13 @@ HTMLCanvasElement.prototype.getContext = function getContext(contextId, args) { var scratchCanvasContainer; function registerScratchCanvas(scratchCanvas) { - if (scratchCanvasContainer) { + if (logScratchCanvases) { scratchCanvasContainer.appendChild(scratchCanvas); + } else { + // Temporary hack to work around a bug that prevents SVG filters to work for off-screen canvases. + // TODO remove + scratchCanvas.style.display = 'none'; + document.body.appendChild(scratchCanvas); } } diff --git a/examples/inspector/js/inspectorSettings.js b/examples/inspector/js/inspectorSettings.js index db11474f1..276df677c 100644 --- a/examples/inspector/js/inspectorSettings.js +++ b/examples/inspector/js/inspectorSettings.js @@ -26,6 +26,7 @@ var stateDefaults = { logToConsole: false, logToDebugPanel: false, logAssets: false, + logScratchCanvases: false, overlayFlash: false, fileReadChunkSize: 0, mute: false, @@ -84,6 +85,7 @@ function createOptionsGUI() { inspectorOptions.add(state, "logToConsole").onChange(saveInspectorOption); inspectorOptions.add(state, "logToDebugPanel").onChange(saveInspectorOption); inspectorOptions.add(state, "logAssets").onChange(saveInspectorOption); + inspectorOptions.add(state, "logScratchCanvases").onChange(saveInspectorOption); inspectorOptions.add(state, "profileStartup").onChange(saveInspectorOption); inspectorOptions.add(state, "profileStartupDuration").onChange(saveInspectorOption); inspectorOptions.add(state, "overlayFlash").onChange(saveInspectorOption);