summaryrefslogtreecommitdiff
path: root/test/buffer-diff.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-12-14 04:17:07 -0800
committerCarl Worth <cworth@cworth.org>2006-12-14 07:58:02 -0800
commitc426e71141d75dbfd39730bf9c4847309fcd9d9e (patch)
tree7fa222aae5d819c4f1891497a7d58f63abc575b0 /test/buffer-diff.c
parent305cbd8e71a2d21a2c71ed2c382daa5bfcec3992 (diff)
downloadcairo-c426e71141d75dbfd39730bf9c4847309fcd9d9e.tar.gz
Hook up pdiff to the test suite now that its written in C
Diffstat (limited to 'test/buffer-diff.c')
-rw-r--r--test/buffer-diff.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/buffer-diff.c b/test/buffer-diff.c
index 99501bce8..e4324ff2a 100644
--- a/test/buffer-diff.c
+++ b/test/buffer-diff.c
@@ -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