fix broken menu selection.
[platform/upstream/expedite.git] / src / bin / ui.c
1 #include "main.h"
2
3 #include <Eo.h>
4
5 #define PROTO
6 #include "tests.h"
7 #undef PROTO
8
9 static double wfps = 0.0;
10
11 static double t_start = 0.0;
12 static double t_loop = 0.0;
13 static int    f_start = 0;
14 static int    f_loop = 0;
15
16 int async_render = 0;
17 Eina_List *menu = NULL;
18
19 static Evas_Object *o_bg = NULL;
20 static Evas_Object *o_wallpaper = NULL;
21 static Evas_Object *o_title = NULL;
22 static Evas_Object *o_byline = NULL;
23 static Evas_Object *o_menu_logo = NULL;
24 static Evas_Object *o_menu_icon = NULL;
25 static Evas_Object *o_menu_icon_sel = NULL;
26 static Evas_Object *o_menu_icon_sel2 = NULL;
27 static Evas_Object *o_menu_text_sel = NULL;
28 static Evas_Object *o_menu_title = NULL;
29 static int          menu_sel = 0;
30 static int          menu_active = 0;
31 static double       menu_anim = 0.0;
32 static double       menu_anim_sel = 0.0;
33
34 static double       p_fps = 0.0;
35
36 static void (*key_func) (const char *key) = NULL;
37 static void (*loop_func) (double t, int f) = NULL;
38
39 double weights[] =
40 {
41    0.0, // no test 0
42    0.0, // all tests 0
43
44    50.4851, // test 1
45    97.3703, // test 2
46    10.0000, // test 3
47    87.3703, // ...
48    10.0000,
49
50    150.0000, // test 6
51    10.0000,
52    150.0000,
53    10.0000,
54    150.0000,
55
56    10.0000, // test 11
57    150.0000,
58    10.0000,
59    10.6493,
60    38.4818,
61
62    40.7314, // test 16
63    32.0866,
64    21.3337,
65    21.2167,
66    71.6141,
67
68    64.8893, // test 21
69    95.0880,
70    121.0438,
71    41.2646,
72    162.7149,
73
74    89.1650, // test 26
75    105.3571,
76    40.9657,
77    98.4671,
78    28.4322,
79
80    60.000, // test 31
81    75.5507,
82    51.6601,
83    135.4753,
84    38.2705,
85
86    35.9915, // test 36
87    31.9500,
88    22.6752,
89    38.2702,
90    37.4459,
91
92    37.2009, // test 41
93    34.5459,
94    38.5043,
95    50.0000,
96    37.0282,
97
98    55.8886, // test 46
99    17.2535,
100    23.1457,
101    36.9874,
102    37.9336,
103
104    17.1830, // test 51
105    20.7521,
106    29.0141,
107    131.6784,
108    13.6851,
109
110    23.4462, // test 56
111    14.7573,
112    36.5261,
113    5.0000,
114    5.0000,
115
116    24.3482, // test 61
117    10.4611,
118    86.0290,
119    82.0735,
120    18.6459,
121
122    37.4608, // test 66
123    32.4417,
124    11.5449,
125    5.0000,
126    11.4172,
127
128    13.3682, // test 71
129    10.0324,
130    10.0584,
131    10.0170,
132    5.4029,
133
134    10.6349, // test 76
135    21.7728,
136    12.7933,
137    19.4177,
138    34.4192,
139
140    23.9110, // test 81
141    22.8287,
142    41.2399,
143    30.1383,
144    22.0342,
145
146    38.2952, // test 86
147    5.5560,
148    0.5000,
149    1.000,
150    10.000,
151
152    5.000, // test 91
153    1.000, // test 92 (line)
154    10.000, // test 93 Image Blend Many Smooth Down Scaled
155
156    20.000, // MASK
157    20.000, // MASK 2
158    20.000, // MASK 3
159    20.000, // MASK 4
160
161    20.000, // test 96
162    20.000, // MASK 6
163    20.000, // MASK 7
164    20.000, // MASK 8
165    20.000, // MASK 9
166
167    20.000, // test 101
168    20.000, // MASK 11
169    20.000, // MASK 12
170    20.000, // MASK 13
171    20.000, // MASK 14
172
173    20.000, // test 106 MASK 15
174    1.000,
175    2.000,
176    1.000,
177    2.000,
178
179    1.000, // test 111
180    2.000,
181    1.000,
182    2.000,
183    1.000,
184
185    2.000,   // test 116
186    10.000,
187    10.000,
188
189    0.0, // Exit
190
191    0.0, // no final test - add a 0 at the end anyway to pad
192    0.0,
193    0.0,
194    0.0,
195    0.0,
196    0.0
197 };
198
199 static void
200 _ui_exit(void)
201 {
202    Menu_Item *mi;
203
204    EINA_LIST_FREE(menu, mi)
205      {
206         free(mi->icon);
207         free(mi->text);
208         free(mi);
209      }
210    ecore_main_loop_quit();
211 }
212
213 extern const char *profile;
214 extern int win_w, win_h;
215 extern int loops;
216
217 static int test_item = -1;
218
219 static void
220 _ui_menu_show(Eina_Bool visibility)
221 {
222    efl_gfx_entity_visible_set(o_menu_logo, visibility);
223    efl_gfx_entity_visible_set(o_menu_title, visibility);
224    efl_gfx_entity_visible_set(o_menu_icon, visibility);
225    efl_gfx_entity_visible_set(o_menu_icon_sel, visibility);
226    /* FIXME: ask if it's ok o_menu_icon_sel2 == NULL */
227    efl_gfx_entity_visible_set(o_menu_icon_sel2, visibility);
228    efl_gfx_entity_visible_set(o_menu_text_sel, visibility);
229    efl_gfx_entity_visible_set(o_title, visibility);
230    efl_gfx_entity_visible_set(o_byline, visibility);
231 }
232
233 static void
234 _ui_select(void)
235 {
236    Eina_List *l;
237    int i;
238    void (*func) (void) = NULL;
239
240    _ui_menu_show(EINA_FALSE);
241    for (i = 0, l = menu; l; l = l->next, i++)
242      {
243         Menu_Item *mi;
244
245         mi = l->data;
246         efl_gfx_entity_visible_set(mi->o_icon, EINA_FALSE);
247         if (i == menu_sel)
248           func = mi->func;
249      }
250    efl_gfx_entity_visible_set(o_title, EINA_FALSE);
251    efl_gfx_entity_visible_set(o_byline, EINA_FALSE);
252
253    menu_active = 0;
254    if (func) func();
255 }
256
257 static void
258 _ui_key(void *data EINA_UNUSED, const Efl_Event *event)
259 {
260    Efl_Input_Key *ev = event->info;
261    const char *keyname = efl_input_key_name_get(ev);
262
263    if (!keyname) return;
264
265    if (key_func)
266      {
267         key_func(keyname);
268         return;
269      }
270
271    if ((!strcmp(keyname, "Escape")) ||
272        (!strcmp(keyname, "q")) ||
273        (!strcmp(keyname, "Q")))
274      {
275         _ui_exit();
276         return;
277      }
278
279    if (menu_active)
280      {
281         if (!strcmp(keyname, "Left")) menu_sel++;
282         else if (!strcmp(keyname, "Right")) menu_sel--;
283         else if (!strcmp(keyname, "Up")) menu_sel++;
284         else if (!strcmp(keyname, "Down")) menu_sel--;
285         else if (!strcmp(keyname, "Home")) menu_sel = eina_list_count(menu) - 1;
286         else if (!strcmp(keyname, "End")) menu_sel = 0;
287         else if (!strcmp(keyname, "Next")) menu_sel -= 10;
288         else if (!strcmp(keyname, "Prior")) menu_sel += 10;
289         if (menu_sel < 0) menu_sel = 0;
290         else if ((unsigned int)menu_sel >= eina_list_count(menu)) menu_sel = eina_list_count(menu) - 1;
291         menu_anim_sel = menu_sel;
292         if (!strcmp(keyname, "Return")) _ui_select();
293      }
294 }
295
296 static Eina_Position2D down;
297 static int down_menu_sel = 0;
298
299 //FIXME: efl_input_pointer_button_get() doesn't work!
300 static Eina_Bool mdown = EINA_FALSE;
301
302 static void
303 _ui_mouse_down(void *data EINA_UNUSED, const Efl_Event *event)
304 {
305    Efl_Input_Pointer *ev = event->info;
306
307    if (efl_input_pointer_button_get(ev) != 1) return;
308    if (menu_active)
309      {
310         down = efl_input_pointer_position_get(ev);
311         down_menu_sel = menu_sel;
312         mdown = EINA_TRUE;
313      }
314 }
315
316 static void
317 _ui_mouse_up(void *data EINA_UNUSED, const Efl_Event *event)
318 {
319    Efl_Input_Pointer *ev = event->info;
320
321    if (efl_input_pointer_button_get(ev) != 1) return;
322    if (menu_active)
323      {
324         Evas_Coord dx, dy, x, y;
325
326         exp_input_pointer_pos_get(ev, &x, &y);
327         dx = x - down.x;
328         dy = y - down.y;
329         if ((((dx * dx) + (dy * dy)) < (20 * 20)) &&
330             (menu_sel == down_menu_sel))
331           _ui_select();
332         mdown = EINA_FALSE;
333      }
334    else
335      {
336         evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
337         evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
338      }
339 }
340
341 static void
342 _ui_mouse_move(void *data EINA_UNUSED, const Efl_Event *event)
343 {
344    Efl_Input_Pointer *ev = event->info;
345
346    /* FIXME: This mdown should be replace with the original call
347       if (efl_input_pointer_button_get(ev) != 1) return; */
348    if (!mdown) return;
349
350    if (menu_active)
351      {
352         Evas_Coord x;
353
354         exp_input_pointer_pos_get(ev, &x, NULL);
355         menu_sel = down_menu_sel + ((x - down.x) / 25);
356         /* scroll */
357         if (menu_sel < 0) menu_sel = 0;
358         else if ((unsigned int)menu_sel >= eina_list_count(menu))
359           menu_sel = eina_list_count(menu) - 1;
360         menu_anim_sel = menu_sel;
361      }
362 }
363
364 static void
365 _ui_menu_item_full_add(Eina_Bool test,
366                        char *icon, char *text,
367                        void (*func) (void))
368 {
369    Menu_Item *mi;
370
371    mi = malloc(sizeof(Menu_Item));
372    mi->o_icon = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
373    efl_file_simple_load(mi->o_icon, build_path(icon), NULL);
374    efl_gfx_entity_size_set(mi->o_icon, EINA_SIZE2D(32, 32));
375    efl_gfx_fill_set(mi->o_icon, EINA_RECT(0, 0, 32, 32));
376    mi->test = test;
377    mi->icon = strdup(icon);
378    mi->text = strdup(text);
379    mi->func = func;
380    menu = eina_list_append(menu, mi);
381    efl_gfx_stack_raise_to_top(o_menu_icon_sel2);
382 }
383
384 #define _ui_menu_item_add(Icon, Text, Func) _ui_menu_item_full_add(EINA_TRUE, Icon, Text, Func)
385
386 EFL_CALLBACKS_ARRAY_DEFINE(ui_callbacks,
387                            { EFL_EVENT_KEY_DOWN, _ui_key },
388                            { EFL_EVENT_POINTER_DOWN, _ui_mouse_down },
389                            { EFL_EVENT_POINTER_UP, _ui_mouse_up },
390                            { EFL_EVENT_POINTER_MOVE, _ui_mouse_move });
391
392 void
393 ui_setup(unsigned int ui_w, unsigned int ui_h)
394 {
395    Evas_Object *o;
396    Evas_Coord x, y, w, h;
397
398    win_w = ui_w;
399    win_h = ui_h;
400
401    o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
402    efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
403    efl_gfx_entity_size_set(o, EINA_SIZE2D(win_w, win_h));
404    efl_gfx_color_set(o, 0, 0, 0, 0);
405    efl_gfx_stack_layer_set(o, 1000);
406    evas_object_focus_set(o, 1);
407    efl_gfx_entity_visible_set(o, EINA_TRUE);
408    efl_event_callback_array_add(o, ui_callbacks(), NULL);
409    o_bg = o;
410
411    o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
412    efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
413    efl_gfx_entity_size_set(o, EINA_SIZE2D(win_w, win_h));
414    efl_gfx_color_set(o, 255, 255, 255, 255);
415    efl_gfx_stack_layer_set(o, -99);
416    efl_gfx_entity_visible_set(o, EINA_TRUE);
417    o_wallpaper = o;
418
419    o = evas_object_text_add(evas);
420    efl_text_font_family_set(o, "Vera-Bold");
421    efl_text_font_size_set(o, 10);
422    efl_text_set(o, "EXPEDITE");
423    efl_gfx_stack_layer_set(o, 100);
424    efl_gfx_color_set(o, 0, 0, 0, 100);
425    evas_object_pass_events_set(o, 1);
426    exp_size_get(o, &w, &h);
427    x = (win_w - w) / 2;
428    y = 0;
429    efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
430    efl_gfx_entity_visible_set(o, EINA_TRUE);
431    o_title = o;
432
433    o = evas_object_text_add(evas);
434    efl_text_font_family_set(o, "Vera");
435    efl_text_font_size_set(o, 9);
436    efl_text_set(o, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
437    efl_gfx_stack_layer_set(o, 100);
438    efl_gfx_color_set(o, 0, 0, 0, 60);
439    evas_object_pass_events_set(o, 1);
440    exp_size_get(o, &w, NULL);
441    x = (win_w - w) / 2;
442    y = h + 2;
443    efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
444    efl_gfx_entity_visible_set(o, EINA_TRUE);
445    o_byline = o;
446
447    o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
448    efl_gfx_entity_position_set(o, EINA_POSITION2D((win_w - 120) / 2, ((win_h - 160) / 2)));
449    efl_file_simple_load(o, build_path("e-logo.png"), NULL);
450    efl_gfx_fill_set(o, EINA_RECT(0, 0, 120, 160));
451    efl_gfx_entity_size_set(o, EINA_SIZE2D(120, 160));
452    efl_gfx_stack_layer_set(o, -98);
453    efl_gfx_color_set(o, 255, 255, 255, 255);
454    efl_gfx_entity_visible_set(o, EINA_TRUE);
455    o_menu_logo = o;
456
457    o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
458    efl_gfx_entity_position_set(o, EINA_POSITION2D(win_w - 128, - 128));
459    efl_gfx_fill_set(o, EINA_RECT(0, 0, 256, 256));
460    efl_gfx_entity_size_set(o, EINA_SIZE2D(256, 256));
461    efl_gfx_entity_visible_set(o, EINA_TRUE);
462    o_menu_icon = o;
463
464    o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
465    efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
466    efl_file_simple_load(o, build_path("icon_sel.png"), NULL);
467    efl_gfx_entity_size_set(o, EINA_SIZE2D(48, 48));
468    efl_gfx_fill_set(o, EINA_RECT(0, 0, 48, 48));
469    o_menu_icon_sel = o;
470
471    o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
472    efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
473    efl_file_simple_load(o, build_path("text_sel.png"), NULL);
474    efl_gfx_entity_size_set(o, EINA_SIZE2D(96, 32));
475    efl_gfx_fill_set(o, EINA_RECT(0, 0, 96, 32));
476    efl_gfx_image_border_insets_set(o, 7, 7, 7, 7);
477    o_menu_text_sel = o;
478
479    o = evas_object_text_add(evas);
480    efl_text_font_family_set(o, "Vera");
481    efl_text_font_size_set(o, 10);
482    efl_text_set(o, "");
483    efl_gfx_color_set(o, 0, 0, 0, 100);
484    evas_object_pass_events_set(o, 1);
485    exp_size_get(o, &w, &h);
486    x = (win_w - w) / 2;
487    y = (win_h - h) / 2;
488    efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
489    o_menu_title = o;
490
491    _ui_menu_item_full_add(EINA_FALSE, "e.png", "About", about_start);
492    _ui_menu_item_full_add(EINA_FALSE, "e.png", "All Tests", ui_all);
493 #define UI
494 #include "tests.h"
495 #undef UI
496    _ui_menu_item_full_add(EINA_FALSE, "exit.png", "Exit", _ui_exit);
497
498 #ifdef HAVE_SYNC
499    /* make sure disk io isn't going to turn up unexpectedly */
500    sync();
501    sync();
502    sync();
503 #endif
504    
505    printf("\n#####Test Start#####\n"
506           "profile: %s\n"
507           "window size: %i, %i\n"
508           "loop count: %i\n"
509           "engine: %s\n",
510           profile,
511           win_w, win_h,
512           loops,
513           choosen_engine);
514
515    menu_active = 1;
516 }
517
518 void
519 ui_num(int n)
520 {
521    Menu_Item *mi;
522
523    mi = eina_list_nth(menu, n);
524    if (mi)
525      {
526         if (!mi->test)
527           return;
528         menu_sel = n;
529         if (one_test) test_item = menu_sel;
530         _ui_select();
531      }
532 }
533
534 Eina_Bool
535 ui_loop(void *data EINA_UNUSED)
536 {
537    static int first = 1;
538    static double pt = 0.0;
539    double t, t2;
540
541    efl_gfx_entity_size_set(o_bg, EINA_SIZE2D(win_w, win_h));
542    efl_gfx_entity_size_set(o_wallpaper, EINA_SIZE2D(win_w, win_h));
543
544    if (loop_func)
545      {
546         t = get_time();
547         f_loop++;
548         f_start++;
549         if ((t - t_loop) >= 1.0)
550           {
551              //      ui_fps((double)f_loop / (t - t_loop));
552              t_loop = t;
553              f_loop = 0;
554           }
555         loop_func(t - t_start, f_start);
556         return EINA_TRUE;
557      }
558
559    t2 = get_time();
560    if (first)
561      {
562         t = 0.1;
563         pt = t2;
564      }
565    else
566      {
567         t = t2 - pt;
568         pt = t2;
569      }
570    first = 0;
571
572    /* menu layout */
573    if (menu_active)
574      {
575         Eina_List *l;
576         Menu_Item *mi;
577         int i = 0;
578         static double tr = 0.0;
579         double tt;
580
581         tt = t;
582         tt += tr;
583         while (tt > 0.001)
584           {
585              menu_anim = (menu_anim * 0.995) + (menu_anim_sel * 0.005);
586              tt -= 0.001;
587           }
588         tr = tt;
589         EINA_LIST_FOREACH(menu, l, mi)
590           {
591              Evas_Coord x, y, w, h, tw, th;
592              Evas_Coord len;
593              double a;
594              Evas_Object *o;
595
596              o = mi->o_icon;
597              exp_size_get(o_menu_logo, &w, &h);
598              len = ((w * 3) + 10) / 4;
599              exp_size_get(o, &w, &h);
600              x = (win_w / 2)
601                 + (sin((menu_anim - (double)i) * 0.33) * len)
602                 - (w / 2);
603              y = (win_h / 2)
604                 + (cos((menu_anim - (double)i) * 0.33) * len)
605                 - (h / 2);
606              efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
607              a = menu_anim - (double)i;
608              if (a < 0) a = -a;
609              a = 255 - (30 * a);
610              if (a < 0) a = 0;
611              if (a > 255) a = 255;
612              efl_gfx_color_set(o, a, a, a, a);
613              efl_gfx_entity_visible_set(o, EINA_TRUE);
614
615              if (i == menu_sel)
616                {
617                   a = menu_anim - (double)i;
618                   if (a < 0) a = -a;
619                   a = 255 - (255 * a);
620                   if (a < 0) a = 0;
621                   if (a > 255) a = 255;
622
623                   o = o_menu_icon_sel;
624                   efl_gfx_entity_position_set(o, EINA_POSITION2D(x - ((48 - w) / 2), y - ((48 - h) / 2)));
625                   efl_gfx_color_set(o, a, a, a, a);
626
627                   o = o_menu_title;
628                   efl_gfx_color_set(o, a, a, a, a);
629                   efl_text_set(o, mi->text);
630                   exp_size_get(o, &tw, &th);
631                   x = (win_w - tw) / 2;
632                   y = (win_h / 2) + len + 48;
633                   efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
634
635                   o = o_menu_text_sel;
636                   w = tw + 24;
637                   h = 28;
638                   x = x - 12;
639                   y = y + ((th - h) / 2);
640                   efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
641                   efl_gfx_entity_size_set(o, EINA_SIZE2D(w, h));
642                   efl_gfx_fill_set(o, EINA_RECT(0, 0, w, h));
643                   efl_gfx_color_set(o, a, a, a, a);
644
645                   o = o_menu_icon;
646                   efl_file_simple_load(o, build_path(mi->icon), NULL);
647                   efl_gfx_color_set(o, a / 2, a / 2, a / 2, a / 2);
648                }
649              i++;
650           }
651         efl_gfx_entity_position_set(o_menu_logo, EINA_POSITION2D((win_w - 120) / 2, ((win_h - 160) / 2)));
652         efl_gfx_entity_visible_set(o_menu_logo, EINA_TRUE);
653         _ui_menu_show(EINA_TRUE);
654      }
655    else
656      {
657      }
658
659    return EINA_TRUE;
660 }
661
662 void
663 ui_menu(void)
664 {
665    efl_gfx_entity_visible_set(o_title, EINA_TRUE);
666    efl_gfx_entity_visible_set(o_byline, EINA_TRUE);
667    efl_text_set
668          (o_byline, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
669    menu_active = 1;
670    key_func = NULL;
671    loop_func = NULL;
672
673    ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
674 }
675
676 void
677 ui_func_set(void (*kfunc) (const char *key), void (*lfunc) (double t, int f))
678 {
679    key_func = kfunc;
680    loop_func = lfunc;
681    t_loop = t_start = get_time();
682    f_loop = f_start = 0;
683    ui_fps(0.0);
684
685    if (tick)
686      {
687         ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
688         ecore_animator_custom_tick();
689      }
690 }
691
692 void
693 ui_all(void)
694 {
695    Eina_List *l;
696    Menu_Item *mi;
697    int i = 0;
698    double t, t0;
699
700    _ui_menu_show(EINA_FALSE);
701
702    /* warm up the cpu with some spinning */
703    t0 = time(NULL);
704    for (;;)
705      {
706         t = time(NULL);
707         if (t - t0 > 2) break;
708      }
709
710    wfps = 0;
711
712    EINA_LIST_FOREACH(menu, l, mi)
713      {
714         i++;
715
716         if (!mi->test)
717           continue;
718
719         menu_sel = i - 1;
720         test_item = menu_sel;
721         _ui_select();
722         break;
723      }
724 }
725
726 void
727 ui_fps(double fps)
728 {
729    p_fps += fps;
730    if (fps > 0.0 && test_item > 0)
731      {
732         Menu_Item *mi;
733
734         key_func("Escape");
735
736         /* This does not give time to delete the objects of the previous test
737            and make the result of next test less accurate. Benefit we do not
738            loose track of any of the cost anymore (Would be better to force
739            an empty render and account that to the previous test). */
740
741         wfps += (fps * weights[test_item]);
742
743         test_item++;
744         mi = eina_list_nth(menu, test_item);
745         if (one_test || !mi->test)
746           {
747              char datestr[1024];
748              struct tm *tim;
749              time_t now;
750              double avgw = 0.0;
751              unsigned int i;
752              unsigned int t_count;
753
754              t_count = EINA_C_ARRAY_LENGTH(weights) - 3;
755              for (i = 2; i < EINA_C_ARRAY_LENGTH(weights) - 1; i++)
756                avgw += weights[i];
757              avgw /= t_count;
758
759              now = time(NULL);
760              tim = localtime(&now);
761              if (tim) strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", tim);
762              else snprintf(datestr, sizeof(datestr), "unknown");
763
764              if (cmp_report)
765                printf("%5.2f , EVAS SPEED (WEIGHTED), "
766                       "tn, %i , "
767                       "t, %s , "
768                       "ev , %i.%i.%i.%i , "
769                       "p , %s , "
770                       "sz , %i , %i , "
771                       "c , %i , "
772                       "e , %s , "
773                       "fs , %i\n",
774                       wfps / (t_count * avgw),
775                       // fps / t_count,
776                       t_count,
777                       datestr,
778                       evas_version->major,
779                       evas_version->minor,
780                       evas_version->micro,
781                       evas_version->revision,
782                       profile,
783                       win_w, win_h,
784                       loops,
785                       choosen_engine,
786                       fullscreen);
787              else
788                printf("\n#####Test Result#####\n"
789                       "evas fps speed: %5.2f\n"
790                       "evas fps speed(weighted): %5.2f\n"
791                       "testcase count: %i\n"
792                       "date: %s\n"
793                       "evas version: %i.%i.%i.%i\n"
794                       "profile: %s\n"
795                       "window size: %i, %i\n"
796                       "loop count: %i\n"
797                       "engine: %s\n"
798                       "full screen: %i\n",
799                       (p_fps / t_count),
800                       (wfps / avgw) / t_count,
801                       t_count,
802                       datestr,
803                       evas_version->major, evas_version->minor, evas_version->micro,
804                       evas_version->revision,
805                       profile,
806                       win_w, win_h,
807                       loops,
808                       choosen_engine,
809                       fullscreen);
810
811              ecore_main_loop_quit();
812           }
813         else
814           {
815              menu_sel = test_item;
816              _ui_select();
817           }
818      }
819 }