From 246a7cfeab3a8c416d846312091a1f9ce6987963 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Tue, 15 Aug 2023 11:28:43 +0300 Subject: [PATCH] rendernode, snapshot: Slightly expand color matrix docs Based on reverse engineering the color node and contrary to my expectations, the matrix/offset is expressed in, and applied to, unpremultiplied colors. The colors are being explicitly unpremultiplied, transformed according to the matrix/offset, and premultiplied back (see color_matrix.glsl). The matrix is getting transposed. Also, copy the same blurb to the corresponding GtkSnapshot function. Signed-off-by: Sergey Bugaev --- gsk/gskrendernodeimpl.c | 7 ++++--- gtk/gtksnapshot.c | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 394801ce0b..f65045cb4e 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -3841,11 +3841,12 @@ gsk_color_matrix_node_class_init (gpointer g_class, * Creates a `GskRenderNode` that will drawn the @child with * @color_matrix. * - * In particular, the node will transform the operation + * In particular, the node will transform colors by applying * - * pixel = color_matrix * pixel + color_offset + * pixel = transpose(color_matrix) * pixel + color_offset * - * for every pixel. + * for every pixel. The transformation operates on unpremultiplied + * colors, with color components ordered R, G, B, A. * * Returns: (transfer full) (type GskColorMatrixNode): A new `GskRenderNode` */ diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 5b6adcdf83..9cd4d4ae09 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -656,6 +656,13 @@ gtk_snapshot_collect_color_matrix (GtkSnapshot *snapshot, * Modifies the colors of an image by applying an affine transformation * in RGB space. * + * In particular, the colors will be transformed by applying + * + * pixel = transpose(color_matrix) * pixel + color_offset + * + * for every pixel. The transformation operates on unpremultiplied + * colors, with color components ordered R, G, B, A. + * * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. */ void