@@ -56,6 +56,7 @@ public static void main(String[] args) throws Exception {
56
56
System .setProperty ("sun.java2d.uiScale" , "1" );
57
57
var ge = GraphicsEnvironment .getLocalGraphicsEnvironment ();
58
58
var gc = ge .getDefaultScreenDevice ().getDefaultConfiguration ();
59
+ var className = gc .getClass ().getSimpleName ();
59
60
60
61
var gold = gc .createCompatibleImage (1000 , 1000 , TRANSLUCENT );
61
62
var dstVI2BI = gc .createCompatibleImage (1000 , 1000 , TRANSLUCENT );
@@ -94,24 +95,38 @@ public static void main(String[] args) throws Exception {
94
95
} while (dstVI2VI .contentsLost () || dstBI2VI .contentsLost ()
95
96
|| srcVI .contentsLost ());
96
97
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 );
100
101
}
101
102
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
+ }
115
130
}
116
131
}
117
132
}
@@ -144,4 +159,3 @@ private static void fill(Image image) {
144
159
graphics .dispose ();
145
160
}
146
161
}
147
-
0 commit comments