@@ -442,6 +442,10 @@ private boolean drawImageXT(Image img, AffineTransform xform,
442442 return ret ;
443443 }
444444
445+ private Object imageData ;
446+ private int [] buf8 ;
447+ private int lastx ,lasty ,nx ,ny ;
448+
445449 @ SuppressWarnings ("unused" )
446450 public boolean drawImagePriv (Image img , int x , int y , ImageObserver observer ) {
447451 backgroundPainted = true ;
@@ -465,8 +469,14 @@ public boolean drawImagePriv(Image img, int x, int y, ImageObserver observer) {
465469 if ((imgNode = getImageNode (img )) != null )
466470 ctx .drawImage (imgNode , x , y , width , height );
467471 } else {
468- Object imageData = HTML5CanvasContext2D .getImageData (ctx , x , y , width , height );
469- int [] buf8 = HTML5CanvasContext2D .getBuf8 (imageData );
472+ if (buf8 == null || x != lastx || y != lasty || nx != width || ny != height ) {
473+ imageData = HTML5CanvasContext2D .getImageData (ctx , x , y , width , height );
474+ buf8 = HTML5CanvasContext2D .getBuf8 (imageData );
475+ lastx = x ;
476+ lasty = y ;
477+ nx = width ;
478+ ny = height ;
479+ }
470480 for (int pt = 0 , i = 0 , n = Math .min (buf8 .length /4 , pixels .length ); i < n ; i ++) {
471481 int argb = pixels [i ];
472482 buf8 [pt ++] = (argb >> 16 ) & 0xFF ;
0 commit comments