[Cogl] [PATCH] frame-info: s/_refresh_interval/_refresh_rate/

Robert Bragg robert at sixbynine.org
Tue Jan 15 09:35:23 PST 2013


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

Something I'd meant to comment on before is that
cogl_frame_info_get_refresh_interval() seems inconsistent with
cogl_output_get_refresh_rate(). I think it might be nicer if we could
query a refresh rate from a CoglFrameInfo instead of a refresh interval.

kind regards,
- Robert

-- >8 --

For consistency this reworks the cogl_frame_info_get_refresh_interval
api to instead be cogl_frame_info_get_refresh_rate() and return a
frequency in Hertz instead of an interval in milliseconds. This is
consistent with cogl_output_get_refresh_rate().
---
 cogl/cogl-frame-info-private.h |    2 +-
 cogl/cogl-frame-info.c         |    4 ++--
 cogl/cogl-frame-info.h         |   11 +++++------
 cogl/winsys/cogl-winsys-glx.c  |    9 ++++-----
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/cogl/cogl-frame-info-private.h b/cogl/cogl-frame-info-private.h
index 5d8ac13..e9bf1f4 100644
--- a/cogl/cogl-frame-info-private.h
+++ b/cogl/cogl-frame-info-private.h
@@ -34,7 +34,7 @@ struct _CoglFrameInfo
 
   int64_t frame_counter;
   int64_t presentation_time;
-  int64_t refresh_interval;
+  float refresh_rate;
 
   CoglOutput *output;
 };
diff --git a/cogl/cogl-frame-info.c b/cogl/cogl-frame-info.c
index efb2adf..a130f8d 100644
--- a/cogl/cogl-frame-info.c
+++ b/cogl/cogl-frame-info.c
@@ -60,9 +60,9 @@ cogl_frame_info_get_presentation_time (CoglFrameInfo *info)
 }
 
 int64_t
-cogl_frame_info_get_refresh_interval (CoglFrameInfo *info)
+cogl_frame_info_get_refresh_rate (CoglFrameInfo *info)
 {
-  return info->refresh_interval;
+  return info->refresh_rate;
 }
 
 CoglOutput *
diff --git a/cogl/cogl-frame-info.h b/cogl/cogl-frame-info.h
index c5a7c5a..2cb4e00 100644
--- a/cogl/cogl-frame-info.h
+++ b/cogl/cogl-frame-info.h
@@ -95,21 +95,20 @@ int64_t cogl_frame_info_get_presentation_time (CoglFrameInfo *info);
  * cogl_frame_info_get_refresh_interval:
  * @info: a #CoglFrameInfo 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.
+ * Gets the refresh rate in Hertz for the output that the frame was on
+ * at the time the frame was presented.
  *
  * <note>Some platforms can't associate a #CoglOutput with a
- * #CoglFrameInfo object but are able to report a refresh_interval via
+ * #CoglFrameInfo object but are able to report a refresh rate via
  * this api. Therefore if you need this information then this api is
  * more reliable than using cogl_frame_info_get_output() followed by
  * cogl_output_get_refresh_rate().</note>
  *
- * Return value: the refresh interval, in microsecoonds.
+ * Return value: the refresh rate in Hertz
  * Since: 2.0
  * Stability: unstable
  */
-int64_t cogl_frame_info_get_refresh_interval (CoglFrameInfo *info);
+int64_t cogl_frame_info_get_refresh_rate (CoglFrameInfo *info);
 
 /**
  * cogl_frame_info_get_output:
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index a8e60d8..e0bfab0 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -1413,15 +1413,14 @@ _cogl_winsys_get_vsync_counter (void)
 }
 
 static void
-set_refresh_interval_from_output (CoglOnscreen *onscreen,
-                                  CoglOutput *output)
+set_refresh_rate_from_output (CoglOnscreen *onscreen,
+                              CoglOutput *output)
 {
-#warning "XXX: why not be consistent and also report a refresh_rate for the FrameInfo?"
   float refresh_rate = cogl_output_get_refresh_rate (output);
   if (refresh_rate != 0.0)
     {
       CoglFrameInfo *info = g_queue_peek_tail (&onscreen->pending_frame_infos);
-      info->refresh_interval = (int)(0.5 + (1000000. / refresh_rate));
+      info->refresh_rate = refresh_rate;
     }
 }
 
@@ -1626,7 +1625,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
                                                   y_max - y_min);
 
       if (info->output)
-        set_refresh_interval_from_output (onscreen, info->output);
+        set_refresh_rate_from_output (onscreen, info->output);
     }
 }
 
-- 
1.7.7.6



More information about the Cogl mailing list