[cogl/cogl-1.14] cogl-crate: use new _add_frame_callback api



commit d12f39d0e6f9a1f592e556ad805cf71c376b059c
Author: Robert Bragg <robert linux intel com>
Date:   Tue Jan 29 16:22:15 2013 +0000

    cogl-crate: use new _add_frame_callback api
    
    This updates cogl-crate to use the new
    cogl_onscreen_add_frame_callback() api to use _SYNC events for
    throttling.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    
    (cherry picked from commit 47ea52774025b620258e00a32cb873674d0fc721)

 examples/cogl-crate.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index c23daed..0c6bc1f 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -130,12 +130,15 @@ paint (Data *data)
 }
 
 static void
-swap_notify_cb (CoglFramebuffer *framebuffer,
+frame_event_cb (CoglOnscreen *onscreen,
+                CoglFrameEvent event,
+                CoglFrameInfo *info,
                 void *user_data)
 {
   Data *data = user_data;
 
-  data->swap_ready = TRUE;
+  if (event == COGL_FRAME_EVENT_SYNC)
+    data->swap_ready = TRUE;
 }
 
 int
@@ -149,7 +152,6 @@ main (int argc, char **argv)
   PangoRectangle hello_label_size;
   float fovy, aspect, z_near, z_2d, z_far;
   CoglDepthState depth_state;
-  CoglBool has_swap_notify;
 
   ctx = cogl_context_new (NULL, &error);
   if (!ctx) {
@@ -267,13 +269,10 @@ main (int argc, char **argv)
 
   data.swap_ready = TRUE;
 
-  has_swap_notify =
-    cogl_has_feature (ctx, COGL_FEATURE_ID_SWAP_BUFFERS_EVENT);
-
-  if (has_swap_notify)
-    cogl_onscreen_add_swap_buffers_callback (COGL_ONSCREEN (fb),
-                                             swap_notify_cb,
-                                             &data);
+  cogl_onscreen_add_frame_callback (COGL_ONSCREEN (fb),
+                                    frame_event_cb,
+                                    &data,
+                                    NULL); /* destroy notify */
 
   while (1)
     {
@@ -289,14 +288,6 @@ main (int argc, char **argv)
 
       cogl_poll_get_info (ctx, &poll_fds, &n_poll_fds, &timeout);
 
-      if (!has_swap_notify)
-        {
-          /* If the winsys doesn't support swap event notification
-             then we'll just redraw constantly */
-          data.swap_ready = TRUE;
-          timeout = 0;
-        }
-
       g_poll ((GPollFD *) poll_fds, n_poll_fds,
               timeout == -1 ? -1 : timeout / 1000);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]