[gtk/matthiasc/color-profile-rebased: 13/43] gdk: Take a profile in gdk_texture_do_download




commit 7e2c2a05fd09d074d0c7ccbd9032f92acba73091
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 8 08:45:14 2022 -0400

    gdk: Take a profile in gdk_texture_do_download
    
    Allow specifying a color profile in addition to
    a memory format when downloading.

 gdk/gdkgltexture.c      | 7 +++++--
 gdk/gdkmemorytexture.c  | 5 +++--
 gdk/gdktexture.c        | 5 ++++-
 gdk/gdktextureprivate.h | 2 ++
 4 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c
index 27acc486ed..629f41b745 100644
--- a/gdk/gdkgltexture.c
+++ b/gdk/gdkgltexture.c
@@ -115,6 +115,7 @@ typedef struct _Download Download;
 struct _Download
 {
   GdkMemoryFormat format;
+  GdkColorProfile *profile;
   guchar *data;
   gsize stride;
 };
@@ -212,7 +213,7 @@ gdk_gl_texture_do_download (gpointer texture_,
           gdk_memory_convert (download->data,
                               download->stride,
                               download->format,
-                              gdk_color_profile_get_srgb (),
+                              download->profile,
                               pixels,
                               texture->width * actual_bpp,
                               actual_format,
@@ -230,6 +231,7 @@ gdk_gl_texture_do_download (gpointer texture_,
 static void
 gdk_gl_texture_download (GdkTexture      *texture,
                          GdkMemoryFormat  format,
+                         GdkColorProfile *profile,
                          guchar          *data,
                          gsize            stride)
 {
@@ -238,11 +240,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, profile, data, stride);
       return;
     }
 
   download.format = format;
+  download.profile = profile;
   download.data = data;
   download.stride = stride;
 
diff --git a/gdk/gdkmemorytexture.c b/gdk/gdkmemorytexture.c
index 61f72a53e0..2e6f2cad5a 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,
+                             GdkColorProfile *profile,
                              guchar          *data,
                              gsize            stride)
 {
@@ -66,7 +67,7 @@ gdk_memory_texture_download (GdkTexture      *texture,
 
   gdk_memory_convert (data, stride,
                       format,
-                      gdk_color_profile_get_srgb (),
+                      profile,
                       (guchar *) g_bytes_get_data (self->bytes, NULL),
                       self->stride,
                       texture->format,
@@ -267,7 +268,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_profile_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 d298510be3..72b05f050f 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -226,6 +226,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkTexture, gdk_texture, G_TYPE_OBJECT,
 static void
 gdk_texture_default_download (GdkTexture      *texture,
                               GdkMemoryFormat  format,
+                              GdkColorProfile *profile,
                               guchar          *data,
                               gsize            stride)
 {
@@ -722,10 +723,11 @@ gdk_texture_get_color_profile (GdkTexture *texture)
 void
 gdk_texture_do_download (GdkTexture      *texture,
                          GdkMemoryFormat  format,
+                         GdkColorProfile *profile,
                          guchar          *data,
                          gsize            stride)
 {
-  GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, data,stride);
+  GDK_TEXTURE_GET_CLASS (texture)->download (texture, format, profile, data, stride);
 }
 
 cairo_surface_t *
@@ -788,6 +790,7 @@ gdk_texture_download (GdkTexture *texture,
 
   gdk_texture_do_download (texture,
                            GDK_MEMORY_DEFAULT,
+                           gdk_color_profile_get_srgb (),
                            data,
                            stride);
 }
diff --git a/gdk/gdktextureprivate.h b/gdk/gdktextureprivate.h
index 42b6a16266..37bc8ed0cf 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,
+                                                         GdkColorProfile        *profile,
                                                          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,
+                                                         GdkColorProfile        *profile,
                                                          guchar                 *data,
                                                          gsize                   stride);
 GdkMemoryFormat         gdk_texture_get_format          (GdkTexture             *self);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]