[RFC 8/9] gbm: add a release_buffer callback to dri backend

Ander Conselvan de Oliveira conselvan2 at gmail.com
Wed Dec 14 02:00:07 PST 2011


From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>

This adds a mechanism for the egl platform code to be notified when
the user releases a bo created from a surface.
---
 src/gbm/backends/dri/gbm_dri.c    |    8 ++++++++
 src/gbm/backends/dri/gbm_driint.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index d6ac956..1a08a35 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -444,6 +444,7 @@ gbm_dri_surface_get_bo(struct gbm_surface *_surf)
    if (bo == NULL)
       return NULL;
 
+   bo->dri_buffer = dri_buffer;
    bo->base.base.gbm = _surf->gbm;
    bo->base.base.width = _surf->width;
    bo->base.base.height = _surf->height;
@@ -465,6 +466,13 @@ gbm_dri_surface_get_bo(struct gbm_surface *_surf)
 static void
 gbm_dri_surface_release_bo(struct gbm_surface *_surf, struct gbm_bo *_bo)
 {
+   struct gbm_dri_surface *surf = gbm_dri_surface(_surf);
+   struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+
+   if (surf->release_buffer && bo->dri_buffer)
+      surf->release_buffer(surf, bo->dri_buffer, surf->dri_private);
+
+   bo->dri_buffer = NULL;
 }
 
 static void
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index 8853251..3551be3 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -72,12 +72,14 @@ struct gbm_dri_bo {
    struct gbm_drm_bo base;
 
    __DRIimage *image;
+   __DRIbuffer *dri_buffer;
 };
 
 struct gbm_dri_surface {
    struct gbm_surface base;
 
    __DRIbuffer *(*get_front_buffer)(struct gbm_dri_surface *, void *);
+   void (*release_buffer)(struct gbm_dri_surface *, __DRIbuffer *, void *);
    void *dri_private;
 };
 
-- 
1.7.4.1



More information about the wayland-devel mailing list