author | prr |
Wed, 29 Nov 2017 09:47:02 -0800 | |
changeset 47982 | 44371ff1ee9a |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
26603
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
1 |
/* |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
4 |
* |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
8 |
* |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
13 |
* accompanied this code). |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
14 |
* |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
18 |
* |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
21 |
* questions. |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
22 |
*/ |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
23 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
24 |
import java.awt.*; |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
25 |
import java.awt.image.*; |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
26 |
import javax.swing.*; |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
27 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
28 |
/** |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
29 |
* @test |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
26603
diff
changeset
|
30 |
* @key headful |
26603
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
31 |
* @bug 8056009 |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
32 |
* @summary tests whether Graphics.setColor-calls with Color.white are ignored directly |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
33 |
* after pipeline initialization for a certain set of operations. |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
34 |
* @author ceisserer |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
35 |
*/ |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
26603
diff
changeset
|
36 |
|
26603
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
37 |
public class WhiteTextColorTest extends Frame { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
38 |
public static volatile boolean success = false; |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
39 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
40 |
public WhiteTextColorTest() { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
41 |
Image dstImg = getGraphicsConfiguration() |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
42 |
.createCompatibleVolatileImage(30, 20); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
43 |
Graphics g = dstImg.getGraphics(); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
44 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
45 |
g.setColor(Color.BLACK); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
46 |
g.fillRect(0, 0, dstImg.getWidth(null), dstImg.getHeight(null)); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
47 |
g.setColor(Color.WHITE); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
48 |
g.drawString("Test", 0, 15); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
49 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
50 |
BufferedImage readBackImg = new BufferedImage(dstImg.getWidth(null), |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
51 |
dstImg.getHeight(null), BufferedImage.TYPE_INT_RGB); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
52 |
readBackImg.getGraphics().drawImage(dstImg, 0, 0, null); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
53 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
54 |
for (int x = 0; x < readBackImg.getWidth(); x++) { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
55 |
for (int y = 0; y < readBackImg.getHeight(); y++) { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
56 |
int pixel = readBackImg.getRGB(x, y); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
57 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
58 |
// In case a single white pixel is found, the |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
59 |
// setColor(Color.WHITE) |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
60 |
// call before was not ignored and the bug is not present |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
61 |
if (pixel == 0xFFFFFFFF) { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
62 |
return; |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
63 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
64 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
65 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
66 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
67 |
throw new RuntimeException("Test Failed"); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
68 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
69 |
|
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
70 |
public static void main(String[] args) throws Exception { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
71 |
SwingUtilities.invokeLater(new Runnable() { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
72 |
public void run() { |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
73 |
new WhiteTextColorTest(); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
74 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
75 |
}); |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
76 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
77 |
} |
0f04bb1f4b09
8054638: xrender: text drawn after setColor(Color.white) is actually black
ceisserer
parents:
diff
changeset
|
78 |