[gtk/wip/otte/color-profiles: 3/4] ngl: Linearize colors too
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/color-profiles: 3/4] ngl: Linearize colors too
- Date: Thu, 30 Sep 2021 11:35:05 +0000 (UTC)
commit 1be2d6fa7f09a5d6e4fe406942387c8e30988b7d
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 30 07:24:28 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 | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index f882a3e8ee..4582ad06c3 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>
@@ -925,11 +926,24 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
return TRUE;
}
+/* Convert from sRGB floats to linear sRGB half-floats */
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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]