summaryrefslogtreecommitdiff
path: root/src/tests/emotion
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-02-16 19:37:55 +0100
committerdavemds <dave@gurumeditation.it>2014-02-16 19:37:55 +0100
commit828e6f995d107d621964695eb45025b46b874be6 (patch)
tree4aa0143561acff482c25818324fa6d97b22efbdf /src/tests/emotion
parent690a60c3ccf1d2320628587a0da7b8d0d0ede83b (diff)
Emotion test: some small cleanups
* simpler and stronger way to search the theme file * removed unused verbose option * removed unused start_time var
Diffstat (limited to 'src/tests/emotion')
-rw-r--r--src/tests/emotion/emotion_test_main.c72
1 files changed, 33 insertions, 39 deletions
diff --git a/src/tests/emotion/emotion_test_main.c b/src/tests/emotion/emotion_test_main.c
index e78b50dab8..56e56f72c1 100644
--- a/src/tests/emotion/emotion_test_main.c
+++ b/src/tests/emotion/emotion_test_main.c
@@ -31,7 +31,6 @@ static const Ecore_Getopt options = {
31 ECORE_GETOPT_STORE_STR('b', "backend", "backend to use"), 31 ECORE_GETOPT_STORE_STR('b', "backend", "backend to use"),
32 ECORE_GETOPT_STORE_INT('v', "vis", "visualization type"), 32 ECORE_GETOPT_STORE_INT('v', "vis", "visualization type"),
33 ECORE_GETOPT_STORE_TRUE('w', "webcams", "show all the available v4l streams"), 33 ECORE_GETOPT_STORE_TRUE('w', "webcams", "show all the available v4l streams"),
34 ECORE_GETOPT_COUNT('v', "verbose", "be more verbose"),
35 ECORE_GETOPT_STORE_TRUE('R', "reflex", "show video reflex effect"), 34 ECORE_GETOPT_STORE_TRUE('R', "reflex", "show video reflex effect"),
36 ECORE_GETOPT_VERSION('V', "version"), 35 ECORE_GETOPT_VERSION('V', "version"),
37 ECORE_GETOPT_COPYRIGHT('R', "copyright"), 36 ECORE_GETOPT_COPYRIGHT('R', "copyright"),
@@ -61,7 +60,6 @@ static void bg_key_down(void *data, Evas * e, Evas_Object * obj, void *event_inf
61 60
62static Evas_Object *o_bg = NULL; 61static Evas_Object *o_bg = NULL;
63 62
64static double start_time = 0.0;
65static Ecore_Evas *ecore_evas = NULL; 63static Ecore_Evas *ecore_evas = NULL;
66static Evas *evas = NULL; 64static Evas *evas = NULL;
67static int startw = 800; 65static int startw = 800;
@@ -70,6 +68,7 @@ static int starth = 600;
70static Eina_List *video_objs = NULL; 68static Eina_List *video_objs = NULL;
71static Emotion_Vis vis = EMOTION_VIS_NONE; 69static Emotion_Vis vis = EMOTION_VIS_NONE;
72static unsigned char reflex = 0; 70static unsigned char reflex = 0;
71static const char *theme_file = NULL;
73 72
74static void 73static void
75main_resize(Ecore_Evas *ee) 74main_resize(Ecore_Evas *ee)
@@ -100,29 +99,13 @@ main_delete_request(Ecore_Evas *ee EINA_UNUSED)
100 ecore_main_loop_quit(); 99 ecore_main_loop_quit();
101} 100}
102 101
103static const char *
104theme_get(void)
105{
106 static int is_local = -1;
107 if (is_local == -1)
108 {
109 struct stat st;
110 is_local = (stat(PACKAGE_BUILD_DIR"/src/tests/emotion/data/theme.edj", &st) == 0);
111 }
112
113 if (is_local)
114 return PACKAGE_BUILD_DIR"/src/tests/emotion/data/theme.edj";
115 else
116 return PACKAGE_DATA_DIR"/data/theme.edj";
117}
118
119void 102void
120bg_setup(void) 103bg_setup(void)
121{ 104{
122 Evas_Object *o; 105 Evas_Object *o;
123 106
124 o = edje_object_add(evas); 107 o = edje_object_add(evas);
125 edje_object_file_set(o, theme_get(), "background"); 108 edje_object_file_set(o, theme_file, "background");
126 evas_object_move(o, 0, 0); 109 evas_object_move(o, 0, 0);
127 evas_object_resize(o, startw, starth); 110 evas_object_resize(o, startw, starth);
128 evas_object_layer_set(o, -999); 111 evas_object_layer_set(o, -999);
@@ -615,9 +598,9 @@ init_video_object(const char *module_filename, const char *filename)
615 evas_object_event_callback_add(oe, EVAS_CALLBACK_FREE, _oe_free_cb, NULL); 598 evas_object_event_callback_add(oe, EVAS_CALLBACK_FREE, _oe_free_cb, NULL);
616 evas_object_data_set(oe, "frame_data", fd); 599 evas_object_data_set(oe, "frame_data", fd);
617 if (reflex) 600 if (reflex)
618 edje_object_file_set(oe, theme_get(), "video_controller/reflex"); 601 edje_object_file_set(oe, theme_file, "video_controller/reflex");
619 else 602 else
620 edje_object_file_set(oe, theme_get(), "video_controller"); 603 edje_object_file_set(oe, theme_file, "video_controller");
621 edje_extern_object_min_size_set(o, w, h); 604 edje_extern_object_min_size_set(o, w, h);
622 edje_object_part_swallow(oe, "video_swallow", o); 605 edje_object_part_swallow(oe, "video_swallow", o);
623 edje_object_size_min_calc(oe, &w, &h); 606 edje_object_size_min_calc(oe, &w, &h);
@@ -683,7 +666,6 @@ main(int argc, char **argv)
683 Eina_Rectangle geometry = {0, 0, startw, starth}; 666 Eina_Rectangle geometry = {0, 0, startw, starth};
684 char *engine = NULL; 667 char *engine = NULL;
685 char *backend = NULL; 668 char *backend = NULL;
686 int verbose = 0;
687 Eina_Bool webcams = EINA_FALSE; 669 Eina_Bool webcams = EINA_FALSE;
688 int visual = EMOTION_VIS_NONE; 670 int visual = EMOTION_VIS_NONE;
689 unsigned char help = 0; 671 unsigned char help = 0;
@@ -695,7 +677,6 @@ main(int argc, char **argv)
695 ECORE_GETOPT_VALUE_STR(backend), 677 ECORE_GETOPT_VALUE_STR(backend),
696 ECORE_GETOPT_VALUE_INT(visual), 678 ECORE_GETOPT_VALUE_INT(visual),
697 ECORE_GETOPT_VALUE_BOOL(webcams), 679 ECORE_GETOPT_VALUE_BOOL(webcams),
698 ECORE_GETOPT_VALUE_INT(verbose),
699 ECORE_GETOPT_VALUE_BOOL(reflex), 680 ECORE_GETOPT_VALUE_BOOL(reflex),
700 ECORE_GETOPT_VALUE_NONE, 681 ECORE_GETOPT_VALUE_NONE,
701 ECORE_GETOPT_VALUE_NONE, 682 ECORE_GETOPT_VALUE_NONE,
@@ -704,15 +685,29 @@ main(int argc, char **argv)
704 ECORE_GETOPT_VALUE_NONE 685 ECORE_GETOPT_VALUE_NONE
705 }; 686 };
706 687
688 // init ecore_evas
707 if (!ecore_evas_init()) 689 if (!ecore_evas_init())
708 return -1; 690 return -1;
691
692 // init edje
709 if (!edje_init()) 693 if (!edje_init())
710 goto shutdown_ecore_evas; 694 goto shutdown_ecore_evas;
711
712 start_time = ecore_time_get();
713 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, NULL);
714 edje_frametime_set(1.0 / 30.0); 695 edje_frametime_set(1.0 / 30.0);
715 696
697 // search the theme file
698 struct stat st;
699 if (stat(PACKAGE_BUILD_DIR"/src/tests/emotion/data/theme.edj", &st) == 0)
700 theme_file = PACKAGE_BUILD_DIR"/src/tests/emotion/data/theme.edj";
701 else if (stat(PACKAGE_DATA_DIR"/data/theme.edj", &st) == 0)
702 theme_file = PACKAGE_DATA_DIR"/data/theme.edj";
703 else
704 {
705 printf("Cannot find the theme file\n");
706 goto shutdown_edje;
707 }
708 printf("theme file: %s\n", theme_file);
709
710 // parse command line arguments
716 ecore_app_args_set(argc, (const char **)argv); 711 ecore_app_args_set(argc, (const char **)argv);
717 args = ecore_getopt_parse(&options, values, argc, argv); 712 args = ecore_getopt_parse(&options, values, argc, argv);
718 if (args < 0) goto shutdown_edje; 713 if (args < 0) goto shutdown_edje;
@@ -723,25 +718,20 @@ main(int argc, char **argv)
723 printf("must provide at least one file to play!\n"); 718 printf("must provide at least one file to play!\n");
724 goto shutdown_edje; 719 goto shutdown_edje;
725 } 720 }
726 721 if (geometry.w == 0) geometry.w = 320;
727 if ((geometry.w == 0) || (geometry.h == 0)) 722 if (geometry.h == 0) geometry.h = 240;
728 {
729 if (geometry.w == 0) geometry.w = 320;
730 if (geometry.h == 0) geometry.h = 240;
731 }
732 723
733 printf("evas engine: %s\n", engine ? engine : "<auto>"); 724 printf("evas engine: %s\n", engine ? engine : "<auto>");
734 printf("emotion backend: %s\n", backend ? backend : "<auto>"); 725 printf("emotion backend: %s\n", backend ? backend : "<auto>");
735 printf("vis: %d\n", vis); 726 printf("vis: %d\n", vis);
736 printf("geometry: %d %d %dx%d\n", geometry.x, geometry.y, geometry.w, geometry.h); 727 printf("geometry: %d %d %dx%d\n", geometry.x, geometry.y, geometry.w, geometry.h);
737 728
738 ecore_evas = ecore_evas_new 729 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, NULL);
739 (engine, geometry.x, geometry.y, geometry.w, geometry.h, NULL);
740 if (!ecore_evas)
741 goto shutdown_edje;
742
743// ecore_evas_alpha_set(ecore_evas, EINA_TRUE);
744 730
731 // create the ecore_evas window
732 ecore_evas = ecore_evas_new(engine, geometry.x, geometry.y,
733 geometry.w, geometry.h, NULL);
734 if (!ecore_evas) goto shutdown_edje;
745 ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request); 735 ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request);
746 ecore_evas_callback_resize_set(ecore_evas, main_resize); 736 ecore_evas_callback_resize_set(ecore_evas, main_resize);
747 ecore_evas_title_set(ecore_evas, "Evas Media Test Program"); 737 ecore_evas_title_set(ecore_evas, "Evas Media Test Program");
@@ -751,10 +741,13 @@ main(int argc, char **argv)
751 evas_image_cache_set(evas, 8 * 1024 * 1024); 741 evas_image_cache_set(evas, 8 * 1024 * 1024);
752 evas_font_cache_set(evas, 1 * 1024 * 1024); 742 evas_font_cache_set(evas, 1 * 1024 * 1024);
753 743
744 // init emotion
754 emotion_init(); 745 emotion_init();
755 746
747 // create the checkboard background edje object
756 bg_setup(); 748 bg_setup();
757 749
750 // open files and webcams
758 for (; args < argc; args++) 751 for (; args < argc; args++)
759 init_video_object(backend, argv[args]); 752 init_video_object(backend, argv[args]);
760 753
@@ -773,10 +766,11 @@ main(int argc, char **argv)
773 } 766 }
774 } 767 }
775 768
769 // start the main loop
776 ecore_animator_add(check_positions, NULL); 770 ecore_animator_add(check_positions, NULL);
777
778 ecore_main_loop_begin(); 771 ecore_main_loop_begin();
779 772
773 // shutdown
780 main_signal_exit(NULL, 0, NULL); 774 main_signal_exit(NULL, 0, NULL);
781 775
782 emotion_shutdown(); 776 emotion_shutdown();