[cairo-commit] test/fill-alpha.c test/fill-alpha-ref.png test/.gitignore test/Makefile.am

Chris Wilson ickle at kemper.freedesktop.org
Mon Sep 8 04:43:39 PDT 2008


 test/.gitignore         |    1 
 test/Makefile.am        |    2 +
 test/fill-alpha-ref.png |binary
 test/fill-alpha.c       |   89 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+)

New commits:
commit ee5e6c821fedaf8c374d41438e1ca8cf606cd57c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 8 12:34:36 2008 +0100

    [test] Add fill-alpha.
    
    Benjamin Otte reported "who broke rgba fills? they look dithered with
    recent git."
    
    This commit is the result of a skim through the test-suite which revealed
    no single test responsible for checking the basic operation of
    "set_rgba(); fill();".

diff --git a/test/.gitignore b/test/.gitignore
index 456b969..7f5caed 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -65,6 +65,7 @@ fallback-resolution
 fallback-resolution.pdf
 fallback-resolution.ps
 fallback-resolution.svg
+fill-alpha
 fill-and-stroke
 fill-and-stroke-alpha
 fill-and-stroke-alpha-add
diff --git a/test/Makefile.am b/test/Makefile.am
index e00cbd6..ad2c21e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -48,6 +48,7 @@ extend-reflect$(EXEEXT)					\
 extend-reflect-similar$(EXEEXT)				\
 extend-repeat$(EXEEXT)					\
 extend-repeat-similar$(EXEEXT)				\
+fill-alpha$(EXEEXT)					\
 fill-and-stroke$(EXEEXT)				\
 fill-and-stroke-alpha$(EXEEXT)				\
 fill-and-stroke-alpha-add$(EXEEXT)			\
@@ -391,6 +392,7 @@ REFERENCE_IMAGES = \
 	extend-reflect-ps-ref.png \
 	extend-repeat-ref.png	\
 	extend-repeat-similar-ref.png	\
+	fill-alpha-ref.png	\
 	fill-and-stroke-alpha-add-quartz-ref.png	\
 	fill-and-stroke-alpha-add-ref.png	\
 	fill-and-stroke-alpha-quartz-ref.png	\
diff --git a/test/fill-alpha-ref.png b/test/fill-alpha-ref.png
new file mode 100644
index 0000000..cb18226
Binary files /dev/null and b/test/fill-alpha-ref.png differ
diff --git a/test/fill-alpha.c b/test/fill-alpha.c
new file mode 100644
index 0000000..ee71247
--- /dev/null
+++ b/test/fill-alpha.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2008 Chris Wilson
+ *
+ * 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
+ * Chris Wilson not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Chris Wilson makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON 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: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 60 /* needs to be big to check large area effects (dithering) */
+#define PAD 2
+
+static cairo_test_draw_function_t draw;
+
+static const cairo_test_t test = {
+    "fill-alpha",
+    "Tests using set_rgba();fill()",
+    2*SIZE + 4*PAD, 2*SIZE + 4*PAD,
+    draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    int n;
+
+    /* flatten to white */
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_paint (cr);
+
+    /* square */
+    cairo_rectangle (cr, PAD, PAD, SIZE, SIZE);
+    cairo_set_source_rgba (cr, 1, 0, 0, .5);
+    cairo_fill (cr);
+
+    /* circle */
+    cairo_translate (cr, SIZE + 2 * PAD, 0);
+    cairo_arc (cr, PAD + SIZE / 2., PAD + SIZE / 2., SIZE / 2., 0, 2 * M_PI);
+    cairo_set_source_rgba (cr, 0, 1, 0, .5);
+    cairo_fill (cr);
+
+    /* triangle */
+    cairo_translate (cr, 0, SIZE + 2 * PAD);
+    cairo_move_to (cr, PAD + SIZE / 2, PAD);
+    cairo_line_to (cr, PAD + SIZE, PAD + SIZE);
+    cairo_line_to (cr, PAD, PAD + SIZE);
+    cairo_set_source_rgba (cr, 0, 0, 1, .5);
+    cairo_fill (cr);
+
+    /* star */
+    cairo_translate (cr, -(SIZE + 2 * PAD) + SIZE/2., SIZE/2.);
+    for (n = 0; n < 5; n++) {
+	cairo_line_to (cr,
+		       SIZE/2 * cos (2*n * 2*M_PI / 10),
+		       SIZE/2 * sin (2*n * 2*M_PI / 10));
+
+	cairo_line_to (cr,
+		       SIZE/4 * cos ((2*n+1)*2*M_PI / 10),
+		       SIZE/4 * sin ((2*n+1)*2*M_PI / 10));
+    }
+    cairo_set_source_rgba (cr, 0, 0, 0, .5);
+    cairo_fill (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+    return cairo_test (&test);
+}


More information about the cairo-commit mailing list