Improved performance of image filters. See Issue #462

This commit is contained in:
ippo615
2013-08-25 10:35:32 -04:00
parent 1d10a03772
commit cddf36b423

View File

@@ -1,4 +1,5 @@
(function() {
// CONSTANTS
var IMAGE = 'Image',
CROP = 'crop',
@@ -118,15 +119,21 @@
filter = this.getFilter(),
filterCanvas, context, imageData;
filterCanvas = this.filterCanvas = new Kinetic.SceneCanvas({
width: width,
height: height,
pixelRatio: 1
});
if (this.filterCanvas){
filterCanvas = this.filterCanvas;
}
else {
filterCanvas = this.filterCanvas = new Kinetic.SceneCanvas({
width: width,
height: height,
pixelRatio: 1
});
}
context = filterCanvas.getContext();
try {
context.clearRect(0,0,filterCanvas.getWidth(), filterCanvas.getHeight());
this._drawImage(context, [image, 0, 0, filterCanvas.getWidth(), filterCanvas.getHeight()]);
imageData = context.getImageData(0, 0, filterCanvas.getWidth(), filterCanvas.getHeight());
filter.call(this, imageData);