diff options
author | Anton Tarasov <anton.tarasov@jetbrains.com> | 2017-09-26 16:13:52 +0300 |
---|---|---|
committer | Anton Tarasov <anton.tarasov@jetbrains.com> | 2017-10-11 13:03:32 +0300 |
commit | a2917a489382ec2e6ed3fe02479b6f3227b0cb7e (patch) | |
tree | 75289e3bb14db3edcdb4e1f7c1899caf74055d59 /src/macosx | |
parent | 8ffc190fbdb059d5a24842115c0bc3ade8b351b9 (diff) | |
download | jdk8u_jdk-a2917a489382ec2e6ed3fe02479b6f3227b0cb7e.tar.gz |
JRE-310 [backported] JDK-8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
Diffstat (limited to 'src/macosx')
3 files changed, 20 insertions, 46 deletions
diff --git a/src/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java b/src/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java index 700f46bc3d..de39f5c5a6 100644 --- a/src/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java +++ b/src/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java @@ -478,13 +478,9 @@ public class OSXOffScreenSurfaceData extends OSXSurfaceData // implements Raster // <rdar://problem/4488745> For the Sun2D renderer we should rely on the implementation of the super class. // BufImageSurfaceData.java doesn't have an implementation of copyArea() and relies on the super class. - int offsetX = 0; - int offsetY = 0; - if (sg2d.transformState == SunGraphics2D.TRANSFORM_ANY_TRANSLATE || - sg2d.transformState == SunGraphics2D.TRANSFORM_INT_TRANSLATE) { - offsetX = (int) sg2d.transform.getTranslateX(); - offsetY = (int) sg2d.transform.getTranslateY(); - } else if (sg2d.transformState != SunGraphics2D.TRANSFORM_ISIDENT) { return false; } + if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { + return false; + } // reset the clip (this is how it works on windows) // we actually can handle a case with any clips but windows ignores the light clip @@ -498,18 +494,23 @@ public class OSXOffScreenSurfaceData extends OSXSurfaceData // implements Raster return true; } - // the rectangle returned from clipCopyArea() is in the coordinate space of the surface (image) - // we need to substract the offsetX and offsetY to move it to the coordinate space of the graphics2d. - // sg2d.drawImage expects the destination rect to be in the coord space of the graphics2d. <rdar://3746194> - // (vm) - x = clippedCopyAreaRect.x - offsetX; - y = clippedCopyAreaRect.y - offsetY; + // the rectangle returned from clipCopyArea() is in the coordinate space + // of the surface (image) + x = clippedCopyAreaRect.x; + y = clippedCopyAreaRect.y; w = clippedCopyAreaRect.width; h = clippedCopyAreaRect.height; - // copy (dst coordinates are in the coord space of the graphics2d, and src coordinates are - // in the coordinate space of the image) - 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); + // copy (dst coordinates are in the coord space of the graphics2d, and + // src coordinates are in the coordinate space of the image) + // sg2d.drawImage expects the destination rect to be in the coord space + // of the graphics2d. <rdar://3746194> (vm) + // we need to substract the transX and transY to move it + // to the coordinate space of the graphics2d. + int dstX = x + dx - sg2d.transX; + int dstY = y + dy - sg2d.transY; + sg2d.drawImage(this.bim, dstX, dstY, dstX + w, dstY + h, + x, y, x + w, y + h, null); // restore the clip sg2d.setClip(clip); diff --git a/src/macosx/classes/sun/java2d/OSXSurfaceData.java b/src/macosx/classes/sun/java2d/OSXSurfaceData.java index 59b0d7e80f..80cd955bc0 100644 --- a/src/macosx/classes/sun/java2d/OSXSurfaceData.java +++ b/src/macosx/classes/sun/java2d/OSXSurfaceData.java @@ -1172,19 +1172,17 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData { } /** - * Clips the copy area to the heavywieght bounds and returns the cliped rectangle. The tricky part here is the the + * Clips the copy area to the heavywieght bounds and returns the cliped rectangle. The tricky part here is the * passed arguments x, y are in the coordinate space of the sg2d/lightweight comp. In order to do the clipping we * translate them to the coordinate space of the surface, and the returned clipped rectangle is in the coordinate * space of the surface. + * Clips the copy area to the heavyweight bounds and returns the clipped rectangle. + * The returned clipped rectangle is in the coordinate space of the surface. */ protected Rectangle clipCopyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { // we need to clip against the heavyweight bounds copyAreaBounds.setBounds(sg2d.devClip.getLoX(), sg2d.devClip.getLoY(), sg2d.devClip.getWidth(), sg2d.devClip.getHeight()); - // put src rect into surface coordinate space - x += sg2d.transX; - y += sg2d.transY; - // clip src rect srcCopyAreaRect.setBounds(x, y, w, h); intersection(srcCopyAreaRect, copyAreaBounds, srcCopyAreaRect); diff --git a/src/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java b/src/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java index 81e322c653..39f2e4956e 100644 --- a/src/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java +++ b/src/macosx/classes/sun/java2d/opengl/CGLSurfaceData.java @@ -180,31 +180,6 @@ public abstract class CGLSurfaceData extends OGLSurfaceData { return scale; } - @Override - public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, - int dx, int dy) { - final int state = sg2d.transformState; - if (state > SunGraphics2D.TRANSFORM_TRANSLATESCALE - || sg2d.compositeState >= SunGraphics2D.COMP_XOR) { - return false; - } - if (state <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE) { - x += sg2d.transX; - y += sg2d.transY; - } else if (state == SunGraphics2D.TRANSFORM_TRANSLATESCALE) { - final double[] coords = {x, y, x + w, y + h, x + dx, y + dy}; - sg2d.transform.transform(coords, 0, coords, 0, 3); - x = (int) Math.ceil(coords[0] - 0.5); - y = (int) Math.ceil(coords[1] - 0.5); - w = ((int) Math.ceil(coords[2] - 0.5)) - x; - h = ((int) Math.ceil(coords[3] - 0.5)) - y; - dx = ((int) Math.ceil(coords[4] - 0.5)) - x; - dy = ((int) Math.ceil(coords[5] - 0.5)) - y; - } - oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy); - return true; - } - protected native void clearWindow(); public static class CGLWindowSurfaceData extends CGLSurfaceData { |