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