author | pnarayanan |
Fri, 02 Mar 2018 14:39:29 +0530 | |
changeset 49217 | 3b820b878ebe |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1732
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
1 |
/* |
49217
3b820b878ebe
8198613: Test cases result in failure or timeout when run with OpenGL backend
pnarayanan
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. |
1732
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
4 |
* |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
8 |
* |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
13 |
* accompanied this code). |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
14 |
* |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1732
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
22 |
*/ |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
23 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
24 |
/* |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
25 |
* @test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31448
diff
changeset
|
26 |
* @key headful |
49217
3b820b878ebe
8198613: Test cases result in failure or timeout when run with OpenGL backend
pnarayanan
parents:
47216
diff
changeset
|
27 |
* @bug 6764257 8198613 |
1732
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
28 |
* @summary Tests that the color is reset properly after save/restore context |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
29 |
* @author Dmitri.Trembovetski@sun.com: area=Graphics |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
5506
diff
changeset
|
30 |
* @modules java.desktop/sun.java2d |
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
5506
diff
changeset
|
31 |
* java.desktop/sun.java2d.pipe |
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
5506
diff
changeset
|
32 |
* java.desktop/sun.java2d.pipe.hw |
1732
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
33 |
* @compile -XDignore.symbol.file=true RSLContextInvalidationTest.java |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
34 |
* @run main/othervm RSLContextInvalidationTest |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
35 |
* @run main/othervm -Dsun.java2d.noddraw=true RSLContextInvalidationTest |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
36 |
*/ |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
37 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
38 |
import java.awt.Color; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
39 |
import java.awt.Graphics; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
40 |
import java.awt.GraphicsConfiguration; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
41 |
import java.awt.GraphicsDevice; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
42 |
import java.awt.GraphicsEnvironment; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
43 |
import java.awt.image.BufferedImage; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
44 |
import java.awt.image.VolatileImage; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
45 |
import sun.java2d.DestSurfaceProvider; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
46 |
import sun.java2d.Surface; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
47 |
import sun.java2d.pipe.RenderQueue; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
48 |
import sun.java2d.pipe.hw.*; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
49 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
50 |
public class RSLContextInvalidationTest { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
51 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
52 |
public static void main(String[] args) { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
53 |
GraphicsEnvironment ge = |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
54 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
55 |
GraphicsDevice gd = ge.getDefaultScreenDevice(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
56 |
GraphicsConfiguration gc = gd.getDefaultConfiguration(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
57 |
VolatileImage vi = gc.createCompatibleVolatileImage(100, 100); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
58 |
vi.validate(gc); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
59 |
VolatileImage vi1 = gc.createCompatibleVolatileImage(100, 100); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
60 |
vi1.validate(gc); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
61 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
62 |
if (!(vi instanceof DestSurfaceProvider)) { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
63 |
System.out.println("Test considered PASSED: no HW acceleration"); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
64 |
return; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
65 |
} |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
66 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
67 |
DestSurfaceProvider p = (DestSurfaceProvider)vi; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
68 |
Surface s = p.getDestSurface(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
69 |
if (!(s instanceof AccelSurface)) { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
70 |
System.out.println("Test considered PASSED: no HW acceleration"); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
71 |
return; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
72 |
} |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
73 |
AccelSurface dst = (AccelSurface)s; |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
74 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
75 |
Graphics g = vi.createGraphics(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
76 |
g.drawImage(vi1, 95, 95, null); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
77 |
g.setColor(Color.red); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
78 |
g.fillRect(0, 0, 100, 100); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
79 |
g.setColor(Color.black); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
80 |
g.fillRect(0, 0, 100, 100); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
81 |
// after this the validated context color is black |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
82 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
83 |
RenderQueue rq = dst.getContext().getRenderQueue(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
84 |
rq.lock(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
85 |
try { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
86 |
dst.getContext().saveState(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
87 |
dst.getContext().restoreState(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
88 |
} finally { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
89 |
rq.unlock(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
90 |
} |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
91 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
92 |
// this will cause ResetPaint (it will set color to extended EA=ff, |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
93 |
// which is ffffffff==Color.white) |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
94 |
g.drawImage(vi1, 95, 95, null); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
95 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
96 |
// now try filling with black again, but it will come up as white |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
97 |
// because this fill rect won't validate the color properly |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
98 |
g.setColor(Color.black); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
99 |
g.fillRect(0, 0, 100, 100); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
100 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
101 |
BufferedImage bi = vi.getSnapshot(); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
102 |
if (bi.getRGB(50, 50) != Color.black.getRGB()) { |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
103 |
throw new RuntimeException("Test FAILED: found color="+ |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
104 |
Integer.toHexString(bi.getRGB(50, 50))+" instead of "+ |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
105 |
Integer.toHexString(Color.black.getRGB())); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
106 |
} |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
107 |
|
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
108 |
System.out.println("Test PASSED."); |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
109 |
} |
cbd1ef3625fc
6764257: D3D/OGL: color is not reset properly after save/restoreState() [RSL]
tdv
parents:
diff
changeset
|
110 |
} |