[gtk/matthiasc/color-profile-rebased: 8/22] gsk: Upload textures in linear sRGB




commit 24e9abdfae02fa9ebc94b7f7deda74992d03ea07
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 8 13:04:04 2022 -0400

    gsk: Upload textures in linear sRGB
    
    We want to do compositing in a linear colorspace,
    so convert textures to linear sRGB before uploading.
    
    Currently, this causes images to come out dark, since
    we don't have a way to tell the compositor that our
    framebuffer is linear, so it assumes a gamma that we
    don't provide.

 gsk/gl/gskglcommandqueue.c | 3 ++-
 gsk/gl/gskglglyphlibrary.c | 5 +++--
 gsk/gl/gskgliconlibrary.c  | 4 ++--
 gsk/gl/gskglrenderjob.c    | 3 +++
 4 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c
index 584ece82f0..a63e6d700e 100644
--- a/gsk/gl/gskglcommandqueue.c
+++ b/gsk/gl/gskglcommandqueue.c
@@ -28,6 +28,7 @@
 #include <gdk/gdkglcontextprivate.h>
 #include <gdk/gdkmemoryformatprivate.h>
 #include <gdk/gdkmemorytextureprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
 #include <gdk/gdkprofilerprivate.h>
 #include <gsk/gskdebugprivate.h>
 #include <gsk/gskroundedrectprivate.h>
@@ -1391,7 +1392,7 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
         }
     }
 
-  memtex = gdk_memory_texture_from_texture (texture, data_format, gdk_color_profile_get_srgb ());
+  memtex = gdk_memory_texture_from_texture (texture, data_format, gdk_color_profile_get_srgb_linear ());
   data = gdk_memory_texture_get_data (memtex);
   stride = gdk_memory_texture_get_stride (memtex);
   bpp = gdk_memory_format_bytes_per_pixel (data_format);
diff --git a/gsk/gl/gskglglyphlibrary.c b/gsk/gl/gskglglyphlibrary.c
index ae36915323..1872c0c290 100644
--- a/gsk/gl/gskglglyphlibrary.c
+++ b/gsk/gl/gskglglyphlibrary.c
@@ -22,6 +22,7 @@
 
 #include <gdk/gdkglcontextprivate.h>
 #include <gdk/gdkmemoryformatprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
 #include <gdk/gdkprofilerprivate.h>
 
 #include "gskglcommandqueueprivate.h"
@@ -284,11 +285,11 @@ gsk_gl_glyph_library_upload_glyph (GskGLGlyphLibrary     *self,
       gdk_memory_convert (pixel_data,
                           width * 4,
                           GDK_MEMORY_R8G8B8A8_PREMULTIPLIED,
-                          gdk_color_profile_get_srgb (),
+                          gdk_color_profile_get_srgb_linear (),
                           cairo_image_surface_get_data (surface),
                           width * 4,
                           GDK_MEMORY_DEFAULT,
-                          gdk_color_profile_get_srgb (),
+                          gdk_color_profile_get_srgb_linear (),
                           width, height);
       gl_format = GL_RGBA;
       gl_type = GL_UNSIGNED_BYTE;
diff --git a/gsk/gl/gskgliconlibrary.c b/gsk/gl/gskgliconlibrary.c
index 28fea92e6f..b412741252 100644
--- a/gsk/gl/gskgliconlibrary.c
+++ b/gsk/gl/gskgliconlibrary.c
@@ -23,6 +23,7 @@
 #include <gdk/gdkglcontextprivate.h>
 #include <gdk/gdkmemoryformatprivate.h>
 #include <gdk/gdkprofilerprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
 #include <gdk/gdktextureprivate.h>
 #include <gdk/gdkmemorytextureprivate.h>
 
@@ -97,7 +98,6 @@ gsk_ngl_texture_prepare_upload (GdkGLContext *context,
       g_object_unref (memtex);
 
       format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
-      profile = gdk_color_profile_get_srgb ();
       if (!gdk_memory_format_gl_format (format,
                                         gdk_gl_context_get_use_es (context),
                                         gl_internalformat,
@@ -108,7 +108,7 @@ gsk_ngl_texture_prepare_upload (GdkGLContext *context,
         }
     }
 
-  return gdk_memory_texture_from_texture (texture, format, profile);
+  return gdk_memory_texture_from_texture (texture, format, gdk_color_profile_get_srgb_linear ());
 }
 
 static void
diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c
index 97b3d9d4c9..f235bdf7d8 100644
--- a/gsk/gl/gskglrenderjob.c
+++ b/gsk/gl/gskglrenderjob.c
@@ -26,6 +26,7 @@
 #include <gdk/gdkglcontextprivate.h>
 #include <gdk/gdkprofilerprivate.h>
 #include <gdk/gdkrgbaprivate.h>
+#include <gdk/gdkcolorprofileprivate.h>
 #include <gsk/gskrendernodeprivate.h>
 #include <gsk/gskglshaderprivate.h>
 #include <gdk/gdktextureprivate.h>
@@ -1226,6 +1227,8 @@ gsk_gl_render_job_visit_as_fallback (GskGLRenderJob      *job,
                                                    surface_width,
                                                    surface_height);
 
+    gdk_cairo_surface_set_color_profile (rendered_surface, gdk_color_profile_get_srgb_linear ());
+
     cairo_surface_set_device_scale (rendered_surface, scale_x, scale_y);
     cr = cairo_create (rendered_surface);
 


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