[Mesa-dev] [PATCH 09/15] gbm: Factor out gbm_to_dri_format function
Christopher James Halse Rogers
christopher.halse.rogers at canonical.com
Sat Jul 20 04:40:41 PDT 2013
---
src/gbm/backends/dri/gbm_dri.c | 53 +++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index c19d378..8b71cca 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -359,6 +359,37 @@ gbm_dri_to_gbm_format(uint32_t dri_format)
return ret;
}
+static uint32_t
+gbm_to_dri_format(uint32_t gbm_format)
+{
+ uint32_t dri_format = 0;
+
+ switch (gbm_format) {
+ case GBM_FORMAT_RGB565:
+ dri_format =__DRI_IMAGE_FORMAT_RGB565;
+ break;
+ case GBM_FORMAT_XRGB8888:
+ case GBM_BO_FORMAT_XRGB8888:
+ dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
+ break;
+ case GBM_FORMAT_ARGB8888:
+ case GBM_BO_FORMAT_ARGB8888:
+ dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
+ break;
+ case GBM_FORMAT_ABGR8888:
+ dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
+ break;
+ case GBM_FORMAT_XBGR8888:
+ dri_format = __DRI_IMAGE_FORMAT_XBGR8888;
+ break;
+ default:
+ dri_format = __DRI_IMAGE_FORMAT_NONE;
+ break;
+ }
+
+ return dri_format;
+}
+
static struct gbm_bo *
gbm_dri_bo_import(struct gbm_device *gbm,
uint32_t type, void *buffer, uint32_t usage)
@@ -535,27 +566,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
bo->base.base.height = height;
bo->base.base.format = format;
- switch (format) {
- case GBM_FORMAT_RGB565:
- dri_format =__DRI_IMAGE_FORMAT_RGB565;
- break;
- case GBM_FORMAT_XRGB8888:
- case GBM_BO_FORMAT_XRGB8888:
- dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
- break;
- case GBM_FORMAT_ARGB8888:
- case GBM_BO_FORMAT_ARGB8888:
- dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
- break;
- case GBM_FORMAT_ABGR8888:
- dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
- break;
- case GBM_FORMAT_XBGR8888:
- dri_format = __DRI_IMAGE_FORMAT_XBGR8888;
- break;
- default:
- return NULL;
- }
+ dri_format = gbm_to_dri_format(format);
if (usage & GBM_BO_USE_SCANOUT)
dri_use |= __DRI_IMAGE_USE_SCANOUT;
--
1.8.3.2
More information about the mesa-dev
mailing list