Hook up pdiff to the test suite now that its written in C

This commit is contained in:
Carl Worth 2006-12-14 04:17:07 -08:00
parent 305cbd8e71
commit c426e71141
3 changed files with 37 additions and 7 deletions

View file

@ -392,6 +392,7 @@ SUPPORT_PROGS =
INCLUDES = \
-D_GNU_SOURCE \
-I$(srcdir) \
-I$(srcdir)/pdiff \
-I$(top_srcdir)/boilerplate \
-I$(top_srcdir)/pixman/src \
-I$(top_srcdir)/src \
@ -407,6 +408,7 @@ libcairotest_la_SOURCES =\
cairo-test.h
LDADD = libcairotest.la \
$(top_builddir)/test/pdiff/libpdiff.la \
$(top_builddir)/boilerplate/libcairoboilerplate.la \
$(top_builddir)/src/libcairo.la

View file

@ -38,6 +38,7 @@
#include "cairo-test.h"
#include "pdiff.h"
#include "buffer-diff.h"
#include "xmalloc.h"
@ -122,6 +123,18 @@ compare_surfaces (cairo_surface_t *surface_a,
cairo_surface_t *surface_diff,
buffer_diff_result_t *result)
{
/* These default values were taken straight from the
* perceptualdiff program. We'll probably want to tune these as
* necessary. */
double gamma = 2.2;
double luminance = 100.0;
double field_of_view = 45.0;
int discernible_pixels_changed;
/* First, we run cairo's old buffer_diff algorithm which looks for
* pixel-perfect images, (we do this first since the test suite
* runs about 3x slower if we run pdiff_compare first).
*/
buffer_diff_core (cairo_image_surface_get_data (surface_a),
cairo_image_surface_get_data (surface_b),
cairo_image_surface_get_data (surface_diff),
@ -130,6 +143,23 @@ compare_surfaces (cairo_surface_t *surface_a,
cairo_image_surface_get_stride (surface_a),
0xffffffff,
result);
if (result->pixels_changed == 0)
return;
cairo_test_log ("%d pixels differ (with maximum difference of %d) from reference image\n",
result->pixels_changed, result->max_diff);
/* Then, if there are any different pixels, we give the pdiff code
* a crack at the images. If it decides that there are no visually
* discernible differences in any pixels, then we accept this
* result as good enough. */
discernible_pixels_changed = pdiff_compare (surface_a, surface_b,
gamma, luminance, field_of_view);
if (discernible_pixels_changed == 0) {
result->pixels_changed = 0;
cairo_test_log ("But perceptual diff finds no visually discernible difference.\n"
"Accepting result.\n");
}
}
void

View file

@ -313,6 +313,8 @@ cairo_test_for_target (cairo_test_t *test,
goto UNWIND_CAIRO;
}
cairo_test_log ("Comparing result against reference image: %s\n", ref_name);
if (target->content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED) {
diff_status= image_diff_flattened (png_name, ref_name, diff_name,
dev_offset, dev_offset, 0, 0, &result);
@ -326,13 +328,9 @@ cairo_test_for_target (cairo_test_t *test,
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
if (result.pixels_changed) {
cairo_test_log ("%d pixels differ (with maximum difference of %d) from reference image %s\n",
result.pixels_changed, result.max_diff, ref_name);
if (result.max_diff > target->error_tolerance) {
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
if (result.pixels_changed && result.max_diff > target->error_tolerance) {
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
}