summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2005-10-12 13:37:00 +0000
committerCarl Worth <cworth@cworth.org>2005-10-12 13:37:00 +0000
commit7dcbcdf75c5d9a7a691d741ecd1d36160fb725e3 (patch)
tree98b9b4c12774b3b824037c5eeeb7013f8ed87ae8
parent990dfde44762a2e85f4d85f1e2a93a7b976533cd (diff)
Add a couple of tests to improve our coverage (clipping under both fill rules).
-rw-r--r--ChangeLog14
-rw-r--r--test/.cvsignore2
-rw-r--r--test/Makefile.am6
-rw-r--r--test/clip-fill-rule-pixel-aligned-ref.pngbin0 -> 195 bytes
-rw-r--r--test/clip-fill-rule-pixel-aligned-rgb24-ref.pngbin0 -> 194 bytes
-rw-r--r--test/clip-fill-rule-pixel-aligned.c95
-rw-r--r--test/clip-fill-rule-ps-rgb24-ref.pngbin0 -> 309 bytes
-rw-r--r--test/clip-fill-rule-ref.pngbin0 -> 431 bytes
-rw-r--r--test/clip-fill-rule-rgb24-ref.pngbin0 -> 495 bytes
-rw-r--r--test/clip-fill-rule.c79
10 files changed, 196 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c374a4ae..0e48a226 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2005-10-12 Carl Worth <cworth@cworth.org>
+ * test/.cvsignore:
+ * test/Makefile.am:
+ * test/clip-fill-rule-pixel-aligned-ref.png:
+ * test/clip-fill-rule-pixel-aligned-rgb24-ref.png:
+ * test/clip-fill-rule-pixel-aligned.c: (pixel_aligned_path),
+ (draw), (main):
+ * test/clip-fill-rule-ps-rgb24-ref.png:
+ * test/clip-fill-rule-ref.png:
+ * test/clip-fill-rule-rgb24-ref.png:
+ * test/clip-fill-rule.c: (star_path), (draw), (main): Add a couple
+ of tests to improve our coverage (clipping under both fill rules).
+
+2005-10-12 Carl Worth <cworth@cworth.org>
+
* src/cairo-pdf-surface.c (emit_pattern): Add return value at
ASSERT_NOT_REACHED.
diff --git a/test/.cvsignore b/test/.cvsignore
index b382ae0c..8f42bbca 100644
--- a/test/.cvsignore
+++ b/test/.cvsignore
@@ -6,6 +6,8 @@ a8-mask
caps-joins
caps-sub-paths
clip-all
+clip-fill-rule
+clip-fill-rule-pixel-aligned
clip-nesting
clip-operator
clip-twice
diff --git a/test/Makefile.am b/test/Makefile.am
index 8d2d9434..c301b9b4 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,6 +4,8 @@ a8-mask \
caps-joins \
caps-sub-paths \
clip-all \
+clip-fill-rule \
+clip-fill-rule-pixel-aligned \
clip-nesting \
clip-operator \
clip-twice \
@@ -92,6 +94,8 @@ caps-sub-paths-ref.png \
caps-sub-paths-rgb24-ref.png \
clip-all-ref.png \
clip-all-rgb24-ref.png \
+clip-fill-rule-ref.png \
+clip-fill-rule-pixel-aligned-ref.png \
clip-nesting-ps-rgb24-ref.png \
clip-nesting-ref.png \
clip-nesting-rgb24-ref.png \
@@ -255,6 +259,8 @@ a8_mask_LDADD = $(LDADDS)
caps_joins_LDADD = $(LDADDS)
caps_sub_paths_LDADD = $(LDADDS)
clip_all_LDADD = $(LDADDS)
+clip_fill_rule_LDADD = $(LDADDS)
+clip_fill_rule_pixel_aligned_LDADD = $(LDADDS)
clip_nesting_LDADD = $(LDADDS)
clip_operator_LDADD = $(LDADDS)
clip_twice_LDADD = $(LDADDS)
diff --git a/test/clip-fill-rule-pixel-aligned-ref.png b/test/clip-fill-rule-pixel-aligned-ref.png
new file mode 100644
index 00000000..66eb6852
--- /dev/null
+++ b/test/clip-fill-rule-pixel-aligned-ref.png
Binary files differ
diff --git a/test/clip-fill-rule-pixel-aligned-rgb24-ref.png b/test/clip-fill-rule-pixel-aligned-rgb24-ref.png
new file mode 100644
index 00000000..87e4498d
--- /dev/null
+++ b/test/clip-fill-rule-pixel-aligned-rgb24-ref.png
Binary files differ
diff --git a/test/clip-fill-rule-pixel-aligned.c b/test/clip-fill-rule-pixel-aligned.c
new file mode 100644
index 00000000..1b2f4906
--- /dev/null
+++ b/test/clip-fill-rule-pixel-aligned.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2004 Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define PAD 1
+#define SIZE 5
+
+cairo_test_t test = {
+ "clip-fill-rule-pixel-aligned",
+ "Tests interaction of clipping and cairo_set_fill_rule with a pixel-aligned path",
+ PAD + (SIZE*4) + PAD + (SIZE*4) + PAD,
+ PAD + (SIZE*4) + PAD
+};
+
+static void
+pixel_aligned_path (cairo_t *cr)
+{
+ cairo_save (cr);
+ {
+ cairo_scale (cr, SIZE, SIZE);
+ cairo_move_to (cr, 1, 0);
+ cairo_rel_line_to (cr, 1, 0);
+ cairo_rel_line_to (cr, 0, 3);
+ cairo_rel_line_to (cr, 1, 0);
+ cairo_rel_line_to (cr, 0, -1);
+ cairo_rel_line_to (cr, -3, 0);
+ cairo_rel_line_to (cr, 0, -1);
+ cairo_rel_line_to (cr, 4, 0);
+ cairo_rel_line_to (cr, 0, 3);
+ cairo_rel_line_to (cr, -3, 0);
+ cairo_rel_line_to (cr, 0, -4);
+ cairo_close_path (cr);
+ }
+ cairo_restore (cr);
+}
+
+/* Use clipping to draw the same path twice, once with each fill rule */
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 1, 0, 0); /* red */
+
+ cairo_translate (cr, PAD, PAD);
+
+ cairo_save (cr);
+ {
+ pixel_aligned_path (cr);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_clip (cr);
+ cairo_paint (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, SIZE*4 + PAD, 0);
+
+ cairo_save (cr);
+ {
+ pixel_aligned_path (cr);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
+ cairo_clip (cr);
+ cairo_paint (cr);
+ }
+ cairo_restore (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}
diff --git a/test/clip-fill-rule-ps-rgb24-ref.png b/test/clip-fill-rule-ps-rgb24-ref.png
new file mode 100644
index 00000000..f9bd0e1c
--- /dev/null
+++ b/test/clip-fill-rule-ps-rgb24-ref.png
Binary files differ
diff --git a/test/clip-fill-rule-ref.png b/test/clip-fill-rule-ref.png
new file mode 100644
index 00000000..27ae1229
--- /dev/null
+++ b/test/clip-fill-rule-ref.png
Binary files differ
diff --git a/test/clip-fill-rule-rgb24-ref.png b/test/clip-fill-rule-rgb24-ref.png
new file mode 100644
index 00000000..293aff7c
--- /dev/null
+++ b/test/clip-fill-rule-rgb24-ref.png
Binary files differ
diff --git a/test/clip-fill-rule.c b/test/clip-fill-rule.c
new file mode 100644
index 00000000..74722ce8
--- /dev/null
+++ b/test/clip-fill-rule.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2004 Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Author: Carl D. Worth <cworth@cworth.org>
+ */
+
+#include "cairo-test.h"
+
+#define STAR_SIZE 20
+
+cairo_test_t test = {
+ "clip-fill-rule",
+ "Tests interaction of clipping with cairo_set_fill_rule",
+ STAR_SIZE * 2 + 2, STAR_SIZE + 2
+};
+
+static void
+star_path (cairo_t *cr)
+{
+ cairo_move_to (cr, 10, 0);
+ cairo_rel_line_to (cr, 6, 20);
+ cairo_rel_line_to (cr, -16, -12);
+ cairo_rel_line_to (cr, 20, 0);
+ cairo_rel_line_to (cr, -16, 12);
+}
+
+/* Use clipping to draw the same path twice, once with each fill rule */
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 1, 0, 0);
+
+ cairo_translate (cr, 1, 1);
+ cairo_save (cr);
+ {
+ star_path (cr);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
+ cairo_clip (cr);
+ cairo_paint (cr);
+ }
+ cairo_restore (cr);
+
+ cairo_translate (cr, STAR_SIZE + 1, 0);
+ cairo_save (cr);
+ {
+ star_path (cr);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_clip (cr);
+ cairo_paint (cr);
+ }
+ cairo_restore (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test, draw);
+}