[cogl/wip/rib/frame-synchronization: 27/32] Adds cogl_swap_info_get_refresh_interval api back



commit 77ca4ae58a436ab929f4b8fc12948b44843c539a
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jan 9 19:54:41 2013 +0000

    Adds cogl_swap_info_get_refresh_interval api back
    
    After a discussion on IRC we discussed the fact that some window systems
    won't allow us to associate a CoglOutput with a CoglSwapInfo object but
    they can report a refresh_interval. This justifies being able to query
    the refresh_interval without needing to use
    cogl_output_get_refresh_rate().
    
    XXX: One remaining issue here though is why can't we be more consistent
    and return a _refresh_rate() instead of a _refresh_interval().
    
    TODO: squash this back into owen's patch

 cogl/cogl-swap-info-private.h |    1 +
 cogl/cogl-swap-info.c         |    6 ++++++
 cogl/cogl-swap-info.h         |   20 ++++++++++++++++++++
 cogl/winsys/cogl-winsys-glx.c |   16 ++++++++++++++++
 4 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-swap-info-private.h b/cogl/cogl-swap-info-private.h
index 61953fa..2e67fb0 100644
--- a/cogl/cogl-swap-info-private.h
+++ b/cogl/cogl-swap-info-private.h
@@ -34,6 +34,7 @@ struct _CoglSwapInfo
 
   int64_t frame_counter;
   int64_t presentation_time;
+  int64_t refresh_interval;
 
   CoglOutput *output;
 };
diff --git a/cogl/cogl-swap-info.c b/cogl/cogl-swap-info.c
index e8f83bd..dfb0c13 100644
--- a/cogl/cogl-swap-info.c
+++ b/cogl/cogl-swap-info.c
@@ -59,6 +59,12 @@ cogl_swap_info_get_presentation_time (CoglSwapInfo *info)
   return info->presentation_time;
 }
 
+int64_t
+cogl_swap_info_get_refresh_interval (CoglSwapInfo *info)
+{
+  return info->refresh_interval;
+}
+
 CoglOutput *
 cogl_swap_info_get_output (CoglSwapInfo *info)
 {
diff --git a/cogl/cogl-swap-info.h b/cogl/cogl-swap-info.h
index 62728b6..699c845 100644
--- a/cogl/cogl-swap-info.h
+++ b/cogl/cogl-swap-info.h
@@ -82,6 +82,26 @@ int64_t cogl_swap_info_get_frame_counter (CoglSwapInfo *info);
 int64_t cogl_swap_info_get_presentation_time (CoglSwapInfo *info);
 
 /**
+ * cogl_swap_info_get_refresh_interval:
+ * @info: a #CoglSwapInfo object
+ *
+ * Gets the refresh interval for the output that the frame was on at the
+ * time the frame was presented. This is the number of microseconds between
+ * refreshes of the screen, and is equal to 1000000 / refresh_rate.
+ *
+ * <note>Some platforms can't associate a #CoglOutput with a
+ * #CoglSwapInfo object but are able to report a refresh_interval via
+ * this api. Therefore if you need this information then this api is
+ * more reliable than using cogl_swap_info_get_output() followed by
+ * cogl_output_get_refresh_rate().</note>
+ *
+ * Return value: the refresh interval, in microsecoonds.
+ * Since: 2.0
+ * Stability: unstable
+ */
+int64_t cogl_swap_info_get_refresh_interval (CoglSwapInfo *info);
+
+/**
  * cogl_swap_info_get_output:
  * @info: a #CoglSwapInfo object
  *
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index c8878a5..dd88b8f 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -1405,6 +1405,19 @@ _cogl_winsys_get_vsync_counter (void)
 }
 
 static void
+set_refresh_interval_from_output (CoglOnscreen *onscreen,
+                                  CoglOutput *output)
+{
+#warning "XXX: why not be consistent and also report a refresh_rate for the SwapInfo?"
+  float refresh_rate = cogl_output_get_refresh_rate (output);
+  if (refresh_rate != 0.0)
+    {
+      CoglSwapInfo *info = g_queue_peek_tail (&onscreen->pending_swap_infos);
+      info->refresh_interval = (int)(0.5 + (1000000. / refresh_rate));
+    }
+}
+
+static void
 _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
                                    const int *user_rectangles,
                                    int n_rectangles)
@@ -1603,6 +1616,9 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
                                                   xlib_onscreen->y + y_min,
                                                   x_max - x_min,
                                                   y_max - y_min);
+
+      if (info->output)
+        set_refresh_interval_from_output (onscreen, info->output);
     }
 }
 



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