1f7fd6c8cb437d6e0e49e6b43b850f780243c624
[framework/graphics/cairo.git] / perf / micro / twin.c
1 #define WIDTH 1350
2 #define HEIGHT 900
3
4 #include "cairo-perf.h"
5
6 static cairo_time_t
7 do_twin (cairo_t *cr,
8          int width,
9          int height,
10          int loops)
11 {
12     int i, j, h;
13     unsigned char s[2] = {0, 0};
14
15     cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
16     cairo_paint (cr);
17     cairo_set_source_rgb (cr, 0, 0, 0);
18
19     cairo_select_font_face (cr,
20                             "@cairo:",
21                             CAIRO_FONT_SLANT_NORMAL,
22                             CAIRO_FONT_WEIGHT_NORMAL);
23
24     cairo_perf_timer_start ();
25     cairo_perf_set_thread_aware (cr, FALSE);
26
27     while (loops--) {
28         if (loops == 0)
29                 cairo_perf_set_thread_aware (cr, TRUE);
30         h = 2;
31         for (i = 8; i < 48; i >= 24 ? i+=3 : i++) {
32             cairo_set_font_size (cr, i);
33             for (j = 33; j < 128; j++) {
34                 if (j == 33 || (j == 80 && i > 24)) {
35                     h += i + 2;
36                     cairo_move_to (cr, 10, h);
37                 }
38                 s[0] = j;
39                 cairo_text_path (cr, (const char *) s);
40             }
41         }
42         cairo_fill (cr);
43     }
44
45     cairo_perf_timer_stop ();
46     return cairo_perf_timer_elapsed ();
47 }
48
49 cairo_bool_t
50 twin_enabled (cairo_perf_t *perf)
51 {
52     return cairo_perf_can_run (perf, "twin", NULL);
53 }
54
55 void
56 twin (cairo_perf_t *perf,
57       cairo_t      *cr,
58       int           width,
59       int           height)
60 {
61     cairo_perf_run (perf, "twin", do_twin, NULL);
62 }