7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
Reviewed-by: bae, kizune
--- a/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java Tue Jul 17 12:59:57 2012 +0400
+++ b/jdk/src/macosx/classes/sun/awt/CGraphicsDevice.java Wed Jul 18 18:25:49 2012 +0400
@@ -48,6 +48,9 @@
private static AWTPermission fullScreenExclusivePermission;
+ // Save/restore DisplayMode for the Full Screen mode
+ private DisplayMode originalMode;
+
public CGraphicsDevice(int displayID) {
this.displayID = displayID;
configs = new GraphicsConfiguration[] {
@@ -124,18 +127,22 @@
}
boolean fsSupported = isFullScreenSupported();
+
if (fsSupported && old != null) {
// enter windowed mode (and restore original display mode)
exitFullScreenExclusive(old);
-
- // TODO: restore display mode
+ if (originalMode != null) {
+ setDisplayMode(originalMode);
+ originalMode = null;
+ }
}
super.setFullScreenWindow(w);
if (fsSupported && w != null) {
- // TODO: save current display mode
-
+ if (isDisplayChangeSupported()) {
+ originalMode = getDisplayMode();
+ }
// enter fullscreen mode
enterFullScreenExclusive(w);
}
--- a/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m Tue Jul 17 12:59:57 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CGraphicsDevice.m Wed Jul 18 18:25:49 2012 +0400
@@ -28,7 +28,7 @@
/*
* Convert the mode string to the more convinient bits per pixel value
*/
-static int getBPPFromModeString(CFStringRef mode)
+static int getBPPFromModeString(CFStringRef mode)
{
if ((CFStringCompare(mode, CFSTR(kIO30BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) {
// This is a strange mode, where we using 10 bits per RGB component and pack it into 32 bits
@@ -44,7 +44,7 @@
else if (CFStringCompare(mode, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
return 8;
}
-
+
return 0;
}
@@ -68,6 +68,11 @@
// One of the key parameters does not match
continue;
}
+
+ if (refrate == 0) { // REFRESH_RATE_UNKNOWN
+ return cRef;
+ }
+
// Refresh rate might be 0 in display mode and we ask for specific display rate
// but if we do not find exact match then 0 refresh rate might be just Ok
if (CGDisplayModeGetRefreshRate(cRef) == refrate) {
@@ -165,7 +170,10 @@
}
}
}];
+ } else {
+ [JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"];
}
+
CFRelease(allModes);
JNF_COCOA_EXIT(env);
}