summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-10-15 13:19:11 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-10-15 14:08:01 +0100
commitade55037ffa596b690c6a1051394589f76eb1f48 (patch)
tree81d346d2d70dd528aa8b5dfbbf08234c0a5e70bc
parentdac73d260a9b9a848bb97436ad84081c51629511 (diff)
[test] Add clip-device-offset
Exercises a bug demonstrated by WebKit with clipping + device offsets.
-rw-r--r--test/Makefile.am2
-rw-r--r--test/Makefile.sources1
-rw-r--r--test/clip-device-offset.argb32.ref.pngbin0 -> 175 bytes
-rw-r--r--test/clip-device-offset.c79
-rw-r--r--test/clip-device-offset.rgb24.ref.pngbin0 -> 168 bytes
5 files changed, 82 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index a6e8be32..9ad41f52 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -167,6 +167,8 @@ REFERENCE_IMAGES = \
clear.svg12.argb32.xfail.png \
clear.svg12.rgb24.xfail.png \
clip-all.ref.png \
+ clip-device-offset.argb32.ref.png \
+ clip-device-offset.rgb24.ref.png \
clip-disjoint.ref.png \
clip-disjoint.xlib.ref.png \
clip-empty.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 769fb0f3..c313852c 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -15,6 +15,7 @@ test_sources = \
clear.c \
clip-all.c \
clip-disjoint.c \
+ clip-device-offset.c \
clip-empty.c \
clip-fill.c \
clip-fill-rule.c \
diff --git a/test/clip-device-offset.argb32.ref.png b/test/clip-device-offset.argb32.ref.png
new file mode 100644
index 00000000..06be9851
--- /dev/null
+++ b/test/clip-device-offset.argb32.ref.png
Binary files differ
diff --git a/test/clip-device-offset.c b/test/clip-device-offset.c
new file mode 100644
index 00000000..eb0e2495
--- /dev/null
+++ b/test/clip-device-offset.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2009 Benjamin Otte
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#include "cairo-test.h"
+
+#define WIDTH 50
+#define HEIGHT 50
+
+static cairo_pattern_t *
+create_green_source (void)
+{
+ cairo_surface_t *image;
+ cairo_pattern_t *pattern;
+ cairo_t *cr;
+
+ image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT);
+ cr = cairo_create (image);
+ cairo_surface_destroy (image);
+
+ cairo_set_source_rgb (cr, 0, 1, 0);
+ cairo_paint (cr);
+
+ pattern = cairo_pattern_create_for_surface (cairo_get_target (cr));
+ cairo_destroy (cr);
+
+ return pattern;
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *source;
+ double old_x, old_y;
+
+ cairo_surface_get_device_offset (cairo_get_target (cr), &old_x, &old_y);
+ cairo_surface_set_device_offset (cairo_get_target (cr), old_x+5, old_y+5);
+
+ source = create_green_source ();
+ cairo_set_source (cr, source);
+ cairo_pattern_destroy (source);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT);
+ cairo_clip (cr);
+ cairo_paint (cr);
+
+ cairo_surface_set_device_offset (cairo_get_target (cr), old_x, old_y);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (clip_device_offset,
+ "Test clipping on surfaces with device offsets",
+ "clip", /* keywords */
+ NULL, /* requirements */
+ WIDTH+10, HEIGHT+10,
+ NULL, draw)
diff --git a/test/clip-device-offset.rgb24.ref.png b/test/clip-device-offset.rgb24.ref.png
new file mode 100644
index 00000000..24193845
--- /dev/null
+++ b/test/clip-device-offset.rgb24.ref.png
Binary files differ