8041900: [macosx] Java forces the use of discrete GPU

Reviewed-by: ssadetsky, alexsch
This commit is contained in:
Sergey Bylokhov 2015-10-21 21:28:59 +03:00
parent 5c26723516
commit 9a97133265
2 changed files with 15 additions and 10 deletions

View File

@ -26,6 +26,7 @@
#import "AWT_debug.h"
#import "jni_util.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
@ -114,17 +115,20 @@ static void displaycb_handle
{
if (flags == kCGDisplayBeginConfigurationFlag) return;
JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) {
JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo;
[ThreadUtilities performOnMainThreadWaiting:NO block:^() {
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);
});
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);
});
}];
}
/*

View File

@ -233,6 +233,7 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
}
NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFAAllowOfflineRenderers,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAWindow,
NSOpenGLPFAPixelBuffer,