[cogl] Handle all formats in _cogl_texture_driver_pixel_format_to_gl
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] Handle all formats in _cogl_texture_driver_pixel_format_to_gl
- Date: Mon, 20 Feb 2012 23:26:35 +0000 (UTC)
commit cc4aa97579c0b838bb9ae433769bb62084847149
Author: Robert Bragg <robert linux intel com>
Date: Mon Feb 13 17:43:32 2012 +0000
Handle all formats in _cogl_texture_driver_pixel_format_to_gl
The _cogl_texture_driver_pixel_format_to_gl functions for OpenGL and
OpenGLES convert CoglPixelFormats into corresponding gl enums that can
be used to upload texture data. Previously we were only handling a few
specific formats but this patch updates the functions to handle all the
formats we know about. The functions now also switch() on the format so
that we will get build time warnings if we forget to handle new formats
in these functions.
Reviewed-by: Neil Roberts <neil linux intel com>
cogl/driver/gl/cogl-texture-driver-gl.c | 25 +++++++++++++++-------
cogl/driver/gles/cogl-texture-driver-gles.c | 29 +++++++++++++++++++-------
2 files changed, 38 insertions(+), 16 deletions(-)
---
diff --git a/cogl/driver/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/cogl-texture-driver-gl.c
index 2724811..144e37e 100644
--- a/cogl/driver/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/cogl-texture-driver-gl.c
@@ -400,16 +400,14 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
GLenum *out_gltype)
{
CoglPixelFormat required_format;
- GLenum glintformat = 0;
- GLenum glformat = 0;
- GLenum gltype = 0;
-
- /* FIXME: check YUV support */
+ GLenum glintformat;
+ GLenum glformat;
+ GLenum gltype;
required_format = format;
/* Find GL equivalents */
- switch (format & COGL_UNPREMULT_MASK)
+ switch (format)
{
case COGL_PIXEL_FORMAT_A_8:
glintformat = GL_ALPHA;
@@ -433,11 +431,13 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
gltype = GL_UNSIGNED_BYTE;
break;
case COGL_PIXEL_FORMAT_RGBA_8888:
+ case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_BYTE;
break;
case COGL_PIXEL_FORMAT_BGRA_8888:
+ case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
glintformat = GL_RGBA;
glformat = GL_BGRA;
gltype = GL_UNSIGNED_BYTE;
@@ -447,6 +447,7 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
* have no GL equivalent unless defined using
* system word byte ordering */
case COGL_PIXEL_FORMAT_ARGB_8888:
+ case COGL_PIXEL_FORMAT_ARGB_8888_PRE:
glintformat = GL_RGBA;
glformat = GL_BGRA;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
@@ -457,6 +458,7 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
break;
case COGL_PIXEL_FORMAT_ABGR_8888:
+ case COGL_PIXEL_FORMAT_ABGR_8888_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
@@ -467,24 +469,28 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
break;
case COGL_PIXEL_FORMAT_RGBA_1010102:
+ case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_INT_10_10_10_2;
break;
case COGL_PIXEL_FORMAT_BGRA_1010102:
+ case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
glintformat = GL_RGBA;
glformat = GL_BGRA;
gltype = GL_UNSIGNED_INT_10_10_10_2;
break;
case COGL_PIXEL_FORMAT_ABGR_2101010:
+ case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
break;
case COGL_PIXEL_FORMAT_ARGB_2101010:
+ case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
glintformat = GL_RGBA;
glformat = GL_BGRA;
gltype = GL_UNSIGNED_INT_2_10_10_10_REV;
@@ -499,18 +505,21 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
gltype = GL_UNSIGNED_SHORT_5_6_5;
break;
case COGL_PIXEL_FORMAT_RGBA_4444:
+ case COGL_PIXEL_FORMAT_RGBA_4444_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_SHORT_4_4_4_4;
break;
case COGL_PIXEL_FORMAT_RGBA_5551:
+ case COGL_PIXEL_FORMAT_RGBA_5551_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_SHORT_5_5_5_1;
break;
- /* FIXME: check extensions for YUV support */
- default:
+ case COGL_PIXEL_FORMAT_ANY:
+ case COGL_PIXEL_FORMAT_YUV:
+ g_assert_not_reached ();
break;
}
diff --git a/cogl/driver/gles/cogl-texture-driver-gles.c b/cogl/driver/gles/cogl-texture-driver-gles.c
index bf80012..66885c7 100644
--- a/cogl/driver/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gles/cogl-texture-driver-gles.c
@@ -412,16 +412,14 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
GLenum *out_gltype)
{
CoglPixelFormat required_format;
- GLenum glintformat = 0;
- GLenum glformat = 0;
- GLenum gltype = 0;
-
- /* FIXME: check YUV support */
+ GLenum glintformat;
+ GLenum glformat;
+ GLenum gltype;
required_format = format;
/* Find GL equivalents */
- switch (format & COGL_UNPREMULT_MASK)
+ switch (format)
{
case COGL_PIXEL_FORMAT_A_8:
glintformat = GL_ALPHA;
@@ -445,9 +443,21 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
/* Just one 32-bit ordering supported */
case COGL_PIXEL_FORMAT_RGBA_8888:
+ case COGL_PIXEL_FORMAT_RGBA_8888_PRE:
case COGL_PIXEL_FORMAT_BGRA_8888:
+ case COGL_PIXEL_FORMAT_BGRA_8888_PRE:
case COGL_PIXEL_FORMAT_ARGB_8888:
+ case COGL_PIXEL_FORMAT_ARGB_8888_PRE:
case COGL_PIXEL_FORMAT_ABGR_8888:
+ case COGL_PIXEL_FORMAT_ABGR_8888_PRE:
+ case COGL_PIXEL_FORMAT_RGBA_1010102:
+ case COGL_PIXEL_FORMAT_RGBA_1010102_PRE:
+ case COGL_PIXEL_FORMAT_BGRA_1010102:
+ case COGL_PIXEL_FORMAT_BGRA_1010102_PRE:
+ case COGL_PIXEL_FORMAT_ABGR_2101010:
+ case COGL_PIXEL_FORMAT_ABGR_2101010_PRE:
+ case COGL_PIXEL_FORMAT_ARGB_2101010:
+ case COGL_PIXEL_FORMAT_ARGB_2101010_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_BYTE;
@@ -464,18 +474,21 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format,
gltype = GL_UNSIGNED_SHORT_5_6_5;
break;
case COGL_PIXEL_FORMAT_RGBA_4444:
+ case COGL_PIXEL_FORMAT_RGBA_4444_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_SHORT_4_4_4_4;
break;
case COGL_PIXEL_FORMAT_RGBA_5551:
+ case COGL_PIXEL_FORMAT_RGBA_5551_PRE:
glintformat = GL_RGBA;
glformat = GL_RGBA;
gltype = GL_UNSIGNED_SHORT_5_5_5_1;
break;
- /* FIXME: check extensions for YUV support */
- default:
+ case COGL_PIXEL_FORMAT_ANY:
+ case COGL_PIXEL_FORMAT_YUV:
+ g_assert_not_reached ();
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]