Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3ffc5009
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看板
提交
3ffc5009
编写于
7月 25, 2013
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8019201: Regression: java.awt.image.ConvolveOp throws java.awt.image.ImagingOpException
Reviewed-by: prr
上级
5437e125
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
153 addition
and
59 deletion
+153
-59
src/share/native/sun/awt/medialib/awt_ImagingLib.c
src/share/native/sun/awt/medialib/awt_ImagingLib.c
+52
-59
test/sun/awt/image/ImagingLib/SamePackingTypeTest.java
test/sun/awt/image/ImagingLib/SamePackingTypeTest.java
+101
-0
未找到文件。
src/share/native/sun/awt/medialib/awt_ImagingLib.c
浏览文件 @
3ffc5009
...
...
@@ -2606,38 +2606,37 @@ storeDstArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
#define ERR_BAD_IMAGE_LAYOUT (-2)
#define CHECK_DST_ARRAY(start_offset, elements_per_pixel) \
do { \
int offset = (start_offset); \
int lastScanOffset; \
\
if (!SAFE_TO_MULT(rasterP->scanlineStride, \
(rasterP->height - 1))) \
{ \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset = rasterP->scanlineStride * \
(rasterP->height - 1); \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (!SAFE_TO_MULT((elements_per_pixel), rasterP->width)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
offset = (elements_per_pixel) * rasterP->width; \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (dataArrayLength < lastScanOffset) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
} while(0); \
#define CHECK_DST_ARRAY(start_offset, elements_per_scan, elements_per_pixel) \
do { \
int offset = (start_offset); \
int lastScanOffset; \
\
if (!SAFE_TO_MULT((elements_per_scan), \
(rasterP->height - 1))) \
{ \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset = (elements_per_scan) * (rasterP->height - 1); \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (!SAFE_TO_MULT((elements_per_pixel), rasterP->width)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
offset = (elements_per_pixel) * rasterP->width; \
\
if (!SAFE_TO_ADD(offset, lastScanOffset)) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
lastScanOffset += offset; \
\
if (dataArrayLength < lastScanOffset) { \
return ERR_BAD_IMAGE_LAYOUT; \
} \
} while(0); \
static
int
storeImageArray
(
JNIEnv
*
env
,
BufImageS_t
*
srcP
,
BufImageS_t
*
dstP
,
...
...
@@ -2665,39 +2664,33 @@ storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
if
(
hintP
->
packing
==
BYTE_INTERLEAVED
)
{
/* Write it back to the destination */
CHECK_DST_ARRAY
(
hintP
->
channelOffset
,
hintP
->
numChans
);
if
(
rasterP
->
dataType
!=
BYTE_DATA_TYPE
)
{
/* We are working with a raster which was marked
as a byte interleaved due to performance reasons.
So, we have to convert the length of the data
array to bytes as well.
*/
if
(
!
SAFE_TO_MULT
(
rasterP
->
dataSize
,
dataArrayLength
))
{
return
ERR_BAD_IMAGE_LAYOUT
;
}
dataArrayLength
*=
rasterP
->
dataSize
;
}
CHECK_DST_ARRAY
(
hintP
->
dataOffset
,
hintP
->
sStride
,
hintP
->
numChans
);
cmDataP
=
(
unsigned
char
*
)
mlib_ImageGetData
(
mlibImP
);
mStride
=
mlib_ImageGetStride
(
mlibImP
);
dataP
=
(
unsigned
char
*
)(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
rasterP
->
jdata
,
NULL
);
if
(
dataP
==
NULL
)
return
0
;
cDataP
=
dataP
+
hintP
->
channel
Offset
;
cDataP
=
dataP
+
hintP
->
data
Offset
;
for
(
y
=
0
;
y
<
rasterP
->
height
;
y
++
,
cmDataP
+=
mStride
,
cDataP
+=
rasterP
->
scanline
Stride
)
y
++
,
cmDataP
+=
mStride
,
cDataP
+=
hintP
->
s
Stride
)
{
memcpy
(
cDataP
,
cmDataP
,
rasterP
->
width
*
hintP
->
numChans
);
}
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
rasterP
->
jdata
,
dataP
,
JNI_ABORT
);
}
else
if
(
hintP
->
packing
==
SHORT_INTERLEAVED
)
{
/* Write it back to the destination */
unsigned
short
*
sdataP
,
*
sDataP
;
unsigned
short
*
smDataP
=
(
unsigned
short
*
)
mlib_ImageGetData
(
mlibImP
);
CHECK_DST_ARRAY
(
hintP
->
channelOffset
,
hintP
->
numChans
);
mStride
=
mlib_ImageGetStride
(
mlibImP
);
sdataP
=
(
unsigned
short
*
)(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
rasterP
->
jdata
,
NULL
);
if
(
sdataP
==
NULL
)
return
-
1
;
sDataP
=
sdataP
+
hintP
->
channelOffset
;
for
(
y
=
0
;
y
<
rasterP
->
height
;
y
++
,
smDataP
+=
mStride
,
sDataP
+=
rasterP
->
scanlineStride
)
{
memcpy
(
sDataP
,
smDataP
,
rasterP
->
width
*
hintP
->
numChans
);
}
(
*
env
)
->
ReleasePrimitiveArrayCritical
(
env
,
rasterP
->
jdata
,
sdataP
,
JNI_ABORT
);
}
else
if
(
dstP
->
cmodel
.
cmType
==
DIRECT_CM_TYPE
)
{
/* Just need to move bits */
if
(
mlibImP
->
type
==
MLIB_BYTE
)
{
...
...
@@ -3499,7 +3492,7 @@ static int setPackedBCR(JNIEnv *env, RasterS_t *rasterP, int component,
}
dataArrayLength
=
(
*
env
)
->
GetArrayLength
(
env
,
jOutDataP
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
1
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
rasterP
->
scanlineStride
,
1
);
outDataP
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
jOutDataP
,
0
);
if
(
outDataP
==
NULL
)
{
...
...
@@ -3575,7 +3568,7 @@ static int setPackedSCR(JNIEnv *env, RasterS_t *rasterP, int component,
}
dataArrayLength
=
(
*
env
)
->
GetArrayLength
(
env
,
jOutDataP
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
1
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
rasterP
->
scanlineStride
,
1
);
outDataP
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
jOutDataP
,
0
);
if
(
outDataP
==
NULL
)
{
...
...
@@ -3651,7 +3644,7 @@ static int setPackedICR(JNIEnv *env, RasterS_t *rasterP, int component,
}
dataArrayLength
=
(
*
env
)
->
GetArrayLength
(
env
,
jOutDataP
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
1
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
rasterP
->
scanlineStride
,
1
);
outDataP
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
jOutDataP
,
0
);
if
(
outDataP
==
NULL
)
{
...
...
@@ -3730,7 +3723,7 @@ static int setPackedBCRdefault(JNIEnv *env, RasterS_t *rasterP,
}
dataArrayLength
=
(
*
env
)
->
GetArrayLength
(
env
,
jOutDataP
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
1
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
rasterP
->
scanlineStride
,
1
);
outDataP
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
jOutDataP
,
0
);
if
(
outDataP
==
NULL
)
{
...
...
@@ -3827,7 +3820,7 @@ static int setPackedSCRdefault(JNIEnv *env, RasterS_t *rasterP,
return
-
1
;
}
dataArrayLength
=
(
*
env
)
->
GetArrayLength
(
env
,
jOutDataP
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
1
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
rasterP
->
scanlineStride
,
1
);
outDataP
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
jOutDataP
,
0
);
if
(
outDataP
==
NULL
)
{
...
...
@@ -3925,7 +3918,7 @@ static int setPackedICRdefault(JNIEnv *env, RasterS_t *rasterP,
}
dataArrayLength
=
(
*
env
)
->
GetArrayLength
(
env
,
jOutDataP
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
1
);
CHECK_DST_ARRAY
(
rasterP
->
chanOffsets
[
0
],
rasterP
->
scanlineStride
,
1
);
outDataP
=
(
*
env
)
->
GetPrimitiveArrayCritical
(
env
,
jOutDataP
,
0
);
if
(
outDataP
==
NULL
)
{
...
...
test/sun/awt/image/ImagingLib/SamePackingTypeTest.java
0 → 100644
浏览文件 @
3ffc5009
/*
* Copyright (c) 2013, 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 8019201
* @summary Test verifies that medialib glue code does not throw
* an ImagingOpException for certain pairs of source and
* destination images.
*
* @run main SamePackingTypeTest
*/
import
java.awt.Color
;
import
java.awt.Graphics2D
;
import
java.awt.image.BufferedImage
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_4BYTE_ABGR
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_4BYTE_ABGR_PRE
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_INT_ARGB
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_INT_ARGB_PRE
;
import
java.awt.image.BufferedImageOp
;
import
java.awt.image.ConvolveOp
;
import
java.awt.image.ImagingOpException
;
import
java.awt.image.Kernel
;
import
java.util.Arrays
;
public
class
SamePackingTypeTest
{
public
static
void
main
(
String
[]
args
)
{
BufferedImageOp
op
=
createTestOp
();
try
{
System
.
out
.
print
(
"Integer-based images... "
);
doTest
(
op
,
TYPE_INT_ARGB
,
TYPE_INT_ARGB_PRE
);
System
.
out
.
println
(
"done."
);
System
.
out
.
print
(
"Byte-based images... "
);
doTest
(
op
,
TYPE_4BYTE_ABGR
,
TYPE_4BYTE_ABGR_PRE
);
System
.
out
.
println
(
"done"
);
}
catch
(
ImagingOpException
e
)
{
throw
new
RuntimeException
(
"Test FAILED"
,
e
);
}
}
private
static
void
doTest
(
BufferedImageOp
op
,
int
stype
,
int
dtype
)
{
final
int
size
=
100
;
final
BufferedImage
src
=
new
BufferedImage
(
size
,
size
,
stype
);
Graphics2D
g
=
src
.
createGraphics
();
g
.
setColor
(
Color
.
red
);
g
.
fillRect
(
0
,
0
,
size
,
size
);
g
.
dispose
();
final
BufferedImage
dst
=
new
BufferedImage
(
size
,
size
,
dtype
);
g
=
dst
.
createGraphics
();
g
.
setColor
(
Color
.
blue
);
g
.
fillRect
(
0
,
0
,
size
,
size
);
g
.
dispose
();
op
.
filter
(
src
,
dst
);
final
int
rgb
=
dst
.
getRGB
(
size
-
1
,
size
-
1
);
System
.
out
.
printf
(
"dst: 0x%X "
,
rgb
);
if
(
rgb
!=
0xFFFF0000
)
{
throw
new
RuntimeException
(
String
.
format
(
"Wrong color in dst: 0x%X"
,
rgb
));
}
}
private
static
BufferedImageOp
createTestOp
()
{
final
int
size
=
1
;
final
float
v
=
1
f
/
(
size
*
size
);
final
float
[]
k_data
=
new
float
[
size
*
size
];
Arrays
.
fill
(
k_data
,
v
);
Kernel
k
=
new
Kernel
(
size
,
size
,
k_data
);
return
new
ConvolveOp
(
k
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录