Merge branch 'matthiasc/for-main' into 'main'

gsk: Make matrix transforms roundtrip better

See merge request GNOME/gtk!6886
This commit is contained in:
Matthias Clasen 2024-02-12 01:18:34 +00:00
commit a9949a102b
3 changed files with 56 additions and 7 deletions

View File

@ -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"

View File

@ -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 *

View File

@ -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 ();
}