summaryrefslogtreecommitdiff
path: root/src/lib/ecore_evas
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-11 16:57:21 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-11 16:57:21 +0000
commit85f8163c3ee5b5d776d94c70ff9fbc667a615b2a (patch)
tree5428396625bf4a84d287357c6a1e9d576a421b30 /src/lib/ecore_evas
parent9c12a585366c131560582a01e8d28f3acc47c19e (diff)
efl/ecore_evas: merge buffer into core, split extn apart.
buffer is lightweight and dependency for many engines, merge it back into core. extn is a module on its own, and it's the only one linking to ecore_ipc, no need to add that to ecore_evas. minor cosmetic changes to configure to make output consistent. SVN revision: 82648
Diffstat (limited to 'src/lib/ecore_evas')
-rw-r--r--src/lib/ecore_evas/ecore_evas.c77
-rw-r--r--src/lib/ecore_evas/ecore_evas_buffer.c833
-rw-r--r--src/lib/ecore_evas/ecore_evas_buffer.h24
-rw-r--r--src/lib/ecore_evas/ecore_evas_private.h8
4 files changed, 860 insertions, 82 deletions
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index 7d4edaef42..893f9d517b 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -105,11 +105,8 @@ ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine)
105 switch (engine) 105 switch (engine)
106 { 106 {
107 case ECORE_EVAS_ENGINE_SOFTWARE_BUFFER: 107 case ECORE_EVAS_ENGINE_SOFTWARE_BUFFER:
108#ifdef BUILD_ECORE_EVAS_BUFFER
109 return EINA_TRUE; 108 return EINA_TRUE;
110#else 109
111 return EINA_FALSE;
112#endif
113 case ECORE_EVAS_ENGINE_SOFTWARE_XLIB: 110 case ECORE_EVAS_ENGINE_SOFTWARE_XLIB:
114#ifdef BUILD_ECORE_EVAS_SOFTWARE_XLIB 111#ifdef BUILD_ECORE_EVAS_SOFTWARE_XLIB
115 return EINA_TRUE; 112 return EINA_TRUE;
@@ -2669,22 +2666,6 @@ _ecore_evas_window_available_profiles_free(Ecore_Evas *ee)
2669 } 2666 }
2670} 2667}
2671 2668
2672EAPI int
2673ecore_evas_buffer_render(Ecore_Evas *ee)
2674{
2675 Ecore_Evas_Interface_Buffer *iface;
2676 iface = (Ecore_Evas_Interface_Buffer *)_ecore_evas_interface_get(ee, "buffer");
2677 EINA_SAFETY_ON_NULL_RETURN_VAL(iface, 0);
2678
2679 return iface->render(ee);
2680}
2681
2682
2683
2684
2685
2686
2687
2688EAPI Eina_List * 2669EAPI Eina_List *
2689ecore_evas_ecore_evas_list_get(void) 2670ecore_evas_ecore_evas_list_get(void)
2690{ 2671{
@@ -3050,49 +3031,10 @@ ecore_evas_x11_shape_input_apply(Ecore_Evas *ee)
3050} 3031}
3051 3032
3052EAPI Ecore_Evas * 3033EAPI Ecore_Evas *
3053ecore_evas_buffer_new(int w, int h)
3054{
3055 Ecore_Evas *(*new)(int, int);
3056 Eina_Module *m = _ecore_evas_engine_load("buffer");
3057 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
3058
3059 new = eina_module_symbol_get(m, "ecore_evas_buffer_new_internal");
3060 EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL);
3061
3062 return new(w, h);
3063}
3064
3065EAPI const void *
3066ecore_evas_buffer_pixels_get(Ecore_Evas *ee)
3067{
3068 Ecore_Evas_Interface_Buffer *iface;
3069 iface = (Ecore_Evas_Interface_Buffer *)_ecore_evas_interface_get(ee, "buffer");
3070 EINA_SAFETY_ON_NULL_RETURN_VAL(iface, NULL);
3071
3072 return iface->pixels_get(ee);
3073}
3074
3075EAPI Ecore_Evas *
3076ecore_evas_buffer_allocfunc_new(int w, int h,
3077 void *(*alloc_func) (void *data, int size),
3078 void (*free_func) (void *data, void *pix),
3079 const void *data)
3080{
3081 Ecore_Evas *(*new)(int, int, void*(*)(void *, int), void(*)(void *, void *), const void *);
3082 Eina_Module *m = _ecore_evas_engine_load("buffer");
3083 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
3084
3085 new = eina_module_symbol_get(m, "ecore_evas_buffer_allocfunc_new_internal");
3086 EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL);
3087
3088 return new(w, h, alloc_func, free_func, data);
3089}
3090
3091EAPI Ecore_Evas *
3092ecore_evas_extn_socket_new(int w, int h) 3034ecore_evas_extn_socket_new(int w, int h)
3093{ 3035{
3094 Ecore_Evas *(*new)(int, int); 3036 Ecore_Evas *(*new)(int, int);
3095 Eina_Module *m = _ecore_evas_engine_load("buffer"); 3037 Eina_Module *m = _ecore_evas_engine_load("extn");
3096 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); 3038 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
3097 3039
3098 new = eina_module_symbol_get(m, "ecore_evas_extn_socket_new_internal"); 3040 new = eina_module_symbol_get(m, "ecore_evas_extn_socket_new_internal");
@@ -3145,7 +3087,7 @@ EAPI Evas_Object *
3145ecore_evas_extn_plug_new(Ecore_Evas *ee_target) 3087ecore_evas_extn_plug_new(Ecore_Evas *ee_target)
3146{ 3088{
3147 Evas_Object *(*new)(Ecore_Evas *); 3089 Evas_Object *(*new)(Ecore_Evas *);
3148 Eina_Module *m = _ecore_evas_engine_load("buffer"); 3090 Eina_Module *m = _ecore_evas_engine_load("extn");
3149 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); 3091 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
3150 3092
3151 new = eina_module_symbol_get(m, "ecore_evas_extn_plug_new_internal"); 3093 new = eina_module_symbol_get(m, "ecore_evas_extn_plug_new_internal");
@@ -3169,19 +3111,6 @@ ecore_evas_extn_plug_connect(Evas_Object *obj, const char *svcname, int svcnum,
3169 return iface->connect(ee, svcname, svcnum, svcsys); 3111 return iface->connect(ee, svcname, svcnum, svcsys);
3170} 3112}
3171 3113
3172EAPI Evas_Object *
3173ecore_evas_object_image_new(Ecore_Evas *ee_target)
3174{
3175 Evas_Object *(*new)(Ecore_Evas *ee_target);
3176 Eina_Module *m = _ecore_evas_engine_load("buffer");
3177 EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
3178
3179 new = eina_module_symbol_get(m, "ecore_evas_object_image_new_internal");
3180 EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL);
3181
3182 return new(ee_target);
3183}
3184
3185EAPI Ecore_Evas * 3114EAPI Ecore_Evas *
3186ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, 3115ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen,
3187 int hwsurface, int noframe, int alpha) 3116 int hwsurface, int noframe, int alpha)
diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c b/src/lib/ecore_evas/ecore_evas_buffer.c
new file mode 100644
index 0000000000..69acea75ce
--- /dev/null
+++ b/src/lib/ecore_evas/ecore_evas_buffer.c
@@ -0,0 +1,833 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ecore_evas_buffer.h"
6
7static void
8_ecore_evas_buffer_free(Ecore_Evas *ee)
9{
10 Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
11
12 if (bdata->image)
13 {
14 Ecore_Evas *ee2;
15
16 ee2 = evas_object_data_get(bdata->image, "Ecore_Evas_Parent");
17 evas_object_del(bdata->image);
18 ee2->sub_ecore_evas = eina_list_remove(ee2->sub_ecore_evas, ee);
19 }
20 else
21 {
22 bdata->free_func(bdata->data,
23 bdata->pixels);
24 }
25
26 free(bdata);
27}
28
29static void
30_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
31{
32 Evas_Engine_Info_Buffer *einfo;
33 Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
34 int stride = 0;
35
36 if (w < 1) w = 1;
37 if (h < 1) h = 1;
38 ee->req.w = w;
39 ee->req.h = h;
40 if ((w == ee->w) && (h == ee->h)) return;
41 ee->w = w;
42 ee->h = h;
43 evas_output_size_set(ee->evas, ee->w, ee->h);
44 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
45 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
46
47 if (bdata->image)
48 {
49 bdata->pixels = evas_object_image_data_get(bdata->image, 1);
50 stride = evas_object_image_stride_get(bdata->image);
51 }
52 else
53 {
54 if (bdata->pixels)
55 bdata->free_func(bdata->data,
56 bdata->pixels);
57 bdata->pixels = bdata->alloc_func(bdata->data,
58 ee->w * ee->h * sizeof(int));
59 stride = ee->w * sizeof(int);
60 }
61
62 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
63 if (einfo)
64 {
65 if (ee->alpha)
66 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
67 else
68 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
69 einfo->info.dest_buffer = bdata->pixels;
70 einfo->info.dest_buffer_row_bytes = stride;
71 einfo->info.use_color_key = 0;
72 einfo->info.alpha_threshold = 0;
73 einfo->info.func.new_update_region = NULL;
74 einfo->info.func.free_update_region = NULL;
75 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
76 {
77 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
78 }
79 }
80 if (bdata->image)
81 evas_object_image_data_set(bdata->image, bdata->pixels);
82 if (ee->func.fn_resize) ee->func.fn_resize(ee);
83}
84
85static void
86_ecore_evas_move_resize(Ecore_Evas *ee, int x EINA_UNUSED, int y EINA_UNUSED, int w, int h)
87{
88 _ecore_evas_resize(ee, w, h);
89}
90
91static void
92_ecore_evas_show(Ecore_Evas *ee)
93{
94 Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
95
96 if (bdata->image) return;
97 if (ee->prop.focused) return;
98 ee->prop.focused = 1;
99 evas_focus_in(ee->evas);
100 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
101}
102
103static int
104_ecore_evas_buffer_render(Ecore_Evas *ee)
105{
106 Eina_List *updates = NULL, *l, *ll;
107 Ecore_Evas_Engine_Buffer_Data *bdata;
108 Ecore_Evas *ee2;
109 int rend = 0;
110
111 bdata = ee->engine.data;
112 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
113 {
114 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
115 if (ee2->engine.func->fn_render)
116 rend |= ee2->engine.func->fn_render(ee2);
117 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
118 }
119 if (bdata->image)
120 {
121 int w, h;
122
123 evas_object_image_size_get(bdata->image, &w, &h);
124 if ((w != ee->w) || (h != ee->h))
125 _ecore_evas_resize(ee, w, h);
126 bdata->pixels = evas_object_image_data_get(bdata->image, 1);
127 }
128 if (bdata->pixels)
129 {
130 updates = evas_render_updates(ee->evas);
131 }
132 if (bdata->image)
133 {
134 Eina_Rectangle *r;
135
136 evas_object_image_data_set(bdata->image, bdata->pixels);
137 EINA_LIST_FOREACH(updates, l, r)
138 evas_object_image_data_update_add(bdata->image,
139 r->x, r->y, r->w, r->h);
140 }
141 if (updates)
142 {
143 evas_render_updates_free(updates);
144 _ecore_evas_idle_timeout_update(ee);
145 }
146
147 return updates ? 1 : rend;
148}
149
150EAPI int
151ecore_evas_buffer_render(Ecore_Evas *ee)
152{
153 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, 0);
154 return _ecore_evas_buffer_render(ee);
155}
156
157// NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar!
158static void
159_ecore_evas_buffer_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y)
160{
161 Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
162 Evas_Coord xx, yy, ww, hh, fx, fy, fw, fh;
163
164 evas_object_geometry_get(bdata->image, &xx, &yy, &ww, &hh);
165 evas_object_image_fill_get(bdata->image, &fx, &fy, &fw, &fh);
166
167 if (fw < 1) fw = 1;
168 if (fh < 1) fh = 1;
169
170 if (evas_object_map_get(bdata->image) &&
171 evas_object_map_enable_get(bdata->image))
172 {
173 fx = 0; fy = 0;
174 fw = ee->w; fh = ee->h;
175 ww = ee->w; hh = ee->h;
176 }
177
178 if ((fx == 0) && (fy == 0) && (fw == ww) && (fh == hh))
179 {
180 *x = (ee->w * (*x - xx)) / fw;
181 *y = (ee->h * (*y - yy)) / fh;
182 }
183 else
184 {
185 xx = (*x - xx) - fx;
186 while (xx < 0) xx += fw;
187 while (xx > fw) xx -= fw;
188 *x = (ee->w * xx) / fw;
189
190 yy = (*y - yy) - fy;
191 while (yy < 0) yy += fh;
192 while (yy > fh) yy -= fh;
193 *y = (ee->h * yy) / fh;
194 }
195}
196
197static void
198_ecore_evas_buffer_transfer_modifiers_locks(Evas *e, Evas *e2)
199{
200 const char *mods[] =
201 { "Shift", "Control", "Alt", "Meta", "Hyper", "Super", NULL };
202 const char *locks[] =
203 { "Scroll_Lock", "Num_Lock", "Caps_Lock", NULL };
204 int i;
205
206 for (i = 0; mods[i]; i++)
207 {
208 if (evas_key_modifier_is_set(evas_key_modifier_get(e), mods[i]))
209 evas_key_modifier_on(e2, mods[i]);
210 else
211 evas_key_modifier_off(e2, mods[i]);
212 }
213 for (i = 0; locks[i]; i++)
214 {
215 if (evas_key_lock_is_set(evas_key_lock_get(e), locks[i]))
216 evas_key_lock_on(e2, locks[i]);
217 else
218 evas_key_lock_off(e2, locks[i]);
219 }
220}
221
222static void
223_ecore_evas_buffer_cb_mouse_in(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
224{
225 Ecore_Evas *ee;
226 Evas_Event_Mouse_In *ev;
227
228 ee = data;
229 ev = event_info;
230 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
231 evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL);
232}
233
234static void
235_ecore_evas_buffer_cb_mouse_out(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
236{
237 Ecore_Evas *ee;
238 Evas_Event_Mouse_Out *ev;
239
240 ee = data;
241 ev = event_info;
242 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
243 evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL);
244}
245
246static void
247_ecore_evas_buffer_cb_mouse_down(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
248{
249 Ecore_Evas *ee;
250 Evas_Event_Mouse_Down *ev;
251
252 ee = data;
253 ev = event_info;
254 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
255 evas_event_feed_mouse_down(ee->evas, ev->button, ev->flags, ev->timestamp, NULL);
256}
257
258static void
259_ecore_evas_buffer_cb_mouse_up(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
260{
261 Ecore_Evas *ee;
262 Evas_Event_Mouse_Up *ev;
263
264 ee = data;
265 ev = event_info;
266 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
267 evas_event_feed_mouse_up(ee->evas, ev->button, ev->flags, ev->timestamp, NULL);
268}
269
270static void
271_ecore_evas_buffer_cb_mouse_move(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
272{
273 Ecore_Evas *ee;
274 Evas_Event_Mouse_Move *ev;
275 Evas_Coord x, y;
276
277 ee = data;
278 ev = event_info;
279 x = ev->cur.canvas.x;
280 y = ev->cur.canvas.y;
281 _ecore_evas_buffer_coord_translate(ee, &x, &y);
282 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
283 _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp);
284}
285
286static void
287_ecore_evas_buffer_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
288{
289 Ecore_Evas *ee;
290 Evas_Event_Mouse_Wheel *ev;
291
292 ee = data;
293 ev = event_info;
294 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
295 evas_event_feed_mouse_wheel(ee->evas, ev->direction, ev->z, ev->timestamp, NULL);
296}
297
298static void
299_ecore_evas_buffer_cb_multi_down(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
300{
301 Ecore_Evas *ee;
302 Evas_Event_Multi_Down *ev;
303 Evas_Coord x, y, xx, yy;
304 double xf, yf;
305
306 ee = data;
307 ev = event_info;
308 x = ev->canvas.x;
309 y = ev->canvas.y;
310 xx = x;
311 yy = y;
312 _ecore_evas_buffer_coord_translate(ee, &x, &y);
313 xf = (ev->canvas.xsub - (double)xx) + (double)x;
314 yf = (ev->canvas.ysub - (double)yy) + (double)y;
315 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
316 evas_event_feed_multi_down(ee->evas, ev->device, x, y, ev->radius, ev->radius_x, ev->radius_y, ev->pressure, ev->angle, xf, yf, ev->flags, ev->timestamp, NULL);
317}
318
319static void
320_ecore_evas_buffer_cb_multi_up(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
321{
322 Ecore_Evas *ee;
323 Evas_Event_Multi_Up *ev;
324 Evas_Coord x, y, xx, yy;
325 double xf, yf;
326
327 ee = data;
328 ev = event_info;
329 x = ev->canvas.x;
330 y = ev->canvas.y;
331 xx = x;
332 yy = y;
333 _ecore_evas_buffer_coord_translate(ee, &x, &y);
334 xf = (ev->canvas.xsub - (double)xx) + (double)x;
335 yf = (ev->canvas.ysub - (double)yy) + (double)y;
336 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
337 evas_event_feed_multi_up(ee->evas, ev->device, x, y, ev->radius, ev->radius_x, ev->radius_y, ev->pressure, ev->angle, xf, yf, ev->flags, ev->timestamp, NULL);
338}
339
340static void
341_ecore_evas_buffer_cb_multi_move(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
342{
343 Ecore_Evas *ee;
344 Evas_Event_Multi_Move *ev;
345 Evas_Coord x, y, xx, yy;
346 double xf, yf;
347
348 ee = data;
349 ev = event_info;
350 x = ev->cur.canvas.x;
351 y = ev->cur.canvas.y;
352 xx = x;
353 yy = y;
354 _ecore_evas_buffer_coord_translate(ee, &x, &y);
355 xf = (ev->cur.canvas.xsub - (double)xx) + (double)x;
356 yf = (ev->cur.canvas.ysub - (double)yy) + (double)y;
357 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
358 evas_event_feed_multi_move(ee->evas, ev->device, x, y, ev->radius, ev->radius_x, ev->radius_y, ev->pressure, ev->angle, xf, yf, ev->timestamp, NULL);
359}
360
361static void
362_ecore_evas_buffer_cb_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
363{
364 Ecore_Evas *ee;
365
366 ee = data;
367 if (ee->driver) _ecore_evas_free(ee);
368}
369
370static void
371_ecore_evas_buffer_cb_key_down(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
372{
373 Ecore_Evas *ee;
374 Evas_Event_Key_Down *ev;
375
376 ee = data;
377 ev = event_info;
378 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
379 evas_event_feed_key_down(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL);
380}
381
382static void
383_ecore_evas_buffer_cb_key_up(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
384{
385 Ecore_Evas *ee;
386 Evas_Event_Key_Up *ev;
387
388 ee = data;
389 ev = event_info;
390 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
391 evas_event_feed_key_up(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL);
392}
393
394static void
395_ecore_evas_buffer_cb_focus_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
396{
397 Ecore_Evas *ee;
398
399 ee = data;
400 ee->prop.focused = 1;
401 evas_focus_in(ee->evas);
402 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
403}
404
405static void
406_ecore_evas_buffer_cb_focus_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
407{
408 Ecore_Evas *ee;
409
410 ee = data;
411 ee->prop.focused = 0;
412 evas_focus_out(ee->evas);
413 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
414}
415
416static void
417_ecore_evas_buffer_cb_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
418{
419 Ecore_Evas *ee;
420
421 ee = data;
422 ee->visible = 1;
423 if (ee->func.fn_show) ee->func.fn_show(ee);
424}
425
426static void
427_ecore_evas_buffer_cb_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
428{
429 Ecore_Evas *ee;
430
431 ee = data;
432 ee->visible = 0;
433 if (ee->func.fn_hide) ee->func.fn_hide(ee);
434}
435
436static void
437_ecore_evas_buffer_alpha_set(Ecore_Evas *ee, int alpha)
438{
439 Ecore_Evas_Engine_Buffer_Data *bdata = ee->engine.data;
440 if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha))) return;
441 ee->alpha = alpha;
442 if (bdata->image)
443 evas_object_image_alpha_set(bdata->image, ee->alpha);
444 else
445 {
446 Evas_Engine_Info_Buffer *einfo;
447
448 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
449 if (einfo)
450 {
451 if (ee->alpha)
452 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
453 else
454 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
455 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
456 }
457 }
458}
459
460static void
461_ecore_evas_buffer_profile_set(Ecore_Evas *ee, const char *profile)
462{
463 _ecore_evas_window_profile_free(ee);
464 ee->prop.profile.name = NULL;
465
466 if (profile)
467 {
468 ee->prop.profile.name = (char *)eina_stringshare_add(profile);
469
470 /* just change ee's state.*/
471 if (ee->func.fn_state_change)
472 ee->func.fn_state_change(ee);
473 }
474}
475
476static Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
477{
478 _ecore_evas_buffer_free,
479 NULL,
480 NULL,
481 NULL,
482 NULL,
483 NULL,
484 NULL,
485 NULL,
486 NULL,
487 NULL,
488 NULL,
489 NULL,
490 NULL,
491 NULL,
492 NULL,
493 NULL,
494 NULL,
495 _ecore_evas_resize,
496 _ecore_evas_move_resize,
497 NULL,
498 NULL,
499 _ecore_evas_show,
500 NULL,
501 NULL,
502 NULL,
503 NULL,
504 NULL,
505 NULL,
506 NULL,
507 NULL,
508 NULL,
509 NULL,
510 NULL,
511 NULL,
512 NULL,
513 NULL,
514 NULL,
515 NULL,
516 NULL,
517 NULL,
518 NULL,
519 NULL,
520 NULL,
521 NULL,
522 _ecore_evas_buffer_alpha_set,
523 NULL, //transparent
524 NULL, // profiles_set
525 _ecore_evas_buffer_profile_set,
526
527 NULL,
528 NULL,
529 NULL,
530 NULL,
531 NULL,
532 NULL,
533
534 _ecore_evas_buffer_render,
535 NULL, // screen_geometry_get
536 NULL // screen_dpi_get
537};
538
539static void *
540_ecore_evas_buffer_pix_alloc(void *data EINA_UNUSED, int size)
541{
542 return malloc(size);
543}
544
545static void
546_ecore_evas_buffer_pix_free(void *data EINA_UNUSED, void *pix)
547{
548 free(pix);
549}
550
551EAPI Ecore_Evas *
552ecore_evas_buffer_allocfunc_new(int w, int h,
553 void *(*alloc_func) (void *data, int size),
554 void (*free_func) (void *data, void *pix),
555 const void *data)
556{
557 Evas_Engine_Info_Buffer *einfo;
558 Ecore_Evas_Engine_Buffer_Data *bdata;
559 Ecore_Evas *ee;
560 int rmethod;
561
562 EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_func, NULL);
563 EINA_SAFETY_ON_NULL_RETURN_VAL(free_func, NULL);
564
565 rmethod = evas_render_method_lookup("buffer");
566 EINA_SAFETY_ON_TRUE_RETURN_VAL(rmethod == 0, NULL);
567
568 ee = calloc(1, sizeof(Ecore_Evas));
569 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, NULL);
570
571 bdata = calloc(1, sizeof(Ecore_Evas_Engine_Buffer_Data));
572 if (!bdata)
573 {
574 free(ee);
575 return NULL;
576 }
577
578 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
579
580 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func;
581 ee->engine.data = bdata;
582 bdata->alloc_func = alloc_func;
583 bdata->free_func = free_func;
584 bdata->data = (void *)data;
585
586 ee->driver = "buffer";
587
588 if (w < 1) w = 1;
589 if (h < 1) h = 1;
590 ee->rotation = 0;
591 ee->visible = 1;
592 ee->w = w;
593 ee->h = h;
594 ee->req.w = ee->w;
595 ee->req.h = ee->h;
596 ee->profile_supported = 1;
597
598 ee->prop.max.w = 0;
599 ee->prop.max.h = 0;
600 ee->prop.layer = 0;
601 ee->prop.focused = 1;
602 ee->prop.borderless = 1;
603 ee->prop.override = 1;
604 ee->prop.maximized = 1;
605 ee->prop.fullscreen = 0;
606 ee->prop.withdrawn = 0;
607 ee->prop.sticky = 0;
608
609 /* init evas here */
610 ee->evas = evas_new();
611 evas_data_attach_set(ee->evas, ee);
612 evas_output_method_set(ee->evas, rmethod);
613 evas_output_size_set(ee->evas, w, h);
614 evas_output_viewport_set(ee->evas, 0, 0, w, h);
615
616 bdata->pixels = bdata->alloc_func(bdata->data, w * h * sizeof(int));
617
618 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
619 if (einfo)
620 {
621 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
622 einfo->info.dest_buffer = bdata->pixels;
623 einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int);
624 einfo->info.use_color_key = 0;
625 einfo->info.alpha_threshold = 0;
626 einfo->info.func.new_update_region = NULL;
627 einfo->info.func.free_update_region = NULL;
628 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
629 {
630 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
631 ecore_evas_free(ee);
632 return NULL;
633 }
634 }
635 else
636 {
637 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
638 ecore_evas_free(ee);
639 return NULL;
640 }
641 evas_key_modifier_add(ee->evas, "Shift");
642 evas_key_modifier_add(ee->evas, "Control");
643 evas_key_modifier_add(ee->evas, "Alt");
644 evas_key_modifier_add(ee->evas, "Meta");
645 evas_key_modifier_add(ee->evas, "Hyper");
646 evas_key_modifier_add(ee->evas, "Super");
647 evas_key_lock_add(ee->evas, "Caps_Lock");
648 evas_key_lock_add(ee->evas, "Num_Lock");
649 evas_key_lock_add(ee->evas, "Scroll_Lock");
650
651 evas_event_feed_mouse_in(ee->evas, 0, NULL);
652
653 _ecore_evas_register(ee);
654
655 evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
656
657 return ee;
658}
659
660EAPI Ecore_Evas *
661ecore_evas_buffer_new(int w, int h)
662{
663 return ecore_evas_buffer_allocfunc_new
664 (w, h, _ecore_evas_buffer_pix_alloc, _ecore_evas_buffer_pix_free, NULL);
665}
666
667EAPI const void *
668ecore_evas_buffer_pixels_get(Ecore_Evas *ee)
669{
670 Ecore_Evas_Engine_Buffer_Data *bdata;
671
672 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, NULL);
673
674 bdata = ee->engine.data;
675 _ecore_evas_buffer_render(ee);
676 return bdata->pixels;
677}
678
679EAPI Evas_Object *
680ecore_evas_object_image_new(Ecore_Evas *ee_target)
681{
682 Evas_Object *o;
683 Ecore_Evas_Engine_Buffer_Data *bdata;
684 Evas_Engine_Info_Buffer *einfo;
685 Ecore_Evas *ee;
686 int rmethod;
687 int w = 1, h = 1;
688
689 EINA_SAFETY_ON_NULL_RETURN_VAL(ee_target, NULL);
690
691 rmethod = evas_render_method_lookup("buffer");
692 EINA_SAFETY_ON_TRUE_RETURN_VAL(rmethod == 0, NULL);
693
694 ee = calloc(1, sizeof(Ecore_Evas));
695 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, NULL);
696
697 bdata = calloc(1, sizeof(Ecore_Evas_Engine_Buffer_Data));
698 if (!bdata)
699 {
700 free(ee);
701 return NULL;
702 }
703
704 ee->engine.data = bdata;
705
706 o = evas_object_image_add(ee_target->evas);
707 evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
708 evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888);
709 evas_object_image_alpha_set(o, 0);
710 evas_object_image_size_set(o, w, h);
711
712 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
713
714 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func;
715
716 ee->driver = "buffer";
717
718 ee->rotation = 0;
719 ee->visible = 0;
720 ee->w = w;
721 ee->h = h;
722 ee->req.w = ee->w;
723 ee->req.h = ee->h;
724 ee->profile_supported = 1;
725
726 ee->prop.max.w = 0;
727 ee->prop.max.h = 0;
728 ee->prop.layer = 0;
729 ee->prop.focused = 0;
730 ee->prop.borderless = 1;
731 ee->prop.override = 1;
732 ee->prop.maximized = 0;
733 ee->prop.fullscreen = 0;
734 ee->prop.withdrawn = 0;
735 ee->prop.sticky = 0;
736
737 /* init evas here */
738 ee->evas = evas_new();
739 evas_data_attach_set(ee->evas, ee);
740 evas_output_method_set(ee->evas, rmethod);
741 evas_output_size_set(ee->evas, w, h);
742 evas_output_viewport_set(ee->evas, 0, 0, w, h);
743
744 bdata->image = o;
745 evas_object_data_set(bdata->image, "Ecore_Evas", ee);
746 evas_object_data_set(bdata->image, "Ecore_Evas_Parent", ee_target);
747 evas_object_event_callback_add(bdata->image,
748 EVAS_CALLBACK_MOUSE_IN,
749 _ecore_evas_buffer_cb_mouse_in, ee);
750 evas_object_event_callback_add(bdata->image,
751 EVAS_CALLBACK_MOUSE_OUT,
752 _ecore_evas_buffer_cb_mouse_out, ee);
753 evas_object_event_callback_add(bdata->image,
754 EVAS_CALLBACK_MOUSE_DOWN,
755 _ecore_evas_buffer_cb_mouse_down, ee);
756 evas_object_event_callback_add(bdata->image,
757 EVAS_CALLBACK_MOUSE_UP,
758 _ecore_evas_buffer_cb_mouse_up, ee);
759 evas_object_event_callback_add(bdata->image,
760 EVAS_CALLBACK_MOUSE_MOVE,
761 _ecore_evas_buffer_cb_mouse_move, ee);
762 evas_object_event_callback_add(bdata->image,
763 EVAS_CALLBACK_MOUSE_WHEEL,
764 _ecore_evas_buffer_cb_mouse_wheel, ee);
765 evas_object_event_callback_add(bdata->image,
766 EVAS_CALLBACK_MULTI_DOWN,
767 _ecore_evas_buffer_cb_multi_down, ee);
768 evas_object_event_callback_add(bdata->image,
769 EVAS_CALLBACK_MULTI_UP,
770 _ecore_evas_buffer_cb_multi_up, ee);
771 evas_object_event_callback_add(bdata->image,
772 EVAS_CALLBACK_MULTI_MOVE,
773 _ecore_evas_buffer_cb_multi_move, ee);
774 evas_object_event_callback_add(bdata->image,
775 EVAS_CALLBACK_FREE,
776 _ecore_evas_buffer_cb_free, ee);
777 evas_object_event_callback_add(bdata->image,
778 EVAS_CALLBACK_KEY_DOWN,
779 _ecore_evas_buffer_cb_key_down, ee);
780 evas_object_event_callback_add(bdata->image,
781 EVAS_CALLBACK_KEY_UP,
782 _ecore_evas_buffer_cb_key_up, ee);
783 evas_object_event_callback_add(bdata->image,
784 EVAS_CALLBACK_FOCUS_IN,
785 _ecore_evas_buffer_cb_focus_in, ee);
786 evas_object_event_callback_add(bdata->image,
787 EVAS_CALLBACK_FOCUS_OUT,
788 _ecore_evas_buffer_cb_focus_out, ee);
789 evas_object_event_callback_add(bdata->image,
790 EVAS_CALLBACK_SHOW,
791 _ecore_evas_buffer_cb_show, ee);
792 evas_object_event_callback_add(bdata->image,
793 EVAS_CALLBACK_HIDE,
794 _ecore_evas_buffer_cb_hide, ee);
795 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
796 if (einfo)
797 {
798 bdata->pixels = evas_object_image_data_get(o, 1);
799 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
800 einfo->info.dest_buffer = bdata->pixels;
801 einfo->info.dest_buffer_row_bytes = evas_object_image_stride_get(o);
802 einfo->info.use_color_key = 0;
803 einfo->info.alpha_threshold = 0;
804 einfo->info.func.new_update_region = NULL;
805 einfo->info.func.free_update_region = NULL;
806 evas_object_image_data_set(o, bdata->pixels);
807 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
808 {
809 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
810 ecore_evas_free(ee);
811 return NULL;
812 }
813 }
814 else
815 {
816 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
817 ecore_evas_free(ee);
818 return NULL;
819 }
820 evas_key_modifier_add(ee->evas, "Shift");
821 evas_key_modifier_add(ee->evas, "Control");
822 evas_key_modifier_add(ee->evas, "Alt");
823 evas_key_modifier_add(ee->evas, "Meta");
824 evas_key_modifier_add(ee->evas, "Hyper");
825 evas_key_modifier_add(ee->evas, "Super");
826 evas_key_lock_add(ee->evas, "Caps_Lock");
827 evas_key_lock_add(ee->evas, "Num_Lock");
828 evas_key_lock_add(ee->evas, "Scroll_Lock");
829
830 ee_target->sub_ecore_evas = eina_list_append(ee_target->sub_ecore_evas, ee);
831
832 return o;
833}
diff --git a/src/lib/ecore_evas/ecore_evas_buffer.h b/src/lib/ecore_evas/ecore_evas_buffer.h
new file mode 100644
index 0000000000..06f82f9fea
--- /dev/null
+++ b/src/lib/ecore_evas/ecore_evas_buffer.h
@@ -0,0 +1,24 @@
1#ifndef _ECORE_EVAS_BUFFER_PRIVATE_H_
2#define _ECORE_EVAS_BUFFER_PRIVATE_H_
3
4#include <stdlib.h>
5
6#include <Ecore.h>
7#include "ecore_private.h"
8#include <Ecore_Input.h>
9
10#include "ecore_evas_private.h"
11#include "Ecore_Evas.h"
12
13
14typedef struct _Ecore_Evas_Engine_Buffer_Data Ecore_Evas_Engine_Buffer_Data;
15
16struct _Ecore_Evas_Engine_Buffer_Data {
17 void *pixels;
18 Evas_Object *image;
19 void (*free_func) (void *data, void *pix);
20 void *(*alloc_func) (void *data, int size);
21 void *data;
22};
23
24#endif /* _ECORE_EVAS_BUFFER_PRIVATE_H_ */
diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h
index 18d4ce275d..612f7eaeba 100644
--- a/src/lib/ecore_evas/ecore_evas_private.h
+++ b/src/lib/ecore_evas/ecore_evas_private.h
@@ -57,7 +57,6 @@ typedef struct _Ecore_Evas_Engine_Func Ecore_Evas_Engine_Func;
57typedef struct _Ecore_Evas_Interface Ecore_Evas_Interface; 57typedef struct _Ecore_Evas_Interface Ecore_Evas_Interface;
58 58
59/* Engines interfaces */ 59/* Engines interfaces */
60typedef struct _Ecore_Evas_Interface_Buffer Ecore_Evas_Interface_Buffer;
61typedef struct _Ecore_Evas_Interface_Extn Ecore_Evas_Interface_Extn; 60typedef struct _Ecore_Evas_Interface_Extn Ecore_Evas_Interface_Extn;
62typedef struct _Ecore_Evas_Interface_X11 Ecore_Evas_Interface_X11; 61typedef struct _Ecore_Evas_Interface_X11 Ecore_Evas_Interface_X11;
63typedef struct _Ecore_Evas_Interface_Software_X11 Ecore_Evas_Interface_Software_X11; 62typedef struct _Ecore_Evas_Interface_Software_X11 Ecore_Evas_Interface_Software_X11;
@@ -136,13 +135,6 @@ struct _Ecore_Evas_Interface
136 unsigned int version; 135 unsigned int version;
137}; 136};
138 137
139struct _Ecore_Evas_Interface_Buffer {
140 Ecore_Evas_Interface base;
141
142 const void* (*pixels_get)(Ecore_Evas *ee);
143 int (*render)(Ecore_Evas *ee);
144};
145
146struct _Ecore_Evas_Interface_X11 { 138struct _Ecore_Evas_Interface_X11 {
147 Ecore_Evas_Interface base; 139 Ecore_Evas_Interface base;
148 140