summaryrefslogtreecommitdiff
path: root/test/recordflip.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-09-30 14:30:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-09-30 14:33:50 +0100
commit95e147bfa05a122541645f32be52cf1902c3a4b2 (patch)
treed8fc5a4bc259e93a5f66b0b334a4a5be8494b894 /test/recordflip.c
parentccd48b346436a80629e4f9a07f2ba7ffbfd802f1 (diff)
downloadcairo-95e147bfa05a122541645f32be52cf1902c3a4b2.tar.gz
test: Explicitly flip the reference image for recordflip
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'test/recordflip.c')
-rw-r--r--test/recordflip.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/test/recordflip.c b/test/recordflip.c
index ecf82f828..7ddf21ea0 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)));