[gtk/matthiasc/color-profiles: 2/3] ngl: Linearize colors too




commit 4fd497eb0f92022a4fb4672d2e6e8ccb519fbb97
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 29 23:27:57 2021 -0400

    ngl: 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/ngl/gsknglrenderjob.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 4237756675..744a3a8f0f 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -30,6 +30,7 @@
 #include <gsk/gskglshaderprivate.h>
 #include <gdk/gdktextureprivate.h>
 #include <gdk/gdkcolorprofileprivate.h>
+#include <gdk/gdkmemoryformatprivate.h>
 #include <gsk/gsktransformprivate.h>
 #include <gsk/gskroundedrectprivate.h>
 #include <math.h>
@@ -929,7 +930,19 @@ static inline void
 rgba_to_half (const GdkRGBA *rgba,
               guint16        h[4])
 {
-  float_to_half4 ((const float *)rgba, h);
+  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 *)&d, h);
 }
 
 /* fill_vertex_data */
@@ -3997,11 +4010,10 @@ static void
 gsk_ngl_render_job_postprocess (GskNglRenderJob *job,
                                 guint            texture_id)
 {
-  GskNglProgram *program = job->driver->postprocessing_no_clip;
-
   gsk_ngl_command_queue_bind_framebuffer (job->command_queue, job->framebuffer);
+  gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
 
-  gsk_ngl_render_job_begin_draw (job, program);
+  gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, postprocessing));
   gsk_ngl_program_set_uniform_texture (job->current_program,
                                        UNIFORM_SHARED_SOURCE, 0,
                                        GL_TEXTURE_2D, GL_TEXTURE0, texture_id);


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