summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2020-12-24 06:32:17 +0100
committerBenjamin Otte <otte@redhat.com>2020-12-24 06:38:45 +0100
commitdee863dbb2bb2ed8b5922b2a1f9d5f5dea2dcbcc (patch)
tree44bd4ffca54c2c0f3ecfa95b680f7c5cce03e578
parentdb08bccb1133b771e73058db60781eff8fd77105 (diff)
downloadgtk+-dee863dbb2bb2ed8b5922b2a1f9d5f5dea2dcbcc.tar.gz
rendernode: Bail if matrix is invalid
Invalid matrices are okay in GSK (and GL), but not in Cairo. Testcase included.
-rw-r--r--gsk/gskrendernodeimpl.c10
-rw-r--r--testsuite/gsk/compare/invalid-transform.node16
-rw-r--r--testsuite/gsk/compare/invalid-transform.pngbin0 -> 86 bytes
-rw-r--r--testsuite/gsk/meson.build1
4 files changed, 27 insertions, 0 deletions
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index aa19233f4e..6d9a3fd50f 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -2755,6 +2755,16 @@ gsk_transform_node_draw (GskRenderNode *node,
ctm.xx, ctm.yx,
ctm.xy, ctm.yy,
ctm.x0, ctm.y0));
+ if (xx * yy == xy * yx)
+ {
+ /* broken matrix here. This can happen during transitions
+ * (like when flipping an axis at the point where scale == 0)
+ * and just means that nothing should be drawn.
+ * But Cairo thows lots of ugly errors instead of silently
+ * going on. So We silently go on.
+ */
+ return;
+ }
cairo_transform (cr, &ctm);
gsk_render_node_draw (self->child, cr);
diff --git a/testsuite/gsk/compare/invalid-transform.node b/testsuite/gsk/compare/invalid-transform.node
new file mode 100644
index 0000000000..3e34173c92
--- /dev/null
+++ b/testsuite/gsk/compare/invalid-transform.node
@@ -0,0 +1,16 @@
+transform {
+ /* break the transform on purpose, because
+ this is valid in GSK and should result
+ in nothing being drawn. */
+ transform: scale(0);
+ child: color {
+ color: red;
+ bounds: 0 0 100 100;
+ }
+}
+
+/* make sure the rendering has a size */
+color {
+ color: transparent;
+ bounds: 0 0 1 1;
+} \ No newline at end of file
diff --git a/testsuite/gsk/compare/invalid-transform.png b/testsuite/gsk/compare/invalid-transform.png
new file mode 100644
index 0000000000..7238a64657
--- /dev/null
+++ b/testsuite/gsk/compare/invalid-transform.png
Binary files differ
diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build
index ccd29dff5b..c23d371e3e 100644
--- a/testsuite/gsk/meson.build
+++ b/testsuite/gsk/meson.build
@@ -48,6 +48,7 @@ compare_render_tests = [
'empty-shadow',
'empty-texture',
'empty-transform',
+ 'invalid-transform',
'opacity_clip',
'outset_shadow_offset_both',
'outset_shadow_offset_x',