From 374bb630f044d430206bd5e6f3bd2f670fcf51fb Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 18 May 2017 14:57:43 +0200 Subject: [PATCH] cogl: Use pixel_format_to_gl_with_target in find_best_gl_get_data_format Fixes cogl_texture_get_data() resorting to the wrong conversions when extracting the texture data. This notably resulted in RGB/RGBA buffers copied as-is into BGRA buffers, for instance for the fullscreen animation, or single-window screenshots of such buffers. https://bugzilla.gnome.org/show_bug.cgi?id=779234 --- cogl/cogl/cogl-texture-driver.h | 1 + cogl/cogl/cogl-texture.c | 1 + cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c | 12 +++++++----- cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cogl/cogl/cogl-texture-driver.h b/cogl/cogl/cogl-texture-driver.h index 3ab86edb2..e548605db 100644 --- a/cogl/cogl/cogl-texture-driver.h +++ b/cogl/cogl/cogl-texture-driver.h @@ -198,6 +198,7 @@ struct _CoglTextureDriver CoglPixelFormat (* find_best_gl_get_data_format) (CoglContext *context, CoglPixelFormat format, + CoglPixelFormat target_format, GLenum *closest_gl_format, GLenum *closest_gl_type); }; diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index 877d1d75d..729fb0c05 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -1059,6 +1059,7 @@ cogl_texture_get_data (CoglTexture *texture, closest_format = ctx->texture_driver->find_best_gl_get_data_format (ctx, + texture_format, format, &closest_gl_format, &closest_gl_type); 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 d5ee4b4f6..036b04c3d 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c @@ -533,14 +533,16 @@ static CoglPixelFormat _cogl_texture_driver_find_best_gl_get_data_format (CoglContext *context, CoglPixelFormat format, + CoglPixelFormat target_format, GLenum *closest_gl_format, GLenum *closest_gl_type) { - return context->driver_vtable->pixel_format_to_gl (context, - format, - NULL, /* don't need */ - closest_gl_format, - closest_gl_type); + return context->driver_vtable->pixel_format_to_gl_with_target (context, + format, + target_format, + NULL, /* don't need */ + closest_gl_format, + closest_gl_type); } const CoglTextureDriver diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c index 34ba57f34..1f62ade67 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c @@ -615,6 +615,7 @@ static CoglPixelFormat _cogl_texture_driver_find_best_gl_get_data_format (CoglContext *context, CoglPixelFormat format, + CoglPixelFormat target_format, GLenum *closest_gl_format, GLenum *closest_gl_type) {