radial-perf-test.c revision f4f78bb6
1f4f78bb6Smrg#include "utils.h"
2f4f78bb6Smrg#include <stdio.h>
3f4f78bb6Smrg
4f4f78bb6Smrgint
5f4f78bb6Smrgmain ()
6f4f78bb6Smrg{
7f4f78bb6Smrg    static const pixman_point_fixed_t inner = { 0x0000, 0x0000 };
8f4f78bb6Smrg    static const pixman_point_fixed_t outer = { 0x0000, 0x0000 };
9f4f78bb6Smrg    static const pixman_fixed_t r_inner = 0;
10f4f78bb6Smrg    static const pixman_fixed_t r_outer = 64 << 16;
11f4f78bb6Smrg    static const pixman_gradient_stop_t stops[] = {
12f4f78bb6Smrg	{ 0x00000, { 0x6666, 0x6666, 0x6666, 0xffff } },
13f4f78bb6Smrg	{ 0x10000, { 0x0000, 0x0000, 0x0000, 0xffff } }
14f4f78bb6Smrg    };
15f4f78bb6Smrg    static const pixman_transform_t transform = {
16f4f78bb6Smrg	{ { 0x0,        0x26ee, 0x0},
17f4f78bb6Smrg	  { 0xffffeeef, 0x0,    0x0},
18f4f78bb6Smrg	  { 0x0,        0x0,    0x10000}
19f4f78bb6Smrg	}
20f4f78bb6Smrg    };
21f4f78bb6Smrg    static const pixman_color_t z = { 0x0000, 0x0000, 0x0000, 0x0000 };
22f4f78bb6Smrg    pixman_image_t *dest, *radial, *zero;
23f4f78bb6Smrg    int i;
24f4f78bb6Smrg    double before, after;
25f4f78bb6Smrg
26f4f78bb6Smrg    dest = pixman_image_create_bits (
27f4f78bb6Smrg	PIXMAN_x8r8g8b8, 640, 429, NULL, -1);
28f4f78bb6Smrg    zero = pixman_image_create_solid_fill (&z);
29f4f78bb6Smrg    radial = pixman_image_create_radial_gradient (
30f4f78bb6Smrg	&inner, &outer, r_inner, r_outer, stops, ARRAY_LENGTH (stops));
31f4f78bb6Smrg    pixman_image_set_transform (radial, &transform);
32f4f78bb6Smrg    pixman_image_set_repeat (radial, PIXMAN_REPEAT_PAD);
33f4f78bb6Smrg
34f4f78bb6Smrg#define N_COMPOSITE	500
35f4f78bb6Smrg
36f4f78bb6Smrg    before = gettime();
37f4f78bb6Smrg    for (i = 0; i < N_COMPOSITE; ++i)
38f4f78bb6Smrg    {
39f4f78bb6Smrg	before -= gettime();
40f4f78bb6Smrg
41f4f78bb6Smrg	pixman_image_composite (
42f4f78bb6Smrg	    PIXMAN_OP_SRC, zero, NULL, dest,
43f4f78bb6Smrg	    0, 0, 0, 0, 0, 0, 640, 429);
44f4f78bb6Smrg
45f4f78bb6Smrg	before += gettime();
46f4f78bb6Smrg
47f4f78bb6Smrg	pixman_image_composite32 (
48f4f78bb6Smrg	    PIXMAN_OP_OVER, radial, NULL, dest,
49f4f78bb6Smrg	    - 150, -158, 0, 0, 0, 0, 640, 361);
50f4f78bb6Smrg    }
51f4f78bb6Smrg
52f4f78bb6Smrg    after = gettime();
53f4f78bb6Smrg
54f4f78bb6Smrg    write_png (dest, "radial.png");
55f4f78bb6Smrg
56f4f78bb6Smrg    printf ("Average time to composite: %f\n", (after - before) / N_COMPOSITE);
57f4f78bb6Smrg    return 0;
58f4f78bb6Smrg}
59