BlendMode: support DocumentView and return if an item's bounds is null.

This commit is contained in:
Jonathan Puckey 2011-02-28 18:36:06 +01:00
parent 0e011dee2a
commit eee5e63a72

View file

@ -30,15 +30,18 @@ BlendMode = {
process: function(documentContext, item, param) { process: function(documentContext, item, param) {
// TODO: use strokeBounds // TODO: use strokeBounds
var itemBounds = item.bounds; var itemBounds = item.bounds;
if (!itemBounds)
return;
var top = Math.floor(itemBounds.top); var top = Math.floor(itemBounds.top);
var left = Math.floor(itemBounds.left); var left = Math.floor(itemBounds.left);
var size = itemBounds.size.ceil(); var size = itemBounds.size.ceil().add(1, 1);
var width = size.width; var width = size.width;
var height = size.height; var height = size.height;
var itemCanvas = CanvasProvider.getCanvas(size); var itemCanvas = CanvasProvider.getCanvas(size);
var itemContext = itemCanvas.getContext('2d'); var itemContext = itemCanvas.getContext('2d');
if(item.matrix) { itemContext.save();
if (item.matrix) {
var matrix = item.matrix.clone(); var matrix = item.matrix.clone();
var transMatrix = Matrix.getTranslateInstance(-left, -top); var transMatrix = Matrix.getTranslateInstance(-left, -top);
matrix.preConcatenate(transMatrix); matrix.preConcatenate(transMatrix);
@ -210,6 +213,7 @@ BlendMode = {
} }
} }
documentContext.putImageData(dstD, left, top); documentContext.putImageData(dstD, left, top);
itemContext.restore();
CanvasProvider.returnCanvas(itemCanvas); CanvasProvider.returnCanvas(itemCanvas);
} }
}; };