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;
15 static char data_dir[4096];
18 Eina_List *menu = NULL;
20 static Evas_Object *o_bg = NULL;
21 static Evas_Object *o_wallpaper = NULL;
22 static Evas_Object *o_title = NULL;
23 static Evas_Object *o_byline = NULL;
24 static Evas_Object *o_menu_logo = NULL;
25 static Evas_Object *o_menu_icon = NULL;
26 static Evas_Object *o_menu_icon_sel = NULL;
27 static Evas_Object *o_menu_icon_sel2 = NULL;
28 static Evas_Object *o_menu_text_sel = NULL;
29 static Evas_Object *o_menu_title = NULL;
30 static int menu_sel = 0;
31 static int menu_active = 0;
32 static double menu_anim = 0.0;
33 static double menu_anim_sel = 0.0;
35 static double p_fps = 0.0;
37 static void (*key_func) (char *key) = NULL;
38 static void (*loop_func) (double t, int f) = NULL;
154 1.000, // test 92 (line)
155 10.000, // test 93 Image Blend Many Smooth Down Scaled
174 20.000, // test 106 MASK 15
192 0.0, // no final test - add a 0 at the end anyway to pad
205 EINA_LIST_FREE(menu, mi)
211 ecore_main_loop_quit();
214 extern const char *profile;
215 extern int win_w, win_h;
218 static int test_item = -1;
221 _ui_menu_show(Eina_Bool visibility)
223 eo_do(o_menu_logo, efl_gfx_visible_set(visibility));
224 eo_do(o_menu_title, efl_gfx_visible_set(visibility));
225 eo_do(o_menu_icon, efl_gfx_visible_set(visibility));
226 eo_do(o_menu_icon_sel, efl_gfx_visible_set(visibility));
227 /* FIXME: ask if it's ok o_menu_icon_sel2 == NULL */
228 eo_do(o_menu_icon_sel2, efl_gfx_visible_set(visibility));
229 eo_do(o_menu_text_sel, efl_gfx_visible_set(visibility));
230 eo_do(o_title, efl_gfx_visible_set(visibility));
231 eo_do(o_byline, efl_gfx_visible_set(visibility));
239 void (*func) (void) = NULL;
241 _ui_menu_show(EINA_FALSE);
242 for (i = 0, l = menu; l; l = l->next, i++)
247 eo_do(mi->o_icon, efl_gfx_visible_set(EINA_FALSE));
251 eo_do(o_title, efl_gfx_visible_set(EINA_FALSE));
252 eo_do(o_byline, efl_gfx_visible_set(EINA_FALSE));
259 _ui_key(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
260 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
262 Evas_Event_Key_Down *ev = event_info;
266 key_func(ev->keyname);
270 if ((!strcmp(ev->keyname, "Escape")) ||
271 (!strcmp(ev->keyname, "q")) ||
272 (!strcmp(ev->keyname, "Q")))
278 if (!strcmp(ev->keyname, "Left")) menu_sel++;
279 if (!strcmp(ev->keyname, "Right")) menu_sel--;
280 if (menu_sel < 0) menu_sel = 0;
281 else if ((unsigned int)menu_sel >= eina_list_count(menu)) menu_sel = eina_list_count(menu) - 1;
282 menu_anim_sel = menu_sel;
283 if (!strcmp(ev->keyname, "Return")) _ui_select();
289 static Evas_Coord down_x, down_y;
290 static int down_menu_sel = 0;
293 _ui_mouse_down(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
294 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
296 Evas_Event_Mouse_Down *ev = event_info;
298 if (ev->button != 1) return EINA_TRUE;
301 down_x = ev->canvas.x;
302 down_y = ev->canvas.y;
303 down_menu_sel = menu_sel;
310 _ui_mouse_up(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
311 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
313 Evas_Event_Mouse_Up *ev = event_info;
315 if (ev->button != 1) return EINA_TRUE;
320 dx = ev->canvas.x - down_x;
321 dy = ev->canvas.y - down_y;
322 if ((((dx * dx) + (dy * dy)) < (20 * 20)) &&
323 (menu_sel == down_menu_sel))
328 evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
329 evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
336 _ui_mouse_move(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
337 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
339 Evas_Event_Mouse_Move *ev = event_info;
341 if (ev->buttons != 1) return EINA_TRUE;
344 menu_sel = down_menu_sel + ((ev->cur.canvas.x - down_x) / 25);
346 if (menu_sel < 0) menu_sel = 0;
347 else if ((unsigned int)menu_sel >= eina_list_count(menu))
348 menu_sel = eina_list_count(menu) - 1;
349 menu_anim_sel = menu_sel;
356 _ui_menu_item_full_add(Eina_Bool test,
357 char *icon, char *text,
362 mi = malloc(sizeof(Menu_Item));
363 mi->o_icon = eo_add(EVAS_IMAGE_CLASS, evas);
364 eo_do(mi->o_icon, efl_file_set(build_path(icon), NULL),
365 efl_gfx_size_set(32, 32),
366 efl_gfx_fill_set(0, 0, 32, 32));
368 mi->icon = strdup(icon);
369 mi->text = strdup(text);
371 menu = eina_list_append(menu, mi);
372 eo_do(o_menu_icon_sel2, efl_gfx_stack_raise());
375 #define _ui_menu_item_add(Icon, Text, Func) _ui_menu_item_full_add(EINA_TRUE, Icon, Text, Func)
377 EO_CALLBACKS_ARRAY_DEFINE(ui_callbacks,
378 { EVAS_OBJECT_EVENT_KEY_DOWN, _ui_key },
379 { EVAS_OBJECT_EVENT_MOUSE_DOWN, _ui_mouse_down },
380 { EVAS_OBJECT_EVENT_MOUSE_UP, _ui_mouse_up },
381 { EVAS_OBJECT_EVENT_MOUSE_MOVE, _ui_mouse_move });
384 ui_setup(unsigned int ui_w, unsigned int ui_h)
387 Evas_Coord x, y, w, h;
392 o = eo_add(EVAS_RECTANGLE_CLASS, evas);
393 eo_do(o, efl_gfx_position_set(0, 0),
394 efl_gfx_size_set(win_w, win_h),
395 efl_gfx_color_set(0, 0, 0, 0),
396 efl_gfx_stack_layer_set(1000),
397 evas_obj_focus_set(1),
398 efl_gfx_visible_set(EINA_TRUE),
399 eo_event_callback_array_add(ui_callbacks(), NULL));
402 o = eo_add(EVAS_RECTANGLE_CLASS, evas);
403 eo_do(o, efl_gfx_position_set(0, 0),
404 efl_gfx_size_set(win_w, win_h),
405 efl_gfx_color_set(255, 255, 255, 255),
406 efl_gfx_stack_layer_set(-99),
407 efl_gfx_visible_set(EINA_TRUE));
410 o = eo_add(EVAS_TEXT_CLASS, evas);
411 eo_do(o, efl_text_properties_font_set("Vera-Bold", 10),
412 efl_text_set("EXPEDITE"),
413 efl_gfx_stack_layer_set(100),
414 efl_gfx_color_set(0, 0, 0, 100),
415 evas_obj_pass_events_set(1),
416 efl_gfx_size_get(&w, &h));
419 eo_do(o, efl_gfx_position_set(x, y),
420 efl_gfx_visible_set(EINA_TRUE));
423 o = eo_add(EVAS_TEXT_CLASS, evas);
424 eo_do(o, efl_text_properties_font_set("Vera", 9),
425 efl_text_set("LEFT/RIGHT - select, ENTER - select, ESCAPE - exit."),
426 efl_gfx_stack_layer_set(100),
427 efl_gfx_color_set(0, 0, 0, 60),
428 evas_obj_pass_events_set(1),
429 efl_gfx_size_get(&w, NULL));
432 eo_do(o, efl_gfx_position_set(x, y),
433 efl_gfx_visible_set(EINA_TRUE));
436 o = eo_add(EVAS_IMAGE_CLASS, evas);
437 eo_do(o, efl_gfx_position_set((win_w - 120) / 2, ((win_h - 160) / 2)),
438 efl_file_set(build_path("e-logo.png"), NULL),
439 efl_gfx_fill_set(0, 0, 120, 160),
440 efl_gfx_size_set(120, 160),
441 efl_gfx_stack_layer_set(-98),
442 efl_gfx_color_set(255, 255, 255, 255),
443 efl_gfx_visible_set(EINA_TRUE));
446 o = eo_add(EVAS_IMAGE_CLASS, evas);
447 eo_do(o, efl_gfx_position_set(win_w - 128, - 128),
448 efl_gfx_fill_set(0, 0, 256, 256),
449 efl_gfx_size_set(256, 256),
450 efl_gfx_visible_set(EINA_TRUE));
453 o = eo_add(EVAS_IMAGE_CLASS, evas);
454 eo_do(o, efl_gfx_position_set(0, 0),
455 efl_file_set(build_path("icon_sel.png"), NULL),
456 efl_gfx_size_set(48, 48),
457 efl_gfx_fill_set(0, 0, 48, 48));
460 o = eo_add(EVAS_IMAGE_CLASS, evas);
461 eo_do(o, efl_gfx_position_set(0, 0),
462 efl_file_set(build_path("text_sel.png"), NULL),
463 efl_gfx_size_set(96, 32),
464 efl_gfx_fill_set(0, 0, 96, 32),
465 evas_obj_image_border_set(7, 7, 7, 7));
468 o = eo_add(EVAS_TEXT_CLASS, evas);
469 eo_do(o, efl_text_properties_font_set("Vera", 10),
471 efl_gfx_color_set(0, 0, 0, 100),
472 evas_obj_pass_events_set(1),
473 efl_gfx_size_get(&w, &h));
476 eo_do(o, efl_gfx_position_set(x, y));
479 _ui_menu_item_full_add(EINA_FALSE, "e.png", "About", about_start);
480 _ui_menu_item_full_add(EINA_FALSE, "e.png", "All Tests", ui_all);
484 _ui_menu_item_full_add(EINA_FALSE, "exit.png", "Exit", _ui_exit);
487 /* make sure disk io isn't going to turn up unexpectedly */
493 printf("\n#####Test Start#####\n"
495 "window size: %i, %i\n"
511 mi = eina_list_nth(menu, n);
517 if (one_test) test_item = menu_sel;
523 ui_loop(void *data EINA_UNUSED)
525 static int first = 1;
526 static double pt = 0.0;
529 eo_do(o_bg, efl_gfx_size_set(win_w, win_h));
530 eo_do(o_wallpaper, efl_gfx_size_set(win_w, win_h));
537 if ((t - t_loop) >= 1.0)
539 // ui_fps((double)f_loop / (t - t_loop));
543 loop_func(t - t_start, f_start);
566 static double tr = 0.0;
573 menu_anim = (menu_anim * 0.995) + (menu_anim_sel * 0.005);
577 EINA_LIST_FOREACH(menu, l, mi)
580 Evas_Coord x, y, w, h, tw, th;
586 eo_do(o_menu_logo, efl_gfx_size_get(&w, &h));
587 len = ((w * 3) + 10) / 4;
588 eo_do(o, efl_gfx_size_get(&w, &h));
590 + (sin((menu_anim - (double)i) * 0.33) * len)
593 + (cos((menu_anim - (double)i) * 0.33) * len)
595 eo_do(o, efl_gfx_position_set(x, y));
596 a = menu_anim - (double)i;
599 eo_do(o, efl_gfx_color_set(a, a, a, a),
600 efl_gfx_visible_set(EINA_TRUE));
604 a = menu_anim - (double)i;
609 eo_do(o, efl_gfx_position_set(x - ((48 - w) / 2), y - ((48 - h) / 2)),
610 efl_gfx_color_set(a, a, a, a));
613 eo_do(o, efl_gfx_color_set(a, a, a, a),
614 efl_text_set(mi->text),
615 efl_gfx_size_get(&tw, &th));
616 x = (win_w - tw) / 2;
617 y = (win_h / 2) + len + 48;
618 eo_do(o, efl_gfx_position_set(x, y));
624 y = y + ((th - h) / 2);
625 eo_do(o, efl_gfx_position_set(x, y),
626 efl_gfx_size_set(w, h),
627 efl_gfx_fill_set(0, 0, w, h),
628 efl_gfx_color_set(a, a, a, a));
631 snprintf(buf, 4096, "%s%s", data_dir, mi->icon);
632 eo_do(o, efl_file_set(buf, NULL),
633 efl_gfx_color_set(a / 2, a / 2, a / 2, a / 2));
637 eo_do(o_menu_logo, efl_gfx_position_set((win_w - 120) / 2, ((win_h - 160) / 2)),
638 efl_gfx_visible_set(EINA_TRUE));
639 _ui_menu_show(EINA_TRUE);
651 eo_do(o_title, efl_gfx_visible_set(EINA_TRUE));
652 eo_do(o_byline, efl_gfx_visible_set(EINA_TRUE),
654 ("LEFT/RIGHT - select, ENTER - select, ESCAPE - exit."));
659 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
663 ui_func_set(void (*kfunc) (char *key), void (*lfunc) (double t, int f))
667 t_loop = t_start = get_time();
668 f_loop = f_start = 0;
671 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
672 ecore_animator_custom_tick();
684 _ui_menu_show(EINA_FALSE);
686 /* warm up the cpu with some spinning */
691 if (t - t0 > 2) break;
697 EINA_LIST_FOREACH(menu, l, mi)
705 test_item = menu_sel;
715 if (fps > 0.0 && test_item > 0)
721 /* This does not give time to delete the objects of the previous test
722 and make the result of next test less accurate. Benefit we do not
723 loose track of any of the cost anymore (Would be better to force
724 an empty render and account that to the previous test). */
726 wfps += (fps * weights[test_item]);
729 mi = eina_list_nth(menu, test_item);
730 if (one_test || !mi->test)
737 unsigned int t_count;
739 t_count = EINA_C_ARRAY_LENGTH(weights) - 3;
740 for (i = 2; i < EINA_C_ARRAY_LENGTH(weights) - 1; i++)
745 tim = localtime(&now);
746 if (tim) strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", tim);
747 else snprintf(datestr, sizeof(datestr), "unknown");
750 printf("%5.2f , EVAS SPEED (WEIGHTED), "
753 "ev , %i.%i.%i.%i , "
759 wfps / (t_count * avgw),
766 evas_version->revision,
773 printf("\n#####Test Result#####\n"
774 "evas fps speed: %5.2f\n"
775 "evas fps speed(weighted): %5.2f\n"
776 "testcase count: %i\n"
778 "evas version: %i.%i.%i.%i\n"
780 "window size: %i, %i\n"
785 (wfps / avgw) / t_count,
788 evas_version->major, evas_version->minor, evas_version->micro,
789 evas_version->revision,
796 ecore_main_loop_quit();
800 menu_sel = test_item;