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