author | pchelko |
Wed, 23 Apr 2014 17:56:05 +0400 | |
changeset 24529 | c580bcb3aabc |
parent 23685 | 3a2788a3f2ee |
child 39056 | d99e63b6d962 |
permissions | -rw-r--r-- |
23685
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
1 |
/* |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
4 |
* |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
8 |
* |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
13 |
* accompanied this code). |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
14 |
* |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
18 |
* |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
21 |
* questions. |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
22 |
*/ |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
23 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
24 |
/* |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
25 |
* @test |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
26 |
* @bug 8036022 |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
27 |
* @summary Test verifies that drawing shapes with XOR composite |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
28 |
* does not trigger an InternalError in GDI surface data. |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
29 |
* @run main/othervm -Dsun.java2d.d3d=True DrawXORModeTest |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
30 |
*/ |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
31 |
import java.awt.BasicStroke; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
32 |
import java.awt.Color; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
33 |
import java.awt.Component; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
34 |
import java.awt.Dimension; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
35 |
import java.awt.Frame; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
36 |
import java.awt.Graphics; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
37 |
import java.awt.Graphics2D; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
38 |
import java.awt.Stroke; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
39 |
import java.awt.geom.Line2D; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
40 |
import java.util.concurrent.CountDownLatch; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
41 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
42 |
public class DrawXORModeTest extends Component { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
43 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
44 |
public static void main(String[] args) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
45 |
final DrawXORModeTest c = new DrawXORModeTest(); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
46 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
47 |
final Frame f = new Frame("XOR mode test"); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
48 |
f.add(c); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
49 |
f.pack(); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
50 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
51 |
f.setVisible(true); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
52 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
53 |
try { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
54 |
c.checkResult(); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
55 |
} finally { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
56 |
f.dispose(); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
57 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
58 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
59 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
60 |
@Override |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
61 |
public void paint(Graphics g) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
62 |
if (g == null || !(g instanceof Graphics2D)) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
63 |
return; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
64 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
65 |
g.setColor(Color.white); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
66 |
g.setXORMode(Color.black); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
67 |
Graphics2D dg = (Graphics2D) g; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
68 |
Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
69 |
BasicStroke.JOIN_MITER, |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
70 |
10.0f, |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
71 |
new float[]{1.0f, 1.0f}, |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
72 |
0.0f); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
73 |
dg.setStroke(stroke); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
74 |
try { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
75 |
dg.draw(new Line2D.Float(10, 10, 20, 20)); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
76 |
} catch (Throwable e) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
77 |
synchronized (this) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
78 |
theError = e; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
79 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
80 |
} finally { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
81 |
didDraw.countDown(); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
82 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
83 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
84 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
85 |
@Override |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
86 |
public Dimension getPreferredSize() { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
87 |
return new Dimension(400, 100); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
88 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
89 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
90 |
public void checkResult() { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
91 |
try { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
92 |
didDraw.await(); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
93 |
} catch (InterruptedException e) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
94 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
95 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
96 |
synchronized (this) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
97 |
if (theError != null) { |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
98 |
System.out.println("Error: " + theError); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
99 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
100 |
throw new RuntimeException("Test FAILED."); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
101 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
102 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
103 |
System.out.println("Test PASSED."); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
104 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
105 |
} |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
106 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
107 |
private Throwable theError = null; |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
108 |
|
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
109 |
private final CountDownLatch didDraw = new CountDownLatch(1); |
3a2788a3f2ee
8036022: D3D: rendering with XOR composite causes InternalError.
bae
parents:
diff
changeset
|
110 |
} |