diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 2b9a49c73..1cc63e82f 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -174,7 +174,15 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context, case COGL_PIXEL_FORMAT_BGRA_8888: case COGL_PIXEL_FORMAT_BGRA_8888_PRE: glintformat = GL_RGBA; - glformat = GL_BGRA; + /* If the driver has texture_swizzle, pretend internal + * and buffer format are the same here, the pixels + * will be flipped through this extension. + */ + if (_cogl_has_private_feature + (context, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE)) + glformat = GL_RGBA; + else + glformat = GL_BGRA; gltype = GL_UNSIGNED_BYTE; break; diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c index c76a0cf4b..d5ee4b4f6 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c @@ -114,6 +114,18 @@ _cogl_texture_driver_gen (CoglContext *ctx, red_swizzle) ); } + /* If swizzle extension is available, prefer it to flip bgra buffers to rgba */ + if ((internal_format == COGL_PIXEL_FORMAT_BGRA_8888 || + internal_format == COGL_PIXEL_FORMAT_BGRA_8888_PRE) && + _cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_SWIZZLE)) + { + static const GLint bgra_swizzle[] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA }; + + GE( ctx, glTexParameteriv (gl_target, + GL_TEXTURE_SWIZZLE_RGBA, + bgra_swizzle) ); + } + return tex; }