提交 7ace10d5 编写于 作者: S serb

8008660: Failure in 2D Queue Flusher thread on Mac

Reviewed-by: swingler, bae
上级 2ab5ca35
......@@ -53,7 +53,7 @@ public abstract class CGraphicsConfig extends GraphicsConfiguration
@Override
public Rectangle getBounds() {
final Rectangle2D nativeBounds = nativeGetBounds(device.getCoreGraphicsScreen());
final Rectangle2D nativeBounds = nativeGetBounds(device.getCGDisplayID());
return nativeBounds.getBounds(); // does integer rounding
}
......
......@@ -25,11 +25,11 @@
package sun.awt;
import java.awt.AWTPermission;
import java.awt.DisplayMode;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Window;
import java.awt.AWTPermission;
import java.awt.DisplayMode;
import java.util.Objects;
import sun.java2d.opengl.CGLGraphicsConfig;
......@@ -58,9 +58,12 @@ public final class CGraphicsDevice extends GraphicsDevice {
}
/**
* Returns CGDirectDisplayID, which is the same id as @"NSScreenNumber" in
* NSScreen.
*
* @return CoreGraphics display id.
*/
public int getCoreGraphicsScreen() {
public int getCGDisplayID() {
return displayID;
}
......
......@@ -80,10 +80,8 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
private ContextCapabilities oglCaps;
private OGLContext context;
private final Object disposerReferent = new Object();
public static native int getDefaultPixFmt(int screennum);
private static native boolean initCGL();
private static native long getCGLConfigInfo(int screennum, int visualnum,
private static native long getCGLConfigInfo(int displayID, int visualnum,
int swapInterval);
private static native int getOGLCapabilities(long configInfo);
......@@ -137,15 +135,16 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
// Java-level context and flush the queue...
OGLContext.invalidateCurrentContext();
cfginfo = getCGLConfigInfo(device.getCoreGraphicsScreen(), pixfmt,
cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
kOpenGLSwapInterval);
OGLContext.setScratchSurface(cfginfo);
rq.flushAndInvokeNow(new Runnable() {
public void run() {
ids[0] = OGLContext.getOGLIdString();
}
});
if (cfginfo != 0L) {
OGLContext.setScratchSurface(cfginfo);
rq.flushAndInvokeNow(new Runnable() {
public void run() {
ids[0] = OGLContext.getOGLIdString();
}
});
}
} finally {
rq.unlock();
}
......@@ -253,8 +252,8 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
@Override
public String toString() {
int screen = getDevice().getCoreGraphicsScreen();
return ("CGLGraphicsConfig[dev="+screen+",pixfmt="+pixfmt+"]");
int displayID = getDevice().getCGDisplayID();
return ("CGLGraphicsConfig[dev="+displayID+",pixfmt="+pixfmt+"]");
}
@Override
......@@ -413,8 +412,8 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
@Override
public void addDeviceEventListener(AccelDeviceEventListener l) {
int screen = getDevice().getCoreGraphicsScreen();
AccelDeviceEventNotifier.addListener(l, screen);
int displayID = getDevice().getCGDisplayID();
AccelDeviceEventNotifier.addListener(l, displayID);
}
@Override
......
......@@ -65,7 +65,7 @@ class CRobot implements RobotPeer {
mouseLastX = x;
mouseLastY = y;
mouseEvent(fDevice.getCoreGraphicsScreen(), mouseLastX, mouseLastY,
mouseEvent(fDevice.getCGDisplayID(), mouseLastX, mouseLastY,
mouseButtonsState, true, true);
}
......@@ -79,7 +79,7 @@ class CRobot implements RobotPeer {
public void mousePress(int buttons) {
mouseButtonsState |= buttons;
mouseEvent(fDevice.getCoreGraphicsScreen(), mouseLastX, mouseLastY,
mouseEvent(fDevice.getCGDisplayID(), mouseLastX, mouseLastY,
buttons, true, false);
}
......@@ -93,7 +93,7 @@ class CRobot implements RobotPeer {
public void mouseRelease(int buttons) {
mouseButtonsState &= ~buttons;
mouseEvent(fDevice.getCoreGraphicsScreen(), mouseLastX, mouseLastY,
mouseEvent(fDevice.getCGDisplayID(), mouseLastX, mouseLastY,
buttons, false, false);
}
......@@ -163,7 +163,7 @@ class CRobot implements RobotPeer {
}
private native void initRobot();
private native void mouseEvent(int screen, int lastX, int lastY,
private native void mouseEvent(int displayID, int lastX, int lastY,
int buttonsState,
boolean isButtonsDownState,
boolean isMouseMove);
......
......@@ -352,7 +352,7 @@ public final class LWCToolkit extends LWToolkit {
@Override
public Insets getScreenInsets(final GraphicsConfiguration gc) {
final CGraphicsConfig cgc = (CGraphicsConfig) gc;
final int displayId = cgc.getDevice().getCoreGraphicsScreen();
final int displayId = cgc.getDevice().getCGDisplayID();
Rectangle fullScreen, workArea;
final long screen = CWrapper.NSScreen.screenByDisplayId(displayId);
try {
......
......@@ -135,7 +135,7 @@ Java_sun_lwawt_macosx_CRobot_initRobot
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CRobot_mouseEvent
(JNIEnv *env, jobject peer,
jint screenIndex, jint mouseLastX, jint mouseLastY, jint buttonsState,
jint displayID, jint mouseLastX, jint mouseLastY, jint buttonsState,
jboolean isButtonsDownState, jboolean isMouseMove)
{
JNF_COCOA_ENTER(env);
......@@ -149,8 +149,6 @@ Java_sun_lwawt_macosx_CRobot_mouseEvent
CGError err = kCGErrorSuccess;
CGDirectDisplayID displayID =
FindCGDirectDisplayIDForScreenIndex(screenIndex);
CGRect globalDeviceBounds = CGDisplayBounds(displayID);
// Set unknown mouse location, if needed.
......
......@@ -44,8 +44,6 @@ extern jint* gButtonDownMasks;
+ (void) eventCountPlusPlus;
@end
CGDirectDisplayID FindCGDirectDisplayIDForScreenIndex(jint screenIndex);
/*
* Utility Macros
*/
......
......@@ -177,39 +177,6 @@ Java_sun_lwawt_macosx_LWCToolkit_beep
NSBeep(); // produces both sound and visual flash, if configured in System Preferences
}
CGDirectDisplayID
FindCGDirectDisplayIDForScreenIndex(jint screenIndex)
{
// most common case - just one monitor
CGDirectDisplayID screenID = CGMainDisplayID();
CGDisplayCount displayCount = 0;
CGGetOnlineDisplayList(0, NULL, &displayCount);
if ((displayCount > 1) &&
(screenIndex >= 0) &&
(screenIndex < (jint)displayCount))
{
if (displayCount < 10) {
// stack allocated optimization for less than 10 monitors
CGDirectDisplayID onlineDisplays[displayCount];
CGGetOnlineDisplayList(displayCount, onlineDisplays, &displayCount);
screenID = (CGDirectDisplayID)onlineDisplays[screenIndex];
} else {
CGDirectDisplayID *onlineDisplays =
malloc(displayCount*sizeof(CGDirectDisplayID));
if (onlineDisplays != NULL) {
CGGetOnlineDisplayList(displayCount, onlineDisplays,
&displayCount);
screenID = (CGDirectDisplayID)onlineDisplays[screenIndex];
free(onlineDisplays);
}
}
}
return screenID;
}
/*
* Class: sun_lwawt_macosx_LWCToolkit
* Method: initIDs
......
......@@ -192,12 +192,12 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_initCGL
JNIEXPORT jlong JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
(JNIEnv *env, jclass cglgc,
jint screennum, jint pixfmt, jint swapInterval)
jint displayID, jint pixfmt, jint swapInterval)
{
jlong ret = 0L;
JNF_COCOA_ENTER(env);
NSMutableArray * retArray = [NSMutableArray arrayWithCapacity:3];
[retArray addObject: [NSNumber numberWithInt: (int)screennum]];
[retArray addObject: [NSNumber numberWithInt: (int)displayID]];
[retArray addObject: [NSNumber numberWithInt: (int)pixfmt]];
[retArray addObject: [NSNumber numberWithInt: (int)swapInterval]];
if ([NSThread isMainThread]) {
......@@ -217,7 +217,7 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
+ (void) _getCGLConfigInfo: (NSMutableArray *)argValue {
AWT_ASSERT_APPKIT_THREAD;
jint screennum = (jint)[(NSNumber *)[argValue objectAtIndex: 0] intValue];
jint displayID = (jint)[(NSNumber *)[argValue objectAtIndex: 0] intValue];
jint pixfmt = (jint)[(NSNumber *)[argValue objectAtIndex: 1] intValue];
jint swapInterval = (jint)[(NSNumber *)[argValue objectAtIndex: 2] intValue];
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
......@@ -230,16 +230,11 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
CGOpenGLDisplayMask glMask = (CGOpenGLDisplayMask)pixfmt;
if (sharedContext == NULL) {
if (glMask == 0) {
CGDirectDisplayID id =
FindCGDirectDisplayIDForScreenIndex(screennum);
glMask = CGDisplayIDToOpenGLDisplayMask(id);
glMask = CGDisplayIDToOpenGLDisplayMask(displayID);
}
NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFAClosestPolicy,
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFAFullScreen,
NSOpenGLPFAWindow,
NSOpenGLPFAPixelBuffer,
NSOpenGLPFADoubleBuffer,
......@@ -412,7 +407,7 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
return;
}
memset(cglinfo, 0, sizeof(CGLGraphicsConfigInfo));
cglinfo->screen = screennum;
cglinfo->screen = displayID;
cglinfo->pixfmt = sharedPixelFormat;
cglinfo->context = oglc;
......@@ -422,17 +417,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
}
@end //GraphicsConfigUtil
JNIEXPORT jint JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getDefaultPixFmt
(JNIEnv *env, jclass cglgc, jint screennum)
{
J2dTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getDefaultPixFmt");
CGDirectDisplayID id = FindCGDirectDisplayIDForScreenIndex(screennum);
return (jint)CGDisplayIDToOpenGLDisplayMask(id);
}
JNIEXPORT jint JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getOGLCapabilities
(JNIEnv *env, jclass cglgc, jlong configInfo)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册