summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2013-01-24 17:38:38 -0500
committerOwen W. Taylor <otaylor@fishsoup.net>2013-01-25 00:16:13 -0500
commit5cc26c82555e01ca7370772b73b93ca00772c37a (patch)
treeeb47ea5a6648fe4ff7f4fec7f2dad3c8c261acc6
parent8a1a1f56135af22c7316529f9e6f400059e305b8 (diff)
downloadcogl-5cc26c82555e01ca7370772b73b93ca00772c37a.tar.gz
Add cogl_frame_info_get_output()
If available from the windowing system, it could potentially be useful to know something other than the refresh rate of the output that the monitor is currently presenting on. (Note however, an onscreen may span multiple outputs. The windowing system has to pick *one* for timing, but most other attibutes of the window will apply to the parts of the onscreen on that output.)
-rw-r--r--cogl/cogl-frame-info-private.h2
-rw-r--r--cogl/cogl-frame-info.c6
-rw-r--r--cogl/cogl-frame-info.h21
-rw-r--r--cogl/winsys/cogl-winsys-glx.c34
4 files changed, 49 insertions, 14 deletions
diff --git a/cogl/cogl-frame-info-private.h b/cogl/cogl-frame-info-private.h
index 12073e49..ef24d54a 100644
--- a/cogl/cogl-frame-info-private.h
+++ b/cogl/cogl-frame-info-private.h
@@ -36,6 +36,8 @@ struct _CoglFrameInfo
int64_t presentation_time;
float refresh_rate;
+ CoglOutput *output;
+
unsigned int complete : 1;
};
diff --git a/cogl/cogl-frame-info.c b/cogl/cogl-frame-info.c
index a13eba0b..bb4059fe 100644
--- a/cogl/cogl-frame-info.c
+++ b/cogl/cogl-frame-info.c
@@ -76,3 +76,9 @@ cogl_frame_info_get_refresh_rate (CoglFrameInfo *info)
{
return info->refresh_rate;
}
+
+CoglOutput *
+cogl_frame_info_get_output (CoglFrameInfo *info)
+{
+ return info->output;
+}
diff --git a/cogl/cogl-frame-info.h b/cogl/cogl-frame-info.h
index 75c0148f..64dabc57 100644
--- a/cogl/cogl-frame-info.h
+++ b/cogl/cogl-frame-info.h
@@ -32,6 +32,7 @@
#define __COGL_FRAME_INFO_H
#include <cogl/cogl-types.h>
+#include <cogl/cogl-output.h>
#include <glib.h>
G_BEGIN_DECLS
@@ -117,12 +118,32 @@ int64_t cogl_frame_info_get_presentation_time (CoglFrameInfo *info);
* 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 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 rate in Hertz
* Since: 2.0
* Stability: unstable
*/
int64_t cogl_frame_info_get_refresh_rate (CoglFrameInfo *info);
+/**
+ * cogl_frame_info_get_output:
+ * @info: a #CoglFrameInfo object
+ *
+ * Gets the #CoglOutput that the swapped frame was presented to.
+ *
+ * Return value: The #CoglOutput that the frame was presented to, or
+ * %NULL if this could not be determined.
+ * Since: 2.0
+ * Stability: unstable
+ */
+CoglOutput *
+cogl_frame_info_get_output (CoglFrameInfo *info);
+
G_END_DECLS
#endif /* __COGL_FRAME_INFO_H */
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 46e71e06..fff6dfe5 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -1464,15 +1464,19 @@ _cogl_winsys_get_vsync_counter (CoglContext *ctx)
}
static void
-set_refresh_rate_from_output (CoglOnscreen *onscreen,
- CoglOutput *output)
+set_frame_info_output (CoglOnscreen *onscreen,
+ CoglOutput *output)
{
- float refresh_rate = cogl_output_get_refresh_rate (output);
- if (refresh_rate != 0.0)
+ int64_t frame_counter = cogl_onscreen_get_frame_counter (onscreen);
+ CoglFrameInfo *info = cogl_onscreen_get_frame_info (onscreen, frame_counter);
+
+ info->output = output;
+
+ if (output)
{
- int64_t frame_counter = cogl_onscreen_get_frame_counter (onscreen);
- CoglFrameInfo *info = cogl_onscreen_get_frame_info (onscreen, frame_counter);
- info->refresh_rate = refresh_rate;
+ float refresh_rate = cogl_output_get_refresh_rate (output);
+ if (refresh_rate != 0.0)
+ info->refresh_rate = refresh_rate;
}
}
@@ -1669,11 +1673,14 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
y_min = CLAMP (y_min, 0, framebuffer_width);
y_max = CLAMP (y_max, 0, framebuffer_height);
- output = _cogl_xlib_renderer_output_for_rectangle (context->display->renderer,
- xlib_onscreen->x + x_min, xlib_onscreen->y + y_min,
- x_max - x_min, y_max - y_min);
- if (output)
- set_refresh_rate_from_output (onscreen, output);
+ output =
+ _cogl_xlib_renderer_output_for_rectangle (context->display->renderer,
+ xlib_onscreen->x + x_min,
+ xlib_onscreen->y + y_min,
+ x_max - x_min,
+ y_max - y_min);
+
+ set_frame_info_output (onscreen, output);
}
set_info_complete (onscreen);
@@ -1757,8 +1764,7 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
glx_onscreen->last_swap_vsync_counter =
_cogl_winsys_get_vsync_counter (context);
- if (xlib_onscreen->output)
- set_refresh_rate_from_output (onscreen, xlib_onscreen->output);
+ set_frame_info_output (onscreen, xlib_onscreen->output);
if (!(glx_renderer->glXSwapInterval &&
_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_VBLANK_WAIT)))