On Tue, Feb 14, 2012 at 2:53 AM, <zhigang.g...@linux.intel.com> wrote: > From: Zhigang Gong <zhigang.g...@linux.intel.com> > > Added two color formats RGB565 and A8 to gbm layer. > Added A8 to dri layer.
I was planning something like this: http://people.freedesktop.org/~krh/gbm-get-format.patch where we reuse the format codes introduced in drm. Also we rename the formats to just GBM_FORMAT_* since we're planning to introduce a struct gbm_surface, and need the formats for that too. The patch is not complete, we need to query the DRI image format when we create a gbm_bo through the gbm_bo_create_from_egl_image entry point. We need a new __DRIimage function for that but it should be straight forward. Kristian > Signed-off-by: Zhigang Gong <zhigang.g...@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 > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev