[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.
|
|
@ -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 \
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
BIN
test/fallback-resolution-ppi150x300-ref.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
test/fallback-resolution-ppi150x37.5-ref.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
test/fallback-resolution-ppi150x600-ref.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
test/fallback-resolution-ppi150x72-ref.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
test/fallback-resolution-ppi150x75-ref.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
test/fallback-resolution-ppi300x150-ref.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
BIN
test/fallback-resolution-ppi300x37.5-ref.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
test/fallback-resolution-ppi300x600-ref.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
test/fallback-resolution-ppi300x72-ref.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
test/fallback-resolution-ppi300x75-ref.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
test/fallback-resolution-ppi37.5x150-ref.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
test/fallback-resolution-ppi37.5x300-ref.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
test/fallback-resolution-ppi37.5x600-ref.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
test/fallback-resolution-ppi37.5x72-ref.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
test/fallback-resolution-ppi37.5x75-ref.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
test/fallback-resolution-ppi600x150-ref.png
Normal file
|
After Width: | Height: | Size: 6 KiB |
BIN
test/fallback-resolution-ppi600x300-ref.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
test/fallback-resolution-ppi600x37.5-ref.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
BIN
test/fallback-resolution-ppi600x72-ref.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
test/fallback-resolution-ppi600x75-ref.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
test/fallback-resolution-ppi72x150-ref.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
test/fallback-resolution-ppi72x300-ref.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
test/fallback-resolution-ppi72x37.5-ref.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
test/fallback-resolution-ppi72x600-ref.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
BIN
test/fallback-resolution-ppi72x75-ref.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
test/fallback-resolution-ppi75x150-ref.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
test/fallback-resolution-ppi75x300-ref.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
test/fallback-resolution-ppi75x37.5-ref.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
test/fallback-resolution-ppi75x600-ref.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
test/fallback-resolution-ppi75x72-ref.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
|
@ -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;
|
||||
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%g",
|
||||
ppi[page]);
|
||||
xasprintf (&base_name, "%s-%s-%s",
|
||||
test_name,
|
||||
target->name,
|
||||
format);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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 (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);
|
||||
|
||||
/* 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_restore (cr);
|
||||
|
||||
cairo_paint (cr);
|
||||
} 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);
|
||||
|
||||
status = cairo_status (cr);
|
||||
cairo_destroy (cr);
|
||||
cairo_push_group (cr); {
|
||||
draw (cr, SIZE, SIZE);
|
||||
} cairo_pop_group_to_source (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_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||