[Mesa-dev] [PATCH 3/3] gbm: Add interface to create bo from name.
Zhigang Gong
zhigang.gong at gmail.com
Sat Dec 17 18:32:26 PST 2011
Added a new interface to create a gbm_bo from external name.
Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
src/gbm/backends/dri/gbm_dri.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/gbm/main/gbm.c | 12 ++++++++++++
src/gbm/main/gbm.h | 6 ++++++
src/gbm/main/gbmint.h | 4 ++++
4 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 7673953..c8f6196 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -356,6 +356,45 @@ gbm_dri_bo_create(struct gbm_device *gbm,
return &bo->base.base;
}
+static struct gbm_bo *
+gbm_dri_bo_create_from_name(struct gbm_device *gbm,
+ uint32_t width, uint32_t height,
+ enum gbm_bo_format format, int name,
+ int pitch)
+{
+ struct gbm_dri_device *dri = gbm_dri_device(gbm);
+ struct gbm_dri_bo *bo;
+ int dri_format;
+
+ if (gbm_dri_match_format(format, &dri_format) != 0)
+ return NULL;
+
+ bo = calloc(1, sizeof *bo);
+ if (bo == NULL)
+ return NULL;
+
+ bo->base.base.gbm = gbm;
+ bo->base.base.width = width;
+ bo->base.base.height = height;
+
+ bo->image =
+ dri->image->createImageFromName(dri->screen,
+ width, height,
+ dri_format, name, pitch,
+ bo);
+ if (bo->image == NULL) {
+ free(bo);
+ return NULL;
+ }
+
+ dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
+ &bo->base.base.handle.s32);
+ dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
+ (int *) &bo->base.base.pitch);
+
+ return &bo->base.base;
+}
+
static void
dri_destroy(struct gbm_device *gbm)
{
@@ -380,6 +419,7 @@ dri_device_create(int fd)
dri->base.base.fd = fd;
dri->base.base.bo_create = gbm_dri_bo_create;
dri->base.base.bo_create_from_egl_image = gbm_dri_bo_create_from_egl_image;
+ dri->base.base.bo_create_from_name = gbm_dri_bo_create_from_name;
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;
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
index 8440b2c..71c02a2 100644
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -177,6 +177,18 @@ gbm_bo_create(struct gbm_device *gbm,
}
GBM_EXPORT struct gbm_bo *
+gbm_bo_create_from_name(struct gbm_device *gbm,
+ uint32_t width, uint32_t height,
+ enum gbm_bo_format format, int name,
+ int pitch)
+{
+ if (width == 0 || height == 0)
+ return NULL;
+
+ return gbm->bo_create_from_name(gbm, width, height, format, name, pitch);
+}
+
+GBM_EXPORT struct gbm_bo *
gbm_bo_create_from_egl_image(struct gbm_device *gbm,
void *egl_dpy, void *egl_image,
uint32_t width, uint32_t height,
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index e3cecb4..49ff2a8 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -88,6 +88,12 @@ gbm_bo_create(struct gbm_device *gbm,
enum gbm_bo_format format, uint32_t flags);
struct gbm_bo *
+gbm_bo_create_from_name(struct gbm_device *gbm,
+ uint32_t width, uint32_t height,
+ enum gbm_bo_format format, int name,
+ int pitch);
+
+struct gbm_bo *
gbm_bo_create_from_egl_image(struct gbm_device *gbm,
void *egl_dpy, void *egl_img,
uint32_t width, uint32_t height,
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h
index fb8db80..1aab789 100644
--- a/src/gbm/main/gbmint.h
+++ b/src/gbm/main/gbmint.h
@@ -60,6 +60,10 @@ struct gbm_device {
void *egl_dpy, void *egl_img,
uint32_t width, uint32_t height,
uint32_t usage);
+ struct gbm_bo *(*bo_create_from_name)(struct gbm_device *gbm,
+ uint32_t width, uint32_t height,
+ enum gbm_bo_format format, int name,
+ int pitch);
void (*bo_destroy)(struct gbm_bo *bo);
};
--
1.7.3.1
More information about the mesa-dev
mailing list