Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3c0ebbe9
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
You need to sign in or sign up before continuing.
提交
3c0ebbe9
编写于
10月 30, 2014
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8028539: Endless loop in native code of sun.java2d.loops.ScaledBlit
Reviewed-by: flar, jgodinez
上级
c9f22aa3
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
92 addition
and
8 deletion
+92
-8
src/share/classes/sun/java2d/pipe/DrawImage.java
src/share/classes/sun/java2d/pipe/DrawImage.java
+24
-8
test/java/awt/image/DrawImage/DrawImageCoordsTest.java
test/java/awt/image/DrawImage/DrawImageCoordsTest.java
+68
-0
未找到文件。
src/share/classes/sun/java2d/pipe/DrawImage.java
浏览文件 @
3c0ebbe9
...
@@ -278,18 +278,34 @@ public class DrawImage implements DrawImagePipe
...
@@ -278,18 +278,34 @@ public class DrawImage implements DrawImagePipe
Color
bgColor
,
int
interpType
,
Color
bgColor
,
int
interpType
,
double
coords
[])
double
coords
[])
{
{
double
dx
=
coords
[
0
];
double
dx1
=
coords
[
0
];
double
dy
=
coords
[
1
];
double
dy1
=
coords
[
1
];
double
dw
=
coords
[
2
]
-
dx
;
double
dx2
=
coords
[
2
];
double
dh
=
coords
[
3
]
-
dy
;
double
dy2
=
coords
[
3
];
double
dw
=
dx2
-
dx1
;
double
dh
=
dy2
-
dy1
;
/* If any of the destination coordinates exceed the integer range,
* then the calculations performed in calls made here cannot be
* guaranteed to be correct, or to converge (terminate).
* So return out of here, deferring to code that can handle this.
*/
if
(
dx1
<
Integer
.
MIN_VALUE
||
dx1
>
Integer
.
MAX_VALUE
||
dy1
<
Integer
.
MIN_VALUE
||
dy1
>
Integer
.
MAX_VALUE
||
dx2
<
Integer
.
MIN_VALUE
||
dx2
>
Integer
.
MAX_VALUE
||
dy2
<
Integer
.
MIN_VALUE
||
dy2
>
Integer
.
MAX_VALUE
)
{
return
false
;
}
// First check if width and height are very close to img w&h.
// First check if width and height are very close to img w&h.
if
(
closeToInteger
(
sx2
-
sx1
,
dw
)
&&
closeToInteger
(
sy2
-
sy1
,
dh
))
{
if
(
closeToInteger
(
sx2
-
sx1
,
dw
)
&&
closeToInteger
(
sy2
-
sy1
,
dh
))
{
// Round location to nearest pixel and then test
// Round location to nearest pixel and then test
// if it will cause interpolation anomalies.
// if it will cause interpolation anomalies.
int
idx
=
(
int
)
Math
.
floor
(
dx
+
0.5
);
int
idx
=
(
int
)
Math
.
floor
(
dx
1
+
0.5
);
int
idy
=
(
int
)
Math
.
floor
(
dy
+
0.5
);
int
idy
=
(
int
)
Math
.
floor
(
dy
1
+
0.5
);
if
(
interpType
==
AffineTransformOp
.
TYPE_NEAREST_NEIGHBOR
||
if
(
interpType
==
AffineTransformOp
.
TYPE_NEAREST_NEIGHBOR
||
(
closeToInteger
(
idx
,
dx
)
&&
closeToInteger
(
idy
,
dy
)))
(
closeToInteger
(
idx
,
dx
1
)
&&
closeToInteger
(
idy
,
dy1
)))
{
{
renderImageCopy
(
sg
,
img
,
bgColor
,
renderImageCopy
(
sg
,
img
,
bgColor
,
idx
,
idy
,
idx
,
idy
,
...
@@ -302,7 +318,7 @@ public class DrawImage implements DrawImagePipe
...
@@ -302,7 +318,7 @@ public class DrawImage implements DrawImagePipe
if
(
dw
>
0
&&
dh
>
0
)
{
if
(
dw
>
0
&&
dh
>
0
)
{
if
(
renderImageScale
(
sg
,
img
,
bgColor
,
interpType
,
if
(
renderImageScale
(
sg
,
img
,
bgColor
,
interpType
,
sx1
,
sy1
,
sx2
,
sy2
,
sx1
,
sy1
,
sx2
,
sy2
,
coords
[
0
],
coords
[
1
],
coords
[
2
],
coords
[
3
]
))
dx1
,
dy1
,
dx2
,
dy2
))
{
{
return
true
;
return
true
;
}
}
...
...
test/java/awt/image/DrawImage/DrawImageCoordsTest.java
0 → 100644
浏览文件 @
3c0ebbe9
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8028539
* @summary Test that drawing a scaled image terminates.
* @run main/othervm/timeout=60 DrawImageCoordsTest
*/
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
import
java.awt.geom.AffineTransform
;
import
java.awt.image.BufferedImage
;
public
class
DrawImageCoordsTest
{
public
static
void
main
(
String
[]
args
)
{
/* Create an image to draw, filled in solid red. */
BufferedImage
srcImg
=
new
BufferedImage
(
200
,
200
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics
srcG
=
srcImg
.
createGraphics
();
srcG
.
setColor
(
Color
.
red
);
int
w
=
srcImg
.
getWidth
(
null
);
int
h
=
srcImg
.
getHeight
(
null
);
srcG
.
fillRect
(
0
,
0
,
w
,
h
);
/* Create a destination image */
BufferedImage
dstImage
=
new
BufferedImage
(
200
,
200
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics2D
dstG
=
dstImage
.
createGraphics
();
/* draw image under a scaling transform that overflows int */
AffineTransform
tx
=
new
AffineTransform
(
0.5
,
0
,
0
,
0.5
,
0
,
5.8658460197478485E9
);
dstG
.
setTransform
(
tx
);
dstG
.
drawImage
(
srcImg
,
0
,
0
,
null
);
/* draw image under the same overflowing transform, cancelling
* out the 0.5 scale on the graphics
*/
dstG
.
drawImage
(
srcImg
,
0
,
0
,
2
*
w
,
2
*
h
,
null
);
if
(
Color
.
red
.
getRGB
()
==
dstImage
.
getRGB
(
w
/
2
,
h
/
2
))
{
throw
new
RuntimeException
(
"Unexpected color: clipping failed."
);
}
System
.
out
.
println
(
"Test Thread Completed"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录