summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2019-03-03 17:57:11 +0100
committerBenjamin Otte <otte@redhat.com>2019-03-04 23:41:51 +0100
commit3545abc7a1731a5714e5f541c6aa966a48e27ffe (patch)
tree982e63c54690f79ee35c8db85c8da61952b3967a /testsuite
parent70b341139b48a7ee2bbb5bf6ba133fbe673fd2e5 (diff)
downloadgtk+-3545abc7a1731a5714e5f541c6aa966a48e27ffe.tar.gz
transform: Implement gsk_transform_invert()
And use it. And test it.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/transform.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/testsuite/gtk/transform.c b/testsuite/gtk/transform.c
index 0d7a8ad9f1..0a71af4fd0 100644
--- a/testsuite/gtk/transform.c
+++ b/testsuite/gtk/transform.c
@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
-#define EPSILON (1.f / 1024 / 1024)
+#define EPSILON (1.f / 1024 / 32) /* 2^-15 */
/* macros stolen from graphene testsuite, so they get to keep their names */
@@ -66,6 +66,14 @@
} \
} G_STMT_END
+#define graphene_assert_fuzzy_transform_equal(t1,t2,epsilon) \
+ G_STMT_START { \
+ graphene_matrix_t __mat1, __mat2; \
+ gsk_transform_to_matrix ((t1), &__mat1); \
+ gsk_transform_to_matrix ((t2), &__mat2); \
+ graphene_assert_fuzzy_matrix_equal (&__mat1, &__mat2, (epsilon)); \
+ } G_STMT_END
+
static struct {
GskTransformCategory category;
} test_transforms[] = {
@@ -235,6 +243,38 @@ test_conversions_transformed (void)
}
}
+static void
+test_invert (void)
+{
+ GskTransform *transform, *inverse, *identity;
+ guint i, j, k;
+
+ for (i = 0; i < G_N_ELEMENTS (test_transforms); i++)
+ {
+ for (j = 0; j < G_N_ELEMENTS (test_transforms); j++)
+ {
+ for (k = 0; k < G_N_ELEMENTS (test_transforms); k++)
+ {
+ transform = apply_test_transform (NULL, i);
+ transform = apply_test_transform (transform, j);
+ transform = apply_test_transform (transform, k);
+ inverse = gsk_transform_invert (gsk_transform_ref (transform));
+ g_assert (inverse != NULL || transform == NULL);
+
+ identity = gsk_transform_transform (gsk_transform_ref (transform), inverse);
+ graphene_assert_fuzzy_transform_equal (identity, NULL, EPSILON);
+ gsk_transform_unref (identity);
+
+ inverse = gsk_transform_invert (inverse);
+ graphene_assert_fuzzy_transform_equal (transform, inverse, EPSILON);
+
+ gsk_transform_unref (transform);
+ gsk_transform_unref (inverse);
+ }
+ }
+ }
+}
+
int
main (int argc,
char *argv[])
@@ -243,6 +283,7 @@ main (int argc,
g_test_add_func ("/transform/conversions/simple", test_conversions_simple);
g_test_add_func ("/transform/conversions/transformed", test_conversions_transformed);
+ g_test_add_func ("/transform/invert", test_invert);
return g_test_run ();
}