From d521b61a49d5a619c80a3bbe601d37d40abd4402 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 22 Jan 2013 21:21:33 +0000 Subject: [PATCH] egl: support EGL_EXT_buffer_age This adds support for the EGL_EXT_buffer_age extension which is a counterpart to the GLX_EXT_buffer_age extension. Reviewed-by: Neil Roberts (cherry picked from commit 92d869764c03d0bac6b51dac833510c22669ac4a) --- .../cogl-winsys-egl-feature-functions.h | 6 +++++ cogl/winsys/cogl-winsys-egl-private.h | 3 ++- cogl/winsys/cogl-winsys-egl.c | 23 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cogl/winsys/cogl-winsys-egl-feature-functions.h b/cogl/winsys/cogl-winsys-egl-feature-functions.h index 9016f8d86..5068090a2 100644 --- a/cogl/winsys/cogl-winsys-egl-feature-functions.h +++ b/cogl/winsys/cogl-winsys-egl-feature-functions.h @@ -94,4 +94,10 @@ COGL_WINSYS_FEATURE_BEGIN (create_context, COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT) COGL_WINSYS_FEATURE_END () +COGL_WINSYS_FEATURE_BEGIN (buffer_age, + "EXT\0", + "buffer_age\0", + COGL_EGL_WINSYS_FEATURE_BUFFER_AGE) +COGL_WINSYS_FEATURE_END () + #endif diff --git a/cogl/winsys/cogl-winsys-egl-private.h b/cogl/winsys/cogl-winsys-egl-private.h index 13ce9a4e4..0d7606545 100644 --- a/cogl/winsys/cogl-winsys-egl-private.h +++ b/cogl/winsys/cogl-winsys-egl-private.h @@ -69,7 +69,8 @@ typedef enum _CoglEGLWinsysFeature COGL_EGL_WINSYS_FEATURE_SWAP_REGION =1L<<0, COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP =1L<<1, COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2, - COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT =1L<<3 + COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT =1L<<3, + COGL_EGL_WINSYS_FEATURE_BUFFER_AGE =1L<<4 } CoglEGLWinsysFeature; typedef struct _CoglRendererEGL diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c index f6fba0788..32a2d599c 100644 --- a/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/winsys/cogl-winsys-egl.c @@ -689,6 +689,28 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen) bind_onscreen (onscreen); } +#ifndef EGL_BUFFER_AGE_EXT +#define EGL_BUFFER_AGE_EXT 0x313D +#endif + +static int +_cogl_winsys_onscreen_get_buffer_age (CoglOnscreen *onscreen) +{ + CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context; + CoglRenderer *renderer = context->display->renderer; + CoglRendererEGL *egl_renderer = renderer->winsys; + CoglOnscreenEGL *egl_onscreen = onscreen->winsys; + EGLSurface surface = egl_onscreen->egl_surface; + int age; + + if (!(egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_BUFFER_AGE)) + return 0; + + eglQuerySurface (egl_renderer->edpy, surface, EGL_BUFFER_AGE_EXT, &age); + + return age; +} + static void _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen, const int *user_rectangles, @@ -848,6 +870,7 @@ static CoglWinsysVtable _cogl_winsys_vtable = .onscreen_bind = _cogl_winsys_onscreen_bind, .onscreen_swap_buffers = _cogl_winsys_onscreen_swap_buffers, .onscreen_swap_region = _cogl_winsys_onscreen_swap_region, + .onscreen_get_buffer_age = _cogl_winsys_onscreen_get_buffer_age, .onscreen_update_swap_throttled = _cogl_winsys_onscreen_update_swap_throttled,