--- old/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java 2017-11-07 18:05:13.644251111 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java 2017-11-07 18:05:13.464161110 +0530 @@ -26,10 +26,12 @@ import java.awt.AlphaComposite; import java.awt.Color; +import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Window; +import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.awt.image.VolatileImage; @@ -38,6 +40,7 @@ import sun.java2d.DestSurfaceProvider; import sun.java2d.InvalidPipeException; import sun.java2d.Surface; +import sun.java2d.pipe.Region; import sun.java2d.pipe.RenderQueue; import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.hw.AccelGraphicsConfig; @@ -117,6 +120,12 @@ protected abstract boolean update(Image bb); /** + * Create (if needed), clears back buffer (if requested) and return + * graphics for this class depending upon the buffer type + */ + protected abstract Graphics getGraphics(boolean clear); + + /** * Flushes the resources associated with the painter. They will be * recreated as needed. */ @@ -130,10 +139,9 @@ */ public void updateWindow(boolean repaint) { boolean done = false; - Image bb = getBackBuffer(repaint); while (!done) { if (repaint) { - Graphics2D g = (Graphics2D)bb.getGraphics(); + Graphics2D g = (Graphics2D) getGraphics(repaint); try { window.paintAll(g); } finally { @@ -141,10 +149,9 @@ } } - done = update(bb); + done = update(getBackBuffer(false)); if (!done) { repaint = true; - bb = getBackBuffer(true); } } } @@ -178,8 +185,12 @@ @Override protected Image getBackBuffer(boolean clear) { - int w = window.getWidth(); - int h = window.getHeight(); + GraphicsConfiguration gc = peer.getGraphicsConfiguration(); + AffineTransform transform = gc.getDefaultTransform(); + int w = Region.clipRound( + window.getWidth() * transform.getScaleX()); + int h = Region.clipRound( + window.getHeight() * transform.getScaleY()); if (backBuffer == null || backBuffer.getWidth() != w || backBuffer.getHeight() != h) @@ -236,6 +247,19 @@ backBuffer = null; } } + + @Override + protected Graphics getGraphics(boolean clear) { + Graphics g = getBackBuffer(clear).getGraphics(); + /* + This graphics object returned by BuffereImage is not scaled to + graphics configuration, but this graphics object can be used by + components inside this TranslucentWindow. So need to scale this + before returning. + */ + ((Graphics2D)g).transform(peer.getGraphicsConfiguration().getDefaultTransform()); + return g; + } } /** @@ -283,6 +307,11 @@ viBB = null; } } + + @Override + protected Graphics getGraphics(boolean clear) { + return getBackBuffer(clear).getGraphics(); + } } /** --- old/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2017-11-07 18:05:14.140499111 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2017-11-07 18:05:13.952405111 +0530 @@ -717,7 +717,7 @@ public final Graphics getTranslucentGraphics() { synchronized (getStateLock()) { - return isOpaque ? null : painter.getBackBuffer(false).getGraphics(); + return isOpaque ? null : painter.getGraphics(false); } } --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucent.java 2017-11-07 18:05:14.592725110 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucent.java 2017-11-07 18:05:14.412635110 +0530 @@ -25,6 +25,7 @@ /* * @test + * @bug 8164811 * @key headful * @summary Check if a per-pixel translucent window is dragged and resized * by mouse correctly. @@ -42,6 +43,7 @@ * @library ../../../../lib/testlibrary * @build Common ExtendedRobot * @run main PerPixelTranslucent + * @run main/othervm -Dsun.java2d.uiScale=1.5 PerPixelTranslucent */ public class PerPixelTranslucent extends Common { --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java 2017-11-07 18:05:15.032945111 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java 2017-11-07 18:05:14.856857110 +0530 @@ -26,7 +26,7 @@ /* * @test * @key headful - * @bug 8032644 + * @bug 8032644 8164811 * @summary Check if a per-pixel translucent window is dragged and resized by * mouse correctly * Test Description: Check if PERPIXEL_TRANSLUCENT translucency type is supported @@ -44,6 +44,7 @@ * @library ../../../../lib/testlibrary * @build Common ExtendedRobot * @run main PerPixelTranslucentGradient + * @run main/othervm -Dsun.java2d.uiScale=1.5 PerPixelTranslucentGradient */ public class PerPixelTranslucentGradient extends Common { --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java 2017-11-07 18:05:15.513185110 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java 2017-11-07 18:05:15.305081110 +0530 @@ -26,6 +26,7 @@ /* * @test + * @bug 8164811 * @key headful * @summary Check if a per-pixel translucent window shows only the area having * opaque pixels @@ -40,6 +41,7 @@ * @library ../../../../lib/testlibrary * @build Common ExtendedRobot * @run main PerPixelTranslucentSwing + * @run main/othervm -Dsun.java2d.uiScale=1.5 PerPixelTranslucentSwing */ public class PerPixelTranslucentSwing extends Common { --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 2017-11-07 18:05:16.013435111 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 2017-11-07 18:05:15.789323111 +0530 @@ -26,7 +26,7 @@ /* * @test * @key headful - * @bug 7043845 + * @bug 7043845 8164811 * @summary Check if shaped and per-pixel translucent window is dragged and * resized by mouse correctly. * Test Description: Check if PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT @@ -48,6 +48,7 @@ * @library ../../../../lib/testlibrary * @build Common ExtendedRobot * @run main ShapedPerPixelTranslucentGradient + * @run main/othervm -Dsun.java2d.uiScale=1.5 ShapedPerPixelTranslucentGradient */ public class ShapedPerPixelTranslucentGradient extends Common { --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 2017-11-07 18:05:16.469663111 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 2017-11-07 18:05:16.269563111 +0530 @@ -25,6 +25,7 @@ /* * @test + * @bug 8164811 * @key headful * @summary Check if shaped, translucent and per-pixel translucent window is * dragged and resized by mouse correctly. @@ -48,6 +49,7 @@ * @library ../../../../lib/testlibrary * @build Common ExtendedRobot * @run main ShapedTranslucentPerPixelTranslucentGradient + * @run main/othervm -Dsun.java2d.uiScale=1.5 ShapedTranslucentPerPixelTranslucentGradient */ public class ShapedTranslucentPerPixelTranslucentGradient extends Common { --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java 2017-11-07 18:05:16.897877110 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java 2017-11-07 18:05:16.717787111 +0530 @@ -25,7 +25,7 @@ /* * @test - * @bug 8144735 + * @bug 8144735 8164811 * @key headful * @summary Check if a per-pixel translucent and translucent window is dragged * and resized by mouse correctly @@ -46,6 +46,7 @@ * @library ../../../../lib/testlibrary * @build Common ExtendedRobot * @run main TranslucentPerPixelTranslucentGradient + * @run main/othervm -Dsun.java2d.uiScale=1.5 TranslucentPerPixelTranslucentGradient */ public class TranslucentPerPixelTranslucentGradient extends Common {