diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-14 14:24:49 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-14 14:24:49 +0100 |
commit | 595414bb787d570ac95fc91c58c370558e9d5a54 (patch) | |
tree | dfa1e7d5761979c14ea4bb4639f783d94587d6a6 | |
parent | 0d3e152d2fe28b22a27dd6b9f82e2047aea3be94 (diff) |
[test/fallback-resolution] Extend to cover separate ppi x/y.
Adrian Johnson proposed a hack that fixed the current test by simply
scaling the dashed stroke by device_transform.xx. Obviously this exposes a
deficiency in the test case. So add an outer loop to iterate over several
common ppi for both x and y and in doing so reveal more ugly artifacts in
the current fallback code.
38 files changed, 139 insertions, 102 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index e244b550..2a88d53e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -429,12 +429,42 @@ REFERENCE_IMAGES = \ extend-reflect-ps3-ref.png \ extend-repeat-ref.png \ extend-repeat-similar-ref.png \ - fallback-resolution-ppi37.5-ref.png \ - fallback-resolution-ppi72-ref.png \ - fallback-resolution-ppi75-ref.png \ - fallback-resolution-ppi150-ref.png \ - fallback-resolution-ppi300-ref.png \ - fallback-resolution-ppi600-ref.png \ + fallback-resolution-ppi37.5x37.5-ref.png \ + fallback-resolution-ppi37.5x72-ref.png \ + fallback-resolution-ppi37.5x75-ref.png \ + fallback-resolution-ppi37.5x150-ref.png \ + fallback-resolution-ppi37.5x300-ref.png \ + fallback-resolution-ppi37.5x600-ref.png \ + fallback-resolution-ppi72x37.5-ref.png \ + fallback-resolution-ppi72x72-ref.png \ + fallback-resolution-ppi72x75-ref.png \ + fallback-resolution-ppi72x150-ref.png \ + fallback-resolution-ppi72x300-ref.png \ + fallback-resolution-ppi72x600-ref.png \ + fallback-resolution-ppi75x37.5-ref.png \ + fallback-resolution-ppi75x72-ref.png \ + fallback-resolution-ppi75x75-ref.png \ + fallback-resolution-ppi75x150-ref.png \ + fallback-resolution-ppi75x300-ref.png \ + fallback-resolution-ppi75x600-ref.png \ + fallback-resolution-ppi150x37.5-ref.png \ + fallback-resolution-ppi150x72-ref.png \ + fallback-resolution-ppi150x75-ref.png \ + fallback-resolution-ppi150x150-ref.png \ + fallback-resolution-ppi150x300-ref.png \ + fallback-resolution-ppi150x600-ref.png \ + fallback-resolution-ppi300x37.5-ref.png \ + fallback-resolution-ppi300x72-ref.png \ + fallback-resolution-ppi300x75-ref.png \ + fallback-resolution-ppi300x150-ref.png \ + fallback-resolution-ppi300x300-ref.png \ + fallback-resolution-ppi300x600-ref.png \ + fallback-resolution-ppi600x37.5-ref.png \ + fallback-resolution-ppi600x72-ref.png \ + fallback-resolution-ppi600x75-ref.png \ + fallback-resolution-ppi600x150-ref.png \ + fallback-resolution-ppi600x300-ref.png \ + fallback-resolution-ppi600x600-ref.png \ fill-alpha-ref.png \ fill-alpha-pattern-ref.png \ fill-alpha-pattern-pdf-argb32-ref.png \ diff --git a/test/fallback-resolution-ppi150-ref.png b/test/fallback-resolution-ppi150x150-ref.png Binary files differindex 8a69481f..8a69481f 100644 --- a/test/fallback-resolution-ppi150-ref.png +++ b/test/fallback-resolution-ppi150x150-ref.png diff --git a/test/fallback-resolution-ppi150x300-ref.png b/test/fallback-resolution-ppi150x300-ref.png Binary files differnew file mode 100644 index 00000000..a23c62fd --- /dev/null +++ b/test/fallback-resolution-ppi150x300-ref.png diff --git a/test/fallback-resolution-ppi150x37.5-ref.png b/test/fallback-resolution-ppi150x37.5-ref.png Binary files differnew file mode 100644 index 00000000..640046ea --- /dev/null +++ b/test/fallback-resolution-ppi150x37.5-ref.png diff --git a/test/fallback-resolution-ppi150x600-ref.png b/test/fallback-resolution-ppi150x600-ref.png Binary files differnew file mode 100644 index 00000000..baae3567 --- /dev/null +++ b/test/fallback-resolution-ppi150x600-ref.png diff --git a/test/fallback-resolution-ppi150x72-ref.png b/test/fallback-resolution-ppi150x72-ref.png Binary files differnew file mode 100644 index 00000000..beee81d4 --- /dev/null +++ b/test/fallback-resolution-ppi150x72-ref.png diff --git a/test/fallback-resolution-ppi150x75-ref.png b/test/fallback-resolution-ppi150x75-ref.png Binary files differnew file mode 100644 index 00000000..93328190 --- /dev/null +++ b/test/fallback-resolution-ppi150x75-ref.png diff --git a/test/fallback-resolution-ppi300x150-ref.png b/test/fallback-resolution-ppi300x150-ref.png Binary files differnew file mode 100644 index 00000000..30c0e72a --- /dev/null +++ b/test/fallback-resolution-ppi300x150-ref.png diff --git a/test/fallback-resolution-ppi300-ref.png b/test/fallback-resolution-ppi300x300-ref.png Binary files differindex 66ed3ebe..66ed3ebe 100644 --- a/test/fallback-resolution-ppi300-ref.png +++ b/test/fallback-resolution-ppi300x300-ref.png diff --git a/test/fallback-resolution-ppi300x37.5-ref.png b/test/fallback-resolution-ppi300x37.5-ref.png Binary files differnew file mode 100644 index 00000000..42acb2de --- /dev/null +++ b/test/fallback-resolution-ppi300x37.5-ref.png diff --git a/test/fallback-resolution-ppi300x600-ref.png b/test/fallback-resolution-ppi300x600-ref.png Binary files differnew file mode 100644 index 00000000..5be37935 --- /dev/null +++ b/test/fallback-resolution-ppi300x600-ref.png diff --git a/test/fallback-resolution-ppi300x72-ref.png b/test/fallback-resolution-ppi300x72-ref.png Binary files differnew file mode 100644 index 00000000..a96fb72c --- /dev/null +++ b/test/fallback-resolution-ppi300x72-ref.png diff --git a/test/fallback-resolution-ppi300x75-ref.png b/test/fallback-resolution-ppi300x75-ref.png Binary files differnew file mode 100644 index 00000000..9500328a --- /dev/null +++ b/test/fallback-resolution-ppi300x75-ref.png diff --git a/test/fallback-resolution-ppi37.5x150-ref.png b/test/fallback-resolution-ppi37.5x150-ref.png Binary files differnew file mode 100644 index 00000000..18143466 --- /dev/null +++ b/test/fallback-resolution-ppi37.5x150-ref.png diff --git a/test/fallback-resolution-ppi37.5x300-ref.png b/test/fallback-resolution-ppi37.5x300-ref.png Binary files differnew file mode 100644 index 00000000..823ff01e --- /dev/null +++ b/test/fallback-resolution-ppi37.5x300-ref.png diff --git a/test/fallback-resolution-ppi37.5-ref.png b/test/fallback-resolution-ppi37.5x37.5-ref.png Binary files differindex fe87bc18..fe87bc18 100644 --- a/test/fallback-resolution-ppi37.5-ref.png +++ b/test/fallback-resolution-ppi37.5x37.5-ref.png diff --git a/test/fallback-resolution-ppi37.5x600-ref.png b/test/fallback-resolution-ppi37.5x600-ref.png Binary files differnew file mode 100644 index 00000000..614f6074 --- /dev/null +++ b/test/fallback-resolution-ppi37.5x600-ref.png diff --git a/test/fallback-resolution-ppi37.5x72-ref.png b/test/fallback-resolution-ppi37.5x72-ref.png Binary files differnew file mode 100644 index 00000000..5156dd62 --- /dev/null +++ b/test/fallback-resolution-ppi37.5x72-ref.png diff --git a/test/fallback-resolution-ppi37.5x75-ref.png b/test/fallback-resolution-ppi37.5x75-ref.png Binary files differnew file mode 100644 index 00000000..8d3b8280 --- /dev/null +++ b/test/fallback-resolution-ppi37.5x75-ref.png diff --git a/test/fallback-resolution-ppi600x150-ref.png b/test/fallback-resolution-ppi600x150-ref.png Binary files differnew file mode 100644 index 00000000..0173c0c6 --- /dev/null +++ b/test/fallback-resolution-ppi600x150-ref.png diff --git a/test/fallback-resolution-ppi600x300-ref.png b/test/fallback-resolution-ppi600x300-ref.png Binary files differnew file mode 100644 index 00000000..4b91a2e5 --- /dev/null +++ b/test/fallback-resolution-ppi600x300-ref.png diff --git a/test/fallback-resolution-ppi600x37.5-ref.png b/test/fallback-resolution-ppi600x37.5-ref.png Binary files differnew file mode 100644 index 00000000..a65688f7 --- /dev/null +++ b/test/fallback-resolution-ppi600x37.5-ref.png diff --git a/test/fallback-resolution-ppi600-ref.png b/test/fallback-resolution-ppi600x600-ref.png Binary files differindex c5694a3a..c5694a3a 100644 --- a/test/fallback-resolution-ppi600-ref.png +++ b/test/fallback-resolution-ppi600x600-ref.png diff --git a/test/fallback-resolution-ppi600x72-ref.png b/test/fallback-resolution-ppi600x72-ref.png Binary files differnew file mode 100644 index 00000000..e1faae5e --- /dev/null +++ b/test/fallback-resolution-ppi600x72-ref.png diff --git a/test/fallback-resolution-ppi600x75-ref.png b/test/fallback-resolution-ppi600x75-ref.png Binary files differnew file mode 100644 index 00000000..23065b10 --- /dev/null +++ b/test/fallback-resolution-ppi600x75-ref.png diff --git a/test/fallback-resolution-ppi72x150-ref.png b/test/fallback-resolution-ppi72x150-ref.png Binary files differnew file mode 100644 index 00000000..a8662300 --- /dev/null +++ b/test/fallback-resolution-ppi72x150-ref.png diff --git a/test/fallback-resolution-ppi72x300-ref.png b/test/fallback-resolution-ppi72x300-ref.png Binary files differnew file mode 100644 index 00000000..119c1a29 --- /dev/null +++ b/test/fallback-resolution-ppi72x300-ref.png diff --git a/test/fallback-resolution-ppi72x37.5-ref.png b/test/fallback-resolution-ppi72x37.5-ref.png Binary files differnew file mode 100644 index 00000000..8260c104 --- /dev/null +++ b/test/fallback-resolution-ppi72x37.5-ref.png diff --git a/test/fallback-resolution-ppi72x600-ref.png b/test/fallback-resolution-ppi72x600-ref.png Binary files differnew file mode 100644 index 00000000..82f6ad29 --- /dev/null +++ b/test/fallback-resolution-ppi72x600-ref.png diff --git a/test/fallback-resolution-ppi72-ref.png b/test/fallback-resolution-ppi72x72-ref.png Binary files differindex b9b38031..b9b38031 100644 --- a/test/fallback-resolution-ppi72-ref.png +++ b/test/fallback-resolution-ppi72x72-ref.png diff --git a/test/fallback-resolution-ppi72x75-ref.png b/test/fallback-resolution-ppi72x75-ref.png Binary files differnew file mode 100644 index 00000000..2d6c598d --- /dev/null +++ b/test/fallback-resolution-ppi72x75-ref.png diff --git a/test/fallback-resolution-ppi75x150-ref.png b/test/fallback-resolution-ppi75x150-ref.png Binary files differnew file mode 100644 index 00000000..b23395d7 --- /dev/null +++ b/test/fallback-resolution-ppi75x150-ref.png diff --git a/test/fallback-resolution-ppi75x300-ref.png b/test/fallback-resolution-ppi75x300-ref.png Binary files differnew file mode 100644 index 00000000..73971ca7 --- /dev/null +++ b/test/fallback-resolution-ppi75x300-ref.png diff --git a/test/fallback-resolution-ppi75x37.5-ref.png b/test/fallback-resolution-ppi75x37.5-ref.png Binary files differnew file mode 100644 index 00000000..c4481eee --- /dev/null +++ b/test/fallback-resolution-ppi75x37.5-ref.png diff --git a/test/fallback-resolution-ppi75x600-ref.png b/test/fallback-resolution-ppi75x600-ref.png Binary files differnew file mode 100644 index 00000000..01a33248 --- /dev/null +++ b/test/fallback-resolution-ppi75x600-ref.png diff --git a/test/fallback-resolution-ppi75x72-ref.png b/test/fallback-resolution-ppi75x72-ref.png Binary files differnew file mode 100644 index 00000000..323e0e4d --- /dev/null +++ b/test/fallback-resolution-ppi75x72-ref.png diff --git a/test/fallback-resolution-ppi75-ref.png b/test/fallback-resolution-ppi75x75-ref.png Binary files differindex 03aa6c26..03aa6c26 100644 --- a/test/fallback-resolution-ppi75-ref.png +++ b/test/fallback-resolution-ppi75x75-ref.png diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c index 4e78577d..8b5842e2 100644 --- a/test/fallback-resolution.c +++ b/test/fallback-resolution.c @@ -252,14 +252,14 @@ check_result (cairo_test_context_t *ctx, #if GENERATE_REFERENCE static void -generate_reference (double ppi, const char *filename) +generate_reference (double ppi_x, double ppi_y, const char *filename) { cairo_surface_t *surface, *target; cairo_t *cr; cairo_status_t status; surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, - SIZE*ppi/72, SIZE*ppi/72); + SIZE*ppi_x/72, SIZE*ppi_y/72); cr = cairo_create (surface); cairo_surface_destroy (surface); @@ -272,7 +272,7 @@ generate_reference (double ppi, const char *filename) cairo_paint (cr); } cairo_restore (cr); - cairo_scale (cr, ppi/72., ppi/72.); + cairo_scale (cr, ppi_x/72., ppi_y/72.); draw (cr, SIZE, SIZE); surface = cairo_surface_reference (cairo_get_target (cr)); @@ -280,7 +280,7 @@ generate_reference (double ppi, const char *filename) target = cairo_image_surface_create (CAIRO_FORMAT_RGB24, SIZE, SIZE); cr = cairo_create (target); - cairo_scale (cr, 72./ppi, 72./ppi); + cairo_scale (cr, 72./ppi_x, 72./ppi_y); cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); @@ -303,18 +303,21 @@ main (void) cairo_test_status_t ret = CAIRO_TEST_UNTESTED; double ppi[] = { 600., 300., 150., 75., 72, 37.5 }; unsigned int i; - int page, num_pages; + int ppi_x, ppi_y, num_ppi; - num_pages = sizeof (ppi) / sizeof (ppi[0]); + num_ppi = sizeof (ppi) / sizeof (ppi[0]); cairo_test_init (&ctx, "fallback-resolution"); #if GENERATE_REFERENCE - for (page = 0; page < num_pages; page++) { - char *ref_name; - xasprintf (&ref_name, "fallback-resolution-ppi%g-ref.png", ppi[page]); - generate_reference (ppi[page], ref_name); - free (ref_name); + for (ppi_x = 0; ppi_x < num_ppi; ppi_x++) { + for (ppi_y = 0; ppi_y < num_ppi; ppi_y++) { + char *ref_name; + xasprintf (&ref_name, "fallback-resolution-ppi%gx%g-ref.png", + ppi[ppi_x], ppi[ppi_y]); + generate_reference (ppi[ppi_x], ppi[ppi_y], ref_name); + free (ref_name); + } } #endif @@ -335,7 +338,7 @@ main (void) format); surface = (target->create_surface) (base_name, - target->content, + target->content, SIZE, SIZE, SIZE, SIZE, CAIRO_BOILERPLATE_MODE_TEST, @@ -358,102 +361,106 @@ main (void) /* we need to recreate the surface for each resolution as we include * SVG in testing which does not support the paginated interface. */ - for (page = 0; page < num_pages; page++) { - char *test_name; - cairo_bool_t pass; - - xasprintf (&test_name, "fallback-resolution-ppi%g", - ppi[page]); - xasprintf (&base_name, "%s-%s-%s", - test_name, - target->name, - format); - - surface = (target->create_surface) (base_name, - target->content, - SIZE + 25, SIZE + 25, - SIZE + 25, SIZE + 25, - CAIRO_BOILERPLATE_MODE_TEST, - 0, - &closure); - if (surface == NULL || cairo_surface_status (surface)) { - cairo_test_log (&ctx, "Failed to generate surface: %s-%s\n", - target->name, - format); - free (base_name); - ret = CAIRO_TEST_FAILURE; - continue; - } - - cairo_test_log (&ctx, "Testing fallback-resolution %g with %s target\n", ppi[page], target->name); - printf ("%s:\t", base_name); - fflush (stdout); - - if (target->force_fallbacks != NULL) - target->force_fallbacks (surface, ~0U); - cr = cairo_create (surface); + for (ppi_x = 0; ppi_x < num_ppi; ppi_x++) { + for (ppi_y = 0; ppi_y < num_ppi; ppi_y++) { + char *test_name; + cairo_bool_t pass; + + xasprintf (&test_name, "fallback-resolution-ppi%gx%g", + ppi[ppi_x], ppi[ppi_y]); + xasprintf (&base_name, "%s-%s-%s", + test_name, + target->name, + format); + + surface = (target->create_surface) (base_name, + target->content, + SIZE + 25, SIZE + 25, + SIZE + 25, SIZE + 25, + CAIRO_BOILERPLATE_MODE_TEST, + 0, + &closure); + if (surface == NULL || cairo_surface_status (surface)) { + cairo_test_log (&ctx, "Failed to generate surface: %s-%s\n", + target->name, + format); + free (base_name); + ret = CAIRO_TEST_FAILURE; + continue; + } + + cairo_test_log (&ctx, + "Testing fallback-resolution %gx%g with %s target\n", + ppi[ppi_x], ppi[ppi_y], target->name); + printf ("%s:\t", base_name); + fflush (stdout); + + if (target->force_fallbacks != NULL) + target->force_fallbacks (surface, ~0U); + cr = cairo_create (surface); #if SET_TOLERANCE - cairo_set_tolerance (cr, 3.0); + cairo_set_tolerance (cr, 3.0); #endif - cairo_surface_set_device_offset (surface, 25, 25); - cairo_surface_set_fallback_resolution (surface, - ppi[page], ppi[page]); + cairo_surface_set_device_offset (surface, 25, 25); + cairo_surface_set_fallback_resolution (surface, + ppi[ppi_x], ppi[ppi_y]); - cairo_save (cr); { - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_paint (cr); - } cairo_restore (cr); + cairo_save (cr); { + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + } cairo_restore (cr); - /* First draw the top half in a conventional way. */ - cairo_save (cr); { - cairo_rectangle (cr, 0, 0, SIZE, SIZE / 2.0); - cairo_clip (cr); + /* First draw the top half in a conventional way. */ + cairo_save (cr); { + cairo_rectangle (cr, 0, 0, SIZE, SIZE / 2.0); + cairo_clip (cr); - draw (cr, SIZE, SIZE); - } cairo_restore (cr); + draw (cr, SIZE, SIZE); + } cairo_restore (cr); - /* Then draw the bottom half in a separate group, - * (exposing a bug in 1.6.4 with the group not being - * rendered with the correct fallback resolution). */ - cairo_save (cr); { - cairo_rectangle (cr, 0, SIZE / 2.0, SIZE, SIZE / 2.0); - cairo_clip (cr); + /* Then draw the bottom half in a separate group, + * (exposing a bug in 1.6.4 with the group not being + * rendered with the correct fallback resolution). */ + cairo_save (cr); { + cairo_rectangle (cr, 0, SIZE / 2.0, SIZE, SIZE / 2.0); + cairo_clip (cr); - cairo_push_group (cr); { - draw (cr, SIZE, SIZE); - } cairo_pop_group_to_source (cr); - - cairo_paint (cr); - } cairo_restore (cr); - - status = cairo_status (cr); - cairo_destroy (cr); - - pass = FALSE; - if (status) { - cairo_test_log (&ctx, "Error: Failed to create target surface: %s\n", - cairo_status_to_string (status)); - ret = CAIRO_TEST_FAILURE; - } else { - /* extract the image and compare it to our reference */ - if (! check_result (&ctx, target, test_name, base_name, surface)) + cairo_push_group (cr); { + draw (cr, SIZE, SIZE); + } cairo_pop_group_to_source (cr); + + cairo_paint (cr); + } cairo_restore (cr); + + status = cairo_status (cr); + cairo_destroy (cr); + + pass = FALSE; + if (status) { + cairo_test_log (&ctx, "Error: Failed to create target surface: %s\n", + cairo_status_to_string (status)); ret = CAIRO_TEST_FAILURE; - else - pass = TRUE; - } - cairo_surface_destroy (surface); - if (target->cleanup) - target->cleanup (closure); + } else { + /* extract the image and compare it to our reference */ + if (! check_result (&ctx, target, test_name, base_name, surface)) + ret = CAIRO_TEST_FAILURE; + else + pass = TRUE; + } + cairo_surface_destroy (surface); + if (target->cleanup) + target->cleanup (closure); - free (base_name); + free (base_name); - if (pass) { - printf ("PASS\n"); - } else { - printf ("FAIL\n"); + if (pass) { + printf ("PASS\n"); + } else { + printf ("FAIL\n"); + } + fflush (stdout); } - fflush (stdout); } } |