[Cogl] [PATCH] cogl-gles2-gears: use new _add_frame_callback api

Robert Bragg robert at sixbynine.org
Thu Jan 31 06:47:19 PST 2013


From: Robert Bragg <robert at linux.intel.com>

This updates cogl-gles2-gears to use the new
cogl_onscreen_add_frame_callback() api to use _SYNC events for
throttling.
---
 examples/cogl-gles2-gears.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/examples/cogl-gles2-gears.c b/examples/cogl-gles2-gears.c
index e69447c..ad795b0 100644
--- a/examples/cogl-gles2-gears.c
+++ b/examples/cogl-gles2-gears.c
@@ -595,19 +595,16 @@ paint_cb (void *user_data)
     }else
       data->last_elapsed = elapsed;
 
-    /* If the driver can deliver swap complete events then we can remove
-     * the idle paint callback until we next get a swap complete event
-     * otherwise we keep the idle paint callback installed and simply
-     * paint as fast as the driver will allow... */
-    if (cogl_has_feature (data->ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT))
-      return FALSE; /* remove the callback */
-    else
-      return TRUE;
+    return FALSE; /* remove the callback */
 }
 
 static void
-swap_complete_cb (CoglFramebuffer *framebuffer, void *user_data)
+frame_event_cb (CoglOnscreen *onscreen,
+                CoglFrameEvent event,
+                CoglFrameInfo *info,
+                void *user_data)
 {
+  if (event == COGL_FRAME_EVENT_SYNC)
     g_idle_add (paint_cb, user_data);
 }
 
@@ -797,9 +794,10 @@ main (int argc, char **argv)
 
     g_source_attach (cogl_source, NULL);
 
-    if (cogl_has_feature (data.ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT))
-        cogl_onscreen_add_swap_buffers_callback (COGL_ONSCREEN (data.fb),
-                                                 swap_complete_cb, &data);
+    cogl_onscreen_add_frame_callback (COGL_ONSCREEN (data.fb),
+                                      frame_event_cb,
+                                      &data,
+                                      NULL); /* destroy notify */
 
     g_idle_add (paint_cb, &data);
 
-- 
1.8.1.1



More information about the Cogl mailing list