summaryrefslogtreecommitdiff
path: root/test/buffer-diff.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-08-18 12:53:43 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-08-18 16:18:52 +0100
commit17fbb652b1c74ba0ccced48c14c63a4d24bb3891 (patch)
treed8204d532d21318140eb266c0a7a728e05b6b918 /test/buffer-diff.h
parent9b0b55cea724f91eb2835294f929c49224bd0bac (diff)
downloadcairo-17fbb652b1c74ba0ccced48c14c63a4d24bb3891.tar.gz
[test] Avoid redundant writes/reads of test surfaces via png.
As Behdad suggested, we can dramatically speed up the test suite by short-circuiting the write to a png file, only to then immediately read it back in. So for the raster based surfaces, we avoid the round-trip through libpng by implementing a new boilerplate method to directly extract the image buffer from the test result. A secondary speedup is achieved by caching the most recent reference image.
Diffstat (limited to 'test/buffer-diff.h')
-rw-r--r--test/buffer-diff.h38
1 files changed, 18 insertions, 20 deletions
diff --git a/test/buffer-diff.h b/test/buffer-diff.h
index 61daa897d..64bce920a 100644
--- a/test/buffer-diff.h
+++ b/test/buffer-diff.h
@@ -36,21 +36,6 @@ typedef struct _buffer_diff_result {
unsigned int max_diff;
} buffer_diff_result_t;
-/* Compares two image surfaces
- *
- * Provides number of pixels changed and maximum single-channel
- * difference in result.
- *
- * Also fills in a "diff" surface intended to visually show where the
- * images differ.
- */
-void
-compare_surfaces (const cairo_test_context_t *ctx,
- cairo_surface_t *surface_a,
- cairo_surface_t *surface_b,
- cairo_surface_t *surface_diff,
- buffer_diff_result_t *result);
-
/* Compares two image buffers ignoring the alpha channel.
*
* Provides number of pixels changed and maximum single-channel
@@ -60,8 +45,8 @@ compare_surfaces (const cairo_test_context_t *ctx,
* images differ.
*/
void
-buffer_diff_noalpha (unsigned char *buf_a,
- unsigned char *buf_b,
+buffer_diff_noalpha (const unsigned char *buf_a,
+ const unsigned char *buf_b,
unsigned char *buf_diff,
int width,
int height,
@@ -82,7 +67,7 @@ buffer_diff_noalpha (unsigned char *buf_a,
* images differ.
*/
cairo_status_t
-image_diff (const cairo_test_context_t *ctx,
+png_diff (const cairo_test_context_t *ctx,
const char *filename_a,
const char *filename_b,
const char *filename_diff,
@@ -92,9 +77,9 @@ image_diff (const cairo_test_context_t *ctx,
int by,
buffer_diff_result_t *result);
-/* Like image_diff, but blending the contents of b over white first. */
+/* Like png_diff, but blending the contents of b over white first. */
cairo_status_t
-image_diff_flattened (const cairo_test_context_t *ctx,
+png_diff_flattened (const cairo_test_context_t *ctx,
const char *filename_a,
const char *filename_b,
const char *filename_diff,
@@ -104,4 +89,17 @@ image_diff_flattened (const cairo_test_context_t *ctx,
int by,
buffer_diff_result_t *result);
+/* The central algorithm to compare two images, and return the differences
+ * in the surface_diff.
+ *
+ * Provides number of pixels changed and maximum single-channel
+ * difference in result.
+ */
+cairo_status_t
+image_diff (const cairo_test_context_t *ctx,
+ cairo_surface_t *surface_a,
+ cairo_surface_t *surface_b,
+ cairo_surface_t *surface_diff,
+ buffer_diff_result_t *result);
+
#endif