[maemo-commits] [maemo-commits] r19187 - projects/haf/branches/clutter/clutter-ioctl-vsync/clutter/eglx

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Aug 24 17:02:05 EEST 2009
Author: gw
Date: 2009-08-24 17:01:59 +0300 (Mon, 24 Aug 2009)
New Revision: 19187

Modified:
   projects/haf/branches/clutter/clutter-ioctl-vsync/clutter/eglx/clutter-backend-egl.c
Log:
vsync changes


Modified: projects/haf/branches/clutter/clutter-ioctl-vsync/clutter/eglx/clutter-backend-egl.c
===================================================================
--- projects/haf/branches/clutter/clutter-ioctl-vsync/clutter/eglx/clutter-backend-egl.c	2009-08-24 13:57:28 UTC (rev 19186)
+++ projects/haf/branches/clutter/clutter-ioctl-vsync/clutter/eglx/clutter-backend-egl.c	2009-08-24 14:01:59 UTC (rev 19187)
@@ -9,6 +9,15 @@
 #include "../clutter-debug.h"
 #include "../clutter-version.h"
 
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/fb.h>
+
+
+#ifndef OMAPFB_WAITFORVSYNC
+#define OMAPFB_WAITFORVSYNC _IO('O', 57)
+#endif
+
 static ClutterBackendEGL *backend_singleton = NULL;
 
 G_DEFINE_TYPE (ClutterBackendEGL, clutter_backend_egl, CLUTTER_TYPE_BACKEND_X11);
@@ -145,6 +154,21 @@
   */
   if (stage_x11->xwin)
     {
+      /* wait for vsync before calling SwapBuffers. TODO: This should
+       * most likely be handled by eglSwapBuffers, as doing it here does
+       * not guarantee that we will blit in time. Especially as the SGX
+       * may still have things in its buffer to render.
+       */
+      int fb = open("/dev/fb0", 0);
+      if (fb >= 0)
+        {
+          glFinish();
+          if (ioctl(fb, OMAPFB_WAITFORVSYNC, 0))
+            {
+              // fail?
+            }
+          close(fb);
+        }
       /* clutter_feature_wait_for_vblank (); */
       eglSwapBuffers (backend_egl->edpy,  stage_egl->egl_surface);
     }

More information about the maemo-commits mailing list