Upload Tizen2.0 source
[framework/graphics/cairo.git] / TC / perf / fill.c
1 /*
2  * Cairo Performance Test Framework
3  * (c) 2012 Samsung Electronics, Inc.
4  * All rights reserved.
5  *
6  * Measures rendering performance for image, gl backends
7  *
8  * This software is a confidential and proprietary information of Samsung
9  * Electronics, Inc. ("Confidential Information"). You shall not disclose such
10  * Confidential Information and shall use it only in accordance with the terms
11  * of the license agreement you entered into with Samsung Electronics.
12  *
13  * Author: Dongyeon Kim <dy5.kim@samsung.com>
14  */
15
16 #include "common.h"
17
18 #define RENDER_LOOP 100
19
20 extern int WIDTH, HEIGHT;
21
22 int preRender(cairo_t *cr)
23 {
24     return 1;
25 }
26
27 int render(cairo_t *cr)
28 {
29     int i;
30     double r, g, b, a;
31
32     clearCairo(cr, WIDTH, HEIGHT);
33     cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
34
35     for(i = 0; i < RENDER_LOOP; i++)
36     {
37         r = drand48();
38         g = drand48();
39         b = drand48();
40         a = drand48();
41         float x = drand48() * WIDTH;
42         float y = drand48() * HEIGHT;
43         float side = drand48() * 300;
44         int shape = drand48() * 3;
45
46         cairo_set_source_rgba(cr, r, g, b, a);
47
48         if(shape == 0)
49             cairoSquare(cr, x, y, side);
50         else if(shape == 1)
51             cairoCircle(cr, x, y, side/2);
52         else
53             cairoTriangle(cr, x, y, side);
54     }
55
56     return 1;
57 }
58
59 int postRender(cairo_t *cr)
60 {
61     return 1;
62 }
63