8038765: [macosx] Toolkit.sync should be implemented
authorserb
Wed, 09 Apr 2014 14:38:27 +0400
changeset 24169 4efa892f600b
parent 24168 033f79a3fb44
child 24170 8db250c6c7e8
8038765: [macosx] Toolkit.sync should be implemented Reviewed-by: pchelko, anthony
jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
jdk/src/macosx/native/sun/awt/LWCToolkit.m
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Tue Apr 08 14:02:30 2014 +0400
+++ b/jdk/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;
@@ -410,7 +411,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
@@ -809,6 +814,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/jdk/src/macosx/native/sun/awt/LWCToolkit.m	Tue Apr 08 14:02:30 2014 +0400
+++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m	Wed Apr 09 14:38:27 2014 +0400
@@ -144,6 +144,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;");