containing ui setup steps in the profiling again.
[platform/upstream/expedite.git] / src / bin / image_data_argb_alpha.c
1 #undef FNAME
2 #undef NAME
3 #undef ICON
4
5 /* metadata */
6 #define FNAME image_data_argb_alpha_start
7 #define NAME "Image Data ARGB Alpha"
8 #define ICON "data.png"
9
10 #ifndef PROTO
11 # ifndef UI
12 #  include "main.h"
13
14 /* standard var */
15 static int done = 0;
16
17 /* private data */
18 static Evas_Object *o_images[1];
19
20 /* setup */
21 static void _setup(void)
22 {
23    Evas_Object *o;
24    Eina_Slice sl;
25
26    sl.len = 640 * 480 * 4;
27    sl.mem = malloc(sl.len);
28    for (int i = 0; i < 1; i++)
29      {
30         o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
31         o_images[i] = o;
32         efl_gfx_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
33         efl_gfx_buffer_alpha_set(o, 1);
34         efl_gfx_fill_set(o, EINA_RECT(0, 0, 640, 480));
35         efl_gfx_entity_size_set(o, EINA_SIZE2D(640, 480));
36         efl_gfx_entity_visible_set(o, EINA_TRUE);
37         efl_gfx_buffer_managed_set(o, &sl, EINA_SIZE2D(640, 480), 0, EFL_GFX_COLORSPACE_ARGB8888, 0);
38      }
39    done = 0;
40 }
41
42 /* cleanup */
43 static void _cleanup(void)
44 {
45    for (int i = 0; i < 1; i++)
46      {
47         Evas_Object *o = o_images[i];
48         Eina_Slice sl = {};
49
50         sl = efl_gfx_buffer_managed_get(o, 0);
51         free((void *) sl.mem);
52         efl_del(o);
53      }
54 }
55
56 /* loop - do things */
57 static void _loop(double t, int f)
58 {
59    int i, st;
60    Evas_Coord x, y, w, h;
61
62    for (i = 0; i < 1; i++)
63      {
64         Evas_Object *o = o_images[i];
65         unsigned int *p;
66         Eina_Rw_Slice sl = {};
67         int a, r, g, b;
68
69         w = 640;
70         h = 480;
71         x = (win_w / 2) - (w / 2);
72         y = (win_h / 2) - (h / 2);
73         efl_gfx_entity_position_set(o, EINA_POSITION2D(x, y));
74         efl_gfx_entity_size_set(o, EINA_SIZE2D(w, h));
75         efl_gfx_fill_set(o, EINA_RECT(0, 0, w, h));
76         sl = efl_gfx_buffer_map(o, EFL_GFX_BUFFER_ACCESS_MODE_WRITE,
77                            &EINA_RECT(0, 0, w, h), EFL_GFX_COLORSPACE_ARGB8888, 0, &st);
78         if (!sl.mem)
79           {
80              fprintf(stderr, "ERROR: Failed to map image!\n");
81              continue;
82           }
83         st = st >> 2;
84         p = sl.mem;
85         for (y = 0; y < h; y++)
86           {
87              for (x = 0; x < w; x++)
88                {
89                   r = (x * y / 7) + f;
90                   g = (x / 2);
91                   b = (y / 2);
92                   a = (x + y);
93                   r &= 0xff;
94                   g &= 0xff;
95                   b &= 0xff;
96                   a &= 0xff;
97                   r = (a * r) / 255;
98                   g = (a * g) / 255;
99                   b = (a * b) / 255;
100                   *p = (a << 24) | (r << 16) | (g << 8) | b;
101                   p++;
102                }
103              p += (st - w);
104           }
105         efl_gfx_buffer_unmap(o, sl);
106         efl_gfx_buffer_update_add(o, &EINA_RECT(0, 0, w, h));
107      }
108    FPS_STD(NAME);
109 }
110
111 /* prepend special key handlers if interactive (before STD) */
112 static void _key(const char *key)
113 {
114    KEY_STD;
115 }
116
117
118
119
120
121
122
123
124
125
126
127
128 /* template stuff - ignore */
129 # endif
130 #endif
131
132 #ifdef UI
133 //_ui_menu_item_add(ICON, NAME, FNAME);
134 #endif
135
136 #ifdef PROTO
137 void FNAME(void);
138 #endif
139
140 #ifndef PROTO
141 # ifndef UI
142 void FNAME(void)
143 {
144    ui_func_set(_key, _loop, _setup);
145 }
146 # endif
147 #endif
148 #undef FNAME
149 #undef NAME
150 #undef ICON