9 static double wfps = 0.0;
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;
17 Eina_List *menu = NULL;
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;
34 static double p_fps = 0.0;
36 static void (*key_func) (const char *key) = NULL;
37 static void (*loop_func) (double t, int f) = NULL;
153 1.000, // test 92 (line)
154 10.000, // test 93 Image Blend Many Smooth Down Scaled
173 20.000, // test 106 MASK 15
191 0.0, // no final test - add a 0 at the end anyway to pad
204 EINA_LIST_FREE(menu, mi)
210 ecore_main_loop_quit();
213 extern const char *profile;
214 extern int win_w, win_h;
217 static int test_item = -1;
220 _ui_menu_show(Eina_Bool visibility)
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);
238 void (*func) (void) = NULL;
240 _ui_menu_show(EINA_FALSE);
241 for (i = 0, l = menu; l; l = l->next, i++)
246 efl_gfx_entity_visible_set(mi->o_icon, EINA_FALSE);
250 efl_gfx_entity_visible_set(o_title, EINA_FALSE);
251 efl_gfx_entity_visible_set(o_byline, EINA_FALSE);
258 _ui_key(void *data EINA_UNUSED, const Efl_Event *event)
260 Efl_Input_Key *ev = event->info;
261 const char *keyname = efl_input_key_name_get(ev);
263 if (!keyname) return;
271 if ((!strcmp(keyname, "Escape")) ||
272 (!strcmp(keyname, "q")) ||
273 (!strcmp(keyname, "Q")))
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();
296 static Eina_Position2D down;
297 static int down_menu_sel = 0;
299 //FIXME: efl_input_pointer_button_get() doesn't work!
300 static Eina_Bool mdown = EINA_FALSE;
303 _ui_mouse_down(void *data EINA_UNUSED, const Efl_Event *event)
305 Efl_Input_Pointer *ev = event->info;
307 if (efl_input_pointer_button_get(ev) != 1) return;
310 down = efl_input_pointer_position_get(ev);
311 down_menu_sel = menu_sel;
317 _ui_mouse_up(void *data EINA_UNUSED, const Efl_Event *event)
319 Efl_Input_Pointer *ev = event->info;
321 if (efl_input_pointer_button_get(ev) != 1) return;
324 Evas_Coord dx, dy, x, y;
326 exp_input_pointer_pos_get(ev, &x, &y);
329 if ((((dx * dx) + (dy * dy)) < (20 * 20)) &&
330 (menu_sel == down_menu_sel))
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);
342 _ui_mouse_move(void *data EINA_UNUSED, const Efl_Event *event)
344 Efl_Input_Pointer *ev = event->info;
346 /* FIXME: This mdown should be replace with the original call
347 if (efl_input_pointer_button_get(ev) != 1) return; */
354 exp_input_pointer_pos_get(ev, &x, NULL);
355 menu_sel = down_menu_sel + ((x - down.x) / 25);
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;
365 _ui_menu_item_full_add(Eina_Bool test,
366 char *icon, char *text,
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));
377 mi->icon = strdup(icon);
378 mi->text = strdup(text);
380 menu = eina_list_append(menu, mi);
381 efl_gfx_stack_raise_to_top(o_menu_icon_sel2);
384 #define _ui_menu_item_add(Icon, Text, Func) _ui_menu_item_full_add(EINA_TRUE, Icon, Text, Func)
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 });
393 ui_setup(unsigned int ui_w, unsigned int ui_h)
396 Evas_Coord x, y, w, h;
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);
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);
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);
429 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
430 efl_gfx_entity_visible_set(o, EINA_TRUE);
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);
443 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
444 efl_gfx_entity_visible_set(o, EINA_TRUE);
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);
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);
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));
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);
479 o = evas_object_text_add(evas);
480 efl_text_font_family_set(o, "Vera");
481 efl_text_font_size_set(o, 10);
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);
488 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
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);
496 _ui_menu_item_full_add(EINA_FALSE, "exit.png", "Exit", _ui_exit);
499 /* make sure disk io isn't going to turn up unexpectedly */
505 printf("\n#####Test Start#####\n"
507 "window size: %i, %i\n"
523 mi = eina_list_nth(menu, n);
529 if (one_test) test_item = menu_sel;
535 ui_loop(void *data EINA_UNUSED)
537 static int first = 1;
538 static double pt = 0.0;
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));
549 if ((t - t_loop) >= 1.0)
551 // ui_fps((double)f_loop / (t - t_loop));
555 loop_func(t - t_start, f_start);
578 static double tr = 0.0;
585 menu_anim = (menu_anim * 0.995) + (menu_anim_sel * 0.005);
589 EINA_LIST_FOREACH(menu, l, mi)
591 Evas_Coord x, y, w, h, tw, th;
597 exp_size_get(o_menu_logo, &w, &h);
598 len = ((w * 3) + 10) / 4;
599 exp_size_get(o, &w, &h);
601 + (sin((menu_anim - (double)i) * 0.33) * len)
604 + (cos((menu_anim - (double)i) * 0.33) * len)
606 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
607 a = menu_anim - (double)i;
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);
617 a = menu_anim - (double)i;
621 if (a > 255) a = 255;
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);
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));
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);
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);
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);
665 efl_gfx_entity_visible_set(o_title, EINA_TRUE);
666 efl_gfx_entity_visible_set(o_byline, EINA_TRUE);
668 (o_byline, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
673 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
677 ui_func_set(void (*kfunc) (const char *key), void (*lfunc) (double t, int f))
681 t_loop = t_start = get_time();
682 f_loop = f_start = 0;
687 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
688 ecore_animator_custom_tick();
700 _ui_menu_show(EINA_FALSE);
702 /* warm up the cpu with some spinning */
707 if (t - t0 > 2) break;
712 EINA_LIST_FOREACH(menu, l, mi)
720 test_item = menu_sel;
730 if (fps > 0.0 && test_item > 0)
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). */
741 wfps += (fps * weights[test_item]);
744 mi = eina_list_nth(menu, test_item);
745 if (one_test || !mi->test)
752 unsigned int t_count;
754 t_count = EINA_C_ARRAY_LENGTH(weights) - 3;
755 for (i = 2; i < EINA_C_ARRAY_LENGTH(weights) - 1; i++)
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");
765 printf("%5.2f , EVAS SPEED (WEIGHTED), "
768 "ev , %i.%i.%i.%i , "
774 wfps / (t_count * avgw),
781 evas_version->revision,
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"
793 "evas version: %i.%i.%i.%i\n"
795 "window size: %i, %i\n"
800 (wfps / avgw) / t_count,
803 evas_version->major, evas_version->minor, evas_version->micro,
804 evas_version->revision,
811 ecore_main_loop_quit();
815 menu_sel = test_item;