From: Soren Sandmann Pedersen Date: Tue, 8 May 2007 17:19:51 +0000 (-0400) Subject: Make the test program test something useful. X-Git-Tag: pixman-0.9.4~133 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e36c6a5eb4cc89da8cf8d66dd45d02b75584e243;p=platform%2Fupstream%2Fpixman.git Make the test program test something useful. Also add a check that the public image struct is big enough to contain the private union. --- diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index a68ea7e..113ca51 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -22,6 +22,7 @@ */ #include +#include #include "pixman.h" #include "pixman-private.h" @@ -238,6 +239,18 @@ pixman_image_init_bits (pixman_image_t *image, img->bits.bits = bits; img->bits.rowstride = rowstride / 4; /* we store it in number of uint32_t's */ img->bits.indexed = NULL; + + if (sizeof (pixman_image_t) < sizeof (image_t)) + { + fprintf (stderr, "BUG in pixman: sizeof pixman_image_t < sizeof (image_t)\n"); + exit (1); + } + else + { + fprintf (stderr, "sizeof pixman_image_t: %d\n", sizeof (pixman_image_t)); + fprintf (stderr, "sizeof image_t: %d\n", sizeof (image_t)); + } + } void diff --git a/test/composite-test.c b/test/composite-test.c index 6037f05..4e5ca57 100644 --- a/test/composite-test.c +++ b/test/composite-test.c @@ -1,10 +1,38 @@ +#include #include #include "pixman.h" int main () { - printf ("Hello World\n"); + uint32_t *src = malloc (10 * 10 * 4); + uint32_t *dest = malloc (10 * 10 * 4); + pixman_image_t src_img; + pixman_image_t dest_img; + uint32_t real; + + int i; + + for (i = 0; i < 10 * 10; ++i) + src[i] = 0x7f7f0000; /* red */ + + for (i = 0; i < 10 * 10; ++i) + dest[i] = 0x7f0000ff; /* blue */ + + pixman_image_init_bits (&src_img, + PIXMAN_a8r8g8b8, + 10, 10, + src, + 10 * 4); + + pixman_image_init_bits (&dest_img, + PIXMAN_a8r8g8b8, + 10, 10, + dest, + 10 * 4); + + pixman_image_composite (PIXMAN_OP_OVER, &src_img, NULL, &dest_img, + 0, 0, 0, 0, 0, 0, 10, 10); return 0; }