Revert "Revert "Setup before starting fps measurement""
[platform/upstream/expedite.git] / src / bin / proxy_textblock.c
1 #undef FNAME
2 #undef NAME
3 #undef ICON
4
5 /* metadata */
6 #define FNAME proxy_textblock_start
7 #define NAME "Proxy Textblock"
8 #define ICON "text.png"
9
10 #ifndef PROTO
11 # ifndef UI
12 #  include "main.h"
13
14 #undef OBNUM
15 #define OBNUM 4
16
17 /* standard var */
18 static int done = 0;
19
20 /* private data */
21 static Evas_Object *o_texts[OBNUM];
22
23 //uncomment to test vs plain textblock render perf
24 //#define PROXY_CMP 1
25
26 /* setup */
27 static void _setup(void)
28 {
29    int i;
30    Evas_Object *o, *clip, *proxy;
31
32    for (i = 0; i < OBNUM; i++)
33      {
34 #if 0
35         o = efl_add(EFL_CANVAS_TEXTBLOCK_CLASS, evas);
36         o_texts[i] = o;
37 #else
38         o = evas_object_textblock_add(evas);
39         o_texts[i] = o;
40 #endif
41
42 #if 0
43         efl_text_font_family_set(o, "Vera-Bold");
44         efl_text_font_size_set(o, 12);
45 #endif
46         efl_text_wrap_set(o, EFL_TEXT_FORMAT_WRAP_WORD);
47         efl_text_multiline_set(o, 1);
48 #if 0
49         efl_text_set(o,
50           "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
51           "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
52           "enim ad minim veniam, quis nostrud exercitation ullamco laboris "
53           "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
54           "reprehenderit in voluptate velit esse cillum dolore eu fugiat "
55           "nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in "
56           "culpa qui officia deserunt mollit anim id est laborum."
57         );
58         efl_text_color_set(o, 0, 0, 0, 255);
59 #else
60         Evas_Textblock_Style *style = evas_textblock_style_new();
61         evas_textblock_style_set(style, "DEFAULT='font_size=12 font=Vera-Bold color=#000'");
62         evas_object_textblock_style_set(o, style);
63         evas_object_textblock_text_markup_set(o,
64           "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
65           "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
66           "enim ad minim veniam, quis nostrud exercitation ullamco laboris "
67           "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
68           "reprehenderit in voluptate velit esse cillum dolore eu fugiat "
69           "nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in "
70           "culpa qui officia deserunt mollit anim id est laborum."
71         );
72         evas_textblock_style_free(style);
73         evas_object_color_set(o, 0, 0, 0, 255);
74 #endif
75         efl_gfx_entity_size_set(o, EINA_SIZE2D(480, 160));
76         efl_gfx_entity_visible_set(o, EINA_TRUE);
77
78         i++;
79         clip = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
80         o_texts[i] = clip;
81         efl_canvas_object_clipper_set(o, clip);
82 #ifdef PROXY_CMP
83         efl_gfx_entity_size_set(clip, EINA_SIZE2D(480, 160));
84 #else
85         efl_gfx_entity_size_set(clip, EINA_SIZE2D(480, 80));
86 #endif
87         efl_gfx_entity_visible_set(clip, EINA_TRUE);
88         efl_canvas_object_has_fixed_size_set(o, 1);
89
90         i++;
91         proxy = efl_add(EFL_CANVAS_PROXY_CLASS, evas);
92         o_texts[i] = proxy;
93         efl_canvas_proxy_source_set(proxy, o);
94         efl_canvas_proxy_source_clip_set(proxy, EINA_FALSE);
95         /* only draw the lower half of the proxy object */
96         efl_gfx_fill_set(proxy, EINA_RECT(0, 80, 480, 80));
97         efl_gfx_entity_size_set(proxy, EINA_SIZE2D(480, 160));
98 #ifdef PROXY_CMP
99         efl_gfx_entity_visible_set(proxy, EINA_FALSE);
100 #else
101         efl_gfx_entity_visible_set(proxy, EINA_TRUE);
102 #endif
103
104         i++;
105         /* restrict the sampling of the source text to the lower half */
106         clip = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
107         o_texts[i] = clip;
108         efl_canvas_object_clipper_set(proxy, clip);
109         efl_gfx_entity_size_set(clip, EINA_SIZE2D(480, 80));
110 #ifdef PROXY_CMP
111         efl_gfx_entity_visible_set(clip, EINA_FALSE);
112 #else
113         efl_gfx_entity_visible_set(clip, EINA_TRUE);
114         efl_canvas_object_has_fixed_size_set(proxy, 1);
115 #endif
116      }
117    done = 0;
118 }
119
120 /* cleanup */
121 static void _cleanup(void)
122 {
123    int i;
124    for (i = 0; i < OBNUM; i++) efl_del(o_texts[i]);
125 }
126
127 /* loop - do things */
128 static void _loop(double t, int f)
129 {
130    static int k = 0;
131    int i;
132    Evas_Coord x, y, w, h;
133    for (i = 0; i < OBNUM; i++)
134      {
135         w = 480;
136         h = 160;
137         x = (win_w / 2) - (w / 2);
138         x += sin((double)(f + ((i + k) * 13)) / (36.7 * SLOW)) * (w / 2);
139         y = (win_h / 2) - (h / 2);
140         y += cos((double)(f + ((i + k) * 28)) / (43.8 * SLOW)) * (h / 2);
141         efl_gfx_entity_position_set(o_texts[i], EINA_POSITION2D(x, y));
142         i++;
143         efl_gfx_entity_position_set(o_texts[i], EINA_POSITION2D(x, y));
144         i++;
145         efl_gfx_entity_position_set(o_texts[i], EINA_POSITION2D(x, y));
146         i++;
147         efl_gfx_entity_position_set(o_texts[i], EINA_POSITION2D(x, y + (h / 2)));
148      }
149    ++k;
150    FPS_STD(NAME);
151 }
152
153 /* prepend special key handlers if interactive (before STD) */
154 static void _key(const char *key)
155 {
156    KEY_STD;
157 }
158
159
160
161
162
163
164
165
166
167
168
169
170 /* template stuff - ignore */
171 # endif
172 #endif
173
174 #ifdef UI
175 _ui_menu_item_add(ICON, NAME, FNAME);
176 #endif
177
178 #ifdef PROTO
179 void FNAME(void);
180 #endif
181
182 #ifndef PROTO
183 # ifndef UI
184 void FNAME(void)
185 {
186    _setup();
187    ui_func_set(_key, _loop);
188 }
189 # endif
190 #endif
191 #undef FNAME
192 #undef NAME
193 #undef ICON