16ba797d6Smrg#include <stdio.h>
26ba797d6Smrg#include <stdlib.h>
36ba797d6Smrg#include "pixman.h"
46ba797d6Smrg#include "gtk-utils.h"
56ba797d6Smrg
66ba797d6Smrgint
76ba797d6Smrgmain (int argc, char **argv)
86ba797d6Smrg{
96ba797d6Smrg#define WIDTH 400
106ba797d6Smrg#define HEIGHT 200
116ba797d6Smrg
126ba797d6Smrg    uint32_t *dest = malloc (WIDTH * HEIGHT * 4);
136ba797d6Smrg    pixman_image_t *src_img;
146ba797d6Smrg    pixman_image_t *dest_img;
156ba797d6Smrg    int i;
166ba797d6Smrg    pixman_gradient_stop_t stops[2] =
176ba797d6Smrg	{
189ad247e8Sjmcneill	    { pixman_int_to_fixed (0), { 0x0000, 0x0000, 0xffff, 0xffff } },
199ad247e8Sjmcneill	    { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0xffff } }
206ba797d6Smrg	};
219ad247e8Sjmcneill    pixman_point_fixed_t p1 = { pixman_double_to_fixed (50), 0 };
229ad247e8Sjmcneill    pixman_point_fixed_t p2 = { pixman_double_to_fixed (200), 0 };
236ba797d6Smrg#if 0
246ba797d6Smrg    pixman_transform_t trans = {
256ba797d6Smrg	{ { pixman_double_to_fixed (2), pixman_double_to_fixed (0.5), pixman_double_to_fixed (-100), },
266ba797d6Smrg	  { pixman_double_to_fixed (0), pixman_double_to_fixed (3), pixman_double_to_fixed (0), },
276ba797d6Smrg	  { pixman_double_to_fixed (0), pixman_double_to_fixed (0.000), pixman_double_to_fixed (1.0) }
286ba797d6Smrg	}
296ba797d6Smrg    };
306ba797d6Smrg#else
316ba797d6Smrg    pixman_transform_t trans = {
326ba797d6Smrg	{ { pixman_fixed_1, 0, 0 },
336ba797d6Smrg	  { 0, pixman_fixed_1, 0 },
346ba797d6Smrg	  { 0, 0, pixman_fixed_1 } }
356ba797d6Smrg    };
366ba797d6Smrg#endif
376ba797d6Smrg
386ba797d6Smrg#if 0
396ba797d6Smrg    pixman_point_fixed_t c_inner;
406ba797d6Smrg    pixman_point_fixed_t c_outer;
416ba797d6Smrg    pixman_fixed_t r_inner;
426ba797d6Smrg    pixman_fixed_t r_outer;
436ba797d6Smrg#endif
446ba797d6Smrg
456ba797d6Smrg    for (i = 0; i < WIDTH * HEIGHT; ++i)
469ad247e8Sjmcneill	dest[i] = 0xff00ff00;
476ba797d6Smrg
486ba797d6Smrg    dest_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
496ba797d6Smrg					 WIDTH, HEIGHT,
506ba797d6Smrg					 dest,
516ba797d6Smrg					 WIDTH * 4);
526ba797d6Smrg
536ba797d6Smrg#if 0
546ba797d6Smrg    c_inner.x = pixman_double_to_fixed (50.0);
556ba797d6Smrg    c_inner.y = pixman_double_to_fixed (50.0);
566ba797d6Smrg    c_outer.x = pixman_double_to_fixed (50.0);
576ba797d6Smrg    c_outer.y = pixman_double_to_fixed (50.0);
586ba797d6Smrg    r_inner = 0;
596ba797d6Smrg    r_outer = pixman_double_to_fixed (50.0);
606ba797d6Smrg
616ba797d6Smrg    src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
626ba797d6Smrg						    stops, 2);
636ba797d6Smrg#endif
646ba797d6Smrg#if 0
656ba797d6Smrg    src_img = pixman_image_create_conical_gradient (&c_inner, r_inner,
666ba797d6Smrg						    stops, 2);
676ba797d6Smrg    src_img = pixman_image_create_linear_gradient (&c_inner, &c_outer,
686ba797d6Smrg						   r_inner, r_outer,
696ba797d6Smrg						   stops, 2);
706ba797d6Smrg#endif
716ba797d6Smrg
726ba797d6Smrg    src_img = pixman_image_create_linear_gradient  (&p1, &p2,
736ba797d6Smrg						    stops, 2);
746ba797d6Smrg
756ba797d6Smrg    pixman_image_set_transform (src_img, &trans);
769ad247e8Sjmcneill    pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NONE);
776ba797d6Smrg
786ba797d6Smrg    pixman_image_composite (PIXMAN_OP_OVER, src_img, NULL, dest_img,
796ba797d6Smrg			    0, 0, 0, 0, 0, 0, 10 * WIDTH, HEIGHT);
806ba797d6Smrg
816ba797d6Smrg    printf ("0, 0: %x\n", dest[0]);
826ba797d6Smrg    printf ("10, 10: %x\n", dest[10 * 10 + 10]);
836ba797d6Smrg    printf ("w, h: %x\n", dest[(HEIGHT - 1) * 100 + (WIDTH - 1)]);
846ba797d6Smrg
856ba797d6Smrg    show_image (dest_img);
866ba797d6Smrg
876ba797d6Smrg    pixman_image_unref (src_img);
886ba797d6Smrg    pixman_image_unref (dest_img);
896ba797d6Smrg    free (dest);
906ba797d6Smrg
916ba797d6Smrg    return 0;
926ba797d6Smrg}
93