author | serb |
Wed, 22 Oct 2014 12:33:28 +0400 | |
changeset 27283 | 99c4cb470573 |
child 39056 | d99e63b6d962 |
permissions | -rw-r--r-- |
27283
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
1 |
/* |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
4 |
* |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
8 |
* |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
14 |
* |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
18 |
* |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
21 |
* questions. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
22 |
*/ |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
23 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
24 |
import java.awt.Color; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
25 |
import java.awt.Graphics2D; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
26 |
import java.awt.GraphicsConfiguration; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
27 |
import java.awt.GraphicsEnvironment; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
28 |
import java.awt.Image; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
29 |
import java.awt.Rectangle; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
30 |
import java.awt.Shape; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
31 |
import java.awt.geom.AffineTransform; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
32 |
import java.awt.image.BufferedImage; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
33 |
import java.awt.image.DataBuffer; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
34 |
import java.awt.image.DataBufferByte; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
35 |
import java.awt.image.DataBufferInt; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
36 |
import java.awt.image.DataBufferShort; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
37 |
import java.awt.image.VolatileImage; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
38 |
import java.io.File; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
39 |
import java.io.IOException; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
40 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
41 |
import javax.imageio.ImageIO; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
42 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
43 |
import static java.awt.geom.Rectangle2D.Double; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
44 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
45 |
/** |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
46 |
* @test |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
47 |
* @bug 8061456 |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
48 |
* @summary Tests drawing BI to volatile image using different clips + xor mode. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
49 |
* Results of the blit BI to compatibleImage is used for comparison. |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
50 |
* @author Sergey Bylokhov |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
51 |
*/ |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
52 |
public final class IncorrectClipXorModeSW2Surface { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
53 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
54 |
private static int[] SIZES = {2, 10, 100}; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
55 |
private static final Shape[] SHAPES = { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
56 |
new Rectangle(0, 0, 0, 0), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
57 |
new Rectangle(0, 0, 1, 1), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
58 |
new Rectangle(0, 1, 1, 1), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
59 |
new Rectangle(1, 0, 1, 1), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
60 |
new Rectangle(1, 1, 1, 1), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
61 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
62 |
new Double(0, 0, 0.5, 0.5), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
63 |
new Double(0, 0.5, 0.5, 0.5), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
64 |
new Double(0.5, 0, 0.5, 0.5), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
65 |
new Double(0.5, 0.5, 0.5, 0.5), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
66 |
new Double(0.25, 0.25, 0.5, 0.5), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
67 |
new Double(0, 0.25, 1, 0.5), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
68 |
new Double(0.25, 0, 0.5, 1), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
69 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
70 |
new Double(.10, .10, .20, .20), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
71 |
new Double(.75, .75, .20, .20), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
72 |
new Double(.75, .10, .20, .20), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
73 |
new Double(.10, .75, .20, .20), |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
74 |
}; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
75 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
76 |
public static void main(final String[] args) throws IOException { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
77 |
GraphicsEnvironment ge = GraphicsEnvironment |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
78 |
.getLocalGraphicsEnvironment(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
79 |
GraphicsConfiguration gc = ge.getDefaultScreenDevice() |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
80 |
.getDefaultConfiguration(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
81 |
AffineTransform at; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
82 |
for (int size : SIZES) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
83 |
at = AffineTransform.getScaleInstance(size, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
84 |
for (Shape clip : SHAPES) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
85 |
clip = at.createTransformedShape(clip); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
86 |
for (Shape to : SHAPES) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
87 |
to = at.createTransformedShape(to); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
88 |
// Prepare test images |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
89 |
BufferedImage snapshot; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
90 |
BufferedImage bi = getBufferedImage(size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
91 |
VolatileImage vi = getVolatileImage(gc, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
92 |
while (true) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
93 |
vi.validate(gc); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
94 |
Graphics2D g2d = vi.createGraphics(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
95 |
g2d.setColor(Color.GREEN); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
96 |
g2d.fillRect(0, 0, size, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
97 |
g2d.dispose(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
98 |
if (vi.validate(gc) != VolatileImage.IMAGE_OK) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
99 |
continue; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
100 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
101 |
draw(clip, to, bi, vi); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
102 |
snapshot = vi.getSnapshot(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
103 |
if (vi.contentsLost()) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
104 |
continue; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
105 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
106 |
break; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
107 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
108 |
// Prepare gold images |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
109 |
BufferedImage goldvi = getCompatibleImage(gc, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
110 |
BufferedImage goldbi = getBufferedImage(size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
111 |
draw(clip, to, goldbi, goldvi); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
112 |
validate(snapshot, goldvi); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
113 |
vi.flush(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
114 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
115 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
116 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
117 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
118 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
119 |
private static void draw(Shape clip, Shape shape, Image from, Image to) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
120 |
Graphics2D g2d = (Graphics2D) to.getGraphics(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
121 |
g2d.setXORMode(Color.BLACK); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
122 |
g2d.setClip(clip); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
123 |
Rectangle toBounds = shape.getBounds(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
124 |
g2d.drawImage(from, toBounds.x, toBounds.y, toBounds.width, |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
125 |
toBounds.height, null); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
126 |
g2d.dispose(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
127 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
128 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
129 |
private static BufferedImage getBufferedImage(int sw) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
130 |
final BufferedImage bi = new BufferedImage(sw, sw, BufferedImage.TYPE_INT_ARGB); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
131 |
Graphics2D g2d = bi.createGraphics(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
132 |
g2d.setColor(Color.RED); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
133 |
g2d.fillRect(0, 0, sw, sw); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
134 |
g2d.dispose(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
135 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
136 |
final DataBuffer db = bi.getRaster().getDataBuffer(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
137 |
if (db instanceof DataBufferInt) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
138 |
((DataBufferInt) db).getData(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
139 |
} else if (db instanceof DataBufferShort) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
140 |
((DataBufferShort) db).getData(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
141 |
} else if (db instanceof DataBufferByte) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
142 |
((DataBufferByte) db).getData(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
143 |
} else { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
144 |
try { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
145 |
bi.setAccelerationPriority(0.0f); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
146 |
} catch (final Throwable ignored) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
147 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
148 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
149 |
return bi; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
150 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
151 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
152 |
private static VolatileImage getVolatileImage(GraphicsConfiguration gc, |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
153 |
int size) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
154 |
return gc.createCompatibleVolatileImage(size, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
155 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
156 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
157 |
private static BufferedImage getCompatibleImage(GraphicsConfiguration gc, |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
158 |
int size) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
159 |
BufferedImage image = gc.createCompatibleImage(size, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
160 |
Graphics2D g2d = image.createGraphics(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
161 |
g2d.setColor(Color.GREEN); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
162 |
g2d.fillRect(0, 0, size, size); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
163 |
g2d.dispose(); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
164 |
return image; |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
165 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
166 |
|
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
167 |
private static void validate(BufferedImage bi, BufferedImage goldbi) |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
168 |
throws IOException { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
169 |
for (int x = 0; x < bi.getWidth(); ++x) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
170 |
for (int y = 0; y < bi.getHeight(); ++y) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
171 |
if (goldbi.getRGB(x, y) != bi.getRGB(x, y)) { |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
172 |
ImageIO.write(bi, "png", new File("actual.png")); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
173 |
ImageIO.write(goldbi, "png", new File("expected.png")); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
174 |
throw new RuntimeException("Test failed."); |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
175 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
176 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
177 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
178 |
} |
99c4cb470573
8061456: [OGL] Incorrect clip is used during sw->surface blit in xor mode
serb
parents:
diff
changeset
|
179 |
} |