changeset 9563:bf44dd06cd4e

8038765: [macosx] Toolkit.sync should be implemented Reviewed-by: pchelko, anthony
author serb
date Wed, 09 Apr 2014 14:38:27 +0400
parents beb3731f19b6
children 039af1f9be91
files src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java src/macosx/native/sun/awt/LWCToolkit.m
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Mon Apr 07 15:34:27 2014 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Wed Apr 09 14:38:27 2014 +0400
@@ -44,6 +44,7 @@
 
 import sun.awt.*;
 import sun.awt.datatransfer.DataTransferer;
+import sun.java2d.opengl.OGLRenderQueue;
 import sun.lwawt.*;
 import sun.lwawt.LWWindowPeer.PeerType;
 import sun.security.action.GetBooleanAction;
@@ -409,7 +410,11 @@
 
     @Override
     public void sync() {
-        // TODO Auto-generated method stub
+        // flush the OGL pipeline (this is a no-op if OGL is not enabled)
+        OGLRenderQueue.sync();
+        // setNeedsDisplay() selector was sent to the appropriate CALayer so now
+        // we have to flush the native selectors queue.
+        flushNativeSelectors();
     }
 
     @Override
@@ -799,6 +804,11 @@
 
     private native boolean nativeSyncQueue(long timeout);
 
+    /**
+     * Just spin a single empty block synchronously.
+     */
+    private static native void flushNativeSelectors();
+
     @Override
     public Clipboard createPlatformClipboard() {
         return new CClipboard("System");
--- a/src/macosx/native/sun/awt/LWCToolkit.m	Mon Apr 07 15:34:27 2014 +0400
+++ b/src/macosx/native/sun/awt/LWCToolkit.m	Wed Apr 09 14:38:27 2014 +0400
@@ -111,6 +111,18 @@
     return JNI_FALSE;
 }
 
+/*
+ * Class:     sun_lwawt_macosx_LWCToolkit
+ * Method:    flushNativeSelectors
+ * Signature: ()J
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_flushNativeSelectors
+(JNIEnv *env, jclass clz)
+{
+JNF_COCOA_ENTER(env);
+        [ThreadUtilities performOnMainThreadWaiting:YES block:^(){}];
+JNF_COCOA_EXIT(env);
+}
 
 static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
 static JNF_MEMBER_CACHE(jf_Component_appContext, jc_Component, "appContext", "Lsun/awt/AppContext;");