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;
300 _ui_mouse_down(void *data EINA_UNUSED, const Efl_Event *event)
302 Efl_Input_Pointer *ev = event->info;
304 if (efl_input_pointer_button_get(ev) != 1) return;
307 down = efl_input_pointer_position_get(ev);
308 down_menu_sel = menu_sel;
313 _ui_mouse_up(void *data EINA_UNUSED, const Efl_Event *event)
315 Efl_Input_Pointer *ev = event->info;
317 if (efl_input_pointer_button_get(ev) != 1) return;
320 Evas_Coord dx, dy, x, y;
322 exp_input_pointer_pos_get(ev, &x, &y);
325 if ((((dx * dx) + (dy * dy)) < (20 * 20)) &&
326 (menu_sel == down_menu_sel))
331 evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
332 evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
337 _ui_mouse_move(void *data EINA_UNUSED, const Efl_Event *event)
339 Efl_Input_Pointer *ev = event->info;
341 if (efl_input_pointer_button_get(ev) != 1) return;
346 exp_input_pointer_pos_get(ev, &x, NULL);
347 menu_sel = down_menu_sel + ((x - down.x) / 25);
349 if (menu_sel < 0) menu_sel = 0;
350 else if ((unsigned int)menu_sel >= eina_list_count(menu))
351 menu_sel = eina_list_count(menu) - 1;
352 menu_anim_sel = menu_sel;
357 _ui_menu_item_full_add(Eina_Bool test,
358 char *icon, char *text,
363 mi = malloc(sizeof(Menu_Item));
364 mi->o_icon = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
365 efl_file_simple_load(mi->o_icon, build_path(icon), NULL);
366 efl_gfx_entity_size_set(mi->o_icon, EINA_SIZE2D(32, 32));
367 efl_gfx_fill_set(mi->o_icon, EINA_RECT(0, 0, 32, 32));
369 mi->icon = strdup(icon);
370 mi->text = strdup(text);
372 menu = eina_list_append(menu, mi);
373 efl_gfx_stack_raise_to_top(o_menu_icon_sel2);
376 #define _ui_menu_item_add(Icon, Text, Func) _ui_menu_item_full_add(EINA_TRUE, Icon, Text, Func)
378 EFL_CALLBACKS_ARRAY_DEFINE(ui_callbacks,
379 { EFL_EVENT_KEY_DOWN, _ui_key },
380 { EFL_EVENT_POINTER_DOWN, _ui_mouse_down },
381 { EFL_EVENT_POINTER_UP, _ui_mouse_up },
382 { EFL_EVENT_POINTER_MOVE, _ui_mouse_move });
385 ui_setup(unsigned int ui_w, unsigned int ui_h)
388 Evas_Coord x, y, w, h;
393 o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
394 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
395 efl_gfx_entity_size_set(o, EINA_SIZE2D(win_w, win_h));
396 efl_gfx_color_set(o, 0, 0, 0, 0);
397 efl_gfx_stack_layer_set(o, 1000);
398 evas_object_focus_set(o, 1);
399 efl_gfx_entity_visible_set(o, EINA_TRUE);
400 efl_event_callback_array_add(o, ui_callbacks(), NULL);
403 o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
404 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
405 efl_gfx_entity_size_set(o, EINA_SIZE2D(win_w, win_h));
406 efl_gfx_color_set(o, 255, 255, 255, 255);
407 efl_gfx_stack_layer_set(o, -99);
408 efl_gfx_entity_visible_set(o, EINA_TRUE);
411 o = evas_object_text_add(evas);
412 efl_text_font_family_set(o, "Vera-Bold");
413 efl_text_font_size_set(o, 10);
414 efl_text_set(o, "EXPEDITE");
415 efl_gfx_stack_layer_set(o, 100);
416 efl_gfx_color_set(o, 0, 0, 0, 100);
417 evas_object_pass_events_set(o, 1);
418 exp_size_get(o, &w, &h);
421 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
422 efl_gfx_entity_visible_set(o, EINA_TRUE);
425 o = evas_object_text_add(evas);
426 efl_text_font_family_set(o, "Vera");
427 efl_text_font_size_set(o, 9);
428 efl_text_set(o, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
429 efl_gfx_stack_layer_set(o, 100);
430 efl_gfx_color_set(o, 0, 0, 0, 60);
431 evas_object_pass_events_set(o, 1);
432 exp_size_get(o, &w, NULL);
435 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
436 efl_gfx_entity_visible_set(o, EINA_TRUE);
439 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
440 efl_gfx_entity_position_set(o, EINA_POSITION2D((win_w - 120) / 2, ((win_h - 160) / 2)));
441 efl_file_simple_load(o, build_path("e-logo.png"), NULL);
442 efl_gfx_fill_set(o, EINA_RECT(0, 0, 120, 160));
443 efl_gfx_entity_size_set(o, EINA_SIZE2D(120, 160));
444 efl_gfx_stack_layer_set(o, -98);
445 efl_gfx_color_set(o, 255, 255, 255, 255);
446 efl_gfx_entity_visible_set(o, EINA_TRUE);
449 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
450 efl_gfx_entity_position_set(o, EINA_POSITION2D(win_w - 128, - 128));
451 efl_gfx_fill_set(o, EINA_RECT(0, 0, 256, 256));
452 efl_gfx_entity_size_set(o, EINA_SIZE2D(256, 256));
453 efl_gfx_entity_visible_set(o, EINA_TRUE);
456 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
457 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
458 efl_file_simple_load(o, build_path("icon_sel.png"), NULL);
459 efl_gfx_entity_size_set(o, EINA_SIZE2D(48, 48));
460 efl_gfx_fill_set(o, EINA_RECT(0, 0, 48, 48));
463 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
464 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
465 efl_file_simple_load(o, build_path("text_sel.png"), NULL);
466 efl_gfx_entity_size_set(o, EINA_SIZE2D(96, 32));
467 efl_gfx_fill_set(o, EINA_RECT(0, 0, 96, 32));
468 efl_gfx_image_border_insets_set(o, 7, 7, 7, 7);
471 o = evas_object_text_add(evas);
472 efl_text_font_family_set(o, "Vera");
473 efl_text_font_size_set(o, 10);
475 efl_gfx_color_set(o, 0, 0, 0, 100);
476 evas_object_pass_events_set(o, 1);
477 exp_size_get(o, &w, &h);
480 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
483 _ui_menu_item_full_add(EINA_FALSE, "e.png", "About", about_start);
484 _ui_menu_item_full_add(EINA_FALSE, "e.png", "All Tests", ui_all);
488 _ui_menu_item_full_add(EINA_FALSE, "exit.png", "Exit", _ui_exit);
491 /* make sure disk io isn't going to turn up unexpectedly */
497 printf("\n#####Test Start#####\n"
499 "window size: %i, %i\n"
515 mi = eina_list_nth(menu, n);
521 if (one_test) test_item = menu_sel;
527 ui_loop(void *data EINA_UNUSED)
529 static int first = 1;
530 static double pt = 0.0;
533 efl_gfx_entity_size_set(o_bg, EINA_SIZE2D(win_w, win_h));
534 efl_gfx_entity_size_set(o_wallpaper, EINA_SIZE2D(win_w, win_h));
541 if ((t - t_loop) >= 1.0)
543 // ui_fps((double)f_loop / (t - t_loop));
547 loop_func(t - t_start, f_start);
570 static double tr = 0.0;
577 menu_anim = (menu_anim * 0.995) + (menu_anim_sel * 0.005);
581 EINA_LIST_FOREACH(menu, l, mi)
583 Evas_Coord x, y, w, h, tw, th;
589 exp_size_get(o_menu_logo, &w, &h);
590 len = ((w * 3) + 10) / 4;
591 exp_size_get(o, &w, &h);
593 + (sin((menu_anim - (double)i) * 0.33) * len)
596 + (cos((menu_anim - (double)i) * 0.33) * len)
598 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
599 a = menu_anim - (double)i;
603 if (a > 255) a = 255;
604 efl_gfx_color_set(o, a, a, a, a);
605 efl_gfx_entity_visible_set(o, EINA_TRUE);
609 a = menu_anim - (double)i;
613 if (a > 255) a = 255;
616 efl_gfx_entity_position_set(o, EINA_POSITION2D(x - ((48 - w) / 2), y - ((48 - h) / 2)));
617 efl_gfx_color_set(o, a, a, a, a);
620 efl_gfx_color_set(o, a, a, a, a);
621 efl_text_set(o, mi->text);
622 exp_size_get(o, &tw, &th);
623 x = (win_w - tw) / 2;
624 y = (win_h / 2) + len + 48;
625 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
631 y = y + ((th - h) / 2);
632 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
633 efl_gfx_entity_size_set(o, EINA_SIZE2D(w, h));
634 efl_gfx_fill_set(o, EINA_RECT(0, 0, w, h));
635 efl_gfx_color_set(o, a, a, a, a);
638 efl_file_simple_load(o, build_path(mi->icon), NULL);
639 efl_gfx_color_set(o, a / 2, a / 2, a / 2, a / 2);
643 efl_gfx_entity_position_set(o_menu_logo, EINA_POSITION2D((win_w - 120) / 2, ((win_h - 160) / 2)));
644 efl_gfx_entity_visible_set(o_menu_logo, EINA_TRUE);
645 _ui_menu_show(EINA_TRUE);
657 efl_gfx_entity_visible_set(o_title, EINA_TRUE);
658 efl_gfx_entity_visible_set(o_byline, EINA_TRUE);
660 (o_byline, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
665 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
669 ui_func_set(void (*kfunc) (const char *key), void (*lfunc) (double t, int f))
673 t_loop = t_start = get_time();
674 f_loop = f_start = 0;
679 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
680 ecore_animator_custom_tick();
692 _ui_menu_show(EINA_FALSE);
694 /* warm up the cpu with some spinning */
699 if (t - t0 > 2) break;
704 EINA_LIST_FOREACH(menu, l, mi)
712 test_item = menu_sel;
722 if (fps > 0.0 && test_item > 0)
728 /* This does not give time to delete the objects of the previous test
729 and make the result of next test less accurate. Benefit we do not
730 loose track of any of the cost anymore (Would be better to force
731 an empty render and account that to the previous test). */
733 wfps += (fps * weights[test_item]);
736 mi = eina_list_nth(menu, test_item);
737 if (one_test || !mi->test)
744 unsigned int t_count;
746 t_count = EINA_C_ARRAY_LENGTH(weights) - 3;
747 for (i = 2; i < EINA_C_ARRAY_LENGTH(weights) - 1; i++)
752 tim = localtime(&now);
753 if (tim) strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", tim);
754 else snprintf(datestr, sizeof(datestr), "unknown");
757 printf("%5.2f , EVAS SPEED (WEIGHTED), "
760 "ev , %i.%i.%i.%i , "
766 wfps / (t_count * avgw),
773 evas_version->revision,
780 printf("\n#####Test Result#####\n"
781 "evas fps speed: %5.2f\n"
782 "evas fps speed(weighted): %5.2f\n"
783 "testcase count: %i\n"
785 "evas version: %i.%i.%i.%i\n"
787 "window size: %i, %i\n"
792 (wfps / avgw) / t_count,
795 evas_version->major, evas_version->minor, evas_version->micro,
796 evas_version->revision,
803 ecore_main_loop_quit();
807 menu_sel = test_item;