Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a3799e58
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看板
提交
a3799e58
编写于
5月 22, 2015
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8071306: GUI perfomance are very slow compared java 1.6.0_45
Reviewed-by: azvegint, ant
上级
68510f4d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
144 addition
and
54 deletion
+144
-54
src/share/classes/java/awt/Component.java
src/share/classes/java/awt/Component.java
+21
-2
src/share/classes/java/awt/Container.java
src/share/classes/java/awt/Container.java
+51
-52
test/java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java
...omponent/SetEnabledPerformance/SetEnabledPerformance.java
+72
-0
未找到文件。
src/share/classes/java/awt/Component.java
浏览文件 @
a3799e58
...
...
@@ -1301,6 +1301,25 @@ public abstract class Component implements ImageObserver, MenuContainer,
return
visible
&&
(
parent
==
null
||
parent
.
isRecursivelyVisible
());
}
/**
* Determines the bounds of a visible part of the component relative to its
* parent.
*
* @return the visible part of bounds
*/
private
Rectangle
getRecursivelyVisibleBounds
()
{
final
Component
container
=
getContainer
();
final
Rectangle
bounds
=
getBounds
();
if
(
container
==
null
)
{
// we are top level window or haven't a container, return our bounds
return
bounds
;
}
// translate the container's bounds to our coordinate space
final
Rectangle
parentsBounds
=
container
.
getRecursivelyVisibleBounds
();
parentsBounds
.
setLocation
(
0
,
0
);
return
parentsBounds
.
intersection
(
bounds
);
}
/**
* Translates absolute coordinates into coordinates in the coordinate
* space of this component.
...
...
@@ -1473,7 +1492,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
ComponentPeer
peer
=
this
.
peer
;
if
(
peer
!=
null
)
{
peer
.
setEnabled
(
true
);
if
(
visible
)
{
if
(
visible
&&
!
getRecursivelyVisibleBounds
().
isEmpty
()
)
{
updateCursorImmediately
();
}
}
...
...
@@ -1522,7 +1541,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
ComponentPeer
peer
=
this
.
peer
;
if
(
peer
!=
null
)
{
peer
.
setEnabled
(
false
);
if
(
visible
)
{
if
(
visible
&&
!
getRecursivelyVisibleBounds
().
isEmpty
()
)
{
updateCursorImmediately
();
}
}
...
...
src/share/classes/java/awt/Container.java
浏览文件 @
a3799e58
...
...
@@ -44,6 +44,7 @@ import java.io.PrintWriter;
import
java.lang.ref.WeakReference
;
import
java.security.AccessController
;
import
java.util.ArrayList
;
import
java.util.EventListener
;
import
java.util.HashSet
;
import
java.util.Set
;
...
...
@@ -100,7 +101,7 @@ public class Container extends Component {
* @see #add
* @see #getComponents
*/
private
java
.
util
.
List
<
Component
>
component
=
new
java
.
util
.
ArrayList
<
Component
>();
private
java
.
util
.
List
<
Component
>
component
=
new
ArrayList
<
>();
/**
* Layout manager for this container.
...
...
@@ -2545,28 +2546,24 @@ public class Container extends Component {
if
(!
contains
(
x
,
y
))
{
return
null
;
}
Component
lightweight
=
null
;
synchronized
(
getTreeLock
())
{
//
Two passes: see comment in sun.awt.SunGraphicsCallback
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
Component
comp
=
component
.
get
(
i
);
if
(
comp
!=
null
&&
!(
comp
.
peer
instanceof
LightweightPeer
))
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
//
Optimized version of two passes:
// see comment in sun.awt.SunGraphicsCallback
for
(
final
Component
comp
:
component
)
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
if
(!
comp
.
isLightweight
(
))
{
// return heavyweight component as soon as possible
return
comp
;
}
}
}
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
Component
comp
=
component
.
get
(
i
);
if
(
comp
!=
null
&&
comp
.
peer
instanceof
LightweightPeer
)
{
if
(
comp
.
contains
(
x
-
comp
.
x
,
y
-
comp
.
y
))
{
return
comp
;
if
(
lightweight
==
null
)
{
// save and return later the first lightweight component
lightweight
=
comp
;
}
}
}
}
return
this
;
return
lightweight
!=
null
?
lightweight
:
this
;
}
/**
...
...
@@ -2670,52 +2667,54 @@ public class Container extends Component {
return
null
;
}
final
Component
findComponentAtImpl
(
int
x
,
int
y
,
boolean
ignoreEnabled
){
checkTreeLock
();
final
Component
findComponentAtImpl
(
int
x
,
int
y
,
boolean
ignoreEnabled
)
{
// checkTreeLock(); commented for a performance reason
if
(!(
contains
(
x
,
y
)
&&
visible
&&
(
ignoreEnabled
||
enabled
)))
{
return
null
;
}
// Two passes: see comment in sun.awt.SunGraphicsCallback
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
Component
comp
=
component
.
get
(
i
);
if
(
comp
!=
null
&&
!(
comp
.
peer
instanceof
LightweightPeer
))
{
if
(
comp
instanceof
Container
)
{
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
-
comp
.
x
,
y
-
comp
.
y
,
ignoreEnabled
);
}
else
{
comp
=
comp
.
getComponentAt
(
x
-
comp
.
x
,
y
-
comp
.
y
);
}
if
(
comp
!=
null
&&
comp
.
visible
&&
(
ignoreEnabled
||
comp
.
enabled
))
{
return
comp
;
}
Component
lightweight
=
null
;
// Optimized version of two passes:
// see comment in sun.awt.SunGraphicsCallback
for
(
final
Component
comp
:
component
)
{
final
int
x1
=
x
-
comp
.
x
;
final
int
y1
=
y
-
comp
.
y
;
if
(!
comp
.
contains
(
x1
,
y1
))
{
continue
;
// fast path
}
}
for
(
int
i
=
0
;
i
<
component
.
size
();
i
++)
{
Component
comp
=
component
.
get
(
i
);
if
(
comp
!=
null
&&
comp
.
peer
instanceof
LightweightPeer
)
{
if
(
comp
instanceof
Container
)
{
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
-
comp
.
x
,
y
-
comp
.
y
,
ignoreEnabled
);
}
else
{
comp
=
comp
.
getComponentAt
(
x
-
comp
.
x
,
y
-
comp
.
y
);
if
(!
comp
.
isLightweight
())
{
final
Component
child
=
getChildAt
(
comp
,
x1
,
y1
,
ignoreEnabled
);
if
(
child
!=
null
)
{
// return heavyweight component as soon as possible
return
child
;
}
if
(
comp
!=
null
&&
comp
.
visible
&&
(
ignoreEnabled
||
comp
.
enabled
))
{
return
comp
;
}
else
{
if
(
lightweight
==
null
)
{
// save and return later the first lightweight component
lightweight
=
getChildAt
(
comp
,
x1
,
y1
,
ignoreEnabled
)
;
}
}
}
return
lightweight
!=
null
?
lightweight
:
this
;
}
return
this
;
/**
* Helper method for findComponentAtImpl. Finds a child component using
* findComponentAtImpl for Container and getComponentAt for Component.
*/
private
static
Component
getChildAt
(
Component
comp
,
int
x
,
int
y
,
boolean
ignoreEnabled
)
{
if
(
comp
instanceof
Container
)
{
comp
=
((
Container
)
comp
).
findComponentAtImpl
(
x
,
y
,
ignoreEnabled
);
}
else
{
comp
=
comp
.
getComponentAt
(
x
,
y
);
}
if
(
comp
!=
null
&&
comp
.
visible
&&
(
ignoreEnabled
||
comp
.
enabled
))
{
return
comp
;
}
return
null
;
}
/**
...
...
test/java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java
0 → 100644
浏览文件 @
a3799e58
/*
* Copyright (c) 2015, 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.Component
;
import
java.awt.FlowLayout
;
import
java.awt.Frame
;
import
java.awt.Robot
;
import
javax.swing.JButton
;
import
javax.swing.SwingUtilities
;
/**
* @test
* @bug 8071306
* @author Sergey Bylokhov
*/
public
final
class
SetEnabledPerformance
{
private
static
Frame
frame
;
private
static
void
createAndShowGUI
()
{
frame
=
new
Frame
();
frame
.
setLayout
(
new
FlowLayout
(
FlowLayout
.
CENTER
,
25
,
0
));
frame
.
setSize
(
600
,
600
);
frame
.
setLocationRelativeTo
(
null
);
for
(
int
i
=
1
;
i
<
10001
;
++
i
)
{
frame
.
add
(
new
JButton
(
"Button "
+
i
));
}
frame
.
setVisible
(
true
);
}
public
static
void
main
(
final
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
createAndShowGUI
());
final
Robot
robot
=
new
Robot
();
robot
.
waitForIdle
();
robot
.
mouseMove
(
frame
.
getX
()
+
15
,
frame
.
getY
()
+
300
);
robot
.
waitForIdle
();
SwingUtilities
.
invokeAndWait
(()
->
{
long
m
=
System
.
currentTimeMillis
();
for
(
final
Component
comp
:
frame
.
getComponents
())
{
comp
.
setEnabled
(
false
);
}
m
=
System
.
currentTimeMillis
()
-
m
;
System
.
err
.
println
(
"Disabled in "
+
m
+
" ms"
);
frame
.
dispose
();
// we should be much faster, but leaves 1000 for the slow systems
if
(
m
>
1000
)
{
throw
new
RuntimeException
(
"Too slow"
);
}
});
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录