summaryrefslogtreecommitdiff
path: root/libs/cairo-1.16.0/test/push-group-path-offset.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-10-12 12:03:23 -0500
committersanine <sanine.not@pm.me>2022-10-12 12:03:23 -0500
commit530ffd0b7d3c39757b20f00716e486b5caf89aff (patch)
tree76b35fdf57317038acf6b828871f6ae25fce2ebe /libs/cairo-1.16.0/test/push-group-path-offset.c
parent3dbe9332e47c143a237db12440f134caebd1cfbe (diff)
add cairo
Diffstat (limited to 'libs/cairo-1.16.0/test/push-group-path-offset.c')
-rw-r--r--libs/cairo-1.16.0/test/push-group-path-offset.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/libs/cairo-1.16.0/test/push-group-path-offset.c b/libs/cairo-1.16.0/test/push-group-path-offset.c
new file mode 100644
index 0000000..6b73ca4
--- /dev/null
+++ b/libs/cairo-1.16.0/test/push-group-path-offset.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2010 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Author: Benjamin Otte <otte@gnome.org>
+ */
+
+#include "cairo-test.h"
+
+#define CLIP_OFFSET 15
+#define CLIP_SIZE 20
+
+#define WIDTH 50
+#define HEIGHT 50
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ /* Neutral gray background */
+ cairo_set_source_rgb (cr, 0.51613, 0.55555, 0.51613);
+ cairo_paint (cr);
+
+ /* the rest uses CAIRO_OPERATOR_SOURCE so we see better when something goes wrong */
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+
+ /* add a rectangle */
+ cairo_rectangle (cr, CLIP_OFFSET, CLIP_OFFSET, CLIP_SIZE, CLIP_SIZE);
+
+ /* clip to the rectangle */
+ cairo_clip_preserve (cr);
+
+ /* push a group. We now have a device offset. */
+ cairo_push_group (cr);
+
+ /* push a group again. This is where the bug used to happen. */
+ cairo_push_group (cr);
+
+ /* draw something */
+ cairo_set_source_rgb (cr, 1, 0, 0);
+ cairo_fill_preserve (cr);
+
+ /* make sure the stuff we drew ends up on the output */
+ cairo_pop_group_to_source (cr);
+ cairo_fill_preserve (cr);
+
+ cairo_pop_group_to_source (cr);
+ cairo_fill_preserve (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (push_group_path_offset,
+ "Exercises a bug in Cairo 1.9 where existing paths applied the target's"
+ " device offset twice when cairo_push_group() was called.",
+ "group, path", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)