From 29fa604d742191e29af69b0ab0556386ece24bc5 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Sat, 12 Apr 2014 15:16:18 +0200 Subject: [PATCH] Fix : protect LayerRenderer against fake setDisplaySize calls --- src/js/rendering/frame/CachedFrameRenderer.js | 2 +- src/js/rendering/layer/LayersRenderer.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/js/rendering/frame/CachedFrameRenderer.js b/src/js/rendering/frame/CachedFrameRenderer.js index 79e6d5f7..6bdd69ea 100644 --- a/src/js/rendering/frame/CachedFrameRenderer.js +++ b/src/js/rendering/frame/CachedFrameRenderer.js @@ -24,7 +24,7 @@ */ ns.CachedFrameRenderer.prototype.setDisplaySize = function (width, height) { if (this.displayWidth !== width || this.displayHeight !== height) { - pskl.rendering.frame.FrameRenderer.prototype.setDisplaySize.call(this, width, height); + this.superclass.setDisplaySize.call(this, width, height); } }; diff --git a/src/js/rendering/layer/LayersRenderer.js b/src/js/rendering/layer/LayersRenderer.js index cb0e2c76..fd09a45c 100644 --- a/src/js/rendering/layer/LayersRenderer.js +++ b/src/js/rendering/layer/LayersRenderer.js @@ -58,6 +58,20 @@ } }; + + /** + * See @pskl.rendering.frame.CachedFrameRenderer + * Same issue : FrameRenderer setDisplaySize destroys the canvas + * @param {Number} width + * @param {Number} height + */ + ns.LayersRenderer.prototype.setDisplaySize = function (width, height) { + var size = this.getDisplaySize(); + if (size.width !== width || size.height !== height) { + this.superclass.setDisplaySize.call(this, width, height); + } + }; + ns.LayersRenderer.prototype.getFrameForLayersAt_ = function (frameIndex, layers) { var frames = layers.map(function (l) { return l.getFrameAt(frameIndex);