Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
442c804d
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看板
提交
442c804d
编写于
5月 01, 2013
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
Reviewed-by: anthony, bae
上级
8b04346f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
125 addition
and
54 deletion
+125
-54
src/macosx/classes/sun/awt/CGraphicsDevice.java
src/macosx/classes/sun/awt/CGraphicsDevice.java
+38
-12
src/macosx/classes/sun/awt/CGraphicsEnvironment.java
src/macosx/classes/sun/awt/CGraphicsEnvironment.java
+44
-35
src/macosx/classes/sun/lwawt/LWWindowPeer.java
src/macosx/classes/sun/lwawt/LWWindowPeer.java
+29
-2
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+5
-1
src/macosx/native/sun/awt/CGraphicsEnv.m
src/macosx/native/sun/awt/CGraphicsEnv.m
+4
-3
src/macosx/native/sun/java2d/opengl/CGLLayer.m
src/macosx/native/sun/java2d/opengl/CGLLayer.m
+5
-1
未找到文件。
src/macosx/classes/sun/awt/CGraphicsDevice.java
浏览文件 @
442c804d
...
...
@@ -35,10 +35,18 @@ import java.util.Objects;
import
sun.java2d.opengl.CGLGraphicsConfig
;
public
final
class
CGraphicsDevice
extends
GraphicsDevice
{
public
final
class
CGraphicsDevice
extends
GraphicsDevice
implements
DisplayChangedListener
{
// CoreGraphics display ID
private
final
int
displayID
;
/**
* CoreGraphics display ID. This identifier can become non-valid at any time
* therefore methods, which is using this id should be ready to it.
*/
private
volatile
int
displayID
;
private
volatile
Insets
screenInsets
;
private
volatile
double
xResolution
;
private
volatile
double
yResolution
;
private
volatile
int
scale
;
// Array of all GraphicsConfig instances for this device
private
final
GraphicsConfiguration
[]
configs
;
...
...
@@ -51,7 +59,7 @@ public final class CGraphicsDevice extends GraphicsDevice {
// Save/restore DisplayMode for the Full Screen mode
private
DisplayMode
originalMode
;
public
CGraphicsDevice
(
int
displayID
)
{
public
CGraphicsDevice
(
final
int
displayID
)
{
this
.
displayID
=
displayID
;
configs
=
new
GraphicsConfiguration
[]
{
CGLGraphicsConfig
.
getConfig
(
this
,
0
)
...
...
@@ -89,7 +97,7 @@ public final class CGraphicsDevice extends GraphicsDevice {
*/
@Override
public
String
getIDstring
()
{
return
"Display "
+
this
.
displayID
;
return
"Display "
+
displayID
;
}
/**
...
...
@@ -104,15 +112,37 @@ public final class CGraphicsDevice extends GraphicsDevice {
}
public
double
getXResolution
()
{
return
nativeGetXResolution
(
displayID
)
;
return
xResolution
;
}
public
double
getYResolution
()
{
return
nativeGetYResolution
(
displayID
)
;
return
yResolution
;
}
public
Insets
getScreenInsets
()
{
return
nativeGetScreenInsets
(
displayID
);
return
screenInsets
;
}
public
int
getScaleFactor
()
{
return
scale
;
}
public
void
invalidate
(
final
int
defaultDisplayID
)
{
displayID
=
defaultDisplayID
;
}
@Override
public
void
displayChanged
()
{
xResolution
=
nativeGetXResolution
(
displayID
);
yResolution
=
nativeGetYResolution
(
displayID
);
screenInsets
=
nativeGetScreenInsets
(
displayID
);
scale
=
(
int
)
nativeGetScaleFactor
(
displayID
);
//TODO configs/fullscreenWindow/modes?
}
@Override
public
void
paletteChanged
()
{
// devices do not need to react to this event.
}
/**
...
...
@@ -219,10 +249,6 @@ public final class CGraphicsDevice extends GraphicsDevice {
return
nativeGetDisplayModes
(
displayID
);
}
public
int
getScaleFactor
()
{
return
(
int
)
nativeGetScaleFactor
(
displayID
);
}
private
static
native
double
nativeGetScaleFactor
(
int
displayID
);
private
static
native
void
nativeSetDisplayMode
(
int
displayID
,
int
w
,
int
h
,
int
bpp
,
int
refrate
);
...
...
src/macosx/classes/sun/awt/CGraphicsEnvironment.java
浏览文件 @
442c804d
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011,
2013,
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
...
...
@@ -26,19 +26,20 @@
package
sun.awt
;
import
java.awt.*
;
import
java.awt.print.*
;
import
java.util.*
;
import
sun.java2d.*
;
/**
* This is an implementation of a GraphicsEnvironment object for the default local GraphicsEnvironment used by the Java
* Runtime Environment for Mac OS X GUI environments.
* This is an implementation of a GraphicsEnvironment object for the default
* local GraphicsEnvironment used by the Java Runtime Environment for Mac OS X
* GUI environments.
*
* @see GraphicsDevice
* @see GraphicsConfiguration
*/
public
class
CGraphicsEnvironment
extends
SunGraphicsEnvironment
{
public
final
class
CGraphicsEnvironment
extends
SunGraphicsEnvironment
{
// Global initialization of the Cocoa runtime.
private
static
native
void
initCocoa
();
...
...
@@ -53,7 +54,8 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
private
static
native
int
getMainDisplayID
();
/**
* Noop function that just acts as an entry point for someone to force a static initialization of this class.
* Noop function that just acts as an entry point for someone to force a
* static initialization of this class.
*/
public
static
void
init
()
{
}
...
...
@@ -78,8 +80,9 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
}
/**
* Register the instance with CGDisplayRegisterReconfigurationCallback()
* The registration uses a weak global reference -- if our instance is garbage collected, the reference will be dropped.
* Register the instance with CGDisplayRegisterReconfigurationCallback().
* The registration uses a weak global reference -- if our instance is
* garbage collected, the reference will be dropped.
*
* @return Return the registration context (a pointer).
*/
...
...
@@ -91,7 +94,7 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
private
native
void
deregisterDisplayReconfiguration
(
long
context
);
/** Available CoreGraphics displays. */
private
final
Map
<
Integer
,
CGraphicsDevice
>
devices
=
new
HashMap
<
Integer
,
CGraphicsDevice
>(
);
private
final
Map
<
Integer
,
CGraphicsDevice
>
devices
=
new
HashMap
<
>(
5
);
/** Reference to the display reconfiguration callback context. */
private
final
long
displayReconfigContext
;
...
...
@@ -118,11 +121,18 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
/**
* Called by the CoreGraphics Display Reconfiguration Callback.
*
* @param displayId
*
CoreGraphics displayId
* @param displayId
CoreGraphics displayId
*
@param removed true if displayId was removed, false otherwise.
*/
void
_displayReconfiguration
(
long
displayId
)
{
displayChanged
();
void
_displayReconfiguration
(
final
int
displayId
,
final
boolean
removed
)
{
synchronized
(
this
)
{
if
(
removed
&&
devices
.
containsKey
(
displayId
))
{
final
CGraphicsDevice
gd
=
devices
.
remove
(
displayId
);
gd
.
invalidate
(
getMainDisplayID
());
gd
.
displayChanged
();
}
}
initDevices
();
}
@Override
...
...
@@ -135,31 +145,30 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
}
/**
* (Re)create all CGraphicsDevices
*
* @return
* (Re)create all CGraphicsDevices, reuses a devices if it is possible.
*/
private
synchronized
void
initDevices
()
{
devices
.
clear
();
int
mainID
=
getMainDisplayID
();
// initialization of the graphics device may change
// list of displays on hybrid systems via an activation
// of discrete video.
// So, we initialize the main display first, and then
// retrieve actual list of displays.
CGraphicsDevice
mainDevice
=
new
CGraphicsDevice
(
mainID
);
final
int
[]
displayIDs
=
getDisplayIDs
();
private
void
initDevices
()
{
synchronized
(
this
)
{
final
Map
<
Integer
,
CGraphicsDevice
>
old
=
new
HashMap
<>(
devices
);
devices
.
clear
();
int
mainID
=
getMainDisplayID
();
// initialization of the graphics device may change
// list of displays on hybrid systems via an activation
// of discrete video.
// So, we initialize the main display first, and then
// retrieve actual list of displays.
if
(!
old
.
containsKey
(
mainID
))
{
old
.
put
(
mainID
,
new
CGraphicsDevice
(
mainID
));
}
for
(
int
displayID
:
displayIDs
)
{
if
(
displayID
!=
mainID
)
{
devices
.
put
(
displayID
,
new
CGraphicsDevice
(
displayID
));
}
else
{
devices
.
put
(
mainID
,
mainDevice
);
for
(
final
int
id
:
getDisplayIDs
())
{
devices
.
put
(
id
,
old
.
containsKey
(
id
)
?
old
.
get
(
id
)
:
new
CGraphicsDevice
(
id
));
}
}
displayChanged
();
}
@Override
...
...
@@ -167,7 +176,7 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
final
int
mainDisplayID
=
getMainDisplayID
();
CGraphicsDevice
d
=
devices
.
get
(
mainDisplayID
);
if
(
d
==
null
)
{
// we do not ex
epct that this may happen, the only responc
e
// we do not ex
pect that this may happen, the only respons
e
// is to re-initialize the list of devices
initDevices
();
...
...
src/macosx/classes/sun/lwawt/LWWindowPeer.java
浏览文件 @
442c804d
...
...
@@ -41,7 +41,7 @@ import sun.util.logging.PlatformLogger;
public
class
LWWindowPeer
extends
LWContainerPeer
<
Window
,
JComponent
>
implements
WindowPeer
,
FramePeer
,
DialogPeer
,
FullScreenCapable
implements
FramePeer
,
DialogPeer
,
FullScreenCapable
,
DisplayChangedListener
{
public
static
enum
PeerType
{
SIMPLEWINDOW
,
...
...
@@ -189,6 +189,7 @@ public class LWWindowPeer
if
(
getSurfaceData
()
==
null
)
{
replaceSurfaceData
(
false
);
}
activateDisplayListener
();
}
// Just a helper method
...
...
@@ -205,6 +206,7 @@ public class LWWindowPeer
@Override
protected
void
disposeImpl
()
{
deactivateDisplayListener
();
SurfaceData
oldData
=
getSurfaceData
();
synchronized
(
surfaceDataLock
){
surfaceData
=
null
;
...
...
@@ -875,6 +877,18 @@ public class LWWindowPeer
// ---- UTILITY METHODS ---- //
private
void
activateDisplayListener
()
{
final
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
((
SunGraphicsEnvironment
)
ge
).
addDisplayChangedListener
(
this
);
}
private
void
deactivateDisplayListener
()
{
final
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
((
SunGraphicsEnvironment
)
ge
).
removeDisplayChangedListener
(
this
);
}
private
void
postWindowStateChangedEvent
(
int
newWindowState
)
{
if
(
getTarget
()
instanceof
Frame
)
{
AWTAccessor
.
getFrameAccessor
().
setExtendedState
(
...
...
@@ -936,7 +950,6 @@ public class LWWindowPeer
graphicsDevice
=
newGraphicsDevice
;
}
// TODO: DisplayChangedListener stuff
final
GraphicsConfiguration
newGC
=
newGraphicsDevice
.
getDefaultConfiguration
();
if
(!
setGraphicsConfig
(
newGC
))
return
false
;
...
...
@@ -949,6 +962,20 @@ public class LWWindowPeer
return
true
;
}
@Override
public
final
void
displayChanged
()
{
updateGraphicsDevice
();
// Replace surface unconditionally, because internal state of the
// GraphicsDevice could be changed.
replaceSurfaceData
();
repaintPeer
();
}
@Override
public
final
void
paletteChanged
()
{
// components do not need to react to this event.
}
/*
* May be called by delegate to provide SD to Java2D code.
*/
...
...
src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
浏览文件 @
442c804d
...
...
@@ -32,6 +32,7 @@ import java.awt.peer.WindowPeer;
import
java.beans.*
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.List
;
import
java.util.Objects
;
import
javax.swing.*
;
...
...
@@ -916,9 +917,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
final
Rectangle
oldB
=
nativeBounds
;
nativeBounds
=
new
Rectangle
(
x
,
y
,
width
,
height
);
final
GraphicsConfiguration
oldGC
=
peer
.
getGraphicsConfiguration
();
peer
.
notifyReshape
(
x
,
y
,
width
,
height
);
final
GraphicsConfiguration
newGC
=
peer
.
getGraphicsConfiguration
();
// System-dependent appearance optimization.
if
((
byUser
&&
!
oldB
.
getSize
().
equals
(
nativeBounds
.
getSize
()))
||
isFullScreenAnimationOn
)
{
||
isFullScreenAnimationOn
||
!
Objects
.
equals
(
newGC
,
oldGC
)
)
{
flushBuffers
();
}
}
...
...
src/macosx/native/sun/awt/CGraphicsEnv.m
浏览文件 @
442c804d
...
...
@@ -124,10 +124,11 @@ static void displaycb_handle
jobject graphicsEnv = [wrapper jObjectWithEnv:env];
if (graphicsEnv == NULL) return; // ref already GC'd
static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(J)V");
JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration);
static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(IZ)V");
JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
(jint) display,
(jboolean) flags & kCGDisplayRemoveFlag);
});
}
...
...
src/macosx/native/sun/java2d/opengl/CGLLayer.m
浏览文件 @
442c804d
...
...
@@ -216,7 +216,11 @@ Java_sun_java2d_opengl_CGLLayer_nativeSetScale
{
JNF_COCOA_ENTER
(
env
);
CGLLayer
*
layer
=
jlong_to_ptr
(
layerPtr
);
[
ThreadUtilities
performOnMainThreadWaiting
:
NO
block
:
^
(){
// We always call all setXX methods asynchronously, exception is only in
// this method where we need to change native texture size and layer's scale
// in one call on appkit, otherwise we'll get window's contents blinking,
// during screen-2-screen moving.
[
ThreadUtilities
performOnMainThreadWaiting
:[
NSThread
isMainThread
]
block
:
^
(){
layer
.
contentsScale
=
scale
;
}];
JNF_COCOA_EXIT
(
env
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录