8041900: [macosx] Java forces the use of discrete GPU
Reviewed-by: ssadetsky, alexsch
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m Wed Oct 21 09:21:25 2015 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m Wed Oct 21 21:28:59 2015 +0300
@@ -26,6 +26,7 @@
#import "AWT_debug.h"
#import "jni_util.h"
+#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
@@ -114,17 +115,20 @@
{
if (flags == kCGDisplayBeginConfigurationFlag) return;
- JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) {
- JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo;
+ [ThreadUtilities performOnMainThreadWaiting:NO block:^() {
+
+ JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) {
+ JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo;
- 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", "(IZ)V");
- JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
- (jint) display,
- (jboolean) flags & kCGDisplayRemoveFlag);
- });
+ 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","(IZ)V");
+ JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
+ (jint) display, (jboolean) flags & kCGDisplayRemoveFlag);
+ });
+ }];
}
/*
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m Wed Oct 21 09:21:25 2015 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m Wed Oct 21 21:28:59 2015 +0300
@@ -233,6 +233,7 @@
}
NSOpenGLPixelFormatAttribute attrs[] = {
+ NSOpenGLPFAAllowOfflineRenderers,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAWindow,
NSOpenGLPFAPixelBuffer,