summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-13 06:47:46 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-13 19:37:16 -0400
commit809299f9e48662c731123181d54f4fc66891aca4 (patch)
tree6f70508a3ea50db8a13e5b988e3475a626f8c97f
parentc391cf38e26cdbeebbd77310255ed1b59d7149d2 (diff)
downloadgtk+-809299f9e48662c731123181d54f4fc66891aca4.tar.gz
Add some more transform tests
Test that gsk_transform_to_affine works.
-rw-r--r--testsuite/gsk/transform.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/gsk/transform.c b/testsuite/gsk/transform.c
index caf9f72b69..b87699d5c7 100644
--- a/testsuite/gsk/transform.c
+++ b/testsuite/gsk/transform.c
@@ -524,6 +524,49 @@ test_axis_aligned (void)
gsk_transform_unref (transform);
}
+static void
+test_to_affine (void)
+{
+ GskTransform *transform;
+ float sx, sy, dx, dy;
+
+ transform = gsk_transform_scale (NULL, 10.0, 5.0);
+ gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
+ gsk_transform_unref (transform);
+
+ g_assert_cmpfloat (sx, ==, 10.0);
+ g_assert_cmpfloat (sy, ==, 5.0);
+ g_assert_cmpfloat (dx, ==, 0.0);
+ g_assert_cmpfloat (dy, ==, 0.0);
+
+ transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (10.0, 5.0));
+ gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
+ gsk_transform_unref (transform);
+
+ g_assert_cmpfloat (sx, ==, 1.0);
+ g_assert_cmpfloat (sy, ==, 1.0);
+ g_assert_cmpfloat (dx, ==, 10.0);
+ g_assert_cmpfloat (dy, ==, 5.0);
+
+ transform = gsk_transform_translate (gsk_transform_scale (NULL, 2.0, 3.0), &GRAPHENE_POINT_INIT (10.0, 5.0));
+ gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
+ gsk_transform_unref (transform);
+
+ g_assert_cmpfloat (sx, ==, 2.0);
+ g_assert_cmpfloat (sy, ==, 3.0);
+ g_assert_cmpfloat (dx, ==, 2.0 * 10.0);
+ g_assert_cmpfloat (dy, ==, 3.0 * 5.0);
+
+ transform = gsk_transform_scale (gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (10.0, 5.0)), 2.0, 3.0);
+ gsk_transform_to_affine (transform, &sx, &sy, &dx, &dy);
+ gsk_transform_unref (transform);
+
+ g_assert_cmpfloat (sx, ==, 2.0);
+ g_assert_cmpfloat (sy, ==, 3.0);
+ g_assert_cmpfloat (dx, ==, 10.0);
+ g_assert_cmpfloat (dy, ==, 5.0);
+}
+
int
main (int argc,
char *argv[])
@@ -537,6 +580,7 @@ main (int argc,
g_test_add_func ("/transform/invert", test_invert);
g_test_add_func ("/transform/print-parse", test_print_parse);
g_test_add_func ("/transform/check-axis-aligneness", test_axis_aligned);
+ g_test_add_func ("/transform/to-affine", test_to_affine);
return g_test_run ();
}