summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-09-29 00:19:17 +0200
committerBenjamin Otte <otte@gnome.org>2009-11-04 15:50:13 +0100
commitfbe9738c0fae3006502df79a68cd0b226f454f83 (patch)
tree3e422ad05a5590ba03dc8ecbd6ae0881eaa32a37
parentb14556417130f3f036743e8ca80ba9ed9fccee37 (diff)
[test] Add a test for all the pixman formatsyuv
The test works fine, eventual issues have been fixed on master reviously.
-rw-r--r--test/Makefile.sources1
-rw-r--r--test/pixman-formats.c118
-rw-r--r--test/pixman-formats.ref.pngbin0 -> 298 bytes
3 files changed, 119 insertions, 0 deletions
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 82c761b1..b0244a58 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -154,6 +154,7 @@ test_sources = \
path-precision.c \
pattern-get-type.c \
pattern-getters.c \
+ pixman-formats.c \
pixman-rotate.c \
png.c \
push-group.c \
diff --git a/test/pixman-formats.c b/test/pixman-formats.c
new file mode 100644
index 00000000..aee23bf2
--- /dev/null
+++ b/test/pixman-formats.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright © 2009 Benjamin Otte
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#include "cairo-test.h"
+#include <pixman.h>
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+pixman_format_code_t formats[] = {
+ PIXMAN_a8r8g8b8,
+ PIXMAN_x8r8g8b8,
+ PIXMAN_a8b8g8r8,
+ PIXMAN_x8b8g8r8,
+ PIXMAN_b8g8r8a8,
+ PIXMAN_b8g8r8x8,
+ PIXMAN_x2r10g10b10,
+ PIXMAN_a2r10g10b10,
+ PIXMAN_x2b10g10r10,
+ PIXMAN_a2b10g10r10,
+
+ PIXMAN_r8g8b8,
+ PIXMAN_b8g8r8,
+ PIXMAN_r5g6b5,
+ PIXMAN_b5g6r5,
+ PIXMAN_a1r5g5b5,
+ PIXMAN_x1r5g5b5,
+ PIXMAN_a1b5g5r5,
+ PIXMAN_x1b5g5r5,
+ PIXMAN_a4r4g4b4,
+ PIXMAN_x4r4g4b4,
+
+ PIXMAN_a4b4g4r4,
+ PIXMAN_x4b4g4r4,
+ PIXMAN_r3g3b2,
+ PIXMAN_b2g3r3,
+ PIXMAN_a2r2g2b2,
+ PIXMAN_a2b2g2r2
+};
+
+#define SIZE 20
+#define SPACE 5
+#define STRIDE 10
+
+static void
+paint (cairo_t *cr, pixman_format_code_t format)
+{
+ pixman_color_t red = { 0xFFFF, 0, 0, 0xFFFF };
+ pixman_rectangle16_t rect = { 0, 0, SIZE, SIZE };
+ pixman_image_t *image;
+ cairo_surface_t *surface;
+
+ image = pixman_image_create_bits (format, SIZE, SIZE, NULL, 0);
+ if (!image)
+ return;
+ pixman_image_fill_rectangles (PIXMAN_OP_SRC, image, &red, 1, &rect);
+
+ surface = cairo_image_surface_create_with_pixman_format (
+ (unsigned char *) pixman_image_get_data (image),
+ format,
+ SIZE,
+ SIZE,
+ pixman_image_get_stride (image));
+
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (surface);
+ pixman_image_unref (image);
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ unsigned i;
+
+ /* fill with black so output of tests is always the same */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_paint (cr);
+
+ for (i = 0; i < ARRAY_SIZE (formats); i++) {
+ cairo_save (cr);
+ cairo_translate (cr, (SIZE + SPACE) * (i % STRIDE), (SIZE + SPACE) * (i / STRIDE));
+ paint (cr, formats[i]);
+ cairo_restore (cr);
+ }
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (pixman_formats,
+ "Tests all pixman formats are handled properly",
+ "pixman", /* keywords */
+ NULL, /* requirements */
+ STRIDE * (SIZE + SPACE), (ARRAY_SIZE (formats) + STRIDE - 1) / STRIDE * (SIZE + SPACE),
+ NULL, draw)
+
diff --git a/test/pixman-formats.ref.png b/test/pixman-formats.ref.png
new file mode 100644
index 00000000..dc56b40a
--- /dev/null
+++ b/test/pixman-formats.ref.png
Binary files differ