1 #include <assert.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <string.h> 5 #include "utils.h" 6 7 int 8 main (int argc, char **argv) 9 { 10 #define WIDTH 20 11 #define HEIGHT 20 12 13 pixman_image_t *src_img; 14 pixman_image_t *mask_img; 15 pixman_image_t *dest_img; 16 pixman_trap_t trap; 17 pixman_color_t red = { 0xffff, 0x0000, 0x0000, 0xffff }; 18 uint32_t *bits = malloc (WIDTH * HEIGHT * 4); 19 uint32_t *mbits = malloc (WIDTH * HEIGHT); 20 21 memset (mbits, 0, WIDTH * HEIGHT); 22 memset (bits, 0xff, WIDTH * HEIGHT * 4); 23 24 trap.top.l = pixman_double_to_fixed (0.5); 25 trap.top.r = pixman_double_to_fixed (1.5); 26 trap.top.y = pixman_double_to_fixed (0.5); 27 28 trap.bot.l = pixman_double_to_fixed (0.5); 29 trap.bot.r = pixman_double_to_fixed (1.5); 30 trap.bot.y = pixman_double_to_fixed (1.5); 31 32 mask_img = pixman_image_create_bits ( 33 PIXMAN_a1, WIDTH, HEIGHT, mbits, WIDTH); 34 src_img = pixman_image_create_solid_fill (&red); 35 dest_img = pixman_image_create_bits ( 36 PIXMAN_a8r8g8b8, WIDTH, HEIGHT, bits, WIDTH * 4); 37 38 pixman_add_traps (mask_img, 0, 0, 1, &trap); 39 40 pixman_image_composite (PIXMAN_OP_OVER, 41 src_img, mask_img, dest_img, 42 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); 43 44 assert (bits[0] == 0xffff0000); 45 assert (bits[1] == 0xffffffff); 46 assert (bits[1 * WIDTH + 0] == 0xffffffff); 47 assert (bits[1 * WIDTH + 1] == 0xffffffff); 48 49 /* The check-formats test depends on operator_name() and format_name() returning 50 * these precise formats, so if those change, check-formats.c must be updated too. 51 */ 52 assert ( 53 strcmp (operator_name (PIXMAN_OP_DISJOINT_OVER), "PIXMAN_OP_DISJOINT_OVER") == 0); 54 assert ( 55 strcmp (format_name (PIXMAN_r5g6b5), "r5g6b5") == 0); 56 57 return 0; 58 } 59