diff options
author | Carl Worth <cworth@cworth.org> | 2005-03-29 00:02:19 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2005-03-29 00:02:19 +0000 |
commit | 35b9e3c45d8a4c2aa24eff5acb04d0e1eb7bc6ba (patch) | |
tree | f66a6bb1ef0a0633a8fb4b263a83e69e49f8a128 | |
parent | d9c2be3dcd27baa91b67cc9179bc98e06805a365 (diff) |
More _/- renames in the test directory.
48 files changed, 83 insertions, 2163 deletions
@@ -1,3 +1,8 @@ +2005-03-29 Carl Worth <cworth@cworth.org> + + * test/Makefile.am: + * test/*_*.c: More _/- renames in the test directory. + 2005-03-28 Carl Worth <cworth@cworth.org> * src/Makefile.am: diff --git a/test/.cvsignore b/test/.cvsignore index 94b04f2a..2eb69123 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -2,20 +2,20 @@ .libs Makefile Makefile.in -clip_twice +clip-twice coverage -fill_rule -get_and_set +fill-rule +get-and-set imagediff -leaky_polygon -line_width -linear_gradient -move_to_show_surface -path_data -pixman_rotate -text_cache_crash -text_rotate -user_data +leaky-polygon +line-width +linear-gradient +move-to-show-surface +path-data +pixman-rotate +text-cache-crash +text-rotate +user-data *-out.png *-diff.png *.la diff --git a/test/Makefile.am b/test/Makefile.am index e32254cd..95f7fcfb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,36 +1,36 @@ # All new test cases go here TESTS = \ -clip_twice \ +clip-twice \ coverage \ -fill_rule \ -get_and_set \ -leaky_polygon \ -line_width \ -linear_gradient \ -move_to_show_surface \ -path_data \ -pixman_rotate \ -text_cache_crash \ -text_rotate \ -user_data +fill-rule \ +get-and-set \ +leaky-polygon \ +line-width \ +linear-gradient \ +move-to-show-surface \ +path-data \ +pixman-rotate \ +text-cache-crash \ +text-rotate \ +user-data # And all new tests go here too. I really don't like having to repeat # this list. Anyone know a good way to avoid it? Can I use a wildcard # here? EXTRA_DIST = \ -fill_rule-ref.png \ -leaky_polygon-ref.png \ -line_width-ref.png \ -linear_gradient-ref.png \ -move_to_show_surface-ref.png \ +fill-rule-ref.png \ +leaky-polygon-ref.png \ +line-width-ref.png \ +linear-gradient-ref.png \ +move-to-show-surface-ref.png \ coverage-ref.png \ -clip_twice-ref.png \ -path_data-ref.png \ -pixman_rotate-ref.png \ +clip-twice-ref.png \ +path-data-ref.png \ +pixman-rotate-ref.png \ romedalen.png -# Once we can draw the text_rotate.c test case correctly, we should -# create and add text_rotate-ref.png to the list of reference PNGs. +# Once we can draw the text-rotate.c test case correctly, we should +# create and add text-rotate-ref.png to the list of reference PNGs. # This list is only for known bugs (not regressions). We do need to # fix these before the next release, but they are expected to fail for @@ -41,9 +41,9 @@ romedalen.png # regression bugs that should not be listed here. Instead they should # be fixed before the code is committed. XFAIL_TESTS = \ -move_to_show_surface \ -pixman_rotate \ -text_rotate +move-to-show-surface \ +pixman-rotate \ +text-rotate check_PROGRAMS = $(TESTS) @@ -56,14 +56,14 @@ INCLUDES = -D_GNU_SOURCE -I$(srcdir) $(CAIRO_CFLAGS) -I$(top_srcdir)/src noinst_LTLIBRARIES = libcairotest.la libcairotest_la_SOURCES =\ -buffer_diff.c \ -buffer_diff.h \ -cairo_test.c \ -cairo_test.h \ -read_png.c \ -read_png.h \ -write_png.c \ -write_png.h \ +buffer-diff.c \ +buffer-diff.h \ +cairo-test.c \ +cairo-test.h \ +read-png.c \ +read-png.h \ +write-png.c \ +write-png.h \ xmalloc.c \ xmalloc.h diff --git a/test/buffer-diff.c b/test/buffer-diff.c index 07abd62a..486aff1d 100644 --- a/test/buffer-diff.c +++ b/test/buffer-diff.c @@ -23,7 +23,7 @@ * * Author: Richard D. Worth <richard@theworths.org> */ -#include "buffer_diff.h" +#include "buffer-diff.h" /* Image comparison code courttesy of Richard Worth. * Returns number of pixels changed. diff --git a/test/buffer_diff.c b/test/buffer_diff.c deleted file mode 100644 index 07abd62a..00000000 --- a/test/buffer_diff.c +++ /dev/null @@ -1,73 +0,0 @@ -/* imagediff - Compare two images - * - * Copyright © 2004 Richard D. Worth - * - * 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 Richard Worth - * not be used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Richard Worth makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL RICHARD WORTH 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: Richard D. Worth <richard@theworths.org> */ - -#include "buffer_diff.h" - -/* Image comparison code courttesy of Richard Worth. - * Returns number of pixels changed. - * Also fills out a "diff" image intended to visually show where the - * images differ. - */ -int -buffer_diff (char *buf_a, char *buf_b, char *buf_diff, - int width, int height, int stride) -{ - int x, y; - int total_pixels_changed = 0; - unsigned char *row_a, *row_b, *row; - - for (y = 0; y < height; y++) - { - row_a = buf_a + y * stride; - row_b = buf_b + y * stride; - row = buf_diff + y * stride; - for (x = 0; x < width; x++) - { - int channel; - unsigned char value_a, value_b; - int pixel_changed = 0; - for (channel = 0; channel < 4; channel++) - { - double diff; - value_a = row_a[x * 4 + channel]; - value_b = row_b[x * 4 + channel]; - if (value_a != value_b) - pixel_changed = 1; - diff = value_a - value_b; - row[x * 4 + channel] = 128 + diff / 3.0; - } - if (pixel_changed) { - total_pixels_changed++; - } else { - row[x*4+0] = 0; - row[x*4+1] = 0; - row[x*4+2] = 0; - } - row[x * 4 + 3] = 0xff; /* Set ALPHA to 100% (opaque) */ - } - } - - return total_pixels_changed; -} diff --git a/test/buffer_diff.h b/test/buffer_diff.h deleted file mode 100644 index 9ee51c3c..00000000 --- a/test/buffer_diff.h +++ /dev/null @@ -1,38 +0,0 @@ -/* imagediff - Compare two images - * - * Copyright © 2004 Richard D. Worth - * - * 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 Richard Worth - * not be used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Richard Worth makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * RICHARD WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL RICHARD WORTH 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: Richard D. Worth <richard@theworths.org> */ - -#ifndef BUFFER_DIFF_H -#define BUFFER_DIFF_H - -/* Image comparison code courttesy of Richard Worth. - * Returns number of pixels changed. - * Also fills out a "diff" image intended to visually show where the - * images differ. - */ -int -buffer_diff (char *buf_a, char *buf_b, char *buf_diff, - int width, int height, int stride); - -#endif diff --git a/test/cairo-test.c b/test/cairo-test.c index 5cee2058..835bf38a 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -30,11 +30,11 @@ #include <errno.h> #include <string.h> -#include "cairo_test.h" +#include "cairo-test.h" -#include "buffer_diff.h" -#include "read_png.h" -#include "write_png.h" +#include "buffer-diff.h" +#include "read-png.h" +#include "write-png.h" #include "xmalloc.h" #define CAIRO_TEST_LOG_SUFFIX ".log" diff --git a/test/cairo_test.c b/test/cairo_test.c deleted file mode 100644 index 5cee2058..00000000 --- a/test/cairo_test.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * 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 <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> - -#include "cairo_test.h" - -#include "buffer_diff.h" -#include "read_png.h" -#include "write_png.h" -#include "xmalloc.h" - -#define CAIRO_TEST_LOG_SUFFIX ".log" -#define CAIRO_TEST_PNG_SUFFIX "-out.png" -#define CAIRO_TEST_REF_SUFFIX "-ref.png" -#define CAIRO_TEST_DIFF_SUFFIX "-diff.png" - -static void -xasprintf (char **strp, const char *fmt, ...) -{ -#ifdef HAVE_VASPRINTF - va_list va; - int ret; - - va_start (va, fmt); - ret = vasprintf (strp, fmt, va); - va_end (va); - - if (ret < 0) { - fprintf (stderr, "Out of memory\n"); - exit (1); - } -#else /* !HAVE_VASNPRINTF */ -#define BUF_SIZE 1024 - va_list va; - char buffer[BUF_SIZE]; - int ret; - - va_start (va, fmt); - ret = vsnprintf (buffer, sizeof(buffer), fmt, va); - va_end (va); - - if (ret < 0) { - fprintf (stderr, "Failure in vsnprintf\n"); - exit (1); - } - - if (strlen (buffer) == sizeof(buffer) - 1) { - fprintf (stderr, "Overflowed fixed buffer\n"); - exit (1); - } - - *strp = strdup (buffer); - if (!*strp) { - fprintf (stderr, "Out of memory\n"); - exit (1); - } -#endif /* !HAVE_VASNPRINTF */ -} - -static void -xunlink (const char *pathname) -{ - if (unlink (pathname) < 0 && errno != ENOENT) { - fprintf (stderr, " Error: Cannot remove %s: %s\n", - pathname, strerror (errno)); - exit (1); - } -} - -cairo_test_status_t -cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw) -{ - cairo_test_status_t status; - cairo_t *cr; - int stride; - unsigned char *png_buf, *ref_buf, *diff_buf; - char *log_name, *png_name, *ref_name, *diff_name; - char *srcdir; - int pixels_changed; - int ref_width, ref_height, ref_stride; - read_png_status_t png_status; - cairo_test_status_t ret; - FILE *png_file; - FILE *log_file; - - /* Get the strings ready that we'll need. */ - srcdir = getenv ("srcdir"); - if (!srcdir) - srcdir = "."; - xasprintf (&log_name, "%s%s", test->name, CAIRO_TEST_LOG_SUFFIX); - xasprintf (&png_name, "%s%s", test->name, CAIRO_TEST_PNG_SUFFIX); - xasprintf (&ref_name, "%s/%s%s", srcdir, test->name, CAIRO_TEST_REF_SUFFIX); - xasprintf (&diff_name, "%s%s", test->name, CAIRO_TEST_DIFF_SUFFIX); - - xunlink (log_name); - - /* Run the actual drawing code. */ - cr = cairo_create (); - - stride = 4 * test->width; - - png_buf = xcalloc (stride * test->height, 1); - diff_buf = xcalloc (stride * test->height, 1); - - cairo_set_target_image (cr, png_buf, CAIRO_FORMAT_ARGB32, - test->width, test->height, stride); - - status = (draw) (cr, test->width, test->height); - - /* Then, check all the different ways it could fail. */ - if (status) { - log_file = fopen (log_name, "a"); - fprintf (log_file, "Error: Function under test failed\n"); - fclose (log_file); - return status; - } - - if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { - log_file = fopen (log_name, "a"); - fprintf (log_file, "Error: Function under test left cairo status in an error state: %s\n", cairo_status_string (cr)); - fclose (log_file); - return CAIRO_TEST_FAILURE; - } - - cairo_destroy (cr); - - /* Skip image check for tests with no image (width,height == 0,0) */ - if (test->width == 0 || test->height == 0) { - free (png_buf); - free (diff_buf); - return CAIRO_TEST_SUCCESS; - } - - png_file = fopen (png_name, "wb"); - write_png_argb32 (png_buf, png_file, test->width, test->height, stride); - fclose (png_file); - - ref_buf = NULL; - png_status = (read_png_argb32 (ref_name, &ref_buf, &ref_width, &ref_height, &ref_stride)); - if (png_status) { - log_file = fopen (log_name, "a"); - switch (png_status) - { - case READ_PNG_FILE_NOT_FOUND: - fprintf (log_file, "Error: No reference image found: %s\n", ref_name); - break; - case READ_PNG_FILE_NOT_PNG: - fprintf (log_file, "Error: %s is not a png image\n", ref_name); - break; - default: - fprintf (log_file, "Error: Failed to read %s\n", ref_name); - } - fclose (log_file); - - ret = CAIRO_TEST_FAILURE; - goto BAIL; - } else { - } - - if (test->width != ref_width || test->height != ref_height) { - log_file = fopen (log_name, "a"); - fprintf (log_file, - "Error: Image size mismatch: (%dx%d) vs. (%dx%d)\n" - " for %s vs %s\n", - test->width, test->height, - ref_width, ref_height, - png_name, ref_name); - fclose (log_file); - - ret = CAIRO_TEST_FAILURE; - goto BAIL; - } - - pixels_changed = buffer_diff (png_buf, ref_buf, diff_buf, - test->width, test->height, stride); - if (pixels_changed) { - log_file = fopen (log_name, "a"); - fprintf (log_file, "Error: %d pixels differ from reference image %s\n", - pixels_changed, ref_name); - png_file = fopen (diff_name, "wb"); - write_png_argb32 (diff_buf, png_file, test->width, test->height, stride); - fclose (png_file); - fclose (log_file); - - ret = CAIRO_TEST_FAILURE; - goto BAIL; - } else { - xunlink (diff_name); - } - - ret = CAIRO_TEST_SUCCESS; - -BAIL: - free (png_buf); - free (ref_buf); - free (diff_buf); - free (log_name); - free (png_name); - free (ref_name); - free (diff_name); - - return ret; -} - -cairo_pattern_t * -cairo_test_create_png_pattern (cairo_t *cr, const char *filename) -{ - cairo_surface_t *image; - cairo_pattern_t *pattern; - unsigned char *buffer; - int w, h, stride; - read_png_status_t status; - char *srcdir = getenv ("srcdir"); - - status = read_png_argb32 (filename, &buffer, &w,&h, &stride); - if (status != READ_PNG_SUCCESS) { - if (srcdir) { - char *srcdir_filename; - xasprintf (&srcdir_filename, "%s/%s", srcdir, filename); - status = read_png_argb32 (srcdir_filename, &buffer, &w,&h, &stride); - free (srcdir_filename); - } - } - if (status != READ_PNG_SUCCESS) - return NULL; - - image = cairo_surface_create_for_image (buffer, CAIRO_FORMAT_ARGB32, - w, h, stride); - - cairo_surface_set_repeat (image, 1); - - pattern = cairo_pattern_create_for_surface (image); - - return pattern; -} diff --git a/test/cairo_test.h b/test/cairo_test.h deleted file mode 100644 index cc18a793..00000000 --- a/test/cairo_test.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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> - */ - -#ifndef _CAIRO_TEST_H_ -#define _CAIRO_TEST_H_ - -#include <math.h> -#include <cairo.h> - -typedef enum cairo_test_status { - CAIRO_TEST_SUCCESS = 0, - CAIRO_TEST_FAILURE -} cairo_test_status_t; - -typedef struct cairo_test { - char *name; - char *description; - int width; - int height; -} cairo_test_t; - -typedef cairo_test_status_t (*cairo_test_draw_function_t) (cairo_t *cr, int width, int height); - -/* cairo_test.c */ -cairo_test_status_t -cairo_test (cairo_test_t *test, cairo_test_draw_function_t draw); - -cairo_pattern_t * -cairo_test_create_png_pattern (cairo_t *cr, const char *filename); - - -#endif - diff --git a/test/clip-twice.c b/test/clip-twice.c index 50db5fe2..8862199e 100644 --- a/test/clip-twice.c +++ b/test/clip-twice.c @@ -23,13 +23,13 @@ * Author: Kristian Høgsberg <krh@redhat.com> */ -#include "cairo_test.h" +#include "cairo-test.h" #define WIDTH 64 #define HEIGHT 64 cairo_test_t test = { - "clip_twice", + "clip-twice", "Verifies that the clip mask is updated correctly when it constructed by setting the clip path twice.", WIDTH, HEIGHT }; diff --git a/test/clip_twice-ref.png b/test/clip_twice-ref.png Binary files differdeleted file mode 100644 index ab0ae1ae..00000000 --- a/test/clip_twice-ref.png +++ /dev/null diff --git a/test/clip_twice.c b/test/clip_twice.c deleted file mode 100644 index 50db5fe2..00000000 --- a/test/clip_twice.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2005 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: Kristian Høgsberg <krh@redhat.com> - */ - -#include "cairo_test.h" - -#define WIDTH 64 -#define HEIGHT 64 - -cairo_test_t test = { - "clip_twice", - "Verifies that the clip mask is updated correctly when it constructed by setting the clip path twice.", - WIDTH, HEIGHT -}; - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - cairo_set_alpha (cr, 1.0); - cairo_new_path (cr); - cairo_arc (cr, WIDTH / 2, HEIGHT / 2, WIDTH / 3, 0, 2 * M_PI); - cairo_clip (cr); - - cairo_new_path (cr); - cairo_move_to (cr, 0, 0); - cairo_line_to (cr, WIDTH / 4, HEIGHT / 2); - cairo_line_to (cr, 0, HEIGHT); - cairo_line_to (cr, WIDTH, HEIGHT); - cairo_line_to (cr, 3 * WIDTH / 4, HEIGHT / 2); - cairo_line_to (cr, WIDTH, 0); - cairo_close_path (cr); - cairo_clip (cr); - - cairo_set_rgb_color (cr, 0, 0, 0.6); - - cairo_new_path (cr); - cairo_move_to (cr, 0, 0); - cairo_line_to (cr, 0, HEIGHT); - cairo_line_to (cr, WIDTH / 2, 3 * HEIGHT / 4); - cairo_line_to (cr, WIDTH, HEIGHT); - cairo_line_to (cr, WIDTH, 0); - cairo_line_to (cr, WIDTH / 2, HEIGHT / 4); - cairo_close_path (cr); - cairo_fill (cr); - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/coverage.c b/test/coverage.c index e11c99b8..1928e221 100644 --- a/test/coverage.c +++ b/test/coverage.c @@ -24,7 +24,7 @@ */ #include <math.h> -#include "cairo_test.h" +#include "cairo-test.h" #define WIDTH 64 #define HEIGHT 64 diff --git a/test/fill-rule.c b/test/fill-rule.c index 20a74eb9..6d5f3b46 100644 --- a/test/fill-rule.c +++ b/test/fill-rule.c @@ -61,13 +61,13 @@ * */ -#include "cairo_test.h" +#include "cairo-test.h" #define LITTLE_STAR_SIZE 20 #define BIG_STAR_SIZE 80 cairo_test_t test = { - "fill_rule", + "fill-rule", "Tests cairo_set_full_rule with some star shapes", BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3 }; diff --git a/test/fill_rule-ref.png b/test/fill_rule-ref.png Binary files differdeleted file mode 100644 index e2e10d4a..00000000 --- a/test/fill_rule-ref.png +++ /dev/null diff --git a/test/fill_rule.c b/test/fill_rule.c deleted file mode 100644 index 20a74eb9..00000000 --- a/test/fill_rule.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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> - */ - -/* Bug history - * - * 2004-10-27 Carl Worth <cworth@cworth.org> - * - * There's currently a regression bug in the tessellation code. This - * causes each of these simple star shapes to be filled incorrectly. - * - * It looks like right now we can get this test to pass by doing: - * - * cvs update -r 1.16 src/cairo_traps.c - * - * But we don't want to revert that change permanently since it - * really does correct some bugs. It must be that the old version of - * the code is masking some other bugs in the tessellation code. My - * current plan is to back this revision up for the next snapshot, - * but not to list the test as an expected failure since I'm - * planning on doing the new tessellator which should fix this - * problem. - * - * 2005-01-11 Carl Worth <cworth@cworth.org> - * - * Keith committed some fixes that fix the original size-20 - * star_path: - * - * * src/cairo_wideint.c: (_cairo_int32x32_64_mul), - * (_cairo_int64x64_128_mul): - * * src/cairo_wideint.h: - * int32x32_64_mul and int64x64_128_mul are different from their - * unsigned compatriots - * - * 2005-01-12 Carl Worth <cworth@cworth.org> - * - * Going back to the SVG test suite, however, the original star - * shape is still broken. Adding both shapes now as little_star_path - * and big_star_path. - * - */ - -#include "cairo_test.h" - -#define LITTLE_STAR_SIZE 20 -#define BIG_STAR_SIZE 80 - -cairo_test_t test = { - "fill_rule", - "Tests cairo_set_full_rule with some star shapes", - BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3 -}; - -/* The SVG start trimmed down, but still showing the bug (originally) */ -static void -little_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); -} - -/* The star shape from the SVG test suite. This was is still buggy even after - we got little_star_path working. */ -static void -big_star_path (cairo_t *cr) -{ - cairo_move_to (cr, 40, 0); - cairo_rel_line_to (cr, 25, 80); - cairo_rel_line_to (cr, -65, -50); - cairo_rel_line_to (cr, 80, 0); - cairo_rel_line_to (cr, -65, 50); - cairo_close_path (cr); -} - -/* Fill the same path twice, once with each fill rule */ -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - cairo_set_rgb_color (cr, 1, 0, 0); - - cairo_translate (cr, 1, 1); - little_star_path (cr); - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); - cairo_fill (cr); - - cairo_translate (cr, LITTLE_STAR_SIZE + 1, 0); - little_star_path (cr); - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); - cairo_fill (cr); - - cairo_translate (cr, -(LITTLE_STAR_SIZE + 1), LITTLE_STAR_SIZE + 1); - big_star_path (cr); - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); - cairo_fill (cr); - - cairo_translate (cr, BIG_STAR_SIZE + 1, 0); - big_star_path (cr); - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); - cairo_fill (cr); - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/get-and-set.c b/test/get-and-set.c index 05643ca2..c7d54a67 100644 --- a/test/get-and-set.c +++ b/test/get-and-set.c @@ -23,10 +23,10 @@ * Author: Carl D. Worth <cworth@cworth.org> */ -#include "cairo_test.h" +#include "cairo-test.h" cairo_test_t test = { - "get_and_set", + "get-and-set", "Tests calls to the most trivial cairo_get and cairo_set functions", 0, 0 }; diff --git a/test/get_and_set.c b/test/get_and_set.c deleted file mode 100644 index 05643ca2..00000000 --- a/test/get_and_set.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright © 2005 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" - -cairo_test_t test = { - "get_and_set", - "Tests calls to the most trivial cairo_get and cairo_set functions", - 0, 0 -}; - -typedef struct { - cairo_operator_t operator; - double tolerance; - double point_x; - double point_y; - cairo_fill_rule_t fill_rule; - double line_width; - cairo_line_cap_t line_cap; - cairo_line_join_t line_join; - double miter_limit; - /* XXX: Add cairo_matrix_t here when it is exposed */ -} settings_t; - -/* Two sets of settings, no defaults */ -settings_t settings[] = { - { - CAIRO_OPERATOR_IN, - 2.0, - 12.3, - 4.56, - CAIRO_FILL_RULE_EVEN_ODD, - 7.7, - CAIRO_LINE_CAP_SQUARE, - CAIRO_LINE_JOIN_ROUND, - 3.14 - }, - { - CAIRO_OPERATOR_ATOP, - 5.25, - 99.99, - 0.001, - CAIRO_FILL_RULE_WINDING, - 2.17, - CAIRO_LINE_CAP_ROUND, - CAIRO_LINE_JOIN_BEVEL, - 1000.0 - } -}; - -static void -settings_set (cairo_t *cr, settings_t *settings) -{ - cairo_set_operator (cr, settings->operator); - cairo_set_tolerance (cr, settings->tolerance); - cairo_move_to (cr, settings->point_x, settings->point_y); - cairo_set_fill_rule (cr, settings->fill_rule); - cairo_set_line_width (cr, settings->line_width); - cairo_set_line_cap (cr, settings->line_cap); - cairo_set_line_join (cr, settings->line_join); - cairo_set_miter_limit (cr, settings->miter_limit); -} - -static void -settings_get (cairo_t *cr, settings_t *settings) -{ - settings->operator = cairo_get_operator (cr); - settings->tolerance = cairo_get_tolerance (cr); - cairo_get_current_point (cr, &settings->point_x, &settings->point_y); - settings->fill_rule = cairo_get_fill_rule (cr); - settings->line_width = cairo_get_line_width (cr); - settings->line_cap = cairo_get_line_cap (cr); - settings->line_join = cairo_get_line_join (cr); - settings->miter_limit = cairo_get_miter_limit (cr); -} - -/* Maximum error is one part of our fixed-point grid */ -#define EPSILON (1.0 / 65536.0) - -static int -DOUBLES_WITHIN_EPSILON(double a, double b) { - double delta = fabs(a - b); - return delta < EPSILON; -} - -static int -settings_equal (settings_t *a, settings_t *b) -{ - return (a->operator == b->operator && - a->tolerance == b->tolerance && - DOUBLES_WITHIN_EPSILON (a->point_x, b->point_x) && - DOUBLES_WITHIN_EPSILON (a->point_y, b->point_y) && - a->fill_rule == b->fill_rule && - a->line_width == b->line_width && - a->line_cap == b->line_cap && - a->line_join == b->line_join && - a->miter_limit == b->miter_limit); -} - -static cairo_test_status_t -get_and_set (cairo_t *cr, int width, int height) -{ - settings_t check; - - settings_set (cr, &settings[0]); - - cairo_save (cr); - { - settings_set (cr, &settings[1]); - settings_get (cr, &check); - - if (!settings_equal (&settings[1], &check)) - return CAIRO_TEST_FAILURE; - } - cairo_restore (cr); - - settings_get (cr, &check); - - if (!settings_equal (&settings[0], &check)) - return CAIRO_TEST_FAILURE; - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, get_and_set); -} diff --git a/test/imagediff.c b/test/imagediff.c index 36962f11..52ea7d41 100644 --- a/test/imagediff.c +++ b/test/imagediff.c @@ -26,9 +26,9 @@ #include <stdio.h> #include <stdlib.h> -#include "buffer_diff.h" -#include "read_png.h" -#include "write_png.h" +#include "buffer-diff.h" +#include "read-png.h" +#include "write-png.h" #include "xmalloc.h" int diff --git a/test/leaky-polygon.c b/test/leaky-polygon.c index 6ac3698e..575311ee 100644 --- a/test/leaky-polygon.c +++ b/test/leaky-polygon.c @@ -51,13 +51,13 @@ * */ -#include "cairo_test.h" +#include "cairo-test.h" #define WIDTH 21 #define HEIGHT 21 cairo_test_t test = { - "leaky_polygon", + "leaky-polygon", "Exercises a corner case in the trapezoid rasterization in which pixels outside the trapezoids received a non-zero alpha", WIDTH, HEIGHT }; diff --git a/test/leaky_polygon-ref.png b/test/leaky_polygon-ref.png Binary files differdeleted file mode 100644 index 0daabe15..00000000 --- a/test/leaky_polygon-ref.png +++ /dev/null diff --git a/test/leaky_polygon.c b/test/leaky_polygon.c deleted file mode 100644 index 6ac3698e..00000000 --- a/test/leaky_polygon.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright © 2005 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> - */ - -/* Bug history - * - * 2005-01-07 Carl Worth <cworth@cworth.org> - * - * Bug reported: - * - * From: Chris <fltk@functionalfuture.com> - * Subject: [cairo] Render to image buffer artifacts - * To: cairo@cairographics.org - * Date: Fri, 07 Jan 2005 02:22:28 -0500 - * - * I've attached the code and image that shows this off. Scaling at - * different levels seems to change the corruption. - * - * For some reason there are artifacts in the alpha channel. I don't know - * if that's the only place, but the alpha channel looks bad. - * - * If you run the code and parse the attached image, directing stdout to a - * file, you can see in the lower left corner there are alpha values where - * it should be transparent. - * [...] - * - * 2005-01-11 Carl Worth <cworth@cworth.org> - * - * I trimmed the original test case down to the code that appears here. - * - */ - -#include "cairo_test.h" - -#define WIDTH 21 -#define HEIGHT 21 - -cairo_test_t test = { - "leaky_polygon", - "Exercises a corner case in the trapezoid rasterization in which pixels outside the trapezoids received a non-zero alpha", - WIDTH, HEIGHT -}; - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - cairo_scale (cr, 1.0/(1<<16), 1.0/(1<<16)); - - cairo_move_to (cr, 131072,39321); - cairo_line_to (cr, 1103072,1288088); - cairo_line_to (cr, 1179648,1294990); - cairo_close_path (cr); - - cairo_fill (cr); - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/line-width.c b/test/line-width.c index 41e74199..285b66b8 100644 --- a/test/line-width.c +++ b/test/line-width.c @@ -23,7 +23,7 @@ * Author: Carl D. Worth <cworth@cworth.org> */ -#include "cairo_test.h" +#include "cairo-test.h" #define LINES 5 #define LINE_LENGTH 10 @@ -31,7 +31,7 @@ #define IMAGE_HEIGHT ((LINES+4)*LINES)/2 + 2 cairo_test_t test = { - "line_width", + "line-width", "Tests cairo_set_line_width", IMAGE_WIDTH, IMAGE_HEIGHT }; diff --git a/test/line_width-ref.png b/test/line_width-ref.png Binary files differdeleted file mode 100644 index ddcd929d..00000000 --- a/test/line_width-ref.png +++ /dev/null diff --git a/test/line_width.c b/test/line_width.c deleted file mode 100644 index 41e74199..00000000 --- a/test/line_width.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 LINES 5 -#define LINE_LENGTH 10 -#define IMAGE_WIDTH 2 * LINE_LENGTH + 6 -#define IMAGE_HEIGHT ((LINES+4)*LINES)/2 + 2 - -cairo_test_t test = { - "line_width", - "Tests cairo_set_line_width", - IMAGE_WIDTH, IMAGE_HEIGHT -}; - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - int i; - - cairo_set_rgb_color (cr, 0, 0, 0); - cairo_translate (cr, 2, 2); - - for (i=0; i < LINES; i++) { - cairo_set_line_width (cr, i+1); - cairo_move_to (cr, 0, 0); - cairo_rel_line_to (cr, LINE_LENGTH, 0); - cairo_stroke (cr); - cairo_move_to (cr, LINE_LENGTH + 2, 0.5); - cairo_rel_line_to (cr, LINE_LENGTH, 0); - cairo_stroke (cr); - cairo_translate (cr, 0, i+3); - } - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/linear-gradient.c b/test/linear-gradient.c index 5711d15b..418ddf2f 100644 --- a/test/linear-gradient.c +++ b/test/linear-gradient.c @@ -23,7 +23,7 @@ * Author: Owen Taylor <otaylor@redhat.com> */ -#include "cairo_test.h" +#include "cairo-test.h" #include "stdio.h" /* The test matrix is @@ -55,7 +55,7 @@ static const int n_stops[] = { 2, 3 }; #define HEIGHT N_N_STOPS * N_ROTATE_ANGLES * UNIT_SIZE + (N_N_STOPS * N_ROTATE_ANGLES + 1) * PAD cairo_test_t test = { - "linear_gradient", + "linear-gradient", "Tests the drawing of linear gradients", WIDTH, HEIGHT }; diff --git a/test/linear_gradient-ref.png b/test/linear_gradient-ref.png Binary files differdeleted file mode 100644 index 77904144..00000000 --- a/test/linear_gradient-ref.png +++ /dev/null diff --git a/test/linear_gradient.c b/test/linear_gradient.c deleted file mode 100644 index 5711d15b..00000000 --- a/test/linear_gradient.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright © 2005 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: Owen Taylor <otaylor@redhat.com> - */ - -#include "cairo_test.h" -#include "stdio.h" - -/* The test matrix is - * - * A) Horizontal B) 5° C) 45° D) Vertical - * 1) Rotated 0° 2) Rotated 45° C) Rotated 90° - * a) 2 stop b) 3 stop - * - * A1a B1a C1a D1a - * A2a B2a C2a D2a - * A3a B3a C3a D3a - * A1b B1b C1b D1b - * A2b B2b C2b D2b - * A3b B3b C3b D3b - */ - -static const double gradient_angles[] = { 0, 45, 90 }; -#define N_GRADIENT_ANGLES 3 -static const double rotate_angles[] = { 0, 45, 90 }; -#define N_ROTATE_ANGLES 3 -static const int n_stops[] = { 2, 3 }; -#define N_N_STOPS 2 - -#define UNIT_SIZE 75 -#define UNIT_SIZE 75 -#define PAD 5 - -#define WIDTH N_GRADIENT_ANGLES * UNIT_SIZE + (N_GRADIENT_ANGLES + 1) * PAD -#define HEIGHT N_N_STOPS * N_ROTATE_ANGLES * UNIT_SIZE + (N_N_STOPS * N_ROTATE_ANGLES + 1) * PAD - -cairo_test_t test = { - "linear_gradient", - "Tests the drawing of linear gradients", - WIDTH, HEIGHT -}; - -static void -draw_unit (cairo_t *cr, - double gradient_angle, - double rotate_angle, - int n_stops) -{ - cairo_pattern_t *pattern; - - cairo_rectangle (cr, 0, 0, 1, 1); - cairo_clip (cr); - cairo_new_path(cr); - - cairo_set_rgb_color (cr, 0.0, 0.0, 0.0); - cairo_rectangle (cr, 0, 0, 1, 1); - cairo_fill (cr); - - cairo_translate (cr, 0.5, 0.5); - cairo_scale (cr, 1 / 1.5, 1 / 1.5); - cairo_rotate (cr, rotate_angle); - - pattern = cairo_pattern_create_linear (-0.5 * cos (gradient_angle), -0.5 * sin (gradient_angle), - 0.5 * cos (gradient_angle), 0.5 * sin (gradient_angle)); - - if (n_stops == 2) { - cairo_pattern_add_color_stop (pattern, 0., - 0.3, 0.3, 0.3, - 1.0); - cairo_pattern_add_color_stop (pattern, 1., - 1.0, 1.0, 1.0, - 1.0); - } else { - cairo_pattern_add_color_stop (pattern, 0., - 1.0, 0.0, 0.0, - 1.0); - cairo_pattern_add_color_stop (pattern, 0.5, - 1.0, 1.0, 1.0, - 1.0); - cairo_pattern_add_color_stop (pattern, 1., - 0.0, 0.0, 1.0, - 1.0); - } - - cairo_set_pattern (cr, pattern); - cairo_pattern_destroy (pattern); - cairo_rectangle (cr, -0.5, -0.5, 1, 1); - cairo_fill (cr); -} - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - int i, j, k; - - cairo_set_rgb_color (cr, 0.5, 0.5, 0.5); - cairo_rectangle (cr, 0, 0, width, height); - cairo_fill (cr); - - for (i = 0; i < N_GRADIENT_ANGLES; i++) - for (j = 0; j < N_ROTATE_ANGLES; j++) - for (k = 0; k < N_N_STOPS; k++) { - cairo_save (cr); - cairo_translate (cr, - PAD + (PAD + UNIT_SIZE) * i, - PAD + (PAD + UNIT_SIZE) * (N_ROTATE_ANGLES * k + j)); - cairo_scale (cr, UNIT_SIZE, UNIT_SIZE); - - draw_unit (cr, - gradient_angles[i] * M_PI / 180., - rotate_angles[j] * M_PI / 180., - n_stops[k]); - cairo_restore (cr); - } - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/move-to-show-surface.c b/test/move-to-show-surface.c index a52c18ea..48e3b16a 100644 --- a/test/move-to-show-surface.c +++ b/test/move-to-show-surface.c @@ -35,10 +35,10 @@ */ -#include "cairo_test.h" +#include "cairo-test.h" cairo_test_t test = { - "move_to_show_surface", + "move-to-show-surface", "Tests calls to cairo_show_surface after cairo_move_to", 2, 2 }; diff --git a/test/move_to_show_surface-ref.png b/test/move_to_show_surface-ref.png Binary files differdeleted file mode 100644 index 765adc4a..00000000 --- a/test/move_to_show_surface-ref.png +++ /dev/null diff --git a/test/move_to_show_surface.c b/test/move_to_show_surface.c deleted file mode 100644 index a52c18ea..00000000 --- a/test/move_to_show_surface.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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> - */ - -/* Bug history - * - * 2004-10-25 Carl Worth <cworth@cworth.org> - * - * It looks like cairo_show_surface has no effect if it follows a - * call to cairo_move_to to any coordinate other than 0,0. A little - * bit of poking around suggests this isn't a regression, (at least - * not since the last pixman snapshot). - * - */ - - -#include "cairo_test.h" - -cairo_test_t test = { - "move_to_show_surface", - "Tests calls to cairo_show_surface after cairo_move_to", - 2, 2 -}; - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - cairo_surface_t *surface; - uint32_t colors[4] = { - 0xffffffff, 0xffff0000, - 0xff00ff00, 0xff0000ff - }; - int i; - - for (i=0; i < 4; i++) { - surface = cairo_surface_create_for_image ((char *) &colors[i], - CAIRO_FORMAT_ARGB32, 1, 1, 4); - cairo_move_to (cr, i % 2, i / 2); - cairo_show_surface (cr, surface, 1, 1); - cairo_surface_destroy (surface); - } - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/path-data.c b/test/path-data.c index 548d205e..db30e8f5 100644 --- a/test/path-data.c +++ b/test/path-data.c @@ -24,10 +24,10 @@ */ #include <stdlib.h> -#include "cairo_test.h" +#include "cairo-test.h" cairo_test_t test = { - "path_data", + "path-data", "Tests calls to path_data functions: cairo_copy_path_data, cairo_copy_path_data_flat, and cairo_append_path_data", 45, 53 }; diff --git a/test/path_data-ref.png b/test/path_data-ref.png Binary files differdeleted file mode 100644 index f8bc6475..00000000 --- a/test/path_data-ref.png +++ /dev/null diff --git a/test/path_data.c b/test/path_data.c deleted file mode 100644 index 548d205e..00000000 --- a/test/path_data.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright © 2005 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 <stdlib.h> -#include "cairo_test.h" - -cairo_test_t test = { - "path_data", - "Tests calls to path_data functions: cairo_copy_path_data, cairo_copy_path_data_flat, and cairo_append_path_data", - 45, 53 -}; - -static void -scale_by_two (double *x, double *y) -{ - *x = *x * 2.0; - *y = *y * 2.0; -} - -typedef void (*munge_func_t) (double *x, double *y); - -static void -munge_and_set_path (cairo_t *cr, - cairo_path_t *path, - munge_func_t munge) -{ - int i; - cairo_path_data_t *p; - double x1, y1, x2, y2, x3, y3; - - for (i=0; i < path->num_data; i += path->data[i].header.length) { - p = &path->data[i]; - switch (p->header.type) { - case CAIRO_PATH_MOVE_TO: - x1 = p[1].point.x; y1 = p[1].point.y; - (munge) (&x1, &y1); - cairo_move_to (cr, x1, y1); - break; - case CAIRO_PATH_LINE_TO: - x1 = p[1].point.x; y1 = p[1].point.y; - (munge) (&x1, &y1); - cairo_line_to (cr, x1, y1); - break; - case CAIRO_PATH_CURVE_TO: - x1 = p[1].point.x; y1 = p[1].point.y; - x2 = p[2].point.x; y2 = p[2].point.y; - x3 = p[3].point.x; y3 = p[3].point.y; - (munge) (&x1, &y1); - (munge) (&x2, &y2); - (munge) (&x3, &y3); - cairo_curve_to (cr, - x1, y1, - x2, y2, - x3, y3); - break; - case CAIRO_PATH_CLOSE_PATH: - cairo_close_path (cr); - break; - } - } -} - -static void -make_path (cairo_t *cr) -{ - cairo_rectangle (cr, 0, 0, 5, 5); - cairo_move_to (cr, 15, 2.5); - cairo_arc (cr, 12.5, 2.5, 2.5, 0, 2 * M_PI); -} - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - cairo_path_t *path; - - /* copy path, munge, and fill */ - cairo_translate (cr, 5, 5); - make_path (cr); - path = cairo_copy_path (cr); - - cairo_new_path (cr); - munge_and_set_path (cr, path, scale_by_two); - cairo_path_destroy (path); - cairo_fill (cr); - - /* copy flattened path, munge, and fill */ - cairo_translate (cr, 0, 15); - make_path (cr); - path = cairo_copy_path_flat (cr); - - cairo_new_path (cr); - munge_and_set_path (cr, path, scale_by_two); - cairo_path_destroy (path); - cairo_fill (cr); - - /* append two copies of path, and fill */ - cairo_translate (cr, 0, 15); - cairo_scale (cr, 2.0, 2.0); - make_path (cr); - path = cairo_copy_path (cr); - - cairo_new_path (cr); - cairo_append_path (cr, path); - cairo_translate (cr, 2.5, 2.5); - cairo_append_path (cr, path); - - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); - cairo_fill (cr); - - cairo_path_destroy (path); - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - cairo_t *cr; - cairo_path_data_t data; - cairo_path_t path; - - /* Test a few error cases for cairo_append_path_data */ - cr = cairo_create (); - cairo_append_path (cr, NULL); - if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER) - return 1; - cairo_destroy (cr); - - cr = cairo_create (); - path.data = NULL; - path.num_data = 0; - cairo_append_path (cr, &path); - if (cairo_status (cr) != CAIRO_STATUS_NULL_POINTER) - return 1; - cairo_destroy (cr); - - cr = cairo_create (); - /* Intentionally insert bogus header.length value (otherwise would be 2) */ - data.header.type = CAIRO_PATH_MOVE_TO; - data.header.length = 1; - path.data = &data; - path.num_data = 1; - cairo_append_path (cr, &path); - if (cairo_status (cr) != CAIRO_STATUS_INVALID_PATH_DATA) - return 1; - cairo_destroy (cr); - - /* And test the degnerate case */ - cr = cairo_create (); - path.num_data = 0; - cairo_append_path (cr, &path); - if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) - return 1; - cairo_destroy (cr); - - return cairo_test (&test, draw); -} diff --git a/test/pixman-rotate.c b/test/pixman-rotate.c index d2848dd0..a5e52d2c 100644 --- a/test/pixman-rotate.c +++ b/test/pixman-rotate.c @@ -7,7 +7,7 @@ #include <cairo-png.h> #include <cairo-pdf.h> -#include "cairo_test.h" +#include "cairo-test.h" #define WIDTH 32 #define HEIGHT WIDTH @@ -16,7 +16,7 @@ #define IMAGE_HEIGHT IMAGE_WIDTH cairo_test_t test = { - "pixman_rotate", + "pixman-rotate", "Exposes pixman off-by-one error when rotating", IMAGE_WIDTH, IMAGE_HEIGHT }; diff --git a/test/pixman_rotate-ref.png b/test/pixman_rotate-ref.png Binary files differdeleted file mode 100644 index 7e47a4d8..00000000 --- a/test/pixman_rotate-ref.png +++ /dev/null diff --git a/test/pixman_rotate.c b/test/pixman_rotate.c deleted file mode 100644 index d2848dd0..00000000 --- a/test/pixman_rotate.c +++ /dev/null @@ -1,80 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include <cairo.h> -#include <cairo-png.h> -#include <cairo-pdf.h> - -#include "cairo_test.h" - -#define WIDTH 32 -#define HEIGHT WIDTH - -#define IMAGE_WIDTH (3 * WIDTH) -#define IMAGE_HEIGHT IMAGE_WIDTH - -cairo_test_t test = { - "pixman_rotate", - "Exposes pixman off-by-one error when rotating", - IMAGE_WIDTH, IMAGE_HEIGHT -}; - -/* Draw the word cairo at NUM_TEXT different angles */ -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - cairo_surface_t *target, *stamp; - - target = cairo_get_target_surface (cr); - cairo_surface_reference (target); - - stamp = cairo_surface_create_similar (target, CAIRO_FORMAT_ARGB32, - WIDTH, HEIGHT); - cairo_set_target_surface (cr, stamp); - cairo_new_path (cr); - cairo_rectangle (cr, WIDTH / 4, HEIGHT / 4, WIDTH / 2, HEIGHT / 2); - cairo_set_rgb_color (cr, 1, 0, 0); - cairo_set_alpha (cr, 0.8); - cairo_fill (cr); - - cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT); - cairo_set_line_width (cr, 2); - cairo_set_rgb_color (cr, 0, 0, 0); - cairo_set_alpha (cr, 1); - cairo_stroke (cr); - - cairo_set_target_surface (cr, target); - - /* Draw a translucent rectangle for reference where the rotated - * image should be. */ - cairo_new_path (cr); - cairo_rectangle (cr, WIDTH, HEIGHT, WIDTH, HEIGHT); - cairo_set_rgb_color (cr, 1, 1, 0); - cairo_set_alpha (cr, 0.3); - cairo_fill (cr); - -#if 1 /* Set to 0 to generate reference image */ - cairo_translate (cr, 2 * WIDTH, 2 * HEIGHT); - cairo_rotate (cr, M_PI); -#else - cairo_translate (cr, WIDTH, HEIGHT); -#endif - - cairo_set_alpha (cr, 1); - cairo_show_surface (cr, stamp, WIDTH + 2, HEIGHT + 2); - - cairo_show_page (cr); - - cairo_surface_destroy (stamp); - cairo_surface_destroy (target); - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/read-png.c b/test/read-png.c index e7e2a92c..6f4d3e1c 100644 --- a/test/read-png.c +++ b/test/read-png.c @@ -29,7 +29,7 @@ #include <stdlib.h> #include <png.h> -#include "read_png.h" +#include "read-png.h" #include "xmalloc.h" static void diff --git a/test/read_png.c b/test/read_png.c deleted file mode 100644 index e7e2a92c..00000000 --- a/test/read_png.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright © 2003 USC, Information Sciences Institute - * - * 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 the - * University of Southern California not be used in advertising or - * publicity pertaining to distribution of the software without - * specific, written prior permission. The University of Southern - * California makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF - * SOUTHERN CALIFORNIA 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@isi.edu> - */ - -#include <stdio.h> -#include <stdlib.h> -#include <png.h> - -#include "read_png.h" -#include "xmalloc.h" - -static void -premultiply_data (png_structp png, - png_row_infop row_info, - png_bytep data) -{ - int i; - - for (i = 0; i < row_info->rowbytes; i += 4) { - unsigned char *base = &data[i]; - unsigned char blue = base[0]; - unsigned char green = base[1]; - unsigned char red = base[2]; - unsigned char alpha = base[3]; - unsigned long p; - - red = ((unsigned) red * (unsigned) alpha + 127) / 255; - green = ((unsigned) green * (unsigned) alpha + 127) / 255; - blue = ((unsigned) blue * (unsigned) alpha + 127) / 255; - p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); - memcpy (base, &p, sizeof (unsigned long)); - } -} - -read_png_status_t -read_png_argb32 (const char *filename, - unsigned char **data, - unsigned int *width, - unsigned int *height, - unsigned int *stride) -{ - int i; - FILE *file; - static const int PNG_SIG_SIZE = 8; - unsigned char png_sig[PNG_SIG_SIZE]; - int sig_bytes; - png_struct *png; - png_info *info; - png_uint_32 png_width, png_height; - int depth, color_type, interlace; - unsigned int pixel_size; - png_byte **row_pointers; - - file = fopen (filename, "rb"); - if (file == NULL) { - return READ_PNG_FILE_NOT_FOUND; - } - - sig_bytes = fread (png_sig, 1, PNG_SIG_SIZE, file); - if (png_check_sig (png_sig, sig_bytes) == 0) { - fclose (file); - return READ_PNG_FILE_NOT_PNG; - } - - /* XXX: Perhaps we'll want some other error handlers? */ - png = png_create_read_struct (PNG_LIBPNG_VER_STRING, - NULL, - NULL, - NULL); - if (png == NULL) { - fclose (file); - return READ_PNG_NO_MEMORY; - } - - info = png_create_info_struct (png); - if (info == NULL) { - fclose (file); - png_destroy_read_struct (&png, NULL, NULL); - return READ_PNG_NO_MEMORY; - } - - png_init_io (png, file); - png_set_sig_bytes (png, sig_bytes); - - png_read_info (png, info); - - png_get_IHDR (png, info, - &png_width, &png_height, &depth, - &color_type, &interlace, NULL, NULL); - *width = png_width; - *height = png_height; - *stride = 4 * png_width; - - - /* convert palette/gray image to rgb */ - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb (png); - - /* expand gray bit depth if needed */ - if (color_type == PNG_COLOR_TYPE_GRAY && depth < 8) - png_set_gray_1_2_4_to_8 (png); - /* transform transparency to alpha */ - if (png_get_valid(png, info, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha (png); - - if (depth == 16) - png_set_strip_16 (png); - - if (depth < 8) - png_set_packing (png); - - /* convert grayscale to RGB */ - if (color_type == PNG_COLOR_TYPE_GRAY - || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb (png); - - if (interlace != PNG_INTERLACE_NONE) - png_set_interlace_handling (png); - - png_set_bgr (png); - png_set_filler (png, 0xff, PNG_FILLER_AFTER); - - png_set_read_user_transform_fn (png, premultiply_data); - - png_read_update_info (png, info); - - pixel_size = 4; - *data = xmalloc (png_width * png_height * pixel_size); - - row_pointers = malloc (png_height * sizeof(char *)); - for (i=0; i < png_height; i++) - row_pointers[i] = (png_byte *) (*data + i * png_width * pixel_size); - - png_read_image (png, row_pointers); - png_read_end (png, info); - - free (row_pointers); - fclose (file); - - png_destroy_read_struct (&png, &info, NULL); - - return READ_PNG_SUCCESS; -} diff --git a/test/read_png.h b/test/read_png.h deleted file mode 100644 index 9c9ba433..00000000 --- a/test/read_png.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2003 USC, Information Sciences Institute - * - * 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 the - * University of Southern California not be used in advertising or - * publicity pertaining to distribution of the software without - * specific, written prior permission. The University of Southern - * California makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF - * SOUTHERN CALIFORNIA 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@isi.edu> - */ - -#ifndef READ_PNG_H -#define READ_PNG_H - -typedef enum { - READ_PNG_SUCCESS = 0, - READ_PNG_FILE_NOT_FOUND, - READ_PNG_FILE_NOT_PNG, - READ_PNG_NO_MEMORY -} read_png_status_t; - -read_png_status_t -read_png_argb32 (const char *filename, - unsigned char **data, - unsigned int *width, - unsigned int *height, - unsigned int *stride); - -#endif diff --git a/test/text-cache-crash.c b/test/text-cache-crash.c index abf20581..68348cf6 100644 --- a/test/text-cache-crash.c +++ b/test/text-cache-crash.c @@ -60,10 +60,10 @@ * fixed the orginal test case. */ -#include "cairo_test.h" +#include "cairo-test.h" cairo_test_t test = { - "text_cache_crash", + "text-cache-crash", "Test case for bug causing an assertion failure in _cairo_cache_lookup", 0, 0, }; diff --git a/test/text-rotate.c b/test/text-rotate.c index 2597a053..f7c28775 100644 --- a/test/text-rotate.c +++ b/test/text-rotate.c @@ -57,7 +57,7 @@ * builtin font to cairo for pixel-perfect tests with text. */ -#include "cairo_test.h" +#include "cairo-test.h" #define WIDTH 150 #define HEIGHT 150 @@ -65,7 +65,7 @@ #define TEXT_SIZE 12 cairo_test_t test = { - "text_rotate", + "text-rotate", "Tests show_text under various rotations", WIDTH, HEIGHT }; diff --git a/test/text_cache_crash.c b/test/text_cache_crash.c deleted file mode 100644 index abf20581..00000000 --- a/test/text_cache_crash.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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> - */ - -/* Bug history - * - * 2004-11-04 Ned Konz <ned@squeakland.org> - * - * Reported bug on mailing list: - * - * From: Ned Konz <ned@squeakland.org> - * To: cairo@cairographics.org - * Date: Thu, 4 Nov 2004 09:49:38 -0800 - * Subject: [cairo] getting assertions [cairo_cache.c:143: _entry_destroy: - * Assertion `cache->used_memory > entry->memory' failed] - * - * The attached program dies on me with the assert - * - * $ ./testCairo - * testCairo: cairo_cache.c:143: _entry_destroy: Assertion `cache->used_memory > entry->memory' failed. - * - * 2004-11-04 Carl Worth <cworth@cworth.org> - * - * I trimmed down Ned's example to the folllowing test while still - * maintaining the assertion. - * - * Oh, actually, it looks like I may have triggered something - * slightly different: - * - * text_cache_crash: cairo_cache.c:422: _cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed. - * - * I'll have to go back and try the original test after I fix this. - * - * 2004-11-13 Carl Worth <cworth@cworth.org> - * - * Found the bug. cairo_gstate_select_font was noticing when the - * same font was selected twice in a row and was erroneously failing - * to free the old reference. Committed a fix and verified it also - * fixed the orginal test case. - */ - -#include "cairo_test.h" - -cairo_test_t test = { - "text_cache_crash", - "Test case for bug causing an assertion failure in _cairo_cache_lookup", - 0, 0, -}; -#include <cairo.h> - -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - /* Once there was a bug that choked when selecting the same font twice. */ - cairo_select_font(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); - cairo_scale_font(cr, 40.0); - - cairo_select_font(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); - cairo_scale_font(cr, 40.0); - cairo_move_to(cr, 10, 50); - cairo_show_text(cr, "hello"); - - /* Then there was a bug that choked when selecting a font too big - * for the cache. */ - -/* XXX: Sometimes this leads to an assertion: - -_cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed. -Aborted - - But other times my machine hangs completely only to return to life - several minutes later with some programs missing. This seems like - the out-of-memory killer to me. - - It seems like I usually get the assertion when I run - ./text_cache_crash directly and I usually get the machine hang when - I run "make check" but I don't know if there's a perfect - correlation there. - - So there's a bad bug here somewhere that really needs to be fixed. - But in the meantime, I need "make check" not to destory work, so - I'm commenting this test out for now. - - cairo_scale_font (cr, 500); - cairo_show_text (cr, "hello"); -*/ - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - int ret; - - ret = cairo_test (&test, draw); - - /* It's convenient to be able to free all memory (including - * statically allocated memory). This makes it quite easy to use - * tools such as valgrind to verify that there are no memory leaks - * whatsoever. - * - * But I'm not sure what would be a sensible cairo API function - * for this. The cairo_destroy_caches call below is just something - * I made as a local modification to cairo. - */ - /* - cairo_destroy_caches (); - FcFini (); - */ - - return ret; -} - diff --git a/test/text_rotate.c b/test/text_rotate.c deleted file mode 100644 index 2597a053..00000000 --- a/test/text_rotate.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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> - */ - -/* Bug history - * - * 2004-11-03 Steve Chaplin <stevech1097@yahoo.com.au> - * - * Reported bug on mailing list: - * - * From: Steve Chaplin <stevech1097@yahoo.com.au> - * To: cairo@cairographics.org - * Date: Thu, 04 Nov 2004 00:00:17 +0800 - * Subject: [cairo] Rotated text bug on drawable target - * - * The attached file draws text rotated 90 degrees first to a PNG file and - * then to a drawable. The PNG file looks fine, the text on the drawable is - * unreadable. - * - * Steve - * - * 2004-11-03 Carl Worth <cworth@cworth.org> - * - * Looks like the major problems with this bg appeared in the great - * font rework between 0.1.23 and 0.2.0. And it looks like we need - * to fix the regression test suite to test the xlib target (since - * the bug does not show up in the png backend). - * - * Hmm... Actually, things don't look perfect even in the PNG - * output. Look at how that 'o' moves around. It's particularly off - * in the case where it's rotated by PI. - * - * And I'm still not sure about what to do for test cases with - * text--a new version of freetype will change everything. We may - * need to add a simple backend for stroked fonts and add a simple - * builtin font to cairo for pixel-perfect tests with text. - */ - -#include "cairo_test.h" - -#define WIDTH 150 -#define HEIGHT 150 -#define NUM_TEXT 20 -#define TEXT_SIZE 12 - -cairo_test_t test = { - "text_rotate", - "Tests show_text under various rotations", - WIDTH, HEIGHT -}; - -/* Draw the word cairo at NUM_TEXT different angles */ -static cairo_test_status_t -draw (cairo_t *cr, int width, int height) -{ - int i, x_off, y_off; - cairo_text_extents_t extents; - static char text[] = "cairo"; - - cairo_select_font (cr, "Bitstream Vera Sans", - CAIRO_FONT_SLANT_NORMAL, - CAIRO_FONT_WEIGHT_NORMAL); - cairo_scale_font (cr, TEXT_SIZE); - - cairo_set_rgb_color (cr, 0,0,0); - - cairo_translate (cr, WIDTH/2.0, HEIGHT/2.0); - - cairo_text_extents (cr, text, &extents); - - if (NUM_TEXT == 1) { - x_off = y_off = 0; - } else { - y_off = - round (extents.height / 2.0); - x_off = round ((extents.height+1) / (2 * tan (M_PI/NUM_TEXT))); - } - - for (i=0; i < NUM_TEXT; i++) { - cairo_save (cr); - cairo_rotate (cr, 2*M_PI*i/NUM_TEXT); - cairo_set_line_width (cr, 1.0); - cairo_rectangle (cr, x_off - 0.5, y_off - 0.5, extents.width + 1, extents.height + 1); - cairo_set_rgb_color (cr, 1, 0, 0); - cairo_stroke (cr); - cairo_move_to (cr, x_off - extents.x_bearing, y_off - extents.y_bearing); - cairo_set_rgb_color (cr, 0, 0, 0); - cairo_show_text (cr, "cairo"); - cairo_restore (cr); - } - - return CAIRO_TEST_SUCCESS; -} - -int -main (void) -{ - return cairo_test (&test, draw); -} diff --git a/test/user_data.c b/test/user_data.c deleted file mode 100644 index 88a706af..00000000 --- a/test/user_data.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2005 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: Kristian Høgsberg <krh@redhat.com> - */ - -#include <cairo.h> -#include <assert.h> -#include <stdlib.h> - -static void -destroy_data1 (void *p) -{ - *(int *) p = 1; -} - -static void -destroy_data2 (void *p) -{ - *(int *) p = 2; -} - -int -main (void) -{ - cairo_surface_t *surface; - static const cairo_user_data_key_t key1, key2; - int data1, data2; - - data1 = 0; - data2 = 0; - surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1); - assert (cairo_surface_set_user_data (surface, &key1, &data1, destroy_data1) - == CAIRO_STATUS_SUCCESS); - assert (cairo_surface_set_user_data (surface, &key2, &data2, destroy_data2) - == CAIRO_STATUS_SUCCESS); - assert (cairo_surface_get_user_data (surface, &key1) == &data1); - assert (cairo_surface_set_user_data (surface, &key1, NULL, NULL) - == CAIRO_STATUS_SUCCESS); - assert (cairo_surface_get_user_data (surface, &key1) == NULL); - assert (data1 == 1); - assert (data2 == 0); - - data1 = 0; - assert (cairo_surface_set_user_data (surface, &key1, &data1, NULL) - == CAIRO_STATUS_SUCCESS); - assert (cairo_surface_set_user_data (surface, &key1, NULL, NULL) - == CAIRO_STATUS_SUCCESS); - assert (data1 == 0); - assert (cairo_surface_get_user_data (surface, &key1) == NULL); - - assert (cairo_surface_set_user_data (surface, &key1, &data1, destroy_data1) - == CAIRO_STATUS_SUCCESS); - cairo_surface_destroy (surface); - assert (data1 == 1); - assert (data2 == 2); - - return 0; -} diff --git a/test/write-png.c b/test/write-png.c index 0ff5bcd3..a5494b46 100644 --- a/test/write-png.c +++ b/test/write-png.c @@ -29,7 +29,7 @@ #include <stdlib.h> #include <png.h> -#include "write_png.h" +#include "write-png.h" static void unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data) diff --git a/test/write_png.c b/test/write_png.c deleted file mode 100644 index 0ff5bcd3..00000000 --- a/test/write_png.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2003 USC, Information Sciences Institute - * - * 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 the - * University of Southern California not be used in advertising or - * publicity pertaining to distribution of the software without - * specific, written prior permission. The University of Southern - * California makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF - * SOUTHERN CALIFORNIA 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 <stdio.h> -#include <stdlib.h> -#include <png.h> - -#include "write_png.h" - -static void -unpremultiply_data (png_structp png, png_row_infop row_info, png_bytep data) -{ - int i; - - for (i = 0; i < row_info->rowbytes; i += 4) { - unsigned char *b = &data[i]; - unsigned int pixel; - unsigned char alpha; - - memcpy (&pixel, b, sizeof (unsigned int)); - alpha = (pixel & 0xff000000) >> 24; - if (alpha == 0) { - b[0] = b[1] = b[2] = b[3] = 0; - } else { - b[0] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha; - b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha; - b[2] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha; - b[3] = alpha; - } - } -} - -void -write_png_argb32 (char *buffer, FILE *file, - int width, int height, int stride) -{ - int i; - png_struct *png; - png_info *info; - png_byte **rows; - png_color_16 white; - - rows = malloc (height * sizeof(png_byte*)); - - for (i = 0; i < height; i++) { - rows[i] = buffer + i * stride; - } - - png = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - info = png_create_info_struct (png); - - png_init_io (png, file); - png_set_IHDR (png, info, - width, height, 8, - PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - - white.red = 0xff; - white.blue = 0xff; - white.green = 0xff; - png_set_bKGD (png, info, &white); - - png_set_write_user_transform_fn (png, unpremultiply_data); - png_set_bgr (png); - - png_write_info (png, info); - png_write_image (png, rows); - png_write_end (png, info); - - png_destroy_write_struct (&png, &info); - - free (rows); -} diff --git a/test/write_png.h b/test/write_png.h deleted file mode 100644 index fe0e92b2..00000000 --- a/test/write_png.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2003 USC, Information Sciences Institute - * - * 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 the - * University of Southern California not be used in advertising or - * publicity pertaining to distribution of the software without - * specific, written prior permission. The University of Southern - * California makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF - * SOUTHERN CALIFORNIA 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@isi.edu> - */ - -#ifndef WRITE_PNG_H -#define WRITE_PNG_H - -void -write_png_argb32 (char *buffer, FILE * file, - int width, int height, int stride); - -#endif |