changeset 9849:b1b7cc164a69

8038765: [macosx] Toolkit.sync should be implemented Reviewed-by: pchelko, anthony
author serb
date Wed, 09 Apr 2014 14:38:27 +0400
parents d8fd8c0c5ef8
children b35c7f58d9a1
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	Tue Apr 08 14:02:30 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;
@@ -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/src/macosx/native/sun/awt/LWCToolkit.m	Tue Apr 08 14:02:30 2014 +0400
+++ b/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;");