From 865564b32f2e3ff951d6634984dbb3185d416f26 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 11 Feb 2024 19:28:43 -0500 Subject: [PATCH 1/2] gsk: Make matrix transforms roundtrip better When we parse a 2D matrix, we produce a 2D transform, and we can easily regenerate a 2D matrix from it. Tests included. --- gsk/gsktransform.c | 34 +++++++++++++++++++++++++++------- testsuite/gsk/transform.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c index ada7164e37..4ab9e9dc79 100644 --- a/gsk/gsktransform.c +++ b/gsk/gsktransform.c @@ -382,15 +382,35 @@ gsk_matrix_transform_print (GskTransform *transform, guint i; float f[16]; - g_string_append (string, "matrix3d("); - graphene_matrix_to_float (&self->matrix, f); - for (i = 0; i < 16; i++) + if (transform->category >= GSK_TRANSFORM_CATEGORY_2D) { - if (i > 0) - g_string_append (string, ", "); - string_append_double (string, f[i]); + g_string_append (string, "matrix("); + graphene_matrix_to_float (&self->matrix, f); + string_append_double (string, f[0]); + g_string_append (string, ", "); + string_append_double (string, f[1]); + g_string_append (string, ", "); + string_append_double (string, f[4]); + g_string_append (string, ", "); + string_append_double (string, f[5]); + g_string_append (string, ", "); + string_append_double (string, f[12]); + g_string_append (string, ", "); + string_append_double (string, f[13]); + g_string_append (string, ")"); + } + else + { + g_string_append (string, "matrix3d("); + graphene_matrix_to_float (&self->matrix, f); + for (i = 0; i < 16; i++) + { + if (i > 0) + g_string_append (string, ", "); + string_append_double (string, f[i]); + } + g_string_append (string, ")"); } - g_string_append (string, ")"); } static GskTransform * diff --git a/testsuite/gsk/transform.c b/testsuite/gsk/transform.c index 01220a2b2f..7075ce9533 100644 --- a/testsuite/gsk/transform.c +++ b/testsuite/gsk/transform.c @@ -967,6 +967,33 @@ test_matrix_transform (void) gsk_transform_unref (t2); } +static void +test_matrix_roundtrip (void) +{ + GskTransform *transform; + gboolean res; + const char *input; + char *str; + + input = "matrix(2, 3, 4, 5, 6, 7)"; + res = gsk_transform_parse (input, &transform); + g_assert_true (res); + g_assert_true (gsk_transform_get_category (transform) >= GSK_TRANSFORM_CATEGORY_2D); + + str = gsk_transform_to_string (transform); + g_assert_cmpstr (str, ==, input); + g_free (str); + + input = "matrix3d(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)"; + res = gsk_transform_parse (input, &transform); + g_assert_true (res); + g_assert_true (gsk_transform_get_category (transform) < GSK_TRANSFORM_CATEGORY_2D); + + str = gsk_transform_to_string (transform); + g_assert_cmpstr (str, ==, input); + g_free (str); +} + int main (int argc, char *argv[]) @@ -991,6 +1018,7 @@ main (int argc, g_test_add_func ("/transform/rotate", test_rotate_transform); g_test_add_func ("/transform/rotate3d", test_rotate3d_transform); g_test_add_func ("/transform/matrix", test_matrix_transform); + g_test_add_func ("/transform/matrix/roundtrip", test_matrix_roundtrip); return g_test_run (); } From 9bd6d431afd25cd9a93f4b574b4410a3cf479193 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 11 Feb 2024 19:02:39 -0500 Subject: [PATCH 2/2] ci: Capture generated node files for gsk tests For some of the compare render variations (mask, clip, etc), it can be quite useful to have the generated node file around to reproduce the problem. --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f209dcc5a9..3c50f78cd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,6 +78,7 @@ style-check-diff: - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.node" - "${CI_PROJECT_DIR}/_build/testsuite/tools/output/*/*" - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png" + - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.node" - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap" - "${CI_PROJECT_DIR}/_build/testsuite/headless/*/*.log" - "${CI_PROJECT_DIR}/_build_hello/meson-logs"