--- old/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java 2017-11-16 15:29:00.062125259 +0530 +++ new/src/java.desktop/share/classes/sun/awt/image/SunVolatileImage.java 2017-11-16 15:28:59.729959259 +0530 @@ -40,6 +40,7 @@ import sun.java2d.SurfaceManagerFactory; import sun.java2d.DestSurfaceProvider; import sun.java2d.Surface; +import sun.java2d.pipe.Region; import static sun.java2d.pipe.hw.AccelSurface.*; /** @@ -245,8 +246,8 @@ * or a backup surface with the given horizontal and vertical scale factors. */ public BufferedImage getBackupImage(double scaleX, double scaleY) { - int w = (int) Math.ceil(getWidth() * scaleX); - int h = (int) Math.ceil(getHeight() * scaleY); + int w = Region.clipRound(getWidth() * scaleX); + int h = Region.clipRound(getHeight() * scaleY); return graphicsConfig.createCompatibleImage(w, h, getTransparency()); } --- old/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java 2017-11-16 15:29:00.946567259 +0530 +++ new/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java 2017-11-16 15:29:00.558373259 +0530 @@ -58,6 +58,7 @@ import sun.java2d.pipe.PixelToParallelogramConverter; import sun.java2d.pipe.RenderBuffer; import sun.java2d.pipe.TextPipe; +import sun.java2d.pipe.Region; import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; @@ -236,8 +237,8 @@ this.width = scaledSize.width; this.height = scaledSize.height; } else { - this.width = (int) Math.ceil(width * scaleX); - this.height = (int) Math.ceil(height * scaleY); + this.width = Region.clipRound(width * scaleX); + this.height = Region.clipRound(height * scaleY); } this.offscreenImage = image; @@ -812,8 +813,8 @@ double scaleY = getDefaultScaleY(); Rectangle r = peer.getBounds(); r.x = r.y = 0; - r.width = (int) Math.ceil(r.width * scaleX); - r.height = (int) Math.ceil(r.height * scaleY); + r.width = Region.clipRound(r.width * scaleX); + r.height = Region.clipRound(r.height * scaleY); return r; } else { return new Rectangle(width, height); --- old/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java 2017-11-16 15:29:01.766977259 +0530 +++ new/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java 2017-11-16 15:29:01.450819258 +0530 @@ -37,6 +37,7 @@ import sun.awt.Win32GraphicsDevice; import sun.awt.windows.WComponentPeer; import sun.java2d.SurfaceData; +import sun.java2d.pipe.Region; public abstract class WGLSurfaceData extends OGLSurfaceData { @@ -165,8 +166,8 @@ public Rectangle getBounds() { Rectangle r = peer.getBounds(); r.x = r.y = 0; - r.width = (int) Math.ceil(r.width * scaleX); - r.height = (int) Math.ceil(r.height * scaleY); + r.width = Region.clipRound(r.width * scaleX); + r.height = Region.clipRound(r.height * scaleY); return r; } @@ -227,8 +228,8 @@ { super(peer, gc, cm, type); - this.width = (int) Math.ceil(width * scaleX); - this.height = (int) Math.ceil(height * scaleY); + this.width = Region.clipRound(width * scaleX); + this.height = Region.clipRound(height * scaleY); offscreenImage = image; initSurface(this.width, this.height); @@ -241,8 +242,8 @@ public Rectangle getBounds() { if (type == FLIP_BACKBUFFER) { Rectangle r = peer.getBounds(); - r.width = (int) Math.ceil(r.width * scaleX); - r.height = (int) Math.ceil(r.height * scaleY); + r.width = Region.clipRound(r.width * scaleX); + r.height = Region.clipRound(r.height * scaleY); r.x = r.y = 0; return r; } else { --- old/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java 2017-11-16 15:29:02.631409259 +0530 +++ new/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java 2017-11-16 15:29:02.315251259 +0530 @@ -302,8 +302,8 @@ public Rectangle getBounds() { Rectangle r = peer.getBounds(); r.x = r.y = 0; - r.width = (int) Math.ceil(r.width * scaleX); - r.height = (int) Math.ceil(r.height * scaleY); + r.width = Region.clipRound(r.width * scaleX); + r.height = Region.clipRound(r.height * scaleY); return r; } --- old/test/jdk/sun/java2d/SunGraphics2D/DrawImageBilinear.java 2017-11-16 15:29:03.455821259 +0530 +++ new/test/jdk/sun/java2d/SunGraphics2D/DrawImageBilinear.java 2017-11-16 15:29:03.099643258 +0530 @@ -23,11 +23,12 @@ /* * @test * @key headful - * @bug 5009033 6603000 6666362 + * @bug 5009033 6603000 6666362 8159142 * @summary Verifies that images transformed with bilinear filtering do not * leave artifacts at the edges. - * @run main/othervm DrawImageBilinear - * @run main/othervm -Dsun.java2d.opengl=True DrawImageBilinear + * @run main/othervm -Dsun.java2d.uiScale=2.5 DrawImageBilinear + * @run main/othervm -Dsun.java2d.uiScale=2.5 -Dsun.java2d.opengl=True DrawImageBilinear + * @run main/othervm -Dsun.java2d.uiScale=2.5 -Dsun.java2d.d3d=false DrawImageBilinear * @author campbelc */