From 3ccd03e22659e82a4fdea1a550320d1d2a531c80 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 12 Jul 2024 16:55:49 -0400 Subject: [PATCH 1/4] Updates --- NEWS | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/NEWS b/NEWS index bb4249adf87..eca9d535ff8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,41 @@ Overview of Changes in 4.15.4, xx-xx-xxxx ========================================= +* GtkPopover: + - Fix size allocation with wrapping labels + +* CSS: + - Fix fallout from recent changes + - Make implementation of currentcolor inheritance match browsers + +* Gdk: + - Introduce GdkColorState for encoding color space information + +* Gsk: + - Improve caching of glyphs and textures + - Remove the uber shader + - Numerous bug fixes + - Fix corner cases in offload handling + - Implement occlusion culling for opaque content + - Allow offloading (some) transformed textures + - Take colorstate into account when compositing + - Add GDK_DEBUG=linear to opt into linear compositing + - Implement tiling for large textures + +* Wayland: + - Allow offloading GL textures via dmabuf export + +* Deprecations: + - GskGLShader and the render node + +* Tools: + - Improve the rendernode tool extract command + +* Translation updates + Georgian + Hindi + + Overview of Changes in 4.15.3, 29-06-2024 ========================================= -- GitLab From abb7e85260fdf999a95fb23a20b3525b9d9b2210 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 8 Jul 2024 19:16:08 -0400 Subject: [PATCH 2/4] colorstate: Consistent naming Make the conversion functions use srgb_linear in their names, since the name of the color state is srgb-linear. --- gdk/gdkcolorstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdk/gdkcolorstate.c b/gdk/gdkcolorstate.c index 4d8a53f541d..effc8fd5969 100644 --- a/gdk/gdkcolorstate.c +++ b/gdk/gdkcolorstate.c @@ -174,7 +174,7 @@ srgb_eotf (float v) } static void -gdk_default_srgb_to_linear_srgb (GdkColorState *self, +gdk_default_srgb_to_srgb_linear (GdkColorState *self, float (*values)[4], gsize n_values) { @@ -235,7 +235,7 @@ GdkDefaultColorState gdk_default_color_states[] = { .name = "srgb", .no_srgb = GDK_COLOR_STATE_SRGB_LINEAR, .convert_to = { - [GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_srgb_to_linear_srgb, + [GDK_COLOR_STATE_ID_SRGB_LINEAR] = gdk_default_srgb_to_srgb_linear, }, }, [GDK_COLOR_STATE_ID_SRGB_LINEAR] = { -- GitLab From b0effee9b3abe9a57dd4953d56c142bfc763286f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 8 Jul 2024 22:03:00 -0400 Subject: [PATCH 3/4] colorstate: Add tests for conversions Test roundtrip tests between color states. For now, this just tests srgb<>srgb-linear. --- testsuite/gdk/colorstate.c | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/testsuite/gdk/colorstate.c b/testsuite/gdk/colorstate.c index 0f402e653a0..28746e5fb3c 100644 --- a/testsuite/gdk/colorstate.c +++ b/testsuite/gdk/colorstate.c @@ -1,4 +1,7 @@ #include +#include +#include +#include static void test_srgb (void) @@ -14,12 +17,100 @@ test_srgb (void) g_assert_false (gdk_color_state_equal (srgb, srgb_linear)); } +static float +image_distance (const guchar *data, + const guchar *data2, + gsize width, + gsize height, + gsize stride) +{ + float dist = 0; + + for (gsize i = 0; i < height; i++) + { + const float *p = (const float *) (data + i * stride); + const float *p2 = (const float *) (data2 + i * stride); + + for (gsize j = 0; j < width; j++) + { + float dr, dg, db, da; + + dr = p[4 * j + 0] - p2[4 * j + 0]; + dg = p[4 * j + 1] - p2[4 * j + 1]; + db = p[4 * j + 2] - p2[4 * j + 2]; + da = p[4 * j + 3] - p2[4 * j + 3]; + + dist = MAX (dist, dr * dr + dg * dg + db * db + da * da); + } + } + + return sqrt (dist); +} + +static void +test_convert (gconstpointer testdata) +{ + GdkColorState *cs; + char *path; + GdkTexture *texture; + GdkTextureDownloader *downloader; + GError *error = NULL; + GBytes *bytes; + const guchar *data; + guchar *data2; + gsize width, height; + gsize size; + gsize stride; + + cs = gdk_color_state_get_by_id ((GdkColorStateId) GPOINTER_TO_UINT (testdata)); + + path = g_test_build_filename (G_TEST_DIST, "image-data", "image.png", NULL); + + texture = gdk_texture_new_from_filename (path, &error); + g_assert_no_error (error); + + width = gdk_texture_get_width (texture); + height = gdk_texture_get_height (texture); + + downloader = gdk_texture_downloader_new (texture); + gdk_texture_downloader_set_format (downloader, GDK_MEMORY_R32G32B32A32_FLOAT); + + bytes = gdk_texture_downloader_download_bytes (downloader, &stride); + data = g_bytes_get_data (bytes, &size); + data2 = g_memdup2 (data, size); + + gdk_memory_convert_color_state (data2, + stride, + GDK_MEMORY_R32G32B32A32_FLOAT, + gdk_texture_get_color_state (texture), + cs, + width, + height); + + gdk_memory_convert_color_state (data2, + stride, + GDK_MEMORY_R32G32B32A32_FLOAT, + cs, + gdk_texture_get_color_state (texture), + width, + height); + + g_assert_true (image_distance (data, data2, width, height, stride) < 0.001); + + g_free (data2); + g_bytes_unref (bytes); + gdk_texture_downloader_free (downloader); + g_object_unref (texture); + g_free (path); +} + int main (int argc, char *argv[]) { (g_test_init) (&argc, &argv, NULL); g_test_add_func ("/colorstate/srgb", test_srgb); + g_test_add_data_func ("/colorstate/convert/srgb<->srgb-linear", GUINT_TO_POINTER (GDK_COLOR_STATE_ID_SRGB_LINEAR), test_convert); return g_test_run (); } -- GitLab From d0e2d9e2f4831b1760e4445979326aa8f0b26247 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 10 Jul 2024 16:13:54 -0400 Subject: [PATCH 4/4] colorstate: Small reorg Introduce a helper macro. --- gdk/gdkcolorstate.c | 73 ++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/gdk/gdkcolorstate.c b/gdk/gdkcolorstate.c index effc8fd5969..f83963d30d3 100644 --- a/gdk/gdkcolorstate.c +++ b/gdk/gdkcolorstate.c @@ -131,6 +131,7 @@ gboolean /* }}} */ /* {{{ Default implementation */ +/* {{{ Vfuncs */ static gboolean gdk_default_color_state_equal (GdkColorState *self, @@ -155,6 +156,35 @@ gdk_default_color_state_get_no_srgb_tf (GdkColorState *color_state) return self->no_srgb; } +static GdkFloatColorConvert +gdk_default_color_state_get_convert_to (GdkColorState *color_state, + GdkColorState *target) +{ + GdkDefaultColorState *self = (GdkDefaultColorState *) color_state; + + if (!GDK_IS_DEFAULT_COLOR_STATE (target)) + return NULL; + + return self->convert_to[GDK_DEFAULT_COLOR_STATE_ID (target)]; +} + +/* }}} */ +/* {{{ Conversion functions */ + +#define COORDINATE_TRANSFORM(name, tf) \ +static void \ +name(GdkColorState *self, \ + float (*values)[4], \ + gsize n_values) \ +{ \ + for (gsize i = 0; i < n_values; i++) \ + { \ + values[i][0] = tf (values[i][0]); \ + values[i][1] = tf (values[i][1]); \ + values[i][2] = tf (values[i][2]); \ + } \ +} + static inline float srgb_oetf (float v) { @@ -173,47 +203,10 @@ srgb_eotf (float v) return v / 12.92f; } -static void -gdk_default_srgb_to_srgb_linear (GdkColorState *self, - float (*values)[4], - gsize n_values) -{ - gsize i; - - for (i = 0; i < n_values; i++) - { - values[i][0] = srgb_eotf (values[i][0]); - values[i][1] = srgb_eotf (values[i][1]); - values[i][2] = srgb_eotf (values[i][2]); - } -} - -static void -gdk_default_srgb_linear_to_srgb (GdkColorState *self, - float (*values)[4], - gsize n_values) -{ - gsize i; - - for (i = 0; i < n_values; i++) - { - values[i][0] = srgb_oetf (values[i][0]); - values[i][1] = srgb_oetf (values[i][1]); - values[i][2] = srgb_oetf (values[i][2]); - } -} - -static GdkFloatColorConvert -gdk_default_color_state_get_convert_to (GdkColorState *color_state, - GdkColorState *target) -{ - GdkDefaultColorState *self = (GdkDefaultColorState *) color_state; - - if (!GDK_IS_DEFAULT_COLOR_STATE (target)) - return NULL; +COORDINATE_TRANSFORM(gdk_default_srgb_to_srgb_linear, srgb_eotf) +COORDINATE_TRANSFORM(gdk_default_srgb_linear_to_srgb, srgb_oetf) - return self->convert_to[GDK_DEFAULT_COLOR_STATE_ID (target)]; -} +/* }}} */ static const GdkColorStateClass GDK_DEFAULT_COLOR_STATE_CLASS = { -- GitLab