[Cogl] [PATCH] Expose COGL_FEATURE_ID_BUFFER_AGE feature id

Robert Bragg robert at sixbynine.org
Fri Mar 14 08:33:12 PDT 2014


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

This adds a new COGL_FEATURE_ID_BUFFER_AGE feature id that can be used
to determine if cogl_onscreen_get_buffer_age() will ever return an age
other than 0. This should be used instead of querying the winsys feature
via cogl_clutter_winsys_has_feature().
---
 cogl/cogl-context.h           | 4 ++++
 cogl/cogl-onscreen.h          | 5 +++++
 cogl/winsys/cogl-winsys-egl.c | 9 ++++++---
 cogl/winsys/cogl-winsys-glx.c | 3 +++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/cogl/cogl-context.h b/cogl/cogl-context.h
index 3fd03ee..f7cd2e8 100644
--- a/cogl/cogl-context.h
+++ b/cogl/cogl-context.h
@@ -234,6 +234,9 @@ cogl_is_context (void *object);
  * @COGL_FEATURE_ID_SWAP_BUFFERS_EVENT:
  *     Available if the window system supports reporting an event
  *     for swap buffer completions.
+ * @COGL_FEATURE_ID_BUFFER_AGE: Available if the age of #CoglOnscreen back
+ *    buffers are tracked and so cogl_onscreen_get_buffer_age() can be
+ *    expected to return age values other than 0.
  * @COGL_FEATURE_ID_GLES2_CONTEXT: Whether creating new GLES2 contexts is
  *    suported.
  * @COGL_FEATURE_ID_DEPTH_TEXTURE: Whether #CoglFramebuffer support rendering
@@ -273,6 +276,7 @@ typedef enum _CoglFeatureID
   COGL_FEATURE_ID_FENCE,
   COGL_FEATURE_ID_PER_VERTEX_POINT_SIZE,
   COGL_FEATURE_ID_TEXTURE_RG,
+  COGL_FEATURE_ID_BUFFER_AGE,
 
   /*< private >*/
   _COGL_N_FEATURE_IDS   /*< skip >*/
diff --git a/cogl/cogl-onscreen.h b/cogl/cogl-onscreen.h
index 40166d1..867d6f4 100644
--- a/cogl/cogl-onscreen.h
+++ b/cogl/cogl-onscreen.h
@@ -390,6 +390,11 @@ cogl_onscreen_swap_buffers (CoglOnscreen *onscreen);
  * of back buffers then this function will always return 0 which
  * implies that the contents are undefined.</note>
  *
+ * <note>The %COGL_FEATURE_ID_BUFFER_AGE feature can optionally be
+ * explicitly checked to determine if Cogl is currently tracking the
+ * age of #CoglOnscreen back buffer contents. If this feature is
+ * missing then this function will always return 0.</note>
+ *
  * Return value: The age of the buffer contents or 0 when the buffer
  *               contents are undefined.
  *
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index fb205b5..2f15c5c 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -516,9 +516,12 @@ _cogl_winsys_context_init (CoglContext *context, CoglError **error)
     COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_FENCE, TRUE);
 
   if (egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_BUFFER_AGE)
-    COGL_FLAGS_SET (context->winsys_features,
-                    COGL_WINSYS_FEATURE_BUFFER_AGE,
-                    TRUE);
+    {
+      COGL_FLAGS_SET (context->winsys_features,
+                      COGL_WINSYS_FEATURE_BUFFER_AGE,
+                      TRUE);
+      COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_BUFFER_AGE, TRUE);
+    }
 
   /* NB: We currently only support creating standalone GLES2 contexts
    * for offscreen rendering and so we need a dummy (non-visible)
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 9be3d0f..3095acf 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -874,6 +874,9 @@ update_winsys_features (CoglContext *context, CoglError **error)
                   COGL_PRIVATE_FEATURE_DIRTY_EVENTS,
                   TRUE);
 
+  if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE))
+    COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_BUFFER_AGE, TRUE);
+
   return TRUE;
 }
 
-- 
1.9.0



More information about the Cogl mailing list