Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f932a121
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看板
提交
f932a121
编写于
5月 15, 2013
作者:
A
ant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8014227: JLightweightFrame needs another synchronization policy
Reviewed-by: art
上级
4546dbc6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
10 deletion
+62
-10
src/share/classes/sun/swing/JLightweightFrame.java
src/share/classes/sun/swing/JLightweightFrame.java
+62
-10
未找到文件。
src/share/classes/sun/swing/JLightweightFrame.java
浏览文件 @
f932a121
...
...
@@ -35,6 +35,7 @@ import java.awt.Graphics2D;
import
java.awt.Rectangle
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.DataBufferInt
;
import
java.security.AccessController
;
import
javax.swing.JLayeredPane
;
import
javax.swing.JPanel
;
...
...
@@ -43,6 +44,7 @@ import javax.swing.LayoutFocusTraversalPolicy;
import
javax.swing.RootPaneContainer
;
import
sun.awt.LightweightFrame
;
import
sun.security.action.GetPropertyAction
;
/**
* The frame serves as a lightweight container which paints its content
...
...
@@ -65,12 +67,28 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
private
BufferedImage
bbImage
;
/**
* {@code copyBufferEnabled}, true by default, defines the following strategy.
* A duplicating (copy) buffer is created for the original pixel buffer.
* The copy buffer is synchronized with the original buffer every time the
* latter changes. {@code JLightweightFrame} passes the copy buffer array
* to the {@link LightweightContent#imageBufferReset} method. The code spot
* which synchronizes two buffers becomes the only critical section guarded
* by the lock (managed with the {@link LightweightContent#paintLock()},
* {@link LightweightContent#paintUnlock()} methods).
*/
private
boolean
copyBufferEnabled
;
private
int
[]
copyBuffer
;
/**
* Constructs a new, initially invisible {@code JLightweightFrame}
* instance.
*/
public
JLightweightFrame
()
{
super
();
copyBufferEnabled
=
"true"
.
equals
(
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"jlf.copyBufferEnabled"
,
"true"
)));
add
(
rootPane
,
BorderLayout
.
CENTER
);
setFocusTraversalPolicy
(
new
LayoutFocusTraversalPolicy
());
if
(
getGraphicsConfiguration
().
isTranslucencyCapable
())
{
...
...
@@ -124,16 +142,37 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
if
(
content
!=
null
)
content
.
focusUngrabbed
();
}
private
void
syncCopyBuffer
(
boolean
reset
,
int
x
,
int
y
,
int
w
,
int
h
)
{
content
.
paintLock
();
try
{
int
[]
srcBuffer
=
((
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
()).
getData
();
if
(
reset
)
{
copyBuffer
=
new
int
[
srcBuffer
.
length
];
}
int
linestride
=
bbImage
.
getWidth
();
for
(
int
i
=
0
;
i
<
h
;
i
++)
{
int
from
=
(
y
+
i
)
*
linestride
+
x
;
System
.
arraycopy
(
srcBuffer
,
from
,
copyBuffer
,
from
,
w
);
}
}
finally
{
content
.
paintUnlock
();
}
}
private
void
initInterior
()
{
contentPane
=
new
JPanel
()
{
@Override
public
void
paint
(
Graphics
g
)
{
content
.
paintLock
();
if
(!
copyBufferEnabled
)
{
content
.
paintLock
();
}
try
{
super
.
paint
(
g
);
final
Rectangle
clip
=
g
.
getClipBounds
()
!=
null
?
g
.
getClipBounds
()
:
new
Rectangle
(
0
,
0
,
contentPane
.
getWidth
(),
contentPane
.
getHeight
());
g
.
getClipBounds
()
:
new
Rectangle
(
0
,
0
,
contentPane
.
getWidth
(),
contentPane
.
getHeight
());
clip
.
x
=
Math
.
max
(
0
,
clip
.
x
);
clip
.
y
=
Math
.
max
(
0
,
clip
.
y
);
...
...
@@ -143,11 +182,16 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
EventQueue
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
copyBufferEnabled
)
{
syncCopyBuffer
(
false
,
clip
.
x
,
clip
.
y
,
clip
.
width
,
clip
.
height
);
}
content
.
imageUpdated
(
clip
.
x
,
clip
.
y
,
clip
.
width
,
clip
.
height
);
}
});
}
finally
{
content
.
paintUnlock
();
if
(!
copyBufferEnabled
)
{
content
.
paintUnlock
();
}
}
}
@Override
...
...
@@ -167,8 +211,9 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
if
(
width
==
0
||
height
==
0
)
{
return
;
}
content
.
paintLock
();
if
(!
copyBufferEnabled
)
{
content
.
paintLock
();
}
try
{
if
((
bbImage
==
null
)
||
(
width
!=
bbImage
.
getWidth
())
||
(
height
!=
bbImage
.
getHeight
()))
{
boolean
createBB
=
true
;
...
...
@@ -204,14 +249,21 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
oldBB
.
flush
();
}
}
DataBufferInt
dataBuf
=
(
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
();
content
.
imageBufferReset
(
dataBuf
.
getData
(),
0
,
0
,
width
,
height
,
bbImage
.
getWidth
());
}
else
{
content
.
imageReshaped
(
0
,
0
,
width
,
height
);
int
[]
pixels
=
((
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
()).
getData
();
if
(
copyBufferEnabled
)
{
syncCopyBuffer
(
true
,
0
,
0
,
width
,
height
);
pixels
=
copyBuffer
;
}
content
.
imageBufferReset
(
pixels
,
0
,
0
,
width
,
height
,
bbImage
.
getWidth
());
return
;
}
}
content
.
imageReshaped
(
0
,
0
,
width
,
height
);
}
finally
{
content
.
paintUnlock
();
if
(!
copyBufferEnabled
)
{
content
.
paintUnlock
();
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录