8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java

Reviewed-by: serb, prr, pnarayanan
This commit is contained in:
Pankaj Bansal 2017-11-22 11:52:59 +05:30 committed by Pankaj Bansal
parent 7dde2662c4
commit cc0cb9660d
5 changed files with 21 additions and 17 deletions

View File

@ -40,6 +40,7 @@ import sun.java2d.SunGraphics2D;
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 @@ public class SunVolatileImage extends VolatileImage
* 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());
}

View File

@ -58,6 +58,7 @@ import sun.java2d.pipe.ParallelogramPipe;
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 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
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 @@ public class D3DSurfaceData extends SurfaceData implements AccelSurface {
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);

View File

@ -37,6 +37,7 @@ import sun.awt.SunToolkit;
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 abstract class WGLSurfaceData extends OGLSurfaceData {
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 @@ public abstract class WGLSurfaceData extends OGLSurfaceData {
{
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 abstract class WGLSurfaceData extends OGLSurfaceData {
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 {

View File

@ -302,8 +302,8 @@ public class GDIWindowSurfaceData extends SurfaceData {
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;
}

View File

@ -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
*/