[cairo-commit] test/recordflip.c test/reference

Chris Wilson ickle at kemper.freedesktop.org
Tue Sep 30 06:35:53 PDT 2014


 test/recordflip.c                                        |   58 ++++++++++++++-
 test/reference/recordflip-fill-alpha.ref.png             |binary
 test/reference/recordflip-paint-alpha-clip-mask.ref.png  |binary
 test/reference/recordflip-paint-alpha-clip.ref.png       |binary
 test/reference/recordflip-paint-alpha-solid-clip.ref.png |binary
 test/reference/recordflip-paint-alpha.ref.png            |binary
 test/reference/recordflip-select-font-face.ref.png       |binary
 test/reference/recordflip-text-transform.ref.png         |binary
 8 files changed, 55 insertions(+), 3 deletions(-)

New commits:
commit 95e147bfa05a122541645f32be52cf1902c3a4b2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 30 14:30:45 2014 +0100

    test: Explicitly flip the reference image for recordflip
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/recordflip.c b/test/recordflip.c
index ecf82f8..7ddf21e 100644
--- a/test/recordflip.c
+++ b/test/recordflip.c
@@ -357,9 +357,61 @@ record_replay (cairo_t *cr, cairo_t *(*func)(cairo_t *), int width, int height)
     int x, y;
 
 #if GENERATE_REF
-    cairo_scale (cr, -1, -1);
-    cairo_translate (cr, -width, -height);
-    func(cr);
+    {
+	cairo_surface_t *image;
+	uint8_t *data, *tmp;
+	int stride, bpp;
+
+	surface = cairo_get_target (cr);
+
+	func(cr);
+
+	image = cairo_surface_map_to_image (surface, NULL);
+
+	switch (cairo_image_surface_get_format (image)) {
+	case CAIRO_FORMAT_ARGB32:
+	case CAIRO_FORMAT_RGB24:
+	case CAIRO_FORMAT_RGB30:
+	    bpp=4;
+	    break;
+	case CAIRO_FORMAT_RGB16_565:
+	    bpp=2;
+	    break;
+	case CAIRO_FORMAT_A8:
+	    bpp=1;
+	    break;
+	case CAIRO_FORMAT_A1:
+	case CAIRO_FORMAT_INVALID:
+	default:
+	    return CAIRO_TEST_FAILURE;
+	}
+
+	data = cairo_image_surface_get_data (image);
+	stride = cairo_image_surface_get_stride (image);
+
+	tmp = malloc (stride);
+	if (tmp == NULL)
+	    return CAIRO_TEST_FAILURE;
+
+	for (y = 0; y < height; y++) {
+	    uint8_t *row = data + y * stride;
+	    for (x = 0; x < width/2; x++) {
+		memcpy (tmp, row + bpp * x, bpp);
+		memcpy (row + bpp * x, row + bpp * (width - x - 1), bpp);
+		memcpy (row + bpp * (width - x - 1), tmp, bpp);
+	    }
+	}
+
+	for (y = 0; y < height/2; y++) {
+	    memcpy (tmp, data + y * stride, stride);
+	    memcpy (data + y * stride, data + (height - y - 1) * stride, stride);
+	    memcpy (data + (height - y - 1) * stride, tmp, stride);
+	}
+
+	free (tmp);
+
+	cairo_surface_unmap_image (surface, image);
+    }
 #else
     surface = record_get (func (record_create (cr)));
 
diff --git a/test/reference/recordflip-fill-alpha.ref.png b/test/reference/recordflip-fill-alpha.ref.png
index 76b7300..86d9fd1 100644
Binary files a/test/reference/recordflip-fill-alpha.ref.png and b/test/reference/recordflip-fill-alpha.ref.png differ
diff --git a/test/reference/recordflip-paint-alpha-clip-mask.ref.png b/test/reference/recordflip-paint-alpha-clip-mask.ref.png
index 90e5459..2594571 100644
Binary files a/test/reference/recordflip-paint-alpha-clip-mask.ref.png and b/test/reference/recordflip-paint-alpha-clip-mask.ref.png differ
diff --git a/test/reference/recordflip-paint-alpha-clip.ref.png b/test/reference/recordflip-paint-alpha-clip.ref.png
index f60ea4b..d619b6d 100644
Binary files a/test/reference/recordflip-paint-alpha-clip.ref.png and b/test/reference/recordflip-paint-alpha-clip.ref.png differ
diff --git a/test/reference/recordflip-paint-alpha-solid-clip.ref.png b/test/reference/recordflip-paint-alpha-solid-clip.ref.png
index 4fb798a..10dde68 100644
Binary files a/test/reference/recordflip-paint-alpha-solid-clip.ref.png and b/test/reference/recordflip-paint-alpha-solid-clip.ref.png differ
diff --git a/test/reference/recordflip-paint-alpha.ref.png b/test/reference/recordflip-paint-alpha.ref.png
index 7e48cc2..599acfb 100644
Binary files a/test/reference/recordflip-paint-alpha.ref.png and b/test/reference/recordflip-paint-alpha.ref.png differ
diff --git a/test/reference/recordflip-select-font-face.ref.png b/test/reference/recordflip-select-font-face.ref.png
index 64efb47..eb71085 100644
Binary files a/test/reference/recordflip-select-font-face.ref.png and b/test/reference/recordflip-select-font-face.ref.png differ
diff --git a/test/reference/recordflip-text-transform.ref.png b/test/reference/recordflip-text-transform.ref.png
index acc5f15..31784d7 100644
Binary files a/test/reference/recordflip-text-transform.ref.png and b/test/reference/recordflip-text-transform.ref.png differ


More information about the cairo-commit mailing list