Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
69526bc6
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69526bc6
编写于
5月 28, 2014
作者:
A
alexsch
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8040291: [macosx] Http-Images are not fully loaded when using ImageIcon
Reviewed-by: serb, pchelko
上级
fc6f83bc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
189 addition
and
7 deletion
+189
-7
src/share/classes/java/awt/MediaTracker.java
src/share/classes/java/awt/MediaTracker.java
+6
-3
src/share/classes/sun/awt/SunToolkit.java
src/share/classes/sun/awt/SunToolkit.java
+12
-4
src/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
...re/classes/sun/awt/image/MultiResolutionToolkitImage.java
+13
-0
test/java/awt/image/multiresolution/MultiResolutionToolkitImageTest.java
...mage/multiresolution/MultiResolutionToolkitImageTest.java
+158
-0
未找到文件。
src/share/classes/java/awt/MediaTracker.java
浏览文件 @
69526bc6
...
...
@@ -226,7 +226,9 @@ public class MediaTracker implements java.io.Serializable {
addImageImpl
(
image
,
id
,
w
,
h
);
Image
rvImage
=
getResolutionVariant
(
image
);
if
(
rvImage
!=
null
)
{
addImageImpl
(
rvImage
,
id
,
2
*
w
,
2
*
h
);
addImageImpl
(
rvImage
,
id
,
w
==
-
1
?
-
1
:
2
*
w
,
h
==
-
1
?
-
1
:
2
*
h
);
}
}
...
...
@@ -810,8 +812,9 @@ public class MediaTracker implements java.io.Serializable {
removeImageImpl
(
image
,
id
,
width
,
height
);
Image
rvImage
=
getResolutionVariant
(
image
);
if
(
rvImage
!=
null
)
{
removeImageImpl
(
rvImage
,
id
,
2
*
width
,
2
*
height
);
removeImageImpl
(
rvImage
,
id
,
width
==
-
1
?
-
1
:
2
*
width
,
height
==
-
1
?
-
1
:
2
*
height
);
}
notifyAll
();
// Notify in case remaining images are "done".
}
...
...
src/share/classes/sun/awt/SunToolkit.java
浏览文件 @
69526bc6
...
...
@@ -851,22 +851,30 @@ public abstract class SunToolkit extends Toolkit
private
int
checkResolutionVariant
(
Image
img
,
int
w
,
int
h
,
ImageObserver
o
)
{
ToolkitImage
rvImage
=
getResolutionVariant
(
img
);
int
rvw
=
getRVSize
(
w
);
int
rvh
=
getRVSize
(
h
);
// Ignore the resolution variant in case of error
return
(
rvImage
==
null
||
rvImage
.
hasError
())
?
0xFFFF
:
checkImage
(
rvImage
,
2
*
w
,
2
*
h
,
MultiResolutionToolkitImage
.
checkImage
(
rvImage
,
rvw
,
rv
h
,
MultiResolutionToolkitImage
.
getResolutionVariantObserver
(
img
,
o
,
w
,
h
,
2
*
w
,
2
*
h
));
img
,
o
,
w
,
h
,
rvw
,
rvh
,
true
));
}
private
boolean
prepareResolutionVariant
(
Image
img
,
int
w
,
int
h
,
ImageObserver
o
)
{
ToolkitImage
rvImage
=
getResolutionVariant
(
img
);
int
rvw
=
getRVSize
(
w
);
int
rvh
=
getRVSize
(
h
);
// Ignore the resolution variant in case of error
return
rvImage
==
null
||
rvImage
.
hasError
()
||
prepareImage
(
rvImage
,
2
*
w
,
2
*
h
,
rvImage
,
rvw
,
rv
h
,
MultiResolutionToolkitImage
.
getResolutionVariantObserver
(
img
,
o
,
w
,
h
,
2
*
w
,
2
*
h
));
img
,
o
,
w
,
h
,
rvw
,
rvh
,
true
));
}
private
static
int
getRVSize
(
int
size
){
return
size
==
-
1
?
-
1
:
2
*
size
;
}
private
static
ToolkitImage
getResolutionVariant
(
Image
image
)
{
...
...
src/share/classes/sun/awt/image/MultiResolutionToolkitImage.java
浏览文件 @
69526bc6
...
...
@@ -66,6 +66,14 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe
final
Image
image
,
final
ImageObserver
observer
,
final
int
imgWidth
,
final
int
imgHeight
,
final
int
rvWidth
,
final
int
rvHeight
)
{
return
getResolutionVariantObserver
(
image
,
observer
,
imgWidth
,
imgHeight
,
rvWidth
,
rvHeight
,
false
);
}
public
static
ImageObserver
getResolutionVariantObserver
(
final
Image
image
,
final
ImageObserver
observer
,
final
int
imgWidth
,
final
int
imgHeight
,
final
int
rvWidth
,
final
int
rvHeight
,
boolean
concatenateInfo
)
{
if
(
observer
==
null
)
{
return
null
;
...
...
@@ -92,6 +100,11 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe
y
/=
2
;
}
if
(
concatenateInfo
){
flags
&=
((
ToolkitImage
)
image
).
getImageRep
().
check
(
null
);
}
return
observer
.
imageUpdate
(
image
,
flags
,
x
,
y
,
width
,
height
);
};
...
...
test/java/awt/image/multiresolution/MultiResolutionToolkitImageTest.java
0 → 100644
浏览文件 @
69526bc6
/*
* 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.
*/
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Image
;
import
java.awt.Toolkit
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ImageObserver
;
import
static
java
.
awt
.
image
.
ImageObserver
.
ALLBITS
;
import
java.io.File
;
import
javax.imageio.ImageIO
;
import
sun.awt.OSInfo
;
import
sun.awt.SunToolkit
;
import
sun.awt.image.MultiResolutionToolkitImage
;
/**
* @test
* @bug 8040291
* @author Alexander Scherbatiy
* @summary [macosx] Http-Images are not fully loaded when using ImageIcon
* @run main MultiResolutionToolkitImageTest
*/
public
class
MultiResolutionToolkitImageTest
{
private
static
final
int
IMAGE_WIDTH
=
300
;
private
static
final
int
IMAGE_HEIGHT
=
200
;
private
static
final
Color
COLOR_1X
=
Color
.
GREEN
;
private
static
final
Color
COLOR_2X
=
Color
.
BLUE
;
private
static
final
String
IMAGE_NAME_1X
=
"image.png"
;
private
static
final
String
IMAGE_NAME_2X
=
"image@2x.png"
;
private
static
final
int
WAIT_TIME
=
400
;
private
static
volatile
boolean
isImageLoaded
=
false
;
private
static
volatile
boolean
isRVObserverCalled
=
false
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(!
checkOS
())
{
return
;
}
generateImages
();
testToolkitMultiResolutionImageLoad
();
}
static
void
testToolkitMultiResolutionImageLoad
()
throws
Exception
{
File
imageFile
=
new
File
(
IMAGE_NAME_1X
);
String
fileName
=
imageFile
.
getAbsolutePath
();
Image
image
=
Toolkit
.
getDefaultToolkit
().
getImage
(
fileName
);
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
toolkit
.
prepareImage
(
image
,
-
1
,
-
1
,
new
LoadImageObserver
());
final
long
time
=
WAIT_TIME
+
System
.
currentTimeMillis
();
while
((!
isImageLoaded
||
!
isRVObserverCalled
)
&&
System
.
currentTimeMillis
()
<
time
)
{
Thread
.
sleep
(
50
);
}
if
(!
isImageLoaded
){
throw
new
RuntimeException
(
"Image is not loaded!"
);
}
if
(!
isRVObserverCalled
){
throw
new
RuntimeException
(
"Resolution Variant observer is not called!"
);
}
}
static
void
generateImages
()
throws
Exception
{
if
(!
new
File
(
IMAGE_NAME_1X
).
exists
())
{
generateImage
(
1
);
}
if
(!
new
File
(
IMAGE_NAME_2X
).
exists
())
{
generateImage
(
2
);
}
}
static
void
generateImage
(
int
scale
)
throws
Exception
{
BufferedImage
image
=
new
BufferedImage
(
scale
*
IMAGE_WIDTH
,
scale
*
IMAGE_HEIGHT
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics
g
=
image
.
getGraphics
();
g
.
setColor
(
scale
==
1
?
COLOR_1X
:
COLOR_2X
);
g
.
fillRect
(
0
,
0
,
scale
*
IMAGE_WIDTH
,
scale
*
IMAGE_HEIGHT
);
File
file
=
new
File
(
scale
==
1
?
IMAGE_NAME_1X
:
IMAGE_NAME_2X
);
ImageIO
.
write
(
image
,
"png"
,
file
);
}
static
boolean
checkOS
()
{
return
OSInfo
.
getOSType
()
==
OSInfo
.
OSType
.
MACOSX
;
}
static
class
LoadImageObserver
implements
ImageObserver
{
@Override
public
boolean
imageUpdate
(
Image
img
,
int
infoflags
,
int
x
,
int
y
,
int
width
,
int
height
)
{
if
(
isRVObserver
())
{
isRVObserverCalled
=
true
;
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
Image
resolutionVariant
=
getResolutionVariant
(
img
);
int
rvFlags
=
toolkit
.
checkImage
(
resolutionVariant
,
width
,
height
,
new
IdleImageObserver
());
if
(
rvFlags
<
infoflags
)
{
throw
new
RuntimeException
(
"Info flags are greater than"
+
" resolution varint info flags"
);
}
}
else
if
((
infoflags
&
ALLBITS
)
!=
0
)
{
isImageLoaded
=
true
;
}
return
(
infoflags
&
ALLBITS
)
==
0
;
}
}
static
boolean
isRVObserver
()
{
Exception
e
=
new
Exception
();
for
(
StackTraceElement
elem
:
e
.
getStackTrace
())
{
if
(
elem
.
getClassName
().
endsWith
(
"MultiResolutionToolkitImage"
))
{
return
true
;
}
}
return
false
;
}
static
class
IdleImageObserver
implements
ImageObserver
{
@Override
public
boolean
imageUpdate
(
Image
img
,
int
infoflags
,
int
x
,
int
y
,
int
width
,
int
height
)
{
return
false
;
}
}
static
Image
getResolutionVariant
(
Image
image
)
{
return
((
MultiResolutionToolkitImage
)
image
).
getResolutionVariant
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录