From 2da05a4c71bfe9b136384d9e94fbfbef19f24550 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 27 Jun 2012 17:28:06 -0700 Subject: Performance fix for WebGL materials playing even when the dialog/file is no longer in view. Also pausing videos when switching documents. Signed-off-by: Nivesh Rajbhandari --- js/document/views/base.js | 3 ++ js/document/views/design.js | 29 ++++++++++-- js/lib/drawing/world.js | 1 + .../materials-library-panel.js | 2 + .../materials-popup.reel/materials-popup.js | 51 +++++++++++----------- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/js/document/views/base.js b/js/document/views/base.js index d13dce1a..89759195 100755 --- a/js/document/views/base.js +++ b/js/document/views/base.js @@ -40,6 +40,7 @@ exports.BaseDocumentView = Montage.create(Component, { if (this.iframe) { this.iframe.style.display = 'block'; this.iframe.style.opacity = 1; + this.toggleWebGlAnimation(true); } else { console.log('Error: View has no iframe to show!'); } @@ -54,6 +55,8 @@ exports.BaseDocumentView = Montage.create(Component, { if (this.iframe) { this.iframe.style.display = 'none'; this.iframe.style.opacity = 0; + this.pauseVideos(); + this.toggleWebGlAnimation(false); } else { console.log('Error: View has no iframe to hide!'); } diff --git a/js/document/views/design.js b/js/document/views/design.js index 6a60e1f9..5c7ba4fc 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -497,9 +497,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { // pauseVideos:{ value:function(){ - var i, videos = this.document.getElementsByTagName("video"); - for(i = 0; i < videos.length; i++){ - if(!videos[i].paused) videos[i].pause(); + if(this.document) { + var i, videos = this.document.getElementsByTagName("video"); + for(i = 0; i < videos.length; i++){ + if(!videos[i].paused) videos[i].pause(); + } } } }, @@ -523,9 +525,28 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { videos[i].src = ""; } } - } + }, //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// + toggleWebGlAnimation: { + value: function(show) { + if(this.document) { + var glCanvases = this.document.querySelectorAll('[data-RDGE-id]'), + glShapeModel; + if(glCanvases) { + for(var i = 0, len = glCanvases.length; i 0)) @@ -385,7 +385,7 @@ exports.MaterialsPopup = Montage.create(Component, { this.previewShape.setFillMaterial(this._material); this.previewShape.buildBuffers(); - world.render(); + world.restartRenderLoop(); } }, @@ -393,7 +393,8 @@ exports.MaterialsPopup = Montage.create(Component, { destroy: { enumerable: false, value: function() { - // add cleanup routines here +// console.log("cleanup routines here"); + this.previewShape.getWorld().stop(); } }, -- cgit v1.2.3