From 8860a2a688ba75c0078f4334fce0912000417072 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 4 Jun 2023 20:15:24 +0200 Subject: [PATCH 1/6] testsuite: fix memleak Also use the actual diff command we found instead of searching for it again. --- testsuite/testutils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/testsuite/testutils.c b/testsuite/testutils.c index d1776da7b5..6e8ba8e940 100644 --- a/testsuite/testutils.c +++ b/testsuite/testutils.c @@ -34,14 +34,16 @@ diff_with_file (const char *file1, gssize len, GError **error) { - const char *command[] = { "diff", "-u", file1, NULL, NULL }; - char *diff, *tmpfile; + char *diff_cmd, *diff, *tmpfile; int fd; diff = NULL; - if (g_find_program_in_path ("diff")) + diff_cmd = g_find_program_in_path ("diff"); + if (diff_cmd) { + const char *command[] = { diff_cmd, "-u", file1, NULL, NULL }; + if (len < 0) len = strlen (text); @@ -65,7 +67,7 @@ diff_with_file (const char *file1, g_spawn_sync (NULL, (char **) command, NULL, - G_SPAWN_SEARCH_PATH, + 0, NULL, NULL, &diff, NULL, NULL, @@ -74,6 +76,7 @@ diff_with_file (const char *file1, done: g_unlink (tmpfile); g_free (tmpfile); + g_free (diff_cmd); } else { From 8c5e046574b23b23e964d639b6c3fc99e8eefd6d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 21 May 2023 04:48:46 +0200 Subject: [PATCH 2/6] testsuite: Adapt color-matrix testcase Make it use an alpha value that is well defined, ie 0.4 instead of 0.5. 0.4 * 255 = 102 0.5 * 255 = 127.5 This avoids rounding issues where some math may cause the resulting alpha value to be 127, and some other math ends up with 128. --- .../gsk/compare/color-matrix-identity.node | 2 +- testsuite/gsk/compare/color-matrix-identity.png | Bin 162 -> 145 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/gsk/compare/color-matrix-identity.node b/testsuite/gsk/compare/color-matrix-identity.node index a81a474ad0..9498d08ba2 100644 --- a/testsuite/gsk/compare/color-matrix-identity.node +++ b/testsuite/gsk/compare/color-matrix-identity.node @@ -1,7 +1,7 @@ color-matrix { child: color { bounds: 0 0 50 50; - color: rgba(255, 0, 0, 0.5); + color: rgba(255, 0, 0, 0.4); } matrix: none; offset: 0 0 0 0; diff --git a/testsuite/gsk/compare/color-matrix-identity.png b/testsuite/gsk/compare/color-matrix-identity.png index f88dc6ac79dd429676eca7c10aa9b0e37bff66d5..7fcb5001c7f0847b370c10d3f0b84529c8c5b962 100644 GIT binary patch delta 74 zcmZ3)IFWIJifV+Xi(^Pe ei8X@aJy&WbSu>tATP7pH00f?{elF{r5}E*x6dj}h delta 89 zcmbQpxQKCriWysyx4R3&e-K=-cll%n28M7?7srr{#<%Aic^ec24jh<%@@C9*g@uOY s!duQ;Z+^~x?QKKw#0Zs%+5Dn*eTNwzTOQVa1=Pmi>FVdQ&MBb@08>CD4gdfE From c322ab34c701ca3f3b3939458c8fe873ba5d6a10 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 21 May 2023 05:03:49 +0200 Subject: [PATCH 3/6] rendernode: Use cairo_set_device_offset() Simplifies the code. --- gsk/gskrendernodeimpl.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index c60bd5b00f..9a17de149a 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -3956,27 +3956,23 @@ gsk_repeat_node_draw (GskRenderNode *node, cairo_pattern_t *pattern; cairo_surface_t *surface; cairo_t *surface_cr; + double scale_x, scale_y; surface = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, ceilf (self->child_bounds.size.width), ceilf (self->child_bounds.size.height)); + cairo_surface_get_device_scale (surface, &scale_x, &scale_y); + cairo_surface_set_device_offset (surface, + - self->child_bounds.origin.x * scale_x, + - self->child_bounds.origin.y * scale_y); + surface_cr = cairo_create (surface); - cairo_translate (surface_cr, - - self->child_bounds.origin.x, - - self->child_bounds.origin.y); gsk_render_node_draw (self->child, surface_cr); cairo_destroy (surface_cr); pattern = cairo_pattern_create_for_surface (surface); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); - cairo_pattern_set_matrix (pattern, - &(cairo_matrix_t) { - .xx = 1.0, - .yy = 1.0, - .x0 = - self->child_bounds.origin.x, - .y0 = - self->child_bounds.origin.y - }); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_surface_destroy (surface); From bba324ce3001523bd61f91c5f330771ff7bc065b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 5 Jun 2023 05:29:41 +0200 Subject: [PATCH 4/6] rendernode: Scale repeat offscreens properly Respect the matrix in use at time of encountering a repeat node so that the offscreen uses roughly the same device pixel density as the target. Fixes the handling of the clipped-repeat test. --- gsk/gskrendernodeimpl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 9a17de149a..33a317b735 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -3956,13 +3956,19 @@ gsk_repeat_node_draw (GskRenderNode *node, cairo_pattern_t *pattern; cairo_surface_t *surface; cairo_t *surface_cr; - double scale_x, scale_y; + double scale_x, scale_y, width, height; + cairo_matrix_t matrix; + cairo_get_matrix (cr, &matrix); + width = ceil (self->child_bounds.size.width * (ABS (matrix.xx) + ABS (matrix.yx))); + height = ceil (self->child_bounds.size.height * (ABS (matrix.xy) + ABS (matrix.yy))); surface = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR_ALPHA, - ceilf (self->child_bounds.size.width), - ceilf (self->child_bounds.size.height)); + width, height); cairo_surface_get_device_scale (surface, &scale_x, &scale_y); + scale_x *= width / self->child_bounds.size.width; + scale_y *= height / self->child_bounds.size.height; + cairo_surface_set_device_scale (surface, scale_x, scale_y); cairo_surface_set_device_offset (surface, - self->child_bounds.origin.x * scale_x, - self->child_bounds.origin.y * scale_y); From 9070c457d64cea44e927edcfaf7fe48dbf333490 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 21 May 2023 05:40:26 +0200 Subject: [PATCH 5/6] testsuite: Make clipped-repeat test work universally Cover the rounded corners so that they cause no visible difference in the end result. --- .../gsk/compare/clipped-repeat-3d-ngl.png | Bin 1760 -> 0 bytes ...repeat-3d-ngl.node => clipped-repeat.node} | 19 ++++++++++++++++++ testsuite/gsk/compare/clipped-repeat.png | Bin 0 -> 879 bytes testsuite/gsk/meson.build | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) delete mode 100644 testsuite/gsk/compare/clipped-repeat-3d-ngl.png rename testsuite/gsk/compare/{clipped-repeat-3d-ngl.node => clipped-repeat.node} (74%) create mode 100644 testsuite/gsk/compare/clipped-repeat.png diff --git a/testsuite/gsk/compare/clipped-repeat-3d-ngl.png b/testsuite/gsk/compare/clipped-repeat-3d-ngl.png deleted file mode 100644 index b9a847d7c13af6db15e3b19941cba0006821ed27..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1760 zcmdUweN>WH9LKM=uoulJOOKLnc&fwNrkNX3m|NmYs9DrGg)hTnHDgOKrvf3$Y^}!} zxrVPn+K!>Q7t1*@U!bO?Cp9=8GGBlc91=$nof#0Id$j%0+28%M^PKa0zRx}9{+@e( zzwiCr!o!E6+}3%o0|2-kj3$r(aL$D_v<3l3&bd!A;1?n_CW-)-mY*AvIzBv5dXVth zF{aR{ZlrmTw{kUK)A#vD-1JR7fMEF-#9^Cyw<0v2Ub~$hZ2Z)9?WpJMEp=J@T=)-U z*Y|dZUyd%!7*eP3hKhdTC96H8^PEji#!TyT!o8o5C1WO2LQo&+h4k7I+Rc)NQc^?Y zgHq`3lLZz3(M=n7{gdFhG5`Kk`RZW`_T>=Ik$rMS>Q!Ss5YrDy_t(Y|4TD*GIjt=% z=7uSJjNb9kXf*cW^pBwv#Zaldx}4M|dk4%ivM}fd-$h#*W_zY=Aoy_}k;*$iH4Rrrv23)7vd$ISa05p zINg>8g#vChoL(nyZfM2TI9@?^@x_dPk zcYa?aJkz?gUOI5*MIfHH9%NkoE!P^#iTV?Z+E9L!Se$Q<1)zUqVsLO!Ctt#?lXeY> zoWS94g!4y~ItW^>rY4&Tz{jmEjg9AU+CWRDOyH2M0{1(%p-^Wd?WVGs^Tka7+ySDJ z1qi~!X}kEX@Pq_%a&oc^rx$SIox%N7SHuMYPLx$+`V4>*-;;WILQ>mP^Sc0i(BGUy zY#lXwEXzR@^7yMNXTZJK`lG*=Gh5%;#XA&z_os<%-N-#jq|A)cpgr`o3haWOd704WlI!*#O{di+}sYI+>yoZ?r#2s-(La6 z(HO_eiAg7rQk5y&nJ`0`<@HPqVMLGp_H2RyK_ZSMQ7HKioqlIQ06G=#yL6Rw{*I*) zMg-r*$Hyl>*XTlVlR^-Tp4b;KCf2yq)NKpXiDC9HW+PA$)k^qxVfCcm$zO+yLbhAb zS7@e1@2Y33fu(XYV?*c3Ws~6G)_Z;pu k5p#P~%wgHLQ1uIbydA=t diff --git a/testsuite/gsk/compare/clipped-repeat-3d-ngl.node b/testsuite/gsk/compare/clipped-repeat.node similarity index 74% rename from testsuite/gsk/compare/clipped-repeat-3d-ngl.node rename to testsuite/gsk/compare/clipped-repeat.node index 288560c89d..86fe2159af 100644 --- a/testsuite/gsk/compare/clipped-repeat-3d-ngl.node +++ b/testsuite/gsk/compare/clipped-repeat.node @@ -30,3 +30,22 @@ transform { } transform: translate(6, 20); } + +/* cover the rounded corners */ +color { + color: red; + bounds: 6 20 25 25; +} +color { + color: red; + bounds: 617 20 25 25; +} +color { + color: red; + bounds: 6 131 25 25; +} +color { + color: red; + bounds: 617 131 25 25; +} + diff --git a/testsuite/gsk/compare/clipped-repeat.png b/testsuite/gsk/compare/clipped-repeat.png new file mode 100644 index 0000000000000000000000000000000000000000..cffc4dca25937f62757b5a8912dea3d7bea1a14e GIT binary patch literal 879 zcmeAS@N?(olHy`uVBq!ia0y~yV5$MKJ2=>YWNo2Y0RscGnWu|mNX4ADcO3Ji4MkWT z)h`H29&wjBxMy)OGvlf2858`j#wmOaZIwpQ($_zwzt&OLYc@0?mW$3fOK8j>xqx}?f2); zUoKx{-*@>u1H%vT+PAg8B;$xlMCH}T6{|lu9^873JO5MFr~SDUT#`SqC@ i3{;6R3}3SS%b0K^KeHu#lPWMHF?hQAxvX Date: Sat, 27 May 2023 19:05:32 +0200 Subject: [PATCH 6/6] stringsorter: Handle NULL strings NULL is a valid string GValue, so we need to handle it. The utf8 normalizing and collating functions do not, so we better catch it early. --- gtk/gtkstringsorter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gtk/gtkstringsorter.c b/gtk/gtkstringsorter.c index 15866b9304..694e6318c5 100644 --- a/gtk/gtkstringsorter.c +++ b/gtk/gtkstringsorter.c @@ -77,6 +77,11 @@ gtk_string_sorter_get_key (GtkExpression *expression, return NULL; string = g_value_get_string (&value); + if (string == NULL) + { + g_value_unset (&value); + return NULL; + } if (ignore_case) s = g_utf8_casefold (string, -1);