diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-07-30 17:28:21 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-09-12 08:29:48 +0100 |
commit | af9fbd176b145f042408ef5391eef2a51d7531f8 (patch) | |
tree | 5f75d1087d4325a013af6f0a4204a666fb4ca4f0 /test | |
parent | 0540bf384aed344899417d3b0313bd6704679c1c (diff) |
Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.refs | 9 | ||||
-rw-r--r-- | test/Makefile.sources | 5 | ||||
-rw-r--r-- | test/a1-clip-fill-rule.argb32.ref.png | bin | 0 -> 236 bytes | |||
-rw-r--r-- | test/a1-clip-fill-rule.rgb24.ref.png | bin | 0 -> 218 bytes | |||
-rw-r--r-- | test/a1-rectilinear-grid.ref.png | bin | 0 -> 207 bytes | |||
-rw-r--r-- | test/cairo-test-trace.c | 195 | ||||
-rw-r--r-- | test/clear-source.c | 2 | ||||
-rw-r--r-- | test/clip-fill-rule.c | 13 | ||||
-rw-r--r-- | test/map-to-image.c | 4 | ||||
-rw-r--r-- | test/overlapping-boxes.argb32.ref.png | bin | 0 -> 216 bytes | |||
-rw-r--r-- | test/overlapping-boxes.c | 96 | ||||
-rw-r--r-- | test/overlapping-boxes.rgb24.ref.png | bin | 0 -> 204 bytes | |||
-rw-r--r-- | test/rectilinear-grid.c | 14 | ||||
-rw-r--r-- | test/shape-sierpinski.c | 85 | ||||
-rw-r--r-- | test/shape-sierpinski.ref.png | bin | 0 -> 54485 bytes | |||
-rw-r--r-- | test/test-fallback16-surface-source.c | 43 | ||||
-rw-r--r-- | test/test-fallback16-surface-source.ps.ref.png | bin | 292 -> 0 bytes | |||
-rw-r--r-- | test/test-fallback16-surface-source.svg12.argb32.xfail.png | bin | 278 -> 0 bytes | |||
-rw-r--r-- | test/test-fallback16-surface-source.svg12.rgb24.xfail.png | bin | 278 -> 0 bytes | |||
-rw-r--r-- | test/zero-mask.c | 6 |
20 files changed, 338 insertions, 134 deletions
diff --git a/test/Makefile.refs b/test/Makefile.refs index b09f7810..68f721ac 100644 --- a/test/Makefile.refs +++ b/test/Makefile.refs @@ -6,6 +6,8 @@ REFERENCE_IMAGES = \ a1-bug.ref.png \ a1-bug.xlib.ref.png \ a1-clip-fill-equal.ref.png \ + a1-clip-fill-rule.argb32.ref.png \ + a1-clip-fill-rule.rgb24.ref.png \ a1-clip-fill.ref.png \ a1-clip-paint.ref.png \ a1-clip-stroke.ref.png \ @@ -18,6 +20,7 @@ REFERENCE_IMAGES = \ a1-rasterisation-rectangles.ref.png \ a1-rasterisation-triangles.quartz.xfail.png \ a1-rasterisation-triangles.ref.png \ + a1-rectilinear-grid.ref.png \ a1-sample.ref.png \ a1-traps-sample.quartz.xfail.png \ a1-traps-sample.ref.png \ @@ -885,6 +888,8 @@ REFERENCE_IMAGES = \ over-between-source.svg12.rgb24.xfail.png \ over-between-source.xlib.ref.png \ over-between-source.xlib.rgb24.ref.png \ + overlapping-boxes.argb32.ref.png \ + overlapping-boxes.rgb24.ref.png \ overlapping-dash-caps.ref.png \ overlapping-glyphs.argb32.ref.png \ overlapping-glyphs.pdf.argb32.xfail.png \ @@ -1155,6 +1160,7 @@ REFERENCE_IMAGES = \ set-source.ref.png \ set-source.rgb24.ref.png \ shape-general-convex.ref.png \ + shape-sierpinski.ref.png \ show-glyphs-advance.image16.ref.png \ show-glyphs-advance.ps.ref.png \ show-glyphs-advance.quartz.ref.png \ @@ -1299,9 +1305,6 @@ REFERENCE_IMAGES = \ svg-surface-source.rgb24.ref.png \ svg-surface-source.svg12.argb32.xfail.png \ svg-surface-source.svg12.rgb24.xfail.png \ - test-fallback16-surface-source.ps.ref.png \ - test-fallback16-surface-source.svg12.argb32.xfail.png \ - test-fallback16-surface-source.svg12.rgb24.xfail.png \ text-antialias-gray.image16.ref.png \ text-antialias-gray.quartz.ref.png \ text-antialias-gray.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index 526ac8a8..05bcdd0c 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -211,6 +211,7 @@ test_sources = \ over-around-source.c \ over-below-source.c \ over-between-source.c \ + overlapping-boxes.c \ overlapping-glyphs.c \ overlapping-dash-caps.c \ paint.c \ @@ -273,6 +274,7 @@ test_sources = \ show-glyphs-many.c \ show-text-current-point.c \ shape-general-convex.c \ + shape-sierpinski.c \ skew-extreme.c \ smask.c \ smask-fill.c \ @@ -373,9 +375,6 @@ svg_surface_test_sources = \ svg-clip.c \ svg-surface-source.c -test_fallback16_surface_test_sources = \ - test-fallback16-surface-source.c - xcb_surface_test_sources = \ xcb-surface-source.c diff --git a/test/a1-clip-fill-rule.argb32.ref.png b/test/a1-clip-fill-rule.argb32.ref.png Binary files differnew file mode 100644 index 00000000..c3ba9dd5 --- /dev/null +++ b/test/a1-clip-fill-rule.argb32.ref.png diff --git a/test/a1-clip-fill-rule.rgb24.ref.png b/test/a1-clip-fill-rule.rgb24.ref.png Binary files differnew file mode 100644 index 00000000..6fe9346b --- /dev/null +++ b/test/a1-clip-fill-rule.rgb24.ref.png diff --git a/test/a1-rectilinear-grid.ref.png b/test/a1-rectilinear-grid.ref.png Binary files differnew file mode 100644 index 00000000..2dfb85e1 --- /dev/null +++ b/test/a1-rectilinear-grid.ref.png diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c index 146ca6fe..296a229d 100644 --- a/test/cairo-test-trace.c +++ b/test/cairo-test-trace.c @@ -93,8 +93,10 @@ #define DEBUG 0 +#define ignore_image_differences 0 /* XXX make me a cmdline option! */ + #define DATA_SIZE (256 << 20) -#define SHM_PATH_XXX "/shmem-cairo-trace" +#define SHM_PATH_XXX "/.shmem-cairo-trace" typedef struct _test_trace { /* Options from command-line */ @@ -163,6 +165,8 @@ struct surface_tag { }; static const cairo_user_data_key_t surface_tag; +#define TARGET_NAME(T) ((T) ? (T)->name : "recording") + #if CAIRO_HAS_REAL_PTHREAD #define tr_die(t) t->is_recording ? pthread_exit(NULL) : exit(1) #else @@ -253,7 +257,7 @@ send_recording_surface (test_runner_t *tr, closure->end_line, -1, width, height, - cairo_surface_get_type (closure->surface) == CAIRO_SURFACE_TYPE_IMAGE ? 0 : (long) closure->surface, + (long) closure->surface, }; unsigned long offset; unsigned long serial; @@ -320,7 +324,8 @@ send_surface (test_runner_t *tr, unsigned long serial; if (DEBUG > 1) { - printf ("send-surface: '%s'\n", tr->name); + printf ("send-surface: '%s', is-recording? %d\n", + tr->name, tr->is_recording); } if (cairo_surface_get_type (source) == CAIRO_SURFACE_TYPE_IMAGE) { @@ -390,7 +395,8 @@ send_surface (test_runner_t *tr, static cairo_surface_t * _surface_create (void *closure, cairo_content_t content, - double width, double height) + double width, double height, + long uid) { test_runner_t *tr = closure; cairo_surface_t *surface; @@ -416,6 +422,13 @@ _context_create (void *closure, cairo_surface_t *surface) test_runner_t *tr = closure; struct context_closure *l; + if (DEBUG) { + fprintf (stderr, "%s: starting context %lu on line %d\n", + tr->name ? tr->name : "recording" , + tr->context_id + 1, + cairo_script_interpreter_get_line_number (tr->csi)); + } + l = xmalloc (sizeof (*l)); l->next = tr->contexts; l->start_line = cairo_script_interpreter_get_line_number (tr->csi); @@ -438,6 +451,12 @@ _context_destroy (void *closure, void *ptr) while ((l = *prev) != NULL) { if (l->context == ptr) { + if (DEBUG) { + fprintf (stderr, "%s: context %lu complete on line %d\n", + tr->name ? tr->name : "recording" , + tr->context_id, + cairo_script_interpreter_get_line_number (tr->csi)); + } l->end_line = cairo_script_interpreter_get_line_number (tr->csi); if (cairo_surface_status (l->surface) == CAIRO_STATUS_SUCCESS) { @@ -623,7 +642,7 @@ record (void *arg) * 2. Runs in the same process, but separate thread. */ static pid_t -spawn_recorder (const char *socket_path, const char *trace) +spawn_recorder (const char *socket_path, const char *trace, test_runner_t **out) { test_runner_t *tr; pthread_t id; @@ -652,7 +671,7 @@ spawn_recorder (const char *socket_path, const char *trace) tr->trace = trace; tr->surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, - 0, 0); + NULL); if (tr->surface == NULL) { cleanup_recorder (tr); return -1; @@ -667,6 +686,8 @@ spawn_recorder (const char *socket_path, const char *trace) } pthread_attr_destroy (&attr); + + *out = tr; return pid; } #endif @@ -814,6 +835,11 @@ matches_reference (struct slave *slave) bb += stride; } break; + + case CAIRO_FORMAT_RGB30: + case CAIRO_FORMAT_RGB16_565: + case CAIRO_FORMAT_INVALID: + assert (0); } return TRUE; @@ -825,6 +851,9 @@ check_images (struct slave *slaves, int num_slaves) { int n; + if (ignore_image_differences) + return TRUE; + for (n = 0; n < num_slaves; n++) { if (slaves[n].reference == NULL) continue; @@ -861,29 +890,59 @@ write_images (const char *trace, struct slave *slave, int num_slaves) } static void +write_result (const char *trace, struct slave *slave) +{ + static int index; + char *filename; + + xasprintf (&filename, "%s-%s-pass-%d-%d-%d.png", + trace, slave->target->name, ++index, + slave->start_line, slave->end_line); + cairo_surface_write_to_png (slave->image, filename); + free (filename); +} + +static void write_trace (const char *trace, struct slave *slave) { #if CAIRO_HAS_SCRIPT_SURFACE - cairo_device_t *ctx, - cairo_surface_t *script; + cairo_device_t *script; char *filename; - cairo_t *cr; + + assert (slave->is_recording); xasprintf (&filename, "%s-fail.trace", trace); - ctx = cairo_script_create (filename); - script = cairo_script_surface_create (ctx, - cairo_surface_get_content (slave->image), - slave->width, - slave->height); - cairo_device_destroy (ctx); + + script = cairo_script_create (filename); + cairo_script_from_recording_surface (script, slave->image); + cairo_device_destroy (script); + free (filename); +#endif +} - cr = cairo_create (slave->image); - cairo_set_source_surface (cr, script, 0, 0); - cairo_paint (cr); - cairo_destroy (cr); +static void +dump_traces (test_runner_t *tr, + const char *trace, + const char *target, + const char *fail) +{ +#if CAIRO_HAS_SCRIPT_SURFACE + struct context_closure *c; + + for (c = tr->contexts; c; c = c->next) { + cairo_device_t *script; + char *filename; + + xasprintf (&filename, "%s-%s-%s.%lu.trace", + trace, target, fail, c->start_line); + + script = cairo_script_create (filename); + cairo_script_from_recording_surface (script, c->surface); + cairo_device_destroy (script); - cairo_surface_destroy (script); + free (filename); + } #endif } @@ -907,14 +966,16 @@ allocate_image_for_slave (uint8_t *base, slave->height = rq.height; if (DEBUG > 1) { - printf ("allocate-image-for-slave: %s %lu [%lu, %lu] %ldx%ld=> %lu\n", - slave->target->name, + printf ("allocate-image-for-slave: %s %lu [%lu, %lu] %ldx%ld stride=%lu => %lu, is-recording? %d\n", + TARGET_NAME (slave->target), slave->image_serial, slave->start_line, slave->end_line, slave->width, slave->height, - offset); + rq.stride, + offset, + slave->is_recording); } if (slave->is_recording) { @@ -1031,14 +1092,14 @@ test_run (void *base, offset = image, &slaves[i]); if (! writen (pfd[n].fd, &offset, sizeof (offset))) - goto out; + goto done; } else { readn (pfd[n].fd, &slaves[i].image_ready, sizeof (slaves[i].image_ready)); if (DEBUG) { printf ("slave '%s' reports completion on %lu (expecting %lu)\n", - slaves[i].target->name, + TARGET_NAME (slaves[i].target), slaves[i].image_ready, slaves[i].image_serial); } @@ -1062,7 +1123,8 @@ test_run (void *base, if (DEBUG > 1) { printf ("all saves report completion\n"); } - if (! check_images (slaves, num_slaves)) { + if (slaves[0].end_line >= slaves[0].start_line && + ! check_images (slaves, num_slaves)) { error->context_id = slaves[0].image_serial; error->start_line = slaves[0].start_line; error->end_line = slaves[0].end_line; @@ -1082,6 +1144,8 @@ test_run (void *base, goto out; } + if (0) write_result (trace, &slaves[1]); + /* ack */ for (i = 0; i < num_slaves; i++) { cairo_surface_destroy (slaves[i].image); @@ -1089,7 +1153,7 @@ test_run (void *base, if (DEBUG > 1) { printf ("sending continuation to '%s'\n", - slaves[i].target->name); + TARGET_NAME (slaves[i].target)); } if (! writen (slaves[i].fd, &slaves[i].image_serial, @@ -1129,7 +1193,6 @@ out: slaves[n].image_serial = 0; slaves[n].image_ready = 0; - ret = FALSE; } free (pfd); @@ -1137,51 +1200,6 @@ out: return ret; } -/* Paginated surfaces require finalization and external converters and so - * are not suitable for this basic technique. - */ -static cairo_bool_t -target_is_measurable (const cairo_boilerplate_target_t *target) -{ - if (target->content != CAIRO_CONTENT_COLOR_ALPHA) - return FALSE; - - switch (target->expected_type) { - case CAIRO_SURFACE_TYPE_IMAGE: - if (strcmp (target->name, "pdf") == 0 || - strcmp (target->name, "ps") == 0) - { - return FALSE; - } - else - { - return TRUE; - } - case CAIRO_SURFACE_TYPE_XLIB: - case CAIRO_SURFACE_TYPE_XCB: - case CAIRO_SURFACE_TYPE_GLITZ: - case CAIRO_SURFACE_TYPE_QUARTZ: - case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE: - case CAIRO_SURFACE_TYPE_WIN32: - case CAIRO_SURFACE_TYPE_BEOS: - case CAIRO_SURFACE_TYPE_DIRECTFB: - case CAIRO_SURFACE_TYPE_OS2: - case CAIRO_SURFACE_TYPE_QT: - return TRUE; - - case CAIRO_SURFACE_TYPE_PDF: - case CAIRO_SURFACE_TYPE_PS: - case CAIRO_SURFACE_TYPE_SCRIPT: - case CAIRO_SURFACE_TYPE_SVG: - case CAIRO_SURFACE_TYPE_WIN32_PRINTING: - case CAIRO_SURFACE_TYPE_RECORDING: - default: - return FALSE; - } - - return TRUE; -} - static int server_socket (const char *socket_path) { @@ -1241,6 +1259,7 @@ _test_trace (test_trace_t *test, const char *shm_path = SHM_PATH_XXX; const cairo_boilerplate_target_t *target, *image; struct slave *slaves, *s; + test_runner_t *recorder = NULL; pid_t slave; char socket_dir[] = "/tmp/cairo-test-trace.XXXXXX"; char *socket_path; @@ -1249,6 +1268,9 @@ _test_trace (test_trace_t *test, void *base; cairo_bool_t ret = FALSE; + if (DEBUG) + printf ("setting up trace '%s'\n", trace); + /* create a socket to control the test runners */ if (mkdtemp (socket_dir) == NULL) { fprintf (stderr, "Unable to create temporary name for socket\n"); @@ -1265,8 +1287,8 @@ _test_trace (test_trace_t *test, /* allocate some shared memory */ fd = server_shm (shm_path); if (fd == -1) { - fprintf (stderr, "Unable to create shared memory '%s'\n", - shm_path); + fprintf (stderr, "Unable to create shared memory '%s': %s\n", + shm_path, strerror (errno)); goto cleanup_sk; } @@ -1277,7 +1299,7 @@ _test_trace (test_trace_t *test, #if CAIRO_HAS_REAL_PTHREAD /* set-up a recording-surface to reconstruct errors */ - slave = spawn_recorder (socket_path, trace); + slave = spawn_recorder (socket_path, trace, &recorder); if (slave < 0) { fprintf (stderr, "Unable to create recording surface\n"); goto cleanup_sk; @@ -1297,7 +1319,12 @@ _test_trace (test_trace_t *test, struct slave *master; target = test->targets[i]; - if (target == image || ! target_is_measurable (target)) + + if (DEBUG) + printf ("setting up target[%d]? '%s' (image? %d, measurable? %d)\n", + i, target->name, target == image, target->is_measurable); + + if (target == image || ! target->is_measurable) continue; /* find a matching slave to use as a reference for this target */ @@ -1356,14 +1383,22 @@ cleanup: while (s-- > slaves) { int status; + if (s->fd != -1) + close (s->fd); + + cairo_surface_destroy (s->image); + cairo_surface_destroy (s->difference); + if (s->is_recording) /* in-process */ continue; kill (s->pid, SIGKILL); waitpid (s->pid, &status, 0); - ret &= WIFEXITED (status) && WEXITSTATUS (status) == 0; - if (WIFSIGNALED (status) && WTERMSIG(status) != SIGKILL) + if (WIFSIGNALED (status) && WTERMSIG(status) != SIGKILL) { fprintf (stderr, "%s crashed\n", s->target->name); + if (recorder) + dump_traces (recorder, trace, s->target->name, "crash"); + } } free (slaves); shm_unlink (shm_path); @@ -1630,6 +1665,8 @@ main (int argc, char *argv[]) parse_options (&test, argc, argv); + shm_unlink (SHM_PATH_XXX); + if (getenv ("CAIRO_TRACE_DIR") != NULL) trace_dir = getenv ("CAIRO_TRACE_DIR"); diff --git a/test/clear-source.c b/test/clear-source.c index a4c3db2f..5410932f 100644 --- a/test/clear-source.c +++ b/test/clear-source.c @@ -128,7 +128,7 @@ static operation_t operations[] = { glyphs }; - static cairo_test_status_t +static cairo_test_status_t draw (cairo_t *cr, int width, int height) { cairo_content_t contents[] = { CAIRO_CONTENT_COLOR_ALPHA, CAIRO_CONTENT_COLOR, CAIRO_CONTENT_ALPHA }; diff --git a/test/clip-fill-rule.c b/test/clip-fill-rule.c index 8351d868..035b9a83 100644 --- a/test/clip-fill-rule.c +++ b/test/clip-fill-rule.c @@ -66,9 +66,22 @@ draw (cairo_t *cr, int width, int height) return CAIRO_TEST_SUCCESS; } +static cairo_test_status_t +a1_draw (cairo_t *cr, int width, int height) +{ + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + return draw (cr, width, height); +} + CAIRO_TEST (clip_fill_rule, "Tests interaction of clipping with cairo_set_fill_rule", "clip", /* keywords */ NULL, /* requirements */ STAR_SIZE * 2 + 2, STAR_SIZE + 2, NULL, draw) +CAIRO_TEST (a1_clip_fill_rule, + "Tests interaction of clipping with cairo_set_fill_rule", + "clip", /* keywords */ + NULL, /* requirements */ + STAR_SIZE * 2 + 2, STAR_SIZE + 2, + NULL, a1_draw) diff --git a/test/map-to-image.c b/test/map-to-image.c index b7d6df8a..0262245a 100644 --- a/test/map-to-image.c +++ b/test/map-to-image.c @@ -89,7 +89,7 @@ static cairo_test_status_t bit (cairo_t *cr, int width, int height) { cairo_surface_t *surface; - cairo_rectangle_t extents; + cairo_rectangle_int_t extents; cairo_format_t format; uint8_t *data; @@ -117,7 +117,7 @@ static cairo_test_status_t fill (cairo_t *cr, int width, int height) { cairo_surface_t *surface; - cairo_rectangle_t extents; + cairo_rectangle_int_t extents; cairo_t *cr2; extents.x = extents.y = extents.width = extents.height = 1; diff --git a/test/overlapping-boxes.argb32.ref.png b/test/overlapping-boxes.argb32.ref.png Binary files differnew file mode 100644 index 00000000..278e62a8 --- /dev/null +++ b/test/overlapping-boxes.argb32.ref.png diff --git a/test/overlapping-boxes.c b/test/overlapping-boxes.c new file mode 100644 index 00000000..92211ee0 --- /dev/null +++ b/test/overlapping-boxes.c @@ -0,0 +1,96 @@ +/* + * 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> + */ + +/* Not strictly overlapping, but it does highlight the error in + * an optimisation of fill-box handling that I frequently am + * tempted to write. + */ + +#include "cairo-test.h" + +#define WIDTH (20) +#define HEIGHT (20) + +static void +border (cairo_t *cr) +{ + cairo_rectangle (cr, 1, 1, 8, 8); + cairo_rectangle (cr, 1.25, 1.25, 7.5, 7.5); + cairo_rectangle (cr, 1.75, 1.75, 6.5, 6.5); + cairo_rectangle (cr, 2, 2, 6, 6); +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + + border (cr); + cairo_set_source_rgb (cr, 1, 0, 0); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_fill (cr); + + cairo_translate (cr, 10, 0); + + border (cr); + cairo_set_source_rgb (cr, 0, 0, 1); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_fill (cr); + + cairo_translate (cr, 0, 10); + + cairo_rectangle (cr, 0, 0, 10, 10); + cairo_clip (cr); + + border (cr); + cairo_set_source_rgb (cr, 0, 1, 0); + cairo_set_operator (cr, CAIRO_OPERATOR_IN); + cairo_fill (cr); + + cairo_reset_clip (cr); + + cairo_translate (cr, -10, 0); + + cairo_rectangle (cr, 0, 0, 10, 10); + cairo_clip (cr); + + border (cr); + cairo_set_source_rgb (cr, 0, 0, 1); + cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (overlapping_boxes, + "A sub-pixel double border to highlight the danger in an easy optimisation", + "fill", /* keywords */ + NULL, /* requirements */ + WIDTH, HEIGHT, + NULL, draw) diff --git a/test/overlapping-boxes.rgb24.ref.png b/test/overlapping-boxes.rgb24.ref.png Binary files differnew file mode 100644 index 00000000..f35d0e6b --- /dev/null +++ b/test/overlapping-boxes.rgb24.ref.png diff --git a/test/rectilinear-grid.c b/test/rectilinear-grid.c index 1baadf73..8c6b7fca 100644 --- a/test/rectilinear-grid.c +++ b/test/rectilinear-grid.c @@ -70,9 +70,23 @@ draw (cairo_t *cr, int width, int height) return CAIRO_TEST_SUCCESS; } +static cairo_test_status_t +aligned (cairo_t *cr, int width, int height) +{ + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + return draw (cr, width, height); +} + CAIRO_TEST (rectilinear_grid, "Test rectilinear rasterizer (covering partial pixels)", "rectilinear", /* keywords */ NULL, /* requirements */ SIZE, SIZE, NULL, draw) + +CAIRO_TEST (a1_rectilinear_grid, + "Test rectilinear rasterizer (covering whole pixels)", + "rectilinear", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, aligned) diff --git a/test/shape-sierpinski.c b/test/shape-sierpinski.c new file mode 100644 index 00000000..9d201706 --- /dev/null +++ b/test/shape-sierpinski.c @@ -0,0 +1,85 @@ +/* + * 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> + */ + +/* I thought I spied a bug... */ + +#include "cairo-test.h" + +#define WIDTH (1024) +#define HEIGHT (600) + +static const double m_1_sqrt_3 = 0.577359269; + +static void +T (cairo_t *cr, int size) +{ + cairo_move_to (cr, 0, 0); + cairo_line_to (cr, size, 0); + cairo_line_to (cr, size/2, size*m_1_sqrt_3); + + size /= 2; + if (size >= 4) { + T (cr, size); + cairo_save (cr); { + cairo_translate (cr, size, 0); + T (cr, size); + } cairo_restore (cr); + cairo_save (cr); { + cairo_translate (cr, size/2, size*m_1_sqrt_3); + T (cr, size); + } cairo_restore (cr); + } +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + + cairo_translate (cr, 0, 8); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_set_line_width (cr, 1.); + + T (cr, WIDTH); + + cairo_translate (cr, 0, 2*HEIGHT-16); + cairo_scale (cr, 1, -1); + + T (cr, WIDTH); + + cairo_stroke (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (shape_sierpinski, + "A fractal triangle", + "stroke", /* keywords */ + NULL, /* requirements */ + WIDTH, 2*HEIGHT, + NULL, draw) diff --git a/test/shape-sierpinski.ref.png b/test/shape-sierpinski.ref.png Binary files differnew file mode 100644 index 00000000..69755d27 --- /dev/null +++ b/test/shape-sierpinski.ref.png diff --git a/test/test-fallback16-surface-source.c b/test/test-fallback16-surface-source.c deleted file mode 100644 index 7e9f920f..00000000 --- a/test/test-fallback16-surface-source.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2009 Chris Wilson - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without - * fee, provided that the above copyright notice appear in all copies - * and that both that copyright notice and this permission notice - * appear in supporting documentation, and that the name of - * Chris Wilson not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Chris Wilson makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR - * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Chris Wilson <chris@chris-wilson.co.uk> - */ - -#include "cairo-test.h" -#include <test-fallback16-surface.h> - -#include "surface-source.c" - -static cairo_surface_t * -create_source_surface (int size) -{ - return _cairo_test_fallback16_surface_create (CAIRO_CONTENT_COLOR_ALPHA, - size, size); -} - -CAIRO_TEST (test_fallback16_surface_source, - "Test using a 16-bit image (e.g. a low bit-depth XServer) surface as the source", - "source", /* keywords */ - NULL, /* requirements */ - SIZE, SIZE, - preamble, draw) diff --git a/test/test-fallback16-surface-source.ps.ref.png b/test/test-fallback16-surface-source.ps.ref.png Binary files differdeleted file mode 100644 index f686a068..00000000 --- a/test/test-fallback16-surface-source.ps.ref.png +++ /dev/null diff --git a/test/test-fallback16-surface-source.svg12.argb32.xfail.png b/test/test-fallback16-surface-source.svg12.argb32.xfail.png Binary files differdeleted file mode 100644 index 6ebcaf9a..00000000 --- a/test/test-fallback16-surface-source.svg12.argb32.xfail.png +++ /dev/null diff --git a/test/test-fallback16-surface-source.svg12.rgb24.xfail.png b/test/test-fallback16-surface-source.svg12.rgb24.xfail.png Binary files differdeleted file mode 100644 index 6ebcaf9a..00000000 --- a/test/test-fallback16-surface-source.svg12.rgb24.xfail.png +++ /dev/null diff --git a/test/zero-mask.c b/test/zero-mask.c index 29edd0a5..3d2f34d0 100644 --- a/test/zero-mask.c +++ b/test/zero-mask.c @@ -92,7 +92,7 @@ mask_with_alpha_surface (cairo_t *cr) cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT); cairo_mask (cr, pattern); - + cairo_pattern_destroy (pattern); cairo_surface_destroy (surface); } @@ -106,7 +106,7 @@ mask_with_nonclear_surface (cairo_t *cr) 16, 8, 4); cairo_mask_surface (cr, surface, 0, 0); - + cairo_surface_destroy (surface); } @@ -175,7 +175,7 @@ draw (cairo_t *cr, int width, int height) for (op = 0; op < ARRAY_LENGTH (operators); op++) { cairo_set_operator (cr, operators[op]); - + for (i = 0; i < ARRAY_LENGTH (mask_funcs); i++) { cairo_save (cr); cairo_translate (cr, i * (RECT + SPACE), op * (RECT + SPACE)); |