Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
43d89618
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看板
提交
43d89618
编写于
12月 15, 2010
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
Reviewed-by: igor, prr
上级
beff7858
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
135 addition
and
25 deletion
+135
-25
src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java
.../classes/java/awt/image/SinglePixelPackedSampleModel.java
+10
-24
src/share/native/sun/awt/image/awt_parseImage.c
src/share/native/sun/awt/image/awt_parseImage.c
+12
-1
test/java/awt/image/IncorrectSampleMaskTest.java
test/java/awt/image/IncorrectSampleMaskTest.java
+113
-0
未找到文件。
src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java
浏览文件 @
43d89618
...
@@ -92,7 +92,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
...
@@ -92,7 +92,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
* Constructs a SinglePixelPackedSampleModel with bitMasks.length bands.
* Constructs a SinglePixelPackedSampleModel with bitMasks.length bands.
* Each sample is stored in a data array element in the position of
* Each sample is stored in a data array element in the position of
* its corresponding bit mask. Each bit mask must be contiguous and
* its corresponding bit mask. Each bit mask must be contiguous and
* masks must not overlap.
* masks must not overlap. Bit masks exceeding data type capacity are
* truncated.
* @param dataType The data type for storing samples.
* @param dataType The data type for storing samples.
* @param w The width (in pixels) of the region of the
* @param w The width (in pixels) of the region of the
* image data described.
* image data described.
...
@@ -120,7 +121,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
...
@@ -120,7 +121,8 @@ public class SinglePixelPackedSampleModel extends SampleModel
* and a scanline stride equal to scanlineStride data array elements.
* and a scanline stride equal to scanlineStride data array elements.
* Each sample is stored in a data array element in the position of
* Each sample is stored in a data array element in the position of
* its corresponding bit mask. Each bit mask must be contiguous and
* its corresponding bit mask. Each bit mask must be contiguous and
* masks must not overlap.
* masks must not overlap. Bit masks exceeding data type capacity are
* truncated.
* @param dataType The data type for storing samples.
* @param dataType The data type for storing samples.
* @param w The width (in pixels) of the region of
* @param w The width (in pixels) of the region of
* image data described.
* image data described.
...
@@ -153,11 +155,13 @@ public class SinglePixelPackedSampleModel extends SampleModel
...
@@ -153,11 +155,13 @@ public class SinglePixelPackedSampleModel extends SampleModel
this
.
bitOffsets
=
new
int
[
numBands
];
this
.
bitOffsets
=
new
int
[
numBands
];
this
.
bitSizes
=
new
int
[
numBands
];
this
.
bitSizes
=
new
int
[
numBands
];
int
maxMask
=
(
int
)((
1L
<<
DataBuffer
.
getDataTypeSize
(
dataType
))
-
1
);
this
.
maxBitSize
=
0
;
this
.
maxBitSize
=
0
;
for
(
int
i
=
0
;
i
<
numBands
;
i
++)
{
for
(
int
i
=
0
;
i
<
numBands
;
i
++)
{
int
bitOffset
=
0
,
bitSize
=
0
,
mask
;
int
bitOffset
=
0
,
bitSize
=
0
,
mask
;
mask
=
bitMasks
[
i
]
;
this
.
bitMasks
[
i
]
&=
maxMask
;
mask
=
this
.
bitMasks
[
i
];
if
(
mask
!=
0
)
{
if
(
mask
!=
0
)
{
while
((
mask
&
1
)
==
0
)
{
while
((
mask
&
1
)
==
0
)
{
mask
=
mask
>>>
1
;
mask
=
mask
>>>
1
;
...
@@ -243,30 +247,12 @@ public class SinglePixelPackedSampleModel extends SampleModel
...
@@ -243,30 +247,12 @@ public class SinglePixelPackedSampleModel extends SampleModel
/** Returns the number of bits per sample for all bands. */
/** Returns the number of bits per sample for all bands. */
public
int
[]
getSampleSize
()
{
public
int
[]
getSampleSize
()
{
int
mask
;
return
bitSizes
.
clone
();
int
sampleSize
[]
=
new
int
[
numBands
];
for
(
int
i
=
0
;
i
<
numBands
;
i
++)
{
sampleSize
[
i
]
=
0
;
mask
=
bitMasks
[
i
]
>>>
bitOffsets
[
i
];
while
((
mask
&
1
)
!=
0
)
{
sampleSize
[
i
]
++;
mask
=
mask
>>>
1
;
}
}
return
sampleSize
;
}
}
/** Returns the number of bits per sample for the specified band. */
/** Returns the number of bits per sample for the specified band. */
public
int
getSampleSize
(
int
band
)
{
public
int
getSampleSize
(
int
band
)
{
int
sampleSize
=
0
;
return
bitSizes
[
band
];
int
mask
=
bitMasks
[
band
]
>>>
bitOffsets
[
band
];
while
((
mask
&
1
)
!=
0
)
{
sampleSize
++;
mask
=
mask
>>>
1
;
}
return
sampleSize
;
}
}
/** Returns the offset (in data array elements) of pixel (x,y).
/** Returns the offset (in data array elements) of pixel (x,y).
...
...
src/share/native/sun/awt/image/awt_parseImage.c
浏览文件 @
43d89618
...
@@ -178,7 +178,7 @@ int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP) {
...
@@ -178,7 +178,7 @@ int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP) {
jnbits
=
(
*
env
)
->
GetObjectField
(
env
,
rasterP
->
jsampleModel
,
jnbits
=
(
*
env
)
->
GetObjectField
(
env
,
rasterP
->
jsampleModel
,
g_SPPSMnBitsID
);
g_SPPSMnBitsID
);
if
(
jmask
==
NULL
||
joffs
==
NULL
||
jnbits
==
NULL
||
if
(
jmask
==
NULL
||
joffs
==
NULL
||
jnbits
==
NULL
||
rasterP
->
sppsm
.
maxBitSize
<
0
||
rasterP
->
sppsm
.
maxBitSize
>
8
)
rasterP
->
sppsm
.
maxBitSize
<
0
)
{
{
JNU_ThrowInternalError
(
env
,
"Can't grab SPPSM fields"
);
JNU_ThrowInternalError
(
env
,
"Can't grab SPPSM fields"
);
return
-
1
;
return
-
1
;
...
@@ -280,6 +280,17 @@ int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP) {
...
@@ -280,6 +280,17 @@ int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP) {
rasterP
->
chanOffsets
);
rasterP
->
chanOffsets
);
}
}
/* additioanl check for sppsm fields validity: make sure that
* size of raster samples doesn't exceed the data type cpacity.
*/
if
(
rasterP
->
dataType
>
UNKNOWN_DATA_TYPE
&&
/* data type has been recognized */
rasterP
->
sppsm
.
maxBitSize
>
0
&&
/* raster has SPP sample model */
rasterP
->
sppsm
.
maxBitSize
>
(
rasterP
->
dataSize
*
8
))
{
JNU_ThrowInternalError
(
env
,
"Raster samples are too big"
);
return
-
1
;
}
#if 0
#if 0
fprintf(stderr,"---------------------\n");
fprintf(stderr,"---------------------\n");
fprintf(stderr,"Width : %d\n",rasterP->width);
fprintf(stderr,"Width : %d\n",rasterP->width);
...
...
test/java/awt/image/IncorrectSampleMaskTest.java
0 → 100644
浏览文件 @
43d89618
/*
* Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6782574
* @summary Test verifies that incorrect sample masks are correctly handled
* by the constructor of the SinglePixelPackedSampleModel class
* and do not cause internal error in the medialib glue code.
*
* @run main IncorrectSampleMaskTest
*/
import
java.awt.geom.AffineTransform
;
import
java.awt.image.AffineTransformOp
;
import
java.awt.image.BufferedImageOp
;
import
java.awt.image.DataBuffer
;
import
java.awt.image.DataBufferByte
;
import
java.awt.image.DataBufferInt
;
import
java.awt.image.DataBufferUShort
;
import
java.awt.image.Raster
;
import
java.awt.image.RasterOp
;
import
java.awt.image.WritableRaster
;
import
java.awt.image.SinglePixelPackedSampleModel
;
public
class
IncorrectSampleMaskTest
{
public
static
void
main
(
String
[]
args
)
{
int
[]
dataTypes
=
new
int
[]
{
DataBuffer
.
TYPE_BYTE
,
DataBuffer
.
TYPE_USHORT
,
DataBuffer
.
TYPE_INT
};
for
(
int
type
:
dataTypes
)
{
doTest
(
type
);
}
}
private
static
final
int
w
=
100
;
private
static
final
int
h
=
100
;
private
static
AffineTransform
at
=
AffineTransform
.
getScaleInstance
(
0.5
,
0.5
);
private
static
RasterOp
op
=
new
AffineTransformOp
(
at
,
AffineTransformOp
.
TYPE_NEAREST_NEIGHBOR
);
private
static
void
doTest
(
int
dataType
)
{
int
maxSize
=
DataBuffer
.
getDataTypeSize
(
dataType
);
System
.
out
.
println
(
"Type size: "
+
maxSize
);
int
theMask
=
(
int
)(
1L
<<
(
maxSize
+
2
))
-
1
;
System
.
out
.
printf
(
"theMask=%x\n"
,
theMask
);
SinglePixelPackedSampleModel
sm
=
new
SinglePixelPackedSampleModel
(
dataType
,
w
,
h
,
new
int
[]
{
theMask
});
int
[]
sampleSize
=
sm
.
getSampleSize
();
for
(
int
s
:
sampleSize
)
{
if
(
s
>
maxSize
)
{
throw
new
RuntimeException
(
"Test failed: sample size is too big:"
+
s
);
}
}
System
.
out
.
println
(
"Test medialib..."
);
DataBuffer
buf
=
createDataBuffer
(
dataType
);
WritableRaster
wr
=
Raster
.
createWritableRaster
(
sm
,
buf
,
null
);
op
.
filter
(
wr
,
null
);
System
.
out
.
println
(
"Test PASSED."
);
}
private
static
DataBuffer
createDataBuffer
(
int
type
)
{
switch
(
type
)
{
case
DataBuffer
.
TYPE_BYTE
:
{
byte
[]
buf
=
new
byte
[
w
*
h
];
return
new
DataBufferByte
(
buf
,
buf
.
length
);
}
case
DataBuffer
.
TYPE_USHORT
:
{
short
[]
buf
=
new
short
[
w
*
h
];
return
new
DataBufferUShort
(
buf
,
buf
.
length
);
}
case
DataBuffer
.
TYPE_INT
:
{
int
[]
buf
=
new
int
[
w
*
h
];
return
new
DataBufferInt
(
buf
,
buf
.
length
);
}
default
:
throw
new
RuntimeException
(
"Unsupported data type."
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录