Make the test program test something useful.
authorSoren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com>
Tue, 8 May 2007 17:19:51 +0000 (13:19 -0400)
committerSoren Sandmann Pedersen <ssp@dhcp83-218.boston.redhat.com>
Tue, 8 May 2007 17:19:51 +0000 (13:19 -0400)
Also add a check that the public image struct is big enough to contain the
private union.

pixman/pixman-image.c
test/composite-test.c

index a68ea7e..113ca51 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <stdlib.h>
+#include <stdio.h>
 
 #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
index 6037f05..4e5ca57 100644 (file)
@@ -1,10 +1,38 @@
+#include <stdlib.h>
 #include <stdio.h>
 #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;
 }