diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c index ed5977ca41..fd77cb9293 100644 --- a/gdk/gdkgltexture.c +++ b/gdk/gdkgltexture.c @@ -115,6 +115,7 @@ typedef struct _Download Download; struct _Download { GdkMemoryFormat format; + GdkColorSpace *color_space; guchar *data; gsize stride; }; @@ -157,6 +158,7 @@ gdk_gl_texture_do_download (gpointer texture_, expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format); if (download->stride == expected_stride && + download->color_space == texture->color_space && !gdk_gl_context_get_use_es (self->context) && gdk_memory_format_gl_format (download->format, TRUE, &gl_internal_format, &gl_format, &gl_type)) { @@ -181,6 +183,7 @@ gdk_gl_texture_do_download (gpointer texture_, actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */ if (download->format == actual_format && + download->color_space == texture->color_space && (download->stride == expected_stride)) { glReadPixels (0, 0, @@ -203,7 +206,7 @@ gdk_gl_texture_do_download (gpointer texture_, gdk_memory_convert (download->data, download->stride, download->format, - gdk_color_space_get_srgb (), + download->color_space, pixels, texture->width * actual_bpp, actual_format, @@ -221,6 +224,7 @@ gdk_gl_texture_do_download (gpointer texture_, static void gdk_gl_texture_download (GdkTexture *texture, GdkMemoryFormat format, + GdkColorSpace *color_space, guchar *data, gsize stride) { @@ -229,11 +233,12 @@ gdk_gl_texture_download (GdkTexture *texture, if (self->saved) { - gdk_texture_do_download (self->saved, format, data, stride); + gdk_texture_do_download (self->saved, format, color_space, data, stride); return; } download.format = format; + download.color_space = color_space; download.data = data; download.stride = stride; diff --git a/gdk/gdkmemorytexture.c b/gdk/gdkmemorytexture.c index e4f0893f10..0d4700886b 100644 --- a/gdk/gdkmemorytexture.c +++ b/gdk/gdkmemorytexture.c @@ -59,6 +59,7 @@ gdk_memory_texture_dispose (GObject *object) static void gdk_memory_texture_download (GdkTexture *texture, GdkMemoryFormat format, + GdkColorSpace *color_space, guchar *data, gsize stride) { @@ -66,7 +67,7 @@ gdk_memory_texture_download (GdkTexture *texture, gdk_memory_convert (data, stride, format, - gdk_color_space_get_srgb (), + color_space, (guchar *) g_bytes_get_data (self->bytes, NULL), self->stride, texture->format, @@ -269,7 +270,7 @@ gdk_memory_texture_from_texture (GdkTexture *texture, stride = texture->width * gdk_memory_format_bytes_per_pixel (format); data = g_malloc_n (stride, texture->height); - gdk_texture_do_download (texture, format, data, stride); + gdk_texture_do_download (texture, format, gdk_color_space_get_srgb (), data, stride); bytes = g_bytes_new_take (data, stride); result = gdk_memory_texture_new (texture->width, texture->height, diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c index 095653db68..1d3cb88443 100644 --- a/gdk/gdktexture.c +++ b/gdk/gdktexture.c @@ -231,6 +231,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkTexture, gdk_texture, G_TYPE_OBJECT, static void gdk_texture_default_download (GdkTexture *texture, GdkMemoryFormat format, + GdkColorSpace *color_space, guchar *data, gsize stride) { @@ -726,10 +727,11 @@ gdk_texture_get_color_space (GdkTexture *texture) void gdk_texture_do_download (GdkTexture *texture, GdkMemoryFormat format, + GdkColorSpace *color_space, guchar *data, gsize stride) { - GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, data,stride); + GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, color_space, data, stride); } cairo_surface_t * @@ -795,6 +797,7 @@ gdk_texture_download (GdkTexture *texture, gdk_texture_do_download (texture, GDK_MEMORY_DEFAULT, + gdk_color_space_get_srgb (), data, stride); } @@ -840,6 +843,7 @@ gdk_texture_download_float (GdkTexture *texture, gdk_texture_do_download (texture, GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED, + gdk_color_space_get_srgb (), (guchar *) data, stride); } diff --git a/gdk/gdktextureprivate.h b/gdk/gdktextureprivate.h index 7102cecac2..9d852ab2c7 100644 --- a/gdk/gdktextureprivate.h +++ b/gdk/gdktextureprivate.h @@ -31,6 +31,7 @@ struct _GdkTextureClass { /* mandatory: Download in the given format into data */ void (* download) (GdkTexture *texture, GdkMemoryFormat format, + GdkColorSpace *color_space, guchar *data, gsize stride); }; @@ -42,6 +43,7 @@ cairo_surface_t * gdk_texture_download_surface (GdkTexture void gdk_texture_do_download (GdkTexture *texture, GdkMemoryFormat format, + GdkColorSpace *color_space, guchar *data, gsize stride); GdkMemoryFormat gdk_texture_get_format (GdkTexture *self);