[gtk/matthiasc/color-profile-rebased: 3/15] gsk: Linearize colors too




commit 87734dc11b1ad8a3bf7a54c6d51740812b2a6bf8
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 8 13:19:59 2022 -0400

    gsk: Linearize colors too
    
    Convert all the GdkRGBA colors that we have
    in render nodes to linear sRGB before using
    them. This brings the rendering back in line
    with what cairo produces, except for the video.

 gsk/gl/gskglrenderjob.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c
index 19768662d7..d1d43b0b6d 100644
--- a/gsk/gl/gskglrenderjob.c
+++ b/gsk/gl/gskglrenderjob.c
@@ -27,6 +27,7 @@
 #include <gdk/gdkprofilerprivate.h>
 #include <gdk/gdkrgbaprivate.h>
 #include <gdk/gdkcolorprofileprivate.h>
+#include <gdk/gdkmemoryformatprivate.h>
 #include <gsk/gskrendernodeprivate.h>
 #include <gsk/gskglshaderprivate.h>
 #include <gdk/gdktextureprivate.h>
@@ -989,10 +990,23 @@ gsk_gl_render_job_update_clip (GskGLRenderJob        *job,
   return TRUE;
 }
 
+/* Convert from sRGB floats to linear sRGB half-floats */
 static inline void
 rgba_to_half (const GdkRGBA *rgba,
               guint16        h[4])
 {
+  GdkRGBA d;
+  gdk_memory_convert ((guchar *) &d,
+                      sizeof (float) * 4,
+                      GDK_MEMORY_R32G32B32_FLOAT,
+                      gdk_color_profile_get_srgb_linear (),
+                      (guchar *) rgba,
+                      sizeof (float) * 4,
+                      GDK_MEMORY_R32G32B32_FLOAT,
+                      gdk_color_profile_get_srgb (),
+                      1,
+                      1);
+  d.alpha = rgba->alpha;
   float_to_half4 ((const float *)rgba, h);
 }
 


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