diff options
author | Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> | 2012-01-25 16:24:14 +0200 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-03-28 22:14:34 -0400 |
commit | 0d1ef1f57f9011fd2bc3354d60fb19db29af7363 (patch) | |
tree | 101590eab7d5ee8654d093393431983974c85ee5 /src/gbm/backends | |
parent | 7f16246acef4089570abca76a59580691ec6cf68 (diff) | |
download | external_mesa3d-0d1ef1f57f9011fd2bc3354d60fb19db29af7363.zip external_mesa3d-0d1ef1f57f9011fd2bc3354d60fb19db29af7363.tar.gz external_mesa3d-0d1ef1f57f9011fd2bc3354d60fb19db29af7363.tar.bz2 |
gbm: Add gbm_surface interface
The idea here is to be able to create an egl window surface from a
gbm_surface. This avoids the need for the surfaceless extension and
lets the EGL platform handle buffer allocation, while keeping the user
in charge of somehow presenting the buffers (using kms page flipping,
for example).
gbm_surface_lock_front_buffer() locks a surface's front buffer and
returns a gbm bo representing it. This bo should later be returned
to the gbm surface using gbm_surface_release_buffer().
Diffstat (limited to 'src/gbm/backends')
-rw-r--r-- | src/gbm/backends/dri/gbm_dri.c | 30 | ||||
-rw-r--r-- | src/gbm/backends/dri/gbm_driint.h | 15 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 1e02287..5398e3d 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -387,6 +387,34 @@ gbm_dri_bo_create(struct gbm_device *gbm, return &bo->base.base; } +static struct gbm_surface * +gbm_dri_surface_create(struct gbm_device *gbm, + uint32_t width, uint32_t height, + uint32_t format, uint32_t flags) +{ + 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; + surf->base.flags = flags; + + 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 void dri_destroy(struct gbm_device *gbm) { @@ -414,6 +442,8 @@ dri_device_create(int fd) dri->base.base.is_format_supported = gbm_dri_is_format_supported; dri->base.base.bo_destroy = gbm_dri_bo_destroy; dri->base.base.destroy = dri_destroy; + dri->base.base.surface_create = gbm_dri_surface_create; + dri->base.base.surface_destroy = gbm_dri_surface_destroy; dri->base.type = GBM_DRM_DRIVER_TYPE_DRI; dri->base.base.name = "drm"; diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h index d801a08..514b5a6 100644 --- a/src/gbm/backends/dri/gbm_driint.h +++ b/src/gbm/backends/dri/gbm_driint.h @@ -61,6 +61,15 @@ struct gbm_dri_bo { __DRIimage *image; }; +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 *); + int (*has_free_buffers)(void *); + void *dri_private; +}; + static inline struct gbm_dri_device * gbm_dri_device(struct gbm_device *gbm) { @@ -73,6 +82,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); |