summaryrefslogtreecommitdiff
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
parentccd48b346436a80629e4f9a07f2ba7ffbfd802f1 (diff)
downloadcairo-95e147bfa05a122541645f32be52cf1902c3a4b2.tar.gz
test: Explicitly flip the reference image for recordflip
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--test/recordflip.c58
-rw-r--r--test/reference/recordflip-fill-alpha.ref.pngbin2790 -> 2864 bytes
-rw-r--r--test/reference/recordflip-paint-alpha-clip-mask.ref.pngbin340 -> 372 bytes
-rw-r--r--test/reference/recordflip-paint-alpha-clip.ref.pngbin291 -> 316 bytes
-rw-r--r--test/reference/recordflip-paint-alpha-solid-clip.ref.pngbin280 -> 291 bytes
-rw-r--r--test/reference/recordflip-paint-alpha.ref.pngbin242 -> 257 bytes
-rw-r--r--test/reference/recordflip-select-font-face.ref.pngbin2229 -> 2240 bytes
-rw-r--r--test/reference/recordflip-text-transform.ref.pngbin5606 -> 5609 bytes
8 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)));
diff --git a/test/reference/recordflip-fill-alpha.ref.png b/test/reference/recordflip-fill-alpha.ref.png
index 76b73001d..86d9fd101 100644
--- a/test/reference/recordflip-fill-alpha.ref.png
+++ b/test/reference/recordflip-fill-alpha.ref.png
Binary files differ
diff --git a/test/reference/recordflip-paint-alpha-clip-mask.ref.png b/test/reference/recordflip-paint-alpha-clip-mask.ref.png
index 90e545989..259457197 100644
--- a/test/reference/recordflip-paint-alpha-clip-mask.ref.png
+++ b/test/reference/recordflip-paint-alpha-clip-mask.ref.png
Binary files differ
diff --git a/test/reference/recordflip-paint-alpha-clip.ref.png b/test/reference/recordflip-paint-alpha-clip.ref.png
index f60ea4b00..d619b6d60 100644
--- a/test/reference/recordflip-paint-alpha-clip.ref.png
+++ b/test/reference/recordflip-paint-alpha-clip.ref.png
Binary files differ
diff --git a/test/reference/recordflip-paint-alpha-solid-clip.ref.png b/test/reference/recordflip-paint-alpha-solid-clip.ref.png
index 4fb798adc..10dde68c5 100644
--- a/test/reference/recordflip-paint-alpha-solid-clip.ref.png
+++ b/test/reference/recordflip-paint-alpha-solid-clip.ref.png
Binary files differ
diff --git a/test/reference/recordflip-paint-alpha.ref.png b/test/reference/recordflip-paint-alpha.ref.png
index 7e48cc2bd..599acfba2 100644
--- a/test/reference/recordflip-paint-alpha.ref.png
+++ b/test/reference/recordflip-paint-alpha.ref.png
Binary files differ
diff --git a/test/reference/recordflip-select-font-face.ref.png b/test/reference/recordflip-select-font-face.ref.png
index 64efb47a3..eb710858c 100644
--- a/test/reference/recordflip-select-font-face.ref.png
+++ b/test/reference/recordflip-select-font-face.ref.png
Binary files differ
diff --git a/test/reference/recordflip-text-transform.ref.png b/test/reference/recordflip-text-transform.ref.png
index acc5f154e..31784d735 100644
--- a/test/reference/recordflip-text-transform.ref.png
+++ b/test/reference/recordflip-text-transform.ref.png
Binary files differ