summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBryce W. Harrington <b.harrington@samsung.com>2013-09-12 22:55:02 +0000
committerUli Schlachter <psychon@znc.in>2013-09-13 12:57:42 +0200
commit640eb0206738e1d1bfd9beebaf0dcb6ac0e07584 (patch)
treea2c5f626a598321f2b339ab9b84a9950db53497f /test
parenta6ace0cf6b96930c08397c64bffabc4b201ab4e8 (diff)
test: Space out keywords for clarity
As another nitpick, a comma alone is legal for separating keywords, but most tests use a comma and a space. Update the few tests that don't, to make this consistent. Signed-off-by: Bryce Harrington <b.harrington@samsung.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'test')
-rw-r--r--test/image-bug-710072.c80
-rw-r--r--test/mesh-pattern-accuracy.c99
-rw-r--r--test/mesh-pattern-conical.c135
-rw-r--r--test/mesh-pattern-control-points.c114
-rw-r--r--test/mesh-pattern-fold.c82
-rw-r--r--test/mesh-pattern-overlap.c76
-rw-r--r--test/mesh-pattern-transformed.c107
-rw-r--r--test/mesh-pattern.c94
-rw-r--r--test/record1414x.c4
9 files changed, 789 insertions, 2 deletions
diff --git a/test/image-bug-710072.c b/test/image-bug-710072.c
index 0c9cd8a..9cf0da7 100644
--- a/test/image-bug-710072.c
+++ b/test/image-bug-710072.c
@@ -0,0 +1,80 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright 2011 Intel Corporation
+ *
+ * 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: Chris Wilson <chris@chris-wilson.co.uk>
+ */
+
+/*
+ * This test case aims to reproduce the misbehaviour exhibited in
+ * https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/710072
+ * i.e. out of bounds rendering with the rectangular span compositor.
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw_aligned (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_rectangle (cr, -10, -10, 20, 20);
+ cairo_rectangle (cr, 5, 5, 20, 20);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgba (cr, 1, 0, 0, .5);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+static cairo_test_status_t
+draw_unaligned (cairo_t *cr, int width, int height)
+{
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_rectangle (cr, -10.5, -10.5, 20, 20);
+ cairo_rectangle (cr, 5.5, 5.5, 20, 20);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgba (cr, 1, 0, 0, .5);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (image_bug_710072_aligned,
+ "Tests a bug where we may compute spans greater than bounded extents",
+ "extents, fill, stroke", /* keywords */
+ NULL, /* requirements */
+ 15, 15,
+ NULL, draw_aligned)
+
+CAIRO_TEST (image_bug_710072_unaligned,
+ "Tests a bug where we may compute spans greater than bounded extents",
+ "extents, fill, stroke", /* keywords */
+ NULL, /* requirements */
+ 15, 15,
+ NULL, draw_unaligned)
diff --git a/test/mesh-pattern-accuracy.c b/test/mesh-pattern-accuracy.c
index 92e1523..d1f60b2 100644
--- a/test/mesh-pattern-accuracy.c
+++ b/test/mesh-pattern-accuracy.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+#include <float.h>
+
+#define SIZE 256
+
+/* This test is designed to test the accuracy of the rendering of mesh
+ * patterns.
+ *
+ * Color accuracy is tested by a square patch covering the whole
+ * surface with black and white corners.
+ *
+ * Extents accuracy is checked by a small red square patch at the
+ * center of the surface which should measure 2x2 pixels.
+ */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+ double offset;
+
+ cairo_test_paint_checkered (cr);
+
+ pattern = cairo_pattern_create_mesh ();
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 0, 0);
+ cairo_mesh_pattern_line_to (pattern, 1, 0);
+ cairo_mesh_pattern_line_to (pattern, 1, 1);
+ cairo_mesh_pattern_line_to (pattern, 0, 1);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 0, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 1, 1, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 1);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ /* A small 1x1 red patch, that should be rendered as a 2x2 red
+ * square in the center of the image */
+
+ offset = 0.5 / SIZE;
+
+ cairo_mesh_pattern_move_to (pattern, 0.5 + offset, 0.5 + offset);
+ cairo_mesh_pattern_line_to (pattern, 0.5 + offset, 0.5 - offset);
+ cairo_mesh_pattern_line_to (pattern, 0.5 - offset, 0.5 - offset);
+ cairo_mesh_pattern_line_to (pattern, 0.5 - offset, 0.5 + offset);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 0, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_scale (cr, SIZE, SIZE);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (mesh_pattern_accuracy,
+ "Paint mesh pattern",
+ "mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ SIZE, SIZE,
+ NULL, draw)
diff --git a/test/mesh-pattern-conical.c b/test/mesh-pattern-conical.c
index 8138884..4e87eec 100644
--- a/test/mesh-pattern-conical.c
+++ b/test/mesh-pattern-conical.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+#include <math.h>
+
+#define PAT_WIDTH 100
+#define PAT_HEIGHT 100
+#define SIZE PAT_WIDTH
+#define PAD 2
+#define WIDTH (PAD + SIZE + PAD)
+#define HEIGHT WIDTH
+
+
+/*
+ * This test is designed to paint a mesh pattern which contains 8
+ * circular sectors approximating a conical gradient.
+ */
+
+#define CENTER_X 50
+#define CENTER_Y 50
+#define RADIUS 50
+
+static void
+sector_patch (cairo_pattern_t *pattern,
+ double angle_A,
+ double A_r, double A_g, double A_b,
+ double angle_B,
+ double B_r, double B_g, double B_b)
+{
+ double r_sin_A, r_cos_A;
+ double r_sin_B, r_cos_B;
+ double h;
+
+ r_sin_A = RADIUS * sin (angle_A);
+ r_cos_A = RADIUS * cos (angle_A);
+ r_sin_B = RADIUS * sin (angle_B);
+ r_cos_B = RADIUS * cos (angle_B);
+
+ h = 4.0/3.0 * tan ((angle_B - angle_A) / 4.0);
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, CENTER_X, CENTER_Y);
+ cairo_mesh_pattern_line_to (pattern,
+ CENTER_X + r_cos_A,
+ CENTER_Y + r_sin_A);
+
+ cairo_mesh_pattern_curve_to (pattern,
+ CENTER_X + r_cos_A - h * r_sin_A,
+ CENTER_Y + r_sin_A + h * r_cos_A,
+ CENTER_X + r_cos_B + h * r_sin_B,
+ CENTER_Y + r_sin_B - h * r_cos_B,
+ CENTER_X + r_cos_B,
+ CENTER_Y + r_sin_B);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 1, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, A_r, A_g, A_b);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, B_r, B_g, B_b);
+
+ cairo_mesh_pattern_end_patch (pattern);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_translate (cr, PAD, PAD);
+
+ pattern = cairo_pattern_create_mesh ();
+ sector_patch (pattern,
+ 0, 1, 0, 0,
+ M_PI/4, 1, 1, 0);
+ sector_patch (pattern,
+ M_PI/4, 0, 1, 0,
+ M_PI/2, 0, 1, 1);
+ sector_patch (pattern,
+ M_PI/2, 0, 0, 1,
+ 3*M_PI/4, 1, 0, 1);
+ sector_patch (pattern,
+ 3*M_PI/4, 1, 0, 0,
+ M_PI, 1, 1, 0);
+ sector_patch (pattern,
+ -M_PI, 1, 1, 0,
+ -3*M_PI/4, 0, 1, 0);
+ sector_patch (pattern,
+ -3*M_PI/4, 0, 1, 0,
+ -M_PI/2, 0, 1, 1);
+ sector_patch (pattern,
+ -M_PI/2, 0, 1, 1,
+ -M_PI/4, 0, 0, 1);
+ sector_patch (pattern,
+ -M_PI/4, 0, 0, 1,
+ 0, 1, 0, 0);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (mesh_pattern_conical,
+ "Paint a conical pattern using a mesh pattern",
+ "conical, mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)
diff --git a/test/mesh-pattern-control-points.c b/test/mesh-pattern-control-points.c
index 4d59495..057e7a1 100644
--- a/test/mesh-pattern-control-points.c
+++ b/test/mesh-pattern-control-points.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 90
+#define PAD 10
+#define WIDTH (PAD + 2 * (SIZE + PAD))
+#define HEIGHT (PAD + SIZE + PAD)
+
+
+/*
+ * This test is designed to paint a two mesh patches. One with default
+ * control points and one with a control point at a no default
+ * location. The control points of both of them are drawn as squares
+ * to make them visible.
+ */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+ unsigned int i, j;
+ unsigned int num_patches;
+ double x, y;
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_translate (cr, PAD, PAD);
+
+ pattern = cairo_pattern_create_mesh ();
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 0, 0);
+ cairo_mesh_pattern_line_to (pattern, SIZE, 0);
+ cairo_mesh_pattern_line_to (pattern, SIZE, SIZE);
+ cairo_mesh_pattern_line_to (pattern, 0, SIZE);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_set_control_point (pattern, 0, SIZE * .7, SIZE * .7);
+ cairo_mesh_pattern_set_control_point (pattern, 1, SIZE * .9, SIZE * .7);
+ cairo_mesh_pattern_set_control_point (pattern, 2, SIZE * .9, SIZE * .9);
+ cairo_mesh_pattern_set_control_point (pattern, 3, SIZE * .7, SIZE * .9);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, SIZE + PAD, 0);
+ cairo_mesh_pattern_line_to (pattern, 2*SIZE + PAD, 0);
+ cairo_mesh_pattern_line_to (pattern, 2*SIZE + PAD, SIZE);
+ cairo_mesh_pattern_line_to (pattern, SIZE + PAD, SIZE);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+
+ /* mark the location of the control points */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_mesh_pattern_get_patch_count (pattern, &num_patches);
+ for (i = 0; i < num_patches; i++) {
+ for (j = 0; j < 4; j++) {
+ cairo_mesh_pattern_get_control_point (pattern, i, j, &x, &y);
+ cairo_rectangle (cr, x - 5, y - 5, 10, 10);
+ cairo_fill (cr);
+ }
+ }
+
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+
+CAIRO_TEST (mesh_pattern_control_points,
+ "Paint mesh pattern with non default control points",
+ "mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)
diff --git a/test/mesh-pattern-fold.c b/test/mesh-pattern-fold.c
index 4872bc0..cacd712 100644
--- a/test/mesh-pattern-fold.c
+++ b/test/mesh-pattern-fold.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 100
+#define PAD 15
+#define WIDTH (5*SIZE)
+#define HEIGHT (5*SIZE)
+
+
+/* This test is designed to paint a mesh pattern which folds along
+ * both parameters. */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_test_paint_checkered (cr);
+
+ pattern = cairo_pattern_create_mesh ();
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 1, 1);
+
+ cairo_mesh_pattern_curve_to (pattern, 6, 0, -1, 0, 4, 1);
+ cairo_mesh_pattern_curve_to (pattern, 5, 6, 5, -1, 4, 4);
+ cairo_mesh_pattern_curve_to (pattern, -1, 3, 6, 3, 1, 4);
+ cairo_mesh_pattern_curve_to (pattern, 2, -1, 2, 6, 1, 1);
+
+ cairo_mesh_pattern_set_control_point (pattern, 0, 2, 3);
+ cairo_mesh_pattern_set_control_point (pattern, 1, 3, 3);
+ cairo_mesh_pattern_set_control_point (pattern, 2, 3, 2);
+ cairo_mesh_pattern_set_control_point (pattern, 3, 2, 2);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 0, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 0, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_scale (cr, SIZE, SIZE);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (mesh_pattern_fold,
+ "Paint a mesh pattern with complex folds",
+ "mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)
diff --git a/test/mesh-pattern-overlap.c b/test/mesh-pattern-overlap.c
index 5ecbf9f..969bc73 100644
--- a/test/mesh-pattern-overlap.c
+++ b/test/mesh-pattern-overlap.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+
+#define SIZE 100
+#define PAD 15
+#define WIDTH (PAD + SIZE + PAD)
+#define HEIGHT WIDTH
+
+
+/* This test is designed to paint a mesh pattern with a simple
+ * fold. */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_test_paint_checkered (cr);
+
+ cairo_translate (cr, PAD, PAD);
+
+ pattern = cairo_pattern_create_mesh ();
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 0, 0);
+ cairo_mesh_pattern_curve_to (pattern, 30, -30, 60, 30, 100, 0);
+ cairo_mesh_pattern_curve_to (pattern, 130, 140, 60, -40, 100, 100);
+ cairo_mesh_pattern_curve_to (pattern, 60, 70, 30, 130, 0, 100);
+ cairo_mesh_pattern_curve_to (pattern, -30, -40, 30, 140, 0, 0);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (mesh_pattern_overlap,
+ "Paint a mesh pattern with a simple fold",
+ "mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)
diff --git a/test/mesh-pattern-transformed.c b/test/mesh-pattern-transformed.c
index a5c20e7..5fe0dc0 100644
--- a/test/mesh-pattern-transformed.c
+++ b/test/mesh-pattern-transformed.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+
+#define PAT_WIDTH 170
+#define PAT_HEIGHT 170
+#define SIZE PAT_WIDTH
+#define PAD 10
+#define WIDTH 190
+#define HEIGHT 140
+
+
+/* This test is designed to paint a mesh pattern containing two
+ * overlapping patches transformed in different ways. */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_test_paint_checkered (cr);
+
+ cairo_translate (cr, PAD, PAD);
+
+ pattern = cairo_pattern_create_mesh ();
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 0, 0);
+ cairo_mesh_pattern_curve_to (pattern, 30, -30, 60, 30, 100, 0);
+ cairo_mesh_pattern_curve_to (pattern, 60, 30, 130, 60, 100, 100);
+ cairo_mesh_pattern_curve_to (pattern, 60, 70, 30, 130, 0, 100);
+ cairo_mesh_pattern_curve_to (pattern, 30, 70, -30, 30, 0, 0);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 50, 50);
+ cairo_mesh_pattern_curve_to (pattern, 80, 20, 110, 80, 150, 50);
+
+ cairo_mesh_pattern_curve_to (pattern, 110, 80, 180, 110, 150, 150);
+
+ cairo_mesh_pattern_curve_to (pattern, 110, 120, 80, 180, 50, 150);
+
+ cairo_mesh_pattern_curve_to (pattern, 80, 120, 20, 80, 50, 50);
+
+ cairo_mesh_pattern_set_corner_color_rgba (pattern, 0, 1, 0, 0, 0.3);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgba (pattern, 2, 0, 0, 1, 0.3);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_scale (cr, .5, .5);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+
+ cairo_translate (cr, PAT_WIDTH, PAT_HEIGHT);
+ cairo_translate (cr, PAT_WIDTH/2, PAT_HEIGHT/2);
+ cairo_rotate (cr, M_PI/4);
+ cairo_translate (cr, -PAT_WIDTH, -PAT_HEIGHT);
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (mesh_pattern_transformed,
+ "Paint mesh pattern with a transformation",
+ "mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)
+
diff --git a/test/mesh-pattern.c b/test/mesh-pattern.c
index 68f1830..eccbd38 100644
--- a/test/mesh-pattern.c
+++ b/test/mesh-pattern.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2009 Adrian Johnson
+ *
+ * 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: Adrian Johnson <ajohnson@redneon.com>
+ */
+
+#include "cairo-test.h"
+
+#define PAT_WIDTH 170
+#define PAT_HEIGHT 170
+#define SIZE PAT_WIDTH
+#define PAD 2
+#define WIDTH (PAD + SIZE + PAD)
+#define HEIGHT WIDTH
+
+
+/* This test is designed to paint a mesh pattern. The mesh contains
+ * two overlapping patches */
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ cairo_test_paint_checkered (cr);
+
+ cairo_translate (cr, PAD, PAD);
+ cairo_translate (cr, 10, 10);
+
+ pattern = cairo_pattern_create_mesh ();
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 0, 0);
+ cairo_mesh_pattern_curve_to (pattern, 30, -30, 60, 30, 100, 0);
+ cairo_mesh_pattern_curve_to (pattern, 60, 30, 130, 60, 100, 100);
+ cairo_mesh_pattern_curve_to (pattern, 60, 70, 30, 130, 0, 100);
+ cairo_mesh_pattern_curve_to (pattern, 30, 70, -30, 30, 0, 0);
+
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 0, 1, 0, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 2, 0, 0, 1);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_mesh_pattern_begin_patch (pattern);
+
+ cairo_mesh_pattern_move_to (pattern, 50, 50);
+ cairo_mesh_pattern_curve_to (pattern, 80, 20, 110, 80, 150, 50);
+ cairo_mesh_pattern_curve_to (pattern, 110, 80, 180, 110, 150, 150);
+ cairo_mesh_pattern_curve_to (pattern, 110, 120, 80, 180, 50, 150);
+ cairo_mesh_pattern_curve_to (pattern, 80, 120, 20, 80, 50, 50);
+
+ cairo_mesh_pattern_set_corner_color_rgba (pattern, 0, 1, 0, 0, 0.3);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 1, 0, 1, 0);
+ cairo_mesh_pattern_set_corner_color_rgba (pattern, 2, 0, 0, 1, 0.3);
+ cairo_mesh_pattern_set_corner_color_rgb (pattern, 3, 1, 1, 0);
+
+ cairo_mesh_pattern_end_patch (pattern);
+
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (mesh_pattern,
+ "Paint mesh pattern",
+ "mesh, pattern", /* keywords */
+ NULL, /* requirements */
+ WIDTH, HEIGHT,
+ NULL, draw)
diff --git a/test/record1414x.c b/test/record1414x.c
index b8adb86..029e5a4 100644
--- a/test/record1414x.c
+++ b/test/record1414x.c
@@ -444,7 +444,7 @@ record_text_transform (cairo_t *cr, int width, int height)
CAIRO_TEST (record1414x_paint,
"Test replayed calls to cairo_paint",
- "paint,record", /* keywords */
+ "paint, record", /* keywords */
NULL, /* requirements */
M_SQRT2*8, M_SQRT2*8,
NULL, record_paint)
@@ -474,7 +474,7 @@ CAIRO_TEST (record1414x_paint_alpha_clip_mask,
NULL, record_paint_alpha_clip_mask)
CAIRO_TEST (record1414x_fill_alpha,
"Tests using set_rgba();fill()",
- "record,fill, alpha", /* keywords */
+ "record, fill, alpha", /* keywords */
NULL, /* requirements */
M_SQRT2*(2*SIZE + 4*PAD), M_SQRT2*(2*SIZE + 4*PAD),
NULL, record_fill_alpha)