diff --git a/cogl/cogl-internal.h b/cogl/cogl-internal.h index 90198595d..4f53cc3c5 100644 --- a/cogl/cogl-internal.h +++ b/cogl/cogl-internal.h @@ -100,7 +100,8 @@ typedef enum COGL_PRIVATE_FEATURE_PBOS = 1L<<5, COGL_PRIVATE_FEATURE_VBOS = 1L<<6, COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL = 1L<<7, - COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL = 1L<<8 + COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL = 1L<<8, + COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_BGRA8888 = 1L<<9 } CoglPrivateFeatureFlags; /* Sometimes when evaluating pipelines, either during comparisons or diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index 27cbb64d5..ab07f911c 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -166,6 +166,15 @@ _cogl_texture_determine_internal_format (CoglPixelFormat src_format, return src_format; } else + /* XXX: It might be nice to make this match the component ordering + of the source format when the formats are otherwise the same + because on GL there is no way to specify the ordering of the + internal format. However when using GLES with the + GL_EXT_texture_format_BGRA8888 the order of the internal format + becomes important because it must exactly match the format of + the uploaded data. That means that if someone creates a texture + with some RGBA data and then later tries to upload BGRA data we + do actually have to swizzle the components */ return dst_format; } diff --git a/cogl/driver/gles/cogl-gles.c b/cogl/driver/gles/cogl-gles.c index d4c596879..102a19fc8 100644 --- a/cogl/driver/gles/cogl-gles.c +++ b/cogl/driver/gles/cogl-gles.c @@ -69,6 +69,22 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context, gltype = GL_UNSIGNED_BYTE; break; + case COGL_PIXEL_FORMAT_BGRA_8888: + case COGL_PIXEL_FORMAT_BGRA_8888_PRE: + /* There is an extension to support this format */ + if ((context->private_feature_flags & + COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_BGRA8888)) + { + /* For some reason the extension says you have to specify + BGRA for the internal format too */ + glintformat = GL_BGRA_EXT; + glformat = GL_BGRA_EXT; + gltype = GL_UNSIGNED_BYTE; + required_format = format; + break; + } + /* flow through */ + /* Just one 24-bit ordering supported */ case COGL_PIXEL_FORMAT_RGB_888: case COGL_PIXEL_FORMAT_BGR_888: @@ -81,8 +97,6 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context, /* 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: @@ -276,6 +290,9 @@ _cogl_driver_update_features (CoglContext *context, if (_cogl_check_extension ("GL_OES_packed_depth_stencil", gl_extensions)) private_flags |= COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL; + if (_cogl_check_extension ("GL_EXT_texture_format_BGRA8888", gl_extensions)) + private_flags |= COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_BGRA8888; + /* Cache features */ context->private_feature_flags |= private_flags; context->feature_flags |= flags;