Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
47aaa327
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47aaa327
编写于
1月 15, 2013
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7124525: [macosx] No animation on certain Swing components in Aqua LaF
Reviewed-by: alexsch, swingler
上级
c7e57502
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
34 deletion
+32
-34
src/macosx/classes/com/apple/laf/AquaPainter.java
src/macosx/classes/com/apple/laf/AquaPainter.java
+19
-25
src/macosx/classes/com/apple/laf/ImageCache.java
src/macosx/classes/com/apple/laf/ImageCache.java
+13
-9
未找到文件。
src/macosx/classes/com/apple/laf/AquaPainter.java
浏览文件 @
47aaa327
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2012,
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
...
...
@@ -37,7 +37,6 @@ import sun.awt.image.*;
import
sun.java2d.*
;
import
sun.print.*
;
import
apple.laf.*
;
import
apple.laf.JRSUIConstants.Widget
;
import
apple.laf.JRSUIUtils.NineSliceMetricsProvider
;
abstract
class
AquaPainter
<
T
extends
JRSUIState
>
{
...
...
@@ -63,7 +62,7 @@ abstract class AquaPainter <T extends JRSUIState> {
}
static
<
T
extends
JRSUIState
>
AquaPainter
<
T
>
create
(
final
T
state
,
final
NineSliceMetricsProvider
metricsProvider
)
{
return
new
AquaNineSlicingImagePainter
<
T
>(
state
,
metricsProvider
);
return
new
AquaNineSlicingImagePainter
<>(
state
,
metricsProvider
);
}
abstract
void
paint
(
final
Graphics2D
g
,
final
T
stateToPaint
,
final
Component
c
);
...
...
@@ -71,7 +70,7 @@ abstract class AquaPainter <T extends JRSUIState> {
final
Rectangle
boundsRect
=
new
Rectangle
();
final
JRSUIControl
control
;
T
state
;
public
AquaPainter
(
final
JRSUIControl
control
,
final
T
state
)
{
AquaPainter
(
final
JRSUIControl
control
,
final
T
state
)
{
this
.
control
=
control
;
this
.
state
=
state
;
}
...
...
@@ -94,14 +93,14 @@ abstract class AquaPainter <T extends JRSUIState> {
protected
final
HashMap
<
T
,
RecyclableJRSUISlicedImageControl
>
slicedControlImages
;
protected
final
NineSliceMetricsProvider
metricsProvider
;
public
AquaNineSlicingImagePainter
(
final
T
state
)
{
AquaNineSlicingImagePainter
(
final
T
state
)
{
this
(
state
,
null
);
}
public
AquaNineSlicingImagePainter
(
final
T
state
,
final
NineSliceMetricsProvider
metricsProvider
)
{
AquaNineSlicingImagePainter
(
final
T
state
,
final
NineSliceMetricsProvider
metricsProvider
)
{
super
(
new
JRSUIControl
(
false
),
state
);
this
.
metricsProvider
=
metricsProvider
;
slicedControlImages
=
new
HashMap
<
T
,
RecyclableJRSUISlicedImageControl
>();
slicedControlImages
=
new
HashMap
<>();
}
@Override
...
...
@@ -127,7 +126,7 @@ abstract class AquaPainter <T extends JRSUIState> {
}
static
class
AquaSingleImagePainter
<
T
extends
JRSUIState
>
extends
AquaPainter
<
T
>
{
public
AquaSingleImagePainter
(
final
T
state
)
{
AquaSingleImagePainter
(
final
T
state
)
{
super
(
new
JRSUIControl
(
false
),
state
);
}
...
...
@@ -137,12 +136,12 @@ abstract class AquaPainter <T extends JRSUIState> {
}
static
void
paintFromSingleCachedImage
(
final
Graphics2D
g
,
final
JRSUIControl
control
,
final
JRSUIState
controlState
,
final
Component
c
,
final
Rectangle
boundsRect
)
{
Rectangle
clipRect
=
g
.
getClipBounds
();
Rectangle
intersection
=
boundsRect
.
intersection
(
clipRect
);
final
Rectangle
clipRect
=
g
.
getClipBounds
();
final
Rectangle
intersection
=
boundsRect
.
intersection
(
clipRect
);
if
(
intersection
.
width
<=
0
||
intersection
.
height
<=
0
)
return
;
int
imgX1
=
intersection
.
x
-
boundsRect
.
x
;
int
imgY1
=
intersection
.
y
-
boundsRect
.
y
;
final
int
imgX1
=
intersection
.
x
-
boundsRect
.
x
;
final
int
imgY1
=
intersection
.
y
-
boundsRect
.
y
;
final
GraphicsConfiguration
config
=
g
.
getDeviceConfiguration
();
final
ImageCache
cache
=
ImageCache
.
getInstance
();
...
...
@@ -150,19 +149,14 @@ abstract class AquaPainter <T extends JRSUIState> {
if
(
image
==
null
)
{
image
=
new
BufferedImage
(
boundsRect
.
width
,
boundsRect
.
height
,
BufferedImage
.
TYPE_INT_ARGB_PRE
);
cache
.
setImage
(
image
,
config
,
boundsRect
.
width
,
boundsRect
.
height
,
controlState
);
}
else
{
g
.
drawImage
(
image
,
intersection
.
x
,
intersection
.
y
,
intersection
.
x
+
intersection
.
width
,
intersection
.
y
+
intersection
.
height
,
imgX1
,
imgY1
,
imgX1
+
intersection
.
width
,
imgY1
+
intersection
.
height
,
null
);
return
;
}
final
WritableRaster
raster
=
image
.
getRaster
();
final
DataBufferInt
buffer
=
(
DataBufferInt
)
raster
.
getDataBuffer
();
final
WritableRaster
raster
=
image
.
getRaster
();
final
DataBufferInt
buffer
=
(
DataBufferInt
)
raster
.
getDataBuffer
();
control
.
set
(
controlState
);
control
.
paint
(
SunWritableRaster
.
stealData
(
buffer
,
0
),
image
.
getWidth
(),
image
.
getHeight
(),
0
,
0
,
boundsRect
.
width
,
boundsRect
.
height
);
SunWritableRaster
.
markDirty
(
buffer
);
control
.
set
(
controlState
);
control
.
paint
(
SunWritableRaster
.
stealData
(
buffer
,
0
),
image
.
getWidth
(),
image
.
getHeight
(),
0
,
0
,
boundsRect
.
width
,
boundsRect
.
height
);
SunWritableRaster
.
markDirty
(
buffer
);
}
g
.
drawImage
(
image
,
intersection
.
x
,
intersection
.
y
,
intersection
.
x
+
intersection
.
width
,
intersection
.
y
+
intersection
.
height
,
imgX1
,
imgY1
,
imgX1
+
intersection
.
width
,
imgY1
+
intersection
.
height
,
null
);
...
...
@@ -173,7 +167,7 @@ abstract class AquaPainter <T extends JRSUIState> {
final
JRSUIControl
control
;
final
JRSUIState
state
;
public
RecyclableJRSUISlicedImageControl
(
final
JRSUIControl
control
,
final
JRSUIState
state
,
final
NineSliceMetrics
metrics
)
{
RecyclableJRSUISlicedImageControl
(
final
JRSUIControl
control
,
final
JRSUIState
state
,
final
NineSliceMetrics
metrics
)
{
super
(
metrics
);
this
.
control
=
control
;
this
.
state
=
state
;
...
...
src/macosx/classes/com/apple/laf/ImageCache.java
浏览文件 @
47aaa327
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2012,
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
...
...
@@ -30,6 +30,7 @@ import java.lang.ref.*;
import
java.util.*
;
import
java.util.concurrent.locks.*
;
import
apple.laf.JRSUIConstants
;
import
apple.laf.JRSUIState
;
import
com.apple.laf.AquaUtils.RecyclableSingleton
;
...
...
@@ -38,9 +39,9 @@ import com.apple.laf.AquaUtils.RecyclableSingleton;
* SoftReferences so they will be dropped by the GC if heap memory gets tight. When our size hits max pixel count least
* recently requested images are removed first.
*/
class
ImageCache
{
final
class
ImageCache
{
// Ordered Map keyed by args hash, ordered by most recent accessed entry.
private
final
LinkedHashMap
<
Integer
,
PixelCountSoftReference
>
map
=
new
LinkedHashMap
<
Integer
,
PixelCountSoftReference
>(
16
,
0.75f
,
true
);
private
final
LinkedHashMap
<
Integer
,
PixelCountSoftReference
>
map
=
new
LinkedHashMap
<>(
16
,
0.75f
,
true
);
// Maximum number of pixels to cache, this is used if maxCount
private
final
int
maxPixelCount
;
...
...
@@ -50,7 +51,7 @@ class ImageCache {
// Lock for concurrent access to map
private
final
ReadWriteLock
lock
=
new
ReentrantReadWriteLock
();
// Reference queue for tracking lost softreferences to images in the cache
private
final
ReferenceQueue
<
Image
>
referenceQueue
=
new
ReferenceQueue
<
Image
>();
private
final
ReferenceQueue
<
Image
>
referenceQueue
=
new
ReferenceQueue
<>();
// Singleton Instance
private
static
final
RecyclableSingleton
<
ImageCache
>
instance
=
new
RecyclableSingleton
<
ImageCache
>()
{
...
...
@@ -63,11 +64,11 @@ class ImageCache {
return
instance
.
get
();
}
public
ImageCache
(
final
int
maxPixelCount
)
{
ImageCache
(
final
int
maxPixelCount
)
{
this
.
maxPixelCount
=
maxPixelCount
;
}
public
ImageCache
()
{
ImageCache
()
{
this
((
8
*
1024
*
1024
)
/
4
);
// 8Mb of pixels
}
...
...
@@ -99,10 +100,13 @@ class ImageCache {
* @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key
* @param w The image width, used as part of cache key
* @param h The image height, used as part of cache key
* @param args Other arguments to use as part of the cache key
* @return true if the image could be cached or false if the image is too big
* @return true if the image could be cached, false otherwise.
*/
public
boolean
setImage
(
final
Image
image
,
final
GraphicsConfiguration
config
,
final
int
w
,
final
int
h
,
final
JRSUIState
state
)
{
if
(
state
.
is
(
JRSUIConstants
.
Animating
.
YES
))
{
return
false
;
}
final
int
hash
=
hash
(
config
,
w
,
h
,
state
);
lock
.
writeLock
().
lock
();
...
...
@@ -167,7 +171,7 @@ class ImageCache {
private
final
int
h
;
private
final
JRSUIState
state
;
public
PixelCountSoftReference
(
final
Image
referent
,
final
ReferenceQueue
<?
super
Image
>
q
,
final
int
pixelCount
,
final
int
hash
,
final
GraphicsConfiguration
config
,
final
int
w
,
final
int
h
,
final
JRSUIState
state
)
{
PixelCountSoftReference
(
final
Image
referent
,
final
ReferenceQueue
<?
super
Image
>
q
,
final
int
pixelCount
,
final
int
hash
,
final
GraphicsConfiguration
config
,
final
int
w
,
final
int
h
,
final
JRSUIState
state
)
{
super
(
referent
,
q
);
this
.
pixelCount
=
pixelCount
;
this
.
hash
=
hash
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录