--- old/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java 2017-11-06 16:49:44.184480387 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java 2017-11-06 16:49:44.000480387 +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-06 16:49:44.676480387 +0530 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2017-11-06 16:49:44.444480387 +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-06 16:49:45.152480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucent.java 2017-11-06 16:49:44.980480387 +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. --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java 2017-11-06 16:49:45.588480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java 2017-11-06 16:49:45.412480387 +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 --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java 2017-11-06 16:49:46.112480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java 2017-11-06 16:49:45.920480387 +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 --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 2017-11-06 16:49:46.584480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 2017-11-06 16:49:46.388480387 +0530 @@ -34,6 +34,7 @@ /* * @test * @key headful + * @bug 8164811 * @summary Check if a window set with shape clips the contents * Test Description: Check if PERPIXEL_TRANSPARENT translucency type is supported * by the current platform. Proceed if it is supported. Apply different types --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 2017-11-06 16:49:47.160480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 2017-11-06 16:49:46.944480387 +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 --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 2017-11-06 16:49:47.608480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 2017-11-06 16:49:47.416480387 +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. --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 2017-11-06 16:49:48.120480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 2017-11-06 16:49:47.924480387 +0530 @@ -29,7 +29,7 @@ /* * @test * @key headful - * @bug 8024627 + * @bug 8024627 8164811 * @summary Check if a JComboBox present in a window set with opacity less than * 1.0 shows a translucent drop down * Test Description: Check if TRANSLUCENT translucency type is supported on the --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java 2017-11-06 16:49:48.612480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentPerPixelTranslucentGradient.java 2017-11-06 16:49:48.388480387 +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 --- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentWindowClickSwing.java 2017-11-06 16:49:49.160480387 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentWindowClickSwing.java 2017-11-06 16:49:48.952480387 +0530 @@ -28,6 +28,7 @@ /* * @test + * @bug 8164811 * @key headful * @summary Check if swing components present in a window set with opacity less * than 1.0 appears translucent