Skip to content

Commit b3f45f8

Browse files
committedOct 27, 2021
8275689: [TESTBUG] Use color tolerance only for XRender in BlitRotateClippedArea test
Reviewed-by: serb
1 parent 6c05cc9 commit b3f45f8

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed
 

‎test/jdk/java/awt/image/DrawImage/BlitRotateClippedArea.java

+31-17
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static void main(String[] args) throws Exception {
5656
System.setProperty("sun.java2d.uiScale", "1");
5757
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
5858
var gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
59+
var className = gc.getClass().getSimpleName();
5960

6061
var gold = gc.createCompatibleImage(1000, 1000, TRANSLUCENT);
6162
var dstVI2BI = gc.createCompatibleImage(1000, 1000, TRANSLUCENT);
@@ -94,24 +95,38 @@ public static void main(String[] args) throws Exception {
9495
} while (dstVI2VI.contentsLost() || dstBI2VI.contentsLost()
9596
|| srcVI.contentsLost());
9697

97-
validate(gold, snapshotVI2VI);
98-
validate(gold, snapshotBI2VI);
99-
validate(gold, dstVI2BI);
98+
validate(gold, snapshotVI2VI, className);
99+
validate(gold, snapshotBI2VI, className);
100+
validate(gold, dstVI2BI, className);
100101
}
101102

102-
private static void validate(BufferedImage gold, BufferedImage img)
103-
throws IOException {
104-
for (int x = 0; x < gold.getWidth(); ++x) {
105-
for (int y = 0; y < gold.getHeight(); ++y) {
106-
Color goldColor = new Color(gold.getRGB(x, y));
107-
Color actualColor = new Color(img.getRGB(x, y));
108-
if ((Math.abs(goldColor.getRed() - actualColor.getRed()) > 1) ||
109-
(Math.abs(goldColor.getGreen() - actualColor.getGreen()) > 1) ||
110-
(Math.abs(goldColor.getBlue() - actualColor.getBlue()) > 1)) {
111-
ImageIO.write(gold, "png", new File("gold.png"));
112-
ImageIO.write(img, "png", new File("snapshot.png"));
113-
throw new RuntimeException("Test failed for pixel :"
114-
+ x + "/" + y);
103+
private static void validate(BufferedImage gold, BufferedImage img,
104+
String className) throws IOException {
105+
if (!(className.equals("XRGraphicsConfig"))) {
106+
for (int x = 0; x < gold.getWidth(); ++x) {
107+
for (int y = 0; y < gold.getHeight(); ++y) {
108+
if (gold.getRGB(x, y) != img.getRGB(x, y)) {
109+
ImageIO.write(gold, "png", new File("gold.png"));
110+
ImageIO.write(img, "png", new File("snapshot.png"));
111+
throw new RuntimeException("Test failed.");
112+
}
113+
}
114+
}
115+
} else {
116+
// In Linux where we use XRender pipeline there is
117+
// little deviation because of less arithmetic precision
118+
for (int x = 0; x < gold.getWidth(); ++x) {
119+
for (int y = 0; y < gold.getHeight(); ++y) {
120+
Color goldColor = new Color(gold.getRGB(x, y));
121+
Color actualColor = new Color(img.getRGB(x, y));
122+
if ((Math.abs(goldColor.getRed() - actualColor.getRed()) > 1) ||
123+
(Math.abs(goldColor.getGreen() - actualColor.getGreen()) > 1) ||
124+
(Math.abs(goldColor.getBlue() - actualColor.getBlue()) > 1)) {
125+
ImageIO.write(gold, "png", new File("gold.png"));
126+
ImageIO.write(img, "png", new File("snapshot.png"));
127+
throw new RuntimeException("Test failed for pixel :"
128+
+ x + "/" + y);
129+
}
115130
}
116131
}
117132
}
@@ -144,4 +159,3 @@ private static void fill(Image image) {
144159
graphics.dispose();
145160
}
146161
}
147-

0 commit comments

Comments
 (0)