[Mesa-dev] [PATCH 2/2] gbm/dri: Add more color formats support.

zhigang.gong at linux.intel.com zhigang.gong at linux.intel.com
Mon Feb 13 23:53:18 PST 2012


From: Zhigang Gong <zhigang.gong at linux.intel.com>

Added two color formats RGB565 and A8 to gbm layer.
Added A8 to dri layer.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 include/GL/internal/dri_interface.h       |    1 +
 src/gbm/backends/dri/gbm_dri.c            |    6 ++++++
 src/gbm/main/gbm.h                        |    6 +++++-
 src/mesa/drivers/dri/intel/intel_screen.c |    5 +++++
 4 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 701e83e..b98ee3d 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -906,6 +906,7 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
 #define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
 #define __DRI_IMAGE_FORMAT_ABGR8888     0x1004
+#define __DRI_IMAGE_FORMAT_A8           0x1005
 
 #define __DRI_IMAGE_USE_SHARE		0x0001
 #define __DRI_IMAGE_USE_SCANOUT		0x0002
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 7932d12..d5a73f2 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -224,6 +224,12 @@ gbm_dri_match_format(enum gbm_bo_format format, int *dri_format)
    case GBM_BO_FORMAT_ARGB8888:
       *dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
       break;
+   case GBM_BO_FORMAT_RGB565:
+      *dri_format = __DRI_IMAGE_FORMAT_RGB565;
+      break;
+   case GBM_BO_FORMAT_A8:
+      *dri_format = __DRI_IMAGE_FORMAT_A8;
+      break;
    default:
       return -1;
    }
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index ec64b94..2880872 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -72,7 +72,11 @@ enum gbm_bo_format {
    /** RGB with 8 bits per channel in a 32 bit value */
    GBM_BO_FORMAT_XRGB8888, 
    /** ARGB with 8 bits per channel in a 32 bit value */
-   GBM_BO_FORMAT_ARGB8888
+   GBM_BO_FORMAT_ARGB8888,
+   /* RGB with 5 bits red channel, 6 bits green channel and 5 bits blue channel*/
+   GBM_BO_FORMAT_RGB565,
+   /* Alpha with 8 bits alpha channel. */
+   GBM_BO_FORMAT_A8
 };
 
 /**
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 60781e5..f0fc5a4 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -147,6 +147,11 @@ intel_create_image_from_name(__DRIscreen *screen,
 	return NULL;
 
     switch (format) {
+    case __DRI_IMAGE_FORMAT_A8:
+       image->format = MESA_FORMAT_A8;
+       image->internal_format = GL_ALPHA;
+       image->data_type = GL_UNSIGNED_BYTE;
+       break;
     case __DRI_IMAGE_FORMAT_RGB565:
        image->format = MESA_FORMAT_RGB565;
        image->internal_format = GL_RGB;
-- 
1.7.4.4



More information about the mesa-dev mailing list