mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
Improved performance of image filters. See Issue #462
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user