diff options
author | Kristian Høgsberg <[email protected]> | 2012-12-13 23:39:45 -0500 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2013-01-10 15:58:05 -0500 |
commit | 4e42e569dd5643ff948ab4ee31dd16b1683f21fa (patch) | |
tree | 864a60c29a9f1818573d08da373a7fd3f29db0c9 | |
parent | 0ae81b8422e272e44ef40a09dc443c9014adbd0b (diff) |
egl/gbm: Implement EGL_EXT_buffer_age
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 4b639974a2b..eb8c06e08a0 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -189,6 +189,7 @@ struct dri2_egl_surface struct { struct gbm_bo *bo; int locked; + int age; } color_buffers[3], *back, *current; #ifndef HAVE_WAYLAND_PLATFORM __DRIbuffer *dri_buffers[__DRI_BUFFER_COUNT]; diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 3e04a6cdcb0..615648b9e99 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -324,11 +324,16 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); + int i; if (dri2_surf->base.Type == EGL_WINDOW_BIT) { if (dri2_surf->current) _eglError(EGL_BAD_SURFACE, "dri2_swap_buffers"); + for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) + if (dri2_surf->color_buffers[i].age > 0) + dri2_surf->color_buffers[i].age++; dri2_surf->current = dri2_surf->back; + dri2_surf->current->age = 1; dri2_surf->back = NULL; } @@ -338,6 +343,21 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) return EGL_TRUE; } +static EGLint +dri2_query_buffer_age(_EGLDriver *drv, + _EGLDisplay *disp, _EGLSurface *surface) +{ + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface); + __DRIbuffer buffer; + + if (get_back_bo(dri2_surf, &buffer) < 0) { + _eglError(EGL_BAD_ALLOC, "dri2_query_buffer_age"); + return 0; + } + + return dri2_surf->back->age; +} + static _EGLImage * dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, EGLClientBuffer buffer, const EGLint *attr_list) @@ -464,6 +484,9 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) drv->API.DestroySurface = dri2_destroy_surface; drv->API.SwapBuffers = dri2_swap_buffers; drv->API.CreateImageKHR = dri2_drm_create_image_khr; + drv->API.QueryBufferAge = dri2_query_buffer_age; + + disp->Extensions.EXT_buffer_age = EGL_TRUE; #ifdef HAVE_WAYLAND_PLATFORM disp->Extensions.WL_bind_wayland_display = EGL_TRUE; |