-
Bug
-
Resolution: Fixed
-
P2
-
9
-
None
-
JDK 1.9.0-ea-fastdebug-b46
-
b114
-
windows
Run the SwingSet2 sample on Windows with enabled d3d option (-Dsun.java2d.d3d=true) ui scale 2 (-Dsun.java2d.uiScale=2) and drag or scroll an internal frame. There are artifacts on the internal frame (see the attached screen shot).
Below is a simple test case that allows to reproduce the issue:
- Run the code on Windows with enabled d3d (option -Dsun.java2d.d3d=true)
- The copied image is not properly shown (see the attached image):
--------------------------------------------
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.VolatileImage;
public class CopyImageTest extends Frame {
private static final int W = 800;
private static final int H = 800;
private static final double scale = 1.3;
private VolatileImage vImg;
public CopyImageTest() throws HeadlessException {
setSize(W, H);
vImg = createVolatileImage();
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
VolatileImage createVolatileImage() {
return getGraphicsConfiguration().createCompatibleVolatileImage(W, H);
}
// rendering to the image
void renderOffscreen() {
do {
if (vImg.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) {
// old vImg doesn't work with new GraphicsConfig; re-create it
vImg = createVolatileImage();
}
Graphics2D g = vImg.createGraphics();
//
// miscellaneous rendering commands...
//
g.scale(scale, scale);
g.setColor(Color.YELLOW);
g.fillRect(0, 0, W, H);
g.setColor(Color.ORANGE);
g.fillRect(50, 50, 50, 50);
g.setColor(Color.BLUE);
int d = 3;
g.drawRect(50 + d, 50 + d, 50 - 2 * d, 50 - 2 * d);
int N = 2;
int s1 = 5;
int s2 = 3;
for (int i = 0; i < N; i++) {
g.copyArea(50 + i * s1, 50 + i * s2, 50, 50, s1, s2);
}
g.dispose();
} while (vImg.contentsLost());
}
@Override
public void paint(Graphics gScreen) {
super.paint(gScreen); //To change body of generated methods, choose Tools | Templates.
// copying from the image (here, gScreen is the Graphics
// object for the onscreen window)
do {
int returnCode = vImg.validate(getGraphicsConfiguration());
if (returnCode == VolatileImage.IMAGE_RESTORED) {
// Contents need to be restored
renderOffscreen(); // restore contents
} else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
// old vImg doesn't work with new GraphicsConfig; re-create it
vImg = createVolatileImage();
renderOffscreen();
}
gScreen.drawImage(vImg, 0, 0, this);
} while (vImg.contentsLost());
}
public static void main(String[] args) {
new CopyImageTest().setVisible(true);
}
}
--------------------------------------------
Below is a simple test case that allows to reproduce the issue:
- Run the code on Windows with enabled d3d (option -Dsun.java2d.d3d=true)
- The copied image is not properly shown (see the attached image):
--------------------------------------------
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.VolatileImage;
public class CopyImageTest extends Frame {
private static final int W = 800;
private static final int H = 800;
private static final double scale = 1.3;
private VolatileImage vImg;
public CopyImageTest() throws HeadlessException {
setSize(W, H);
vImg = createVolatileImage();
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
VolatileImage createVolatileImage() {
return getGraphicsConfiguration().createCompatibleVolatileImage(W, H);
}
// rendering to the image
void renderOffscreen() {
do {
if (vImg.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) {
// old vImg doesn't work with new GraphicsConfig; re-create it
vImg = createVolatileImage();
}
Graphics2D g = vImg.createGraphics();
//
// miscellaneous rendering commands...
//
g.scale(scale, scale);
g.setColor(Color.YELLOW);
g.fillRect(0, 0, W, H);
g.setColor(Color.ORANGE);
g.fillRect(50, 50, 50, 50);
g.setColor(Color.BLUE);
int d = 3;
g.drawRect(50 + d, 50 + d, 50 - 2 * d, 50 - 2 * d);
int N = 2;
int s1 = 5;
int s2 = 3;
for (int i = 0; i < N; i++) {
g.copyArea(50 + i * s1, 50 + i * s2, 50, 50, s1, s2);
}
g.dispose();
} while (vImg.contentsLost());
}
@Override
public void paint(Graphics gScreen) {
super.paint(gScreen); //To change body of generated methods, choose Tools | Templates.
// copying from the image (here, gScreen is the Graphics
// object for the onscreen window)
do {
int returnCode = vImg.validate(getGraphicsConfiguration());
if (returnCode == VolatileImage.IMAGE_RESTORED) {
// Contents need to be restored
renderOffscreen(); // restore contents
} else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) {
// old vImg doesn't work with new GraphicsConfig; re-create it
vImg = createVolatileImage();
renderOffscreen();
}
gScreen.drawImage(vImg, 0, 0, this);
} while (vImg.contentsLost());
}
public static void main(String[] args) {
new CopyImageTest().setVisible(true);
}
}
--------------------------------------------
- duplicates
-
JDK-8148484 [hidpi] JEditorPane is broken (Windows)
- Closed
-
JDK-8148484 [hidpi] JEditorPane is broken (Windows)
- Closed
- relates to
-
JDK-8143392 SunGraphics2D.copyArea() does not properly handle Blit operation
- Open
-
JDK-8144179 GraphicsExposure event generation investigation in XCopyArea
- Open
-
JDK-8144181 OSXOffScreenSurfaceData.copyArea() method improvement
- Open
-
JDK-8073320 Windows HiDPI Graphics support
- Resolved
-
JDK-8149746 Line artifacts for scaled graphics
- Closed
(2 relates to)