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_sel = NULL;
25 static Evas_Object *o_menu_icon_sel2 = NULL;
26 static Evas_Object *o_menu_text_sel = NULL;
27 static Evas_Object *o_menu_title = NULL;
28 static int menu_sel = 0;
29 static int menu_active = 0;
30 static double menu_anim = 0.0;
31 static double menu_anim_sel = 0.0;
33 static double p_fps = 0.0;
35 static void (*key_func) (const char *key) = NULL;
36 static void (*loop_func) (double t, int f) = NULL;
152 1.000, // test 92 (line)
153 10.000, // test 93 Image Blend Many Smooth Down Scaled
172 20.000, // test 106 MASK 15
190 0.0, // no final test - add a 0 at the end anyway to pad
203 EINA_LIST_FREE(menu, mi)
209 ecore_main_loop_quit();
212 extern const char *profile;
213 extern int win_w, win_h;
216 static int test_item = -1;
219 _ui_menu_show(Eina_Bool visibility)
221 efl_gfx_entity_visible_set(o_menu_logo, visibility);
222 efl_gfx_entity_visible_set(o_menu_title, visibility);
223 efl_gfx_entity_visible_set(o_menu_icon_sel, visibility);
224 /* FIXME: ask if it's ok o_menu_icon_sel2 == NULL */
225 efl_gfx_entity_visible_set(o_menu_icon_sel2, visibility);
226 efl_gfx_entity_visible_set(o_menu_text_sel, visibility);
227 efl_gfx_entity_visible_set(o_title, visibility);
228 efl_gfx_entity_visible_set(o_byline, visibility);
236 void (*func) (void) = NULL;
238 _ui_menu_show(EINA_FALSE);
239 for (i = 0, l = menu; l; l = l->next, i++)
244 efl_gfx_entity_visible_set(mi->o_icon, EINA_FALSE);
248 efl_gfx_entity_visible_set(o_title, EINA_FALSE);
249 efl_gfx_entity_visible_set(o_byline, EINA_FALSE);
256 _ui_key(void *data EINA_UNUSED, const Efl_Event *event)
258 Efl_Input_Key *ev = event->info;
259 const char *keyname = efl_input_key_name_get(ev);
261 if (!keyname) return;
269 if ((!strcmp(keyname, "Escape")) ||
270 (!strcmp(keyname, "q")) ||
271 (!strcmp(keyname, "Q")))
279 if (!strcmp(keyname, "Left")) menu_sel++;
280 else if (!strcmp(keyname, "Right")) menu_sel--;
281 else if (!strcmp(keyname, "Up")) menu_sel++;
282 else if (!strcmp(keyname, "Down")) menu_sel--;
283 else if (!strcmp(keyname, "Home")) menu_sel = eina_list_count(menu) - 1;
284 else if (!strcmp(keyname, "End")) menu_sel = 0;
285 else if (!strcmp(keyname, "Next")) menu_sel -= 10;
286 else if (!strcmp(keyname, "Prior")) menu_sel += 10;
287 if (menu_sel < 0) menu_sel = 0;
288 else if ((unsigned int)menu_sel >= eina_list_count(menu)) menu_sel = eina_list_count(menu) - 1;
289 menu_anim_sel = menu_sel;
290 if (!strcmp(keyname, "Return")) _ui_select();
294 static Eina_Position2D down;
295 static int down_menu_sel = 0;
297 //FIXME: efl_input_pointer_button_get() doesn't work!
298 static Eina_Bool mdown = EINA_FALSE;
301 _ui_mouse_down(void *data EINA_UNUSED, const Efl_Event *event)
303 Efl_Input_Pointer *ev = event->info;
305 if (efl_input_pointer_button_get(ev) != 1) return;
308 down = efl_input_pointer_position_get(ev);
309 down_menu_sel = menu_sel;
315 _ui_mouse_up(void *data EINA_UNUSED, const Efl_Event *event)
317 Efl_Input_Pointer *ev = event->info;
319 if (efl_input_pointer_button_get(ev) != 1) return;
322 Evas_Coord dx, dy, x, y;
324 exp_input_pointer_pos_get(ev, &x, &y);
327 if ((((dx * dx) + (dy * dy)) < (20 * 20)) &&
328 (menu_sel == down_menu_sel))
334 evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
335 evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
340 _ui_mouse_move(void *data EINA_UNUSED, const Efl_Event *event)
342 Efl_Input_Pointer *ev = event->info;
344 /* FIXME: This mdown should be replace with the original call
345 if (efl_input_pointer_button_get(ev) != 1) return; */
352 exp_input_pointer_pos_get(ev, &x, NULL);
353 menu_sel = down_menu_sel + ((x - down.x) / 25);
355 if (menu_sel < 0) menu_sel = 0;
356 else if ((unsigned int)menu_sel >= eina_list_count(menu))
357 menu_sel = eina_list_count(menu) - 1;
358 menu_anim_sel = menu_sel;
363 _ui_menu_item_full_add(Eina_Bool test,
364 char *icon, char *text,
369 mi = malloc(sizeof(Menu_Item));
370 mi->o_icon = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
371 efl_file_simple_load(mi->o_icon, build_path(icon), NULL);
372 efl_gfx_entity_size_set(mi->o_icon, EINA_SIZE2D(32, 32));
373 efl_gfx_fill_set(mi->o_icon, EINA_RECT(0, 0, 32, 32));
375 mi->icon = strdup(icon);
376 mi->text = strdup(text);
378 menu = eina_list_append(menu, mi);
379 efl_gfx_stack_raise_to_top(o_menu_icon_sel2);
382 #define _ui_menu_item_add(Icon, Text, Func) _ui_menu_item_full_add(EINA_TRUE, Icon, Text, Func)
384 EFL_CALLBACKS_ARRAY_DEFINE(ui_callbacks,
385 { EFL_EVENT_KEY_DOWN, _ui_key },
386 { EFL_EVENT_POINTER_DOWN, _ui_mouse_down },
387 { EFL_EVENT_POINTER_UP, _ui_mouse_up },
388 { EFL_EVENT_POINTER_MOVE, _ui_mouse_move });
391 ui_setup(unsigned int ui_w, unsigned int ui_h)
394 Evas_Coord x, y, w, h;
399 o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
400 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
401 efl_gfx_entity_size_set(o, EINA_SIZE2D(win_w, win_h));
402 efl_gfx_color_set(o, 0, 0, 0, 0);
403 efl_gfx_stack_layer_set(o, 1000);
404 evas_object_focus_set(o, 1);
405 efl_gfx_entity_visible_set(o, EINA_TRUE);
406 efl_event_callback_array_add(o, ui_callbacks(), NULL);
409 o = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas);
410 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
411 efl_gfx_entity_size_set(o, EINA_SIZE2D(win_w, win_h));
412 efl_gfx_color_set(o, 255, 255, 255, 255);
413 efl_gfx_stack_layer_set(o, -99);
414 efl_gfx_entity_visible_set(o, EINA_TRUE);
417 o = evas_object_text_add(evas);
419 efl_text_font_family_set(o, "Vera-Bold");
420 efl_text_font_size_set(o, 10);
421 efl_text_set(o, "EXPEDITE");
423 evas_object_text_font_set(o, "Vera-Bold", 10);
424 evas_object_text_text_set(o, "EXPEDITE");
426 efl_gfx_stack_layer_set(o, 100);
427 efl_gfx_color_set(o, 0, 0, 0, 100);
428 evas_object_pass_events_set(o, 1);
429 exp_size_get(o, &w, &h);
432 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
433 efl_gfx_entity_visible_set(o, EINA_TRUE);
436 o = evas_object_text_add(evas);
438 efl_text_font_family_set(o, "Vera");
439 efl_text_font_size_set(o, 9);
440 efl_text_set(o, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
442 evas_object_text_font_set(o, "Vera", 9);
443 evas_object_text_text_set(o, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
445 efl_gfx_stack_layer_set(o, 100);
446 efl_gfx_color_set(o, 0, 0, 0, 60);
447 evas_object_pass_events_set(o, 1);
448 exp_size_get(o, &w, NULL);
451 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
452 efl_gfx_entity_visible_set(o, EINA_TRUE);
455 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
456 efl_gfx_entity_position_set(o, EINA_POSITION2D((win_w - 120) / 2, ((win_h - 160) / 2)));
457 efl_file_simple_load(o, build_path("e-logo.png"), NULL);
458 efl_gfx_fill_set(o, EINA_RECT(0, 0, 120, 160));
459 efl_gfx_entity_size_set(o, EINA_SIZE2D(120, 160));
460 efl_gfx_stack_layer_set(o, -98);
461 efl_gfx_color_set(o, 255, 255, 255, 255);
462 efl_gfx_entity_visible_set(o, EINA_TRUE);
465 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
466 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
467 efl_file_simple_load(o, build_path("icon_sel.png"), NULL);
468 efl_gfx_entity_size_set(o, EINA_SIZE2D(48, 48));
469 efl_gfx_fill_set(o, EINA_RECT(0, 0, 48, 48));
472 o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
473 efl_gfx_entity_position_set(o, EINA_POSITION2D(0, 0));
474 efl_file_simple_load(o, build_path("text_sel.png"), NULL);
475 efl_gfx_entity_size_set(o, EINA_SIZE2D(96, 32));
476 efl_gfx_fill_set(o, EINA_RECT(0, 0, 96, 32));
477 efl_gfx_image_border_insets_set(o, 7, 7, 7, 7);
480 o = evas_object_text_add(evas);
482 efl_text_font_family_set(o, "Vera");
483 efl_text_font_size_set(o, 10);
486 evas_object_text_font_set(o, "Vera", 10);
487 evas_object_text_text_set(o, "");
489 efl_gfx_color_set(o, 0, 0, 0, 100);
490 evas_object_pass_events_set(o, 1);
491 exp_size_get(o, &w, &h);
494 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
497 _ui_menu_item_full_add(EINA_FALSE, "e.png", "About", about_start);
498 _ui_menu_item_full_add(EINA_FALSE, "e.png", "All Tests", ui_all);
502 _ui_menu_item_full_add(EINA_FALSE, "exit.png", "Exit", _ui_exit);
505 /* make sure disk io isn't going to turn up unexpectedly */
511 printf("\n#####Test Start#####\n"
513 "window size: %i, %i\n"
529 mi = eina_list_nth(menu, n);
535 if (one_test) test_item = menu_sel;
541 ui_loop(void *data EINA_UNUSED)
543 static int first = 1;
544 static double pt = 0.0;
547 efl_gfx_entity_size_set(o_bg, EINA_SIZE2D(win_w, win_h));
548 efl_gfx_entity_size_set(o_wallpaper, EINA_SIZE2D(win_w, win_h));
555 if ((t - t_loop) >= 1.0)
557 // ui_fps((double)f_loop / (t - t_loop));
561 loop_func(t - t_start, f_start);
584 static double tr = 0.0;
591 menu_anim = (menu_anim * 0.995) + (menu_anim_sel * 0.005);
595 EINA_LIST_FOREACH(menu, l, mi)
597 Evas_Coord x, y, w, h, tw, th;
603 exp_size_get(o_menu_logo, &w, &h);
604 len = ((w * 3) + 10) / 4;
605 exp_size_get(o, &w, &h);
607 + (sin((menu_anim - (double)i) * 0.33) * len)
610 + (cos((menu_anim - (double)i) * 0.33) * len)
612 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
613 a = menu_anim - (double)i;
617 if (a > 255) a = 255;
618 efl_gfx_color_set(o, a, a, a, a);
619 efl_gfx_entity_visible_set(o, EINA_TRUE);
623 a = menu_anim - (double)i;
627 if (a > 255) a = 255;
630 efl_gfx_entity_position_set(o, EINA_POSITION2D(x - ((48 - w) / 2), y - ((48 - h) / 2)));
631 efl_gfx_color_set(o, a, a, a, a);
634 efl_gfx_color_set(o, a, a, a, a);
635 efl_text_set(o, mi->text);
636 exp_size_get(o, &tw, &th);
637 x = (win_w - tw) / 2;
638 y = (win_h / 2) + len + 48;
639 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
645 y = y + ((th - h) / 2);
646 efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
647 efl_gfx_entity_size_set(o, EINA_SIZE2D(w, h));
648 efl_gfx_fill_set(o, EINA_RECT(0, 0, w, h));
649 efl_gfx_color_set(o, a, a, a, a);
653 efl_gfx_entity_position_set(o_menu_logo, EINA_POSITION2D((win_w - 120) / 2, ((win_h - 160) / 2)));
654 efl_gfx_entity_visible_set(o_menu_logo, EINA_TRUE);
655 _ui_menu_show(EINA_TRUE);
667 efl_gfx_entity_visible_set(o_title, EINA_TRUE);
668 efl_gfx_entity_visible_set(o_byline, EINA_TRUE);
670 (o_byline, "LEFT/RIGHT - select, ENTER - select, ESCAPE - exit.");
675 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
679 ui_func_set(void (*kfunc) (const char *key), void (*lfunc) (double t, int f), void (*lsetup) (void))
683 t_loop = t_start = get_time();
684 f_loop = f_start = 0;
691 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
692 ecore_animator_custom_tick();
704 _ui_menu_show(EINA_FALSE);
706 /* warm up the cpu with some spinning */
711 if (t - t0 > 2) break;
716 EINA_LIST_FOREACH(menu, l, mi)
724 test_item = menu_sel;
734 if (fps > 0.0 && test_item > 0)
740 /* This does not give time to delete the objects of the previous test
741 and make the result of next test less accurate. Benefit we do not
742 loose track of any of the cost anymore (Would be better to force
743 an empty render and account that to the previous test). */
745 wfps += (fps * weights[test_item]);
748 mi = eina_list_nth(menu, test_item);
749 if (one_test || !mi->test)
756 unsigned int t_count;
758 t_count = EINA_C_ARRAY_LENGTH(weights) - 3;
759 for (i = 2; i < EINA_C_ARRAY_LENGTH(weights) - 1; i++)
764 tim = localtime(&now);
765 if (tim) strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", tim);
766 else snprintf(datestr, sizeof(datestr), "unknown");
769 printf("%5.2f , EVAS SPEED (WEIGHTED), "
772 "ev , %i.%i.%i.%i , "
778 wfps / (t_count * avgw),
785 evas_version->revision,
792 printf("\n#####Test Result#####\n"
793 "evas fps speed: %5.2f\n"
794 "evas fps speed(weighted): %5.2f\n"
795 "testcase count: %i\n"
797 "evas version: %i.%i.%i.%i\n"
799 "window size: %i, %i\n"
804 (wfps / avgw) / t_count,
807 evas_version->major, evas_version->minor, evas_version->micro,
808 evas_version->revision,
815 ecore_main_loop_quit();
819 menu_sel = test_item;