diff --git a/src/item/Item.js b/src/item/Item.js index ae8376da..832af936 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1105,10 +1105,13 @@ var Item = this.Item = Base.extend(Callback, { ctx = canvas.getContext('2d'), matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y); matrix.applyToContext(ctx); - // XXX: Decide how to handle _matrix + // TODO: Decide how to handle _matrix this.draw(ctx, {}); var raster = new Raster(canvas); raster.setBounds(bounds); + CanvasProvider.release(canvas); + // NOTE: We don't need to release the canvas since it now belongs to the + // Raster! return raster; }, diff --git a/src/item/Raster.js b/src/item/Raster.js index b44efa54..ab0606a6 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -163,11 +163,12 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ // policies, wrap the call in try-catch and only set _canvas if we // succeeded. try { - if (this._image) - this.getContext(true).drawImage(this._image, 0, 0); this._canvas = canvas; + if (this._image) + this.getContext().drawImage(this._image, 0, 0); } catch (e) { - CanvasProvider.returnCanvas(canvas); + this._canvas = null; + CanvasProvider.release(canvas); } } return this._canvas;