[cogl/wip/rib/frame-synchronization: 478/481] renderer: expose CoglOutputs



commit 58ad66789532b83cacaac97f0bb450590e77bf7e
Author: Robert Bragg <robert linux intel com>
Date:   Mon Jan 21 01:18:25 2013 +0000

    renderer: expose CoglOutputs
    
    This adds a cogl_renderer_foreach_output() function that can be used to
    iterate the display outputs for a particular renderer.
    
    This also updates cogl-info to use this new api so it can dump out all
    the output information.
    
    Reviewed-by: Owen W. Taylor <otaylor fishsoup net>

 cogl/cogl-renderer.c |   14 +++++++++++
 cogl/cogl-renderer.h |   34 ++++++++++++++++++++++++++++
 cogl/cogl.h          |    1 +
 examples/cogl-info.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 108 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index 47d8c30..2535e6a 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -630,3 +630,17 @@ cogl_renderer_get_driver (CoglRenderer *renderer)
 
   return renderer->driver;
 }
+
+void
+cogl_renderer_foreach_output (CoglRenderer *renderer,
+                              CoglOutputCallback callback,
+                              void *user_data)
+{
+  GList *l;
+
+  _COGL_RETURN_IF_FAIL (renderer->connected);
+  _COGL_RETURN_IF_FAIL (callback != NULL);
+
+  for (l = renderer->outputs; l; l = l->next)
+    callback (l->data, user_data);
+}
diff --git a/cogl/cogl-renderer.h b/cogl/cogl-renderer.h
index 35e8bee..7921784 100644
--- a/cogl/cogl-renderer.h
+++ b/cogl/cogl-renderer.h
@@ -31,6 +31,7 @@
 #include <cogl/cogl-types.h>
 #include <cogl/cogl-onscreen-template.h>
 #include <cogl/cogl-error.h>
+#include <cogl/cogl-output.h>
 
 COGL_BEGIN_DECLS
 
@@ -383,6 +384,39 @@ cogl_renderer_set_driver (CoglRenderer *renderer,
 CoglDriver
 cogl_renderer_get_driver (CoglRenderer *renderer);
 
+/**
+ * CoglOutputCallback:
+ * @output: The current display output being iterated
+ * @user_data: The user pointer passed to
+ *             cogl_renderer_foreach_output()
+ *
+ * A callback type that can be passed to
+ * cogl_renderer_foreach_output() for iterating display outputs for a
+ * given renderer.
+ *
+ * Since: 1.14
+ * Stability: Unstable
+ */
+typedef void (*CoglOutputCallback) (CoglOutput *output, void *user_data);
+
+/**
+ * cogl_renderer_foreach_output:
+ * @renderer: A connected #CoglRenderer
+ * @callback: A #CoglOutputCallback to be called for each display output
+ * @user_data: A user pointer to be passed to @callback
+ *
+ * Iterates all known display outputs for the given @renderer and
+ * passes a corresponding #CoglOutput pointer to the given @callback
+ * for each one, along with the given @user_data.
+ *
+ * Since: 1.14
+ * Stability: Unstable
+ */
+void
+cogl_renderer_foreach_output (CoglRenderer *renderer,
+                              CoglOutputCallback callback,
+                              void *user_data);
+
 COGL_END_DECLS
 
 #endif /* __COGL_RENDERER_H__ */
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 6da511d..7d62f76 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -48,6 +48,7 @@
 
 #include <cogl/cogl-swap-chain.h>
 #include <cogl/cogl-renderer.h>
+#include <cogl/cogl-output.h>
 #include <cogl/cogl-display.h>
 #include <cogl/cogl-context.h>
 #include <cogl/cogl-buffer.h>
diff --git a/examples/cogl-info.c b/examples/cogl-info.c
index 3eacdc3..736f42e 100644
--- a/examples/cogl-info.c
+++ b/examples/cogl-info.c
@@ -164,6 +164,58 @@ feature_cb (CoglFeatureID feature, void *user_data)
   printf (" Â Unknown feature %d\n", feature);
 }
 
+typedef struct _OutputState
+{
+  int id;
+} OutputState;
+
+static void
+output_cb (CoglOutput *output, void *user_data)
+{
+  OutputState *state = user_data;
+  const char *order;
+  float refresh;
+
+  printf (" Output%d:\n", state->id++);
+  printf ("  Â position = (%d, %d)\n",
+          cogl_output_get_x (output),
+          cogl_output_get_y (output));
+  printf ("  Â resolution = %d x %d\n",
+          cogl_output_get_width (output),
+          cogl_output_get_height (output));
+  printf ("  Â physical size = %dmm x %dmm\n",
+          cogl_output_get_mm_width (output),
+          cogl_output_get_mm_height (output));
+  switch (cogl_output_get_subpixel_order (output))
+    {
+    case COGL_SUBPIXEL_ORDER_UNKNOWN:
+      order = "unknown";
+      break;
+    case COGL_SUBPIXEL_ORDER_NONE:
+      order = "non-standard";
+      break;
+    case COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB:
+      order = "horizontal,rgb";
+      break;
+    case COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR:
+      order = "horizontal,bgr";
+      break;
+    case COGL_SUBPIXEL_ORDER_VERTICAL_RGB:
+      order = "vertical,rgb";
+      break;
+    case COGL_SUBPIXEL_ORDER_VERTICAL_BGR:
+      order = "vertical,bgr";
+      break;
+    }
+  printf ("  Â sub pixel order = %s\n", order);
+
+  refresh = cogl_output_get_refresh_rate (output);
+  if (refresh)
+    printf ("  Â refresh = %f Hz\n", refresh);
+  else
+    printf ("  Â refresh = unknown\n");
+}
+
 int
 main (int argc, char **argv)
 {
@@ -173,6 +225,7 @@ main (int argc, char **argv)
   CoglError *error = NULL;
   CoglWinsysID winsys_id;
   const char *winsys_name;
+  OutputState output_state;
 
   ctx = cogl_context_new (NULL, &error);
   if (!ctx) {
@@ -189,5 +242,11 @@ main (int argc, char **argv)
   g_print ("Features:\n");
   cogl_foreach_feature (ctx, feature_cb, NULL);
 
+  g_print ("Outputs:\n");
+  output_state.id = 0;
+  cogl_renderer_foreach_output (renderer, output_cb, &output_state);
+  if (output_state.id == 0)
+    printf (" Unknown\n");
+
   return 0;
 }



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