changeset 7095:0e6a232fa8c4

RT-36541: [Glass, Mac] Extremely poor performance with ColorfulCirclesApp on Early 2013 retina MacBook Pro Reviewed-by: anthony, snorthov
author pchelko
date Wed, 21 May 2014 13:32:07 +0400
parents 92f153791fa4
children 173e83b68f7e
files modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java modules/graphics/src/main/native-glass/mac/GlassApplication.h modules/graphics/src/main/native-glass/mac/GlassApplication.m modules/graphics/src/main/native-glass/mac/GlassFrameBufferObject.m
diffstat 4 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java	Wed May 21 09:33:01 2014 +0200
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacApplication.java	Wed May 21 13:32:07 2014 +0400
@@ -44,13 +44,16 @@
 
 final class MacApplication extends Application implements InvokeLaterDispatcher.InvokeLaterSubmitter {
 
-    private native static void _initIDs();
+    private native static void _initIDs(boolean disableSyncRendering);
     static {
         AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
             Application.loadNativeLibrary();
             return null;
         });
-        _initIDs();
+        boolean disableSyncRendering = AccessController
+                .doPrivileged((PrivilegedAction<Boolean>) () ->
+                        Boolean.getBoolean("glass.disableSyncRendering"));
+        _initIDs(disableSyncRendering);
     }
 
     native static int _getMacKey(int code);
--- a/modules/graphics/src/main/native-glass/mac/GlassApplication.h	Wed May 21 09:33:01 2014 +0200
+++ b/modules/graphics/src/main/native-glass/mac/GlassApplication.h	Wed May 21 13:32:07 2014 +0400
@@ -53,4 +53,6 @@
 + (void)registerKeyEvent:(NSEvent*)event;
 + (jint)getKeyCodeForChar:(jchar)c;
 
++ (BOOL)syncRenderingDisabled;
+
 @end
--- a/modules/graphics/src/main/native-glass/mac/GlassApplication.m	Wed May 21 09:33:01 2014 +0200
+++ b/modules/graphics/src/main/native-glass/mac/GlassApplication.m	Wed May 21 13:32:07 2014 +0400
@@ -54,7 +54,7 @@
 static BOOL isFullScreenExitingLoop = NO;
 static NSMutableDictionary * keyCodeForCharMap = nil;
 static BOOL isEmbedded = NO;
-
+static BOOL disableSyncRendering = NO;
 
 jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
 {
@@ -709,6 +709,10 @@
     }
 }
 
++ (BOOL)syncRenderingDisabled {
+    return disableSyncRendering;
+}
+
 @end
 
 #pragma mark --- JNI
@@ -719,10 +723,12 @@
  * Signature: ()V
  */
 JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacApplication__1initIDs
-(JNIEnv *env, jclass jClass)
+(JNIEnv *env, jclass jClass, jboolean jDisableSyncRendering)
 {
     LOG("Java_com_sun_glass_ui_mac_MacApplication__1initIDs");
 
+    disableSyncRendering = jDisableSyncRendering ? YES : NO;
+   
     jApplicationClass = (*env)->NewGlobalRef(env, jClass);
 
     javaIDs.Application.createPixels = (*env)->GetStaticMethodID(
--- a/modules/graphics/src/main/native-glass/mac/GlassFrameBufferObject.m	Wed May 21 09:33:01 2014 +0200
+++ b/modules/graphics/src/main/native-glass/mac/GlassFrameBufferObject.m	Wed May 21 13:32:07 2014 +0400
@@ -25,6 +25,7 @@
 
 #import "GlassFrameBufferObject.h"
 #import "GlassMacros.h"
+#import "GlassApplication.h"
 
 #import <OpenGL/glu.h>
 
@@ -260,7 +261,9 @@
             fprintf(stderr, "ERROR: unexpected fbo is bound! Expected %d, but found %d\n", self->_fbo, framebufferCurrent);
         }
 #endif
-        
+        if (![GlassApplication syncRenderingDisabled]) {         
+            glFinish();
+        }
         GLuint framebufferToRevertTo = self->_fboToRestore;
         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferToRevertTo);
         LOG("               restored to FBO: %d", framebufferToRevertTo);