tests: rewrite check_surfaces_*() API

check_surfaces_geometry() is removed as it was not used by anything, and
unlikely would be.

check_surfaces_equal() is merged into check_surfaces_match_in_clip(),
passing a NULL clip means to compare whole images.

check_surfaces_match_in_clip() is converted to work on pixman_image_t
instead of struct surface. The function is only concerned about
comparing images in memory, and does not care about a wl_buffer or a
wl_surface.

The verbosity of image comparisons is greatly reduced. An image mismatch
no longer prints a flood of raw pixel values. This will be replaced
later with a function writing out an error image instead.

Degenerate comparisons are no longer accepted, be that clip outside
images or zero area. Those are an indication of a programmer error.

The pixel format assumptions are made more visible in the code.

A new internal helper image_check_get_roi() computes and verifies the
area to be compared. Image iterator helper makes it simpler to write
manual pixel-poking loops.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c
index 53e7515..ce41181 100644
--- a/tests/internal-screenshot-test.c
+++ b/tests/internal-screenshot-test.c
@@ -120,16 +120,17 @@
 	reference_bad = load_surface_from_png(fname);
 	assert(reference_bad);
 
-	/* Test check_surfaces_equal()
+	/* Test check_images_match() without a clip.
 	 * We expect this to fail since we use a bad reference image
 	 */
-	match = check_surfaces_equal(screenshot, reference_bad);
+	match = check_images_match(screenshot->buffer->image,
+				   reference_bad->buffer->image, NULL);
 	printf("Screenshot %s reference image\n", match? "equal to" : "different from");
 	assert(!match);
 	buffer_destroy(reference_bad->buffer);
 	free(reference_bad);
 
-	/* Test check_surfaces_match_in_clip()
+	/* Test check_images_match() with clip.
 	 * Alpha-blending and other effects can cause irrelevant discrepancies, so look only
 	 * at a small portion of the solid-colored background
 	 */
@@ -138,8 +139,9 @@
 	clip.width = 100;
 	clip.height = 100;
 	printf("Clip: %d,%d %d x %d\n", clip.x, clip.y, clip.width, clip.height);
-	match = check_surfaces_match_in_clip(screenshot, reference_good,
-					     &clip);
+	match = check_images_match(screenshot->buffer->image,
+				   reference_good->buffer->image,
+				   &clip);
 	printf("Screenshot %s reference image in clipped area\n", match? "matches" : "doesn't match");
 	buffer_destroy(reference_good->buffer);
 	free(reference_good);