mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Fix a recently introduce but in Raster#getCanvas().
This commit is contained in:
parent
357b7dbc54
commit
9600fdb512
2 changed files with 8 additions and 4 deletions
|
@ -1105,10 +1105,13 @@ var Item = this.Item = Base.extend(Callback, {
|
||||||
ctx = canvas.getContext('2d'),
|
ctx = canvas.getContext('2d'),
|
||||||
matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y);
|
matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y);
|
||||||
matrix.applyToContext(ctx);
|
matrix.applyToContext(ctx);
|
||||||
// XXX: Decide how to handle _matrix
|
// TODO: Decide how to handle _matrix
|
||||||
this.draw(ctx, {});
|
this.draw(ctx, {});
|
||||||
var raster = new Raster(canvas);
|
var raster = new Raster(canvas);
|
||||||
raster.setBounds(bounds);
|
raster.setBounds(bounds);
|
||||||
|
CanvasProvider.release(canvas);
|
||||||
|
// NOTE: We don't need to release the canvas since it now belongs to the
|
||||||
|
// Raster!
|
||||||
return raster;
|
return raster;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -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
|
// policies, wrap the call in try-catch and only set _canvas if we
|
||||||
// succeeded.
|
// succeeded.
|
||||||
try {
|
try {
|
||||||
if (this._image)
|
|
||||||
this.getContext(true).drawImage(this._image, 0, 0);
|
|
||||||
this._canvas = canvas;
|
this._canvas = canvas;
|
||||||
|
if (this._image)
|
||||||
|
this.getContext().drawImage(this._image, 0, 0);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
CanvasProvider.returnCanvas(canvas);
|
this._canvas = null;
|
||||||
|
CanvasProvider.release(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this._canvas;
|
return this._canvas;
|
||||||
|
|
Loading…
Reference in a new issue