Revert "Revert "Setup before starting fps measurement""
[platform/upstream/expedite.git] / src / bin / image_blend_solid_stretch.c
1 #undef FNAME
2 #undef NAME
3 #undef ICON
4
5 /* metadata */
6 #define FNAME image_blend_solid_stretch_start
7 #define NAME "Image Blend Solid Stretch"
8 #define ICON "blend.png"
9
10 #ifndef PROTO
11 # ifndef UI
12 #  include "main.h"
13
14 /* standard var */
15 static int done = 0;
16 /* private data */
17 static Evas_Object *o_images[OBNUM];
18
19 // Each  offset is relative to the last block
20 static const Efl_Gfx_Image_Stretch_Region hsz[] = { { 8, 8 }, { 16, 55 } };
21 static const Efl_Gfx_Image_Stretch_Region vsz[] = { { 8, 8 }, { 16, 12 } };
22
23 /* setup */
24 static void _setup(void)
25 {
26    int i;
27    Evas_Object *o;
28    for (i = 0; i < OBNUM; i++)
29      {
30         o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
31         o_images[i] = o;
32         efl_file_simple_load(o, build_path("stretch.png"), NULL);
33         efl_gfx_image_stretch_region_set(o, EINA_C_ARRAY_ITERATOR_NEW(hsz),
34                                          EINA_C_ARRAY_ITERATOR_NEW(vsz));
35         efl_gfx_entity_visible_set(o, EINA_TRUE);
36      }
37    done = 0;
38 }
39
40 /* cleanup */
41 static void _cleanup(void)
42 {
43    int i;
44    for (i = 0; i < OBNUM; i++) efl_del(o_images[i]);
45 }
46
47 /* loop - do things */
48 static void _loop(double t, int f)
49 {
50    int i;
51    Evas_Coord x, y, w, h, w0, h0;
52
53    for (i = 0; i < OBNUM; i++)
54      {
55         w0 = 80;
56         h0 = 80;
57         w = 5 + ((1.0 + cos((double)(f + (i * 10)) / (7.4 * SLOW))) * w0 * 2);
58         h = 5 + ((1.0 + sin((double)(f + (i * 19)) / (12.6 * SLOW))) * w0 * 2);
59         x = (win_w / 2) - (w / 2);
60         x += sin((double)(f + (i * 13)) / (36.7 * SLOW)) * (w0 / 2);
61         y = (win_h / 2) - (h / 2);
62         y += cos((double)(f + (i * 28)) / (43.8 * SLOW)) * (h0 / 2);
63         efl_gfx_entity_position_set(o_images[i], EINA_POSITION2D(x, y));
64         efl_gfx_entity_size_set(o_images[i], EINA_SIZE2D(w, h));
65         efl_gfx_fill_set(o_images[i], EINA_RECT(0, 0, w, h));
66      }
67    FPS_STD(NAME);
68 }
69
70 /* prepend special key handlers if interactive (before STD) */
71 static void _key(const char *key)
72 {
73    KEY_STD;
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87 /* template stuff - ignore */
88 # endif
89 #endif
90
91 #ifdef UI
92 _ui_menu_item_add(ICON, NAME, FNAME);
93 #endif
94
95 #ifdef PROTO
96 void FNAME(void);
97 #endif
98
99 #ifndef PROTO
100 # ifndef UI
101 void FNAME(void)
102 {
103    _setup();
104    ui_func_set(_key, _loop);
105 }
106 # endif
107 #endif
108 #undef FNAME
109 #undef NAME
110 #undef ICON