OpenJDK / bsd-port / jdk8 / jdk
changeset 11398:fabe06a4800a
8041900: [macosx] Java forces the use of discrete GPU
Reviewed-by: ssadetsky, alexsch
author | serb |
---|---|
date | Wed, 21 Oct 2015 21:28:59 +0300 |
parents | 6bf37c9c0871 |
children | 5c1d06cd7d7b |
files | src/macosx/native/sun/awt/CGraphicsEnv.m src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m |
diffstat | 2 files changed, 15 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/CGraphicsEnv.m Wed Oct 21 18:32:56 2015 +0300 +++ b/src/macosx/native/sun/awt/CGraphicsEnv.m Wed Oct 21 21:28:59 2015 +0300 @@ -26,6 +26,7 @@ #import <JavaNativeFoundation/JavaNativeFoundation.h> #import "jni_util.h" +#import "ThreadUtilities.h" #import "LWCToolkit.h" #import "AWT_debug.h" @@ -133,17 +134,20 @@ { 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); + }); + }]; } /*
--- a/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m Wed Oct 21 18:32:56 2015 +0300 +++ b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m Wed Oct 21 21:28:59 2015 +0300 @@ -236,6 +236,7 @@ } NSOpenGLPixelFormatAttribute attrs[] = { + NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFAClosestPolicy, NSOpenGLPFAWindow, NSOpenGLPFAPixelBuffer,