Revert "Revert "Setup before starting fps measurement""
[platform/upstream/expedite.git] / src / bin / vg_basic_rect.c
1 #undef FNAME
2 #undef NAME
3 #undef ICON
4
5 /* metadata */
6 #define FNAME vg_basic_rect_start
7 #define NAME "VG Basic Rect"
8 #define ICON "vector.png"
9
10 #ifndef PROTO
11 # ifndef UI
12 #  include "main.h"
13
14 /* standard var */
15 static int done = 0;
16
17 /* private data */
18 static Eo *o_shapes[OBNUM];
19
20 /* setup
21  * Creating Evas Objects, each holds a vector shape.
22  * Then start moving these Evas Objects. */
23 static void _setup(void)
24 {
25    unsigned int i;
26
27    for (i = 0; i < OBNUM; i++)
28      {
29         Efl_VG *rect;
30         Eo *vector;
31         double w = 70, h = 70, stroke_w = 3;
32
33         vector = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, evas);
34         o_shapes[i] = vector;
35         efl_gfx_entity_size_set(vector, EINA_SIZE2D(w + stroke_w * 2, h + stroke_w * 2));
36         efl_gfx_entity_position_set(vector, EINA_POSITION2D(0, 0));
37         efl_gfx_entity_visible_set(vector, EINA_TRUE);
38
39         rect = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, vector);
40         efl_gfx_path_append_rect(rect, 0 + stroke_w, 0 + stroke_w, w, h, 10, 10);
41         efl_gfx_shape_stroke_width_set(rect, stroke_w);
42         efl_gfx_shape_stroke_color_set(rect, 128, 0, 128, 128);
43         efl_gfx_shape_stroke_join_set(rect, EFL_GFX_JOIN_ROUND);
44
45         efl_canvas_vg_object_root_node_set(vector, rect);
46      }
47    done = 0;
48 }
49
50 /* cleanup */
51 static void _cleanup(void)
52 {
53    unsigned int i;
54
55    for (i = 0; i < OBNUM; i++) efl_del(o_shapes[i]);
56 }
57
58 /* loop - do things */
59 static void _loop(double t, int f)
60 {
61    int i;
62    Evas_Coord x, y, w = 200, h = 200;
63    for (i = 0; i < OBNUM; i++)
64      {
65         x = (win_w / 2) - (w / 2);
66         x += sin((double)(f + (i * 13)) / (36.7 * SLOW)) * (w / 2);
67         y = (win_h / 2) - (h / 2);
68         y += cos((double)(f + (i * 28)) / (43.8 * SLOW)) * (w / 2);
69         efl_gfx_entity_position_set(o_shapes[i], EINA_POSITION2D(x, y));
70      }
71    FPS_STD(NAME);
72 }
73
74 /* prepend special key handlers if interactive (before STD) */
75 static void _key(const char *key)
76 {
77    KEY_STD;
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91 /* template stuff - ignore */
92 # endif
93 #endif
94
95 #ifdef UI
96 _ui_menu_item_add(ICON, NAME, FNAME);
97 #endif
98
99 #ifdef PROTO
100 void FNAME(void);
101 #endif
102
103 #ifndef PROTO
104 # ifndef UI
105 void FNAME(void)
106 {
107    _setup();
108    ui_func_set(_key, _loop);
109 }
110 # endif
111 #endif
112 #undef FNAME
113 #undef NAME
114 #undef ICON