author | prr |
Thu, 30 Oct 2014 13:36:44 -0700 | |
changeset 27508 | 6349bac46ffe |
permissions | -rw-r--r-- |
27508
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
1 |
/* |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
4 |
* |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
8 |
* |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
13 |
* accompanied this code). |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
14 |
* |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
18 |
* |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
21 |
* questions. |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
22 |
*/ |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
23 |
|
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
24 |
/* |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
25 |
* @test |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
26 |
* @bug 8028539 |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
27 |
* @summary Test that drawing a scaled image terminates. |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
28 |
* @run main/othervm/timeout=60 DrawImageCoordsTest |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
29 |
*/ |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
30 |
|
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
31 |
import java.awt.Color; |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
32 |
import java.awt.Graphics; |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
33 |
import java.awt.Graphics2D; |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
34 |
import java.awt.geom.AffineTransform; |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
35 |
import java.awt.image.BufferedImage; |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
36 |
|
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
37 |
public class DrawImageCoordsTest { |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
38 |
|
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
39 |
public static void main(String[] args) { |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
40 |
|
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
41 |
/* Create an image to draw, filled in solid red. */ |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
42 |
BufferedImage srcImg = |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
43 |
new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
44 |
Graphics srcG = srcImg.createGraphics(); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
45 |
srcG.setColor(Color.red); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
46 |
int w = srcImg.getWidth(null); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
47 |
int h = srcImg.getHeight(null); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
48 |
srcG.fillRect(0, 0, w, h); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
49 |
|
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
50 |
/* Create a destination image */ |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
51 |
BufferedImage dstImage = |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
52 |
new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
53 |
Graphics2D dstG = dstImage.createGraphics(); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
54 |
/* draw image under a scaling transform that overflows int */ |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
55 |
AffineTransform tx = new AffineTransform(0.5, 0, 0, 0.5, |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
56 |
0, 5.8658460197478485E9); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
57 |
dstG.setTransform(tx); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
58 |
dstG.drawImage(srcImg, 0, 0, null ); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
59 |
/* draw image under the same overflowing transform, cancelling |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
60 |
* out the 0.5 scale on the graphics |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
61 |
*/ |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
62 |
dstG.drawImage(srcImg, 0, 0, 2*w, 2*h, null); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
63 |
if (Color.red.getRGB() == dstImage.getRGB(w/2, h/2)) { |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
64 |
throw new RuntimeException("Unexpected color: clipping failed."); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
65 |
} |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
66 |
System.out.println("Test Thread Completed"); |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
67 |
} |
6349bac46ffe
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
prr
parents:
diff
changeset
|
68 |
} |