< prev index next >

src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java

Print this page




 461         this.bim = bufImg;
 462 
 463         this.fImageInfo = ByteBuffer.allocateDirect(4 * kSizeOfParameters);
 464         this.fImageInfo.order(ByteOrder.nativeOrder());
 465         this.fImageInfoInt = this.fImageInfo.asIntBuffer();
 466 
 467         this.fImageInfoInt.put(kNeedToSyncFromJavaPixelsIndex, 1); // need to sync from Java the very first time
 468         this.fImageInfoInt.put(kNativePixelsChangedIndex, 0);
 469         this.fImageInfoInt.put(kImageStolenIndex, 0);
 470 
 471         this.lock = new Object();
 472     }
 473 
 474     /**
 475      * Performs a copyArea within this surface.
 476      */
 477     public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) {
 478         // <rdar://problem/4488745> For the Sun2D renderer we should rely on the implementation of the super class.
 479         // BufImageSurfaceData.java doesn't have an implementation of copyArea() and relies on the super class.
 480 
 481         int offsetX = 0;
 482         int offsetY = 0;
 483         if (sg2d.transformState == SunGraphics2D.TRANSFORM_ANY_TRANSLATE ||
 484                     sg2d.transformState == SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
 485             offsetX = (int) sg2d.transform.getTranslateX();
 486             offsetY = (int) sg2d.transform.getTranslateY();
 487         } else if (sg2d.transformState != SunGraphics2D.TRANSFORM_ISIDENT) { return false; }
 488 
 489         // reset the clip (this is how it works on windows)
 490         // we actually can handle a case with any clips but windows ignores the light clip
 491         Shape clip = sg2d.getClip();
 492         sg2d.setClip(getBounds());
 493 
 494         // clip copyArea
 495         Rectangle clippedCopyAreaRect = clipCopyArea(sg2d, x, y, w, h, dx, dy);
 496         if (clippedCopyAreaRect == null) {
 497             // clipped out
 498             return true;
 499         }
 500 
 501         // the rectangle returned from clipCopyArea() is in the coordinate space of the surface (image)
 502         // we need to substract the offsetX and offsetY to move it to the coordinate space of the graphics2d.
 503         // sg2d.drawImage expects the destination rect to be in the coord space of the graphics2d. <rdar://3746194>
 504         // (vm)
 505         x = clippedCopyAreaRect.x - offsetX;
 506         y = clippedCopyAreaRect.y - offsetY;
 507         w = clippedCopyAreaRect.width;
 508         h = clippedCopyAreaRect.height;
 509 
 510         // copy (dst coordinates are in the coord space of the graphics2d, and src coordinates are
 511         // in the coordinate space of the image)
 512         sg2d.drawImage(this.bim, x + dx, y + dy, x + dx + w, y + dy + h, x + offsetX, y + offsetY, x + w + offsetX, y + h + offsetY, null);







 513 
 514         // restore the clip
 515         sg2d.setClip(clip);
 516 
 517         return true;
 518     }
 519 
 520     /**
 521      * Performs a copyarea from this surface to a buffered image. If null is passed in for the image a new image will be
 522      * created.
 523      *
 524      * Only used by compositor code (private API)
 525      */
 526     public BufferedImage copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, BufferedImage dstImage) {
 527         // create the destination image if needed
 528         if (dstImage == null) {
 529             dstImage = getDeviceConfiguration().createCompatibleImage(w, h);
 530         }
 531 
 532         // copy




 461         this.bim = bufImg;
 462 
 463         this.fImageInfo = ByteBuffer.allocateDirect(4 * kSizeOfParameters);
 464         this.fImageInfo.order(ByteOrder.nativeOrder());
 465         this.fImageInfoInt = this.fImageInfo.asIntBuffer();
 466 
 467         this.fImageInfoInt.put(kNeedToSyncFromJavaPixelsIndex, 1); // need to sync from Java the very first time
 468         this.fImageInfoInt.put(kNativePixelsChangedIndex, 0);
 469         this.fImageInfoInt.put(kImageStolenIndex, 0);
 470 
 471         this.lock = new Object();
 472     }
 473 
 474     /**
 475      * Performs a copyArea within this surface.
 476      */
 477     public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) {
 478         // <rdar://problem/4488745> For the Sun2D renderer we should rely on the implementation of the super class.
 479         // BufImageSurfaceData.java doesn't have an implementation of copyArea() and relies on the super class.
 480 
 481         if (sg2d.transformState > SunGraphics2D.TRANSFORM_ANY_TRANSLATE) {
 482             return false;
 483         }




 484 
 485         // reset the clip (this is how it works on windows)
 486         // we actually can handle a case with any clips but windows ignores the light clip
 487         Shape clip = sg2d.getClip();
 488         sg2d.setClip(getBounds());
 489 
 490         // clip copyArea
 491         Rectangle clippedCopyAreaRect = clipCopyArea(sg2d, x, y, w, h, dx, dy);
 492         if (clippedCopyAreaRect == null) {
 493             // clipped out
 494             return true;
 495         }
 496 
 497         // the rectangle returned from clipCopyArea() is in the coordinate space
 498         // of the surface (image)
 499         x = clippedCopyAreaRect.x;
 500         y = clippedCopyAreaRect.y;


 501         w = clippedCopyAreaRect.width;
 502         h = clippedCopyAreaRect.height;
 503 
 504         // copy (dst coordinates are in the coord space of the graphics2d, and
 505         // src coordinates are in the coordinate space of the image)
 506         // sg2d.drawImage expects the destination rect to be in the coord space
 507         // of the graphics2d. <rdar://3746194> (vm)
 508         // we need to substract the transX and transY to move it
 509         // to the coordinate space of the graphics2d.
 510         int dstX = x + dx - sg2d.transX;
 511         int dstY = y + dy - sg2d.transY;
 512         sg2d.drawImage(this.bim, dstX, dstY, dstX + w, dstY + h,
 513                        x, y, x + w, y + h, null);
 514 
 515         // restore the clip
 516         sg2d.setClip(clip);
 517 
 518         return true;
 519     }
 520 
 521     /**
 522      * Performs a copyarea from this surface to a buffered image. If null is passed in for the image a new image will be
 523      * created.
 524      *
 525      * Only used by compositor code (private API)
 526      */
 527     public BufferedImage copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, BufferedImage dstImage) {
 528         // create the destination image if needed
 529         if (dstImage == null) {
 530             dstImage = getDeviceConfiguration().createCompatibleImage(w, h);
 531         }
 532 
 533         // copy


< prev index next >