From ad9db72f7410da6888d15232d1644d3f676831fe Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 14 Mar 2014 15:06:39 +0000 Subject: [PATCH] Expose COGL_FEATURE_ID_BUFFER_AGE feature id 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(). Reviewed-by: Neil Roberts --- 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 3fd03ee0f..f7cd2e8ad 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 40166d1a1..867d6f42c 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. * + * 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. + * * 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 2bb5e2b7c..fbdadfb13 100644 --- a/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/winsys/cogl-winsys-egl.c @@ -515,9 +515,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 e6441c23a..2b135be86 100644 --- a/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/winsys/cogl-winsys-glx.c @@ -873,6 +873,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; }