[RFC 3/9] gbm: implement basic gbm_surface on dri backend

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


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

Make gbm_surface_create return something that the drm egl platform
can use.
---
 src/gbm/backends/dri/gbm_dri.c    |   16 +++++++++++++++-
 src/gbm/backends/dri/gbm_driint.h |   10 ++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index ec5dad5..c1c0bed 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -340,12 +340,26 @@ gbm_dri_surface_create(struct gbm_device *gbm,
                        uint32_t width, uint32_t height,
                        enum gbm_bo_format format)
 {
-   return NULL;
+   struct gbm_dri_surface *surf;
+
+   surf = calloc(1, sizeof *surf);
+   if (surf == NULL)
+      return NULL;
+
+   surf->base.gbm = gbm;
+   surf->base.width = width;
+   surf->base.height = height;
+   surf->base.format = format;
+
+   return &surf->base;
 }
 
 static void
 gbm_dri_surface_destroy(struct gbm_surface *_surf)
 {
+   struct gbm_dri_surface *surf = gbm_dri_surface(_surf);
+
+   free(surf);
 }
 
 static struct gbm_bo *
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index d801a08..d04ae6b 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -61,6 +61,10 @@ struct gbm_dri_bo {
    __DRIimage *image;
 };
 
+struct gbm_dri_surface {
+   struct gbm_surface base;
+};
+
 static inline struct gbm_dri_device *
 gbm_dri_device(struct gbm_device *gbm)
 {
@@ -73,6 +77,12 @@ gbm_dri_bo(struct gbm_bo *bo)
    return (struct gbm_dri_bo *) bo;
 }
 
+static inline struct gbm_dri_surface *
+gbm_dri_surface(struct gbm_surface *surface)
+{
+   return (struct gbm_dri_surface *) surface;
+}
+
 char *
 dri_fd_get_driver_name(int fd);
 
-- 
1.7.4.1



More information about the wayland-devel mailing list