16ba797d6Smrg#include <stdio.h>
26ba797d6Smrg#include <stdlib.h>
36ba797d6Smrg#include <string.h>
46ba797d6Smrg#include "pixman.h"
56ba797d6Smrg#include "gtk-utils.h"
66ba797d6Smrg
76ba797d6Smrg/* This test demonstrates that clipping is done totally different depending
86ba797d6Smrg * on whether the source is transformed or not.
96ba797d6Smrg */
106ba797d6Smrgint
116ba797d6Smrgmain (int argc, char **argv)
126ba797d6Smrg{
136ba797d6Smrg#define WIDTH 200
146ba797d6Smrg#define HEIGHT 200
156ba797d6Smrg
166ba797d6Smrg#define SMALL 25
176ba797d6Smrg
186ba797d6Smrg    uint32_t *sbits = malloc (SMALL * SMALL * 4);
196ba797d6Smrg    uint32_t *bits = malloc (WIDTH * HEIGHT * 4);
206ba797d6Smrg    pixman_transform_t trans = {
216ba797d6Smrg    {
226ba797d6Smrg	{ pixman_double_to_fixed (1.0), pixman_double_to_fixed (0), pixman_double_to_fixed (-0.1), },
236ba797d6Smrg	{ pixman_double_to_fixed (0), pixman_double_to_fixed (1), pixman_double_to_fixed (-0.1), },
246ba797d6Smrg	{ pixman_double_to_fixed (0), pixman_double_to_fixed (0), pixman_double_to_fixed (1.0) }
256ba797d6Smrg    } };
266ba797d6Smrg
276ba797d6Smrg    pixman_image_t *src_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, SMALL, SMALL, sbits, 4 * SMALL);
286ba797d6Smrg    pixman_image_t *dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, bits, 4 * WIDTH);
296ba797d6Smrg
306ba797d6Smrg    memset (bits, 0xff, WIDTH * HEIGHT * 4);
316ba797d6Smrg    memset (sbits, 0x00, SMALL * SMALL * 4);
326ba797d6Smrg
336ba797d6Smrg    pixman_image_composite (PIXMAN_OP_IN,
346ba797d6Smrg			    src_img, NULL, dest_img,
356ba797d6Smrg			    0, 0, 0, 0, SMALL, SMALL, 200, 200);
366ba797d6Smrg
376ba797d6Smrg    pixman_image_set_transform (src_img, &trans);
386ba797d6Smrg
396ba797d6Smrg    pixman_image_composite (PIXMAN_OP_IN,
406ba797d6Smrg			    src_img, NULL, dest_img,
416ba797d6Smrg			    0, 0, 0, 0, SMALL * 2, SMALL * 2, 200, 200);
426ba797d6Smrg
436ba797d6Smrg    show_image (dest_img);
446ba797d6Smrg
456ba797d6Smrg    pixman_image_unref (src_img);
466ba797d6Smrg    pixman_image_unref (dest_img);
476ba797d6Smrg    free (bits);
486ba797d6Smrg
496ba797d6Smrg    return 0;
506ba797d6Smrg}
51