summaryrefslogtreecommitdiff
path: root/src/lib/ecore_evas/ecore_evas_buffer.c
diff options
context:
space:
mode:
authorFlavio Vinicius Alvares Ceolin <flavio.ceolin@profusion.mobi>2012-12-05 21:15:42 +0000
committerFlavio Vinicius Alvares Ceolin <flavio.ceolin@profusion.mobi>2012-12-05 21:15:42 +0000
commitad7579c1294222d0647673499f062b137d30d270 (patch)
tree9c2c8e693ee3e74ff3d9a05ef69a0645a541533a /src/lib/ecore_evas/ecore_evas_buffer.c
parent8783eb70bbaea0a87f7fd4d41d6b062adecf5f67 (diff)
ecore_evas: Make the engines loadable modules
Implementing support for loadables modules. It makes the engines been loaded when they are needed. It not breakes the api, so each engine still has its own api. The implementation basically is: * Functions that creates Ecore_Evas, for example ecore_evas_software_x11_new, request to load its module and then get the module's function to create the Ecore_Evas. * The other functions such as \(.*\)_window_get from the Ecore_Evas its interface and then call the appropriate method. * As there is no unified interface to communicate with the engines (not break api problem), all interfaces were declared in ecore_evas_private.h * Now the data necessary for each module is not declared in the Ecore_Evas_Engine structure, instead of this, the struct has a void pointer that is used by the modules. * In this first moment engines as software_x11 and gl_x11 were put together in the same module, but obviously exporting all the things necessary. SVN revision: 80280
Diffstat (limited to 'src/lib/ecore_evas/ecore_evas_buffer.c')
-rw-r--r--src/lib/ecore_evas/ecore_evas_buffer.c855
1 files changed, 0 insertions, 855 deletions
diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c b/src/lib/ecore_evas/ecore_evas_buffer.c
deleted file mode 100644
index 8dcd71442e..0000000000
--- a/src/lib/ecore_evas/ecore_evas_buffer.c
+++ /dev/null
@@ -1,855 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5// NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar!
6#include <stdlib.h>
7
8#include <Ecore.h>
9#include "ecore_private.h"
10#include <Ecore_Input.h>
11
12#include "ecore_evas_private.h"
13#include "Ecore_Evas.h"
14
15#ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
16static int _ecore_evas_init_count = 0;
17
18static int
19_ecore_evas_buffer_init(void)
20{
21 _ecore_evas_init_count++;
22 return _ecore_evas_init_count;
23}
24
25static void
26_ecore_evas_buffer_free(Ecore_Evas *ee)
27{
28 if (ee->engine.buffer.image)
29 {
30 Ecore_Evas *ee2;
31
32 ee2 = evas_object_data_get(ee->engine.buffer.image, "Ecore_Evas_Parent");
33 evas_object_del(ee->engine.buffer.image);
34 ee2->sub_ecore_evas = eina_list_remove(ee2->sub_ecore_evas, ee);
35 }
36 else
37 {
38 ee->engine.buffer.free_func(ee->engine.buffer.data,
39 ee->engine.buffer.pixels);
40 }
41 _ecore_evas_buffer_shutdown();
42}
43
44static void
45_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
46{
47 Evas_Engine_Info_Buffer *einfo;
48 int stride = 0;
49
50 if (w < 1) w = 1;
51 if (h < 1) h = 1;
52 ee->req.w = w;
53 ee->req.h = h;
54 if ((w == ee->w) && (h == ee->h)) return;
55 ee->w = w;
56 ee->h = h;
57 evas_output_size_set(ee->evas, ee->w, ee->h);
58 evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
59 evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
60
61 if (ee->engine.buffer.image)
62 {
63 ee->engine.buffer.pixels = evas_object_image_data_get(ee->engine.buffer.image, 1);
64 stride = evas_object_image_stride_get(ee->engine.buffer.image);
65 }
66 else
67 {
68 if (ee->engine.buffer.pixels)
69 ee->engine.buffer.free_func(ee->engine.buffer.data,
70 ee->engine.buffer.pixels);
71 ee->engine.buffer.pixels =
72 ee->engine.buffer.alloc_func(ee->engine.buffer.data,
73 ee->w * ee->h * sizeof(int));
74 stride = ee->w * sizeof(int);
75 }
76
77 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
78 if (einfo)
79 {
80 if (ee->alpha)
81 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
82 else
83 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
84 einfo->info.dest_buffer = ee->engine.buffer.pixels;
85 einfo->info.dest_buffer_row_bytes = stride;
86 einfo->info.use_color_key = 0;
87 einfo->info.alpha_threshold = 0;
88 einfo->info.func.new_update_region = NULL;
89 einfo->info.func.free_update_region = NULL;
90 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
91 {
92 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
93 }
94 }
95 if (ee->engine.buffer.image)
96 evas_object_image_data_set(ee->engine.buffer.image, ee->engine.buffer.pixels);
97 if (ee->func.fn_resize) ee->func.fn_resize(ee);
98}
99
100static void
101_ecore_evas_move_resize(Ecore_Evas *ee, int x EINA_UNUSED, int y EINA_UNUSED, int w, int h)
102{
103 _ecore_evas_resize(ee, w, h);
104}
105
106int
107_ecore_evas_buffer_shutdown(void)
108{
109 _ecore_evas_init_count--;
110 if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
111 return _ecore_evas_init_count;
112}
113
114static void
115_ecore_evas_show(Ecore_Evas *ee)
116{
117 if (ee->engine.buffer.image) return;
118 if (ee->prop.focused) return;
119 ee->prop.focused = 1;
120 evas_focus_in(ee->evas);
121 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
122}
123
124int
125_ecore_evas_buffer_render(Ecore_Evas *ee)
126{
127 Eina_List *updates = NULL, *l, *ll;
128 Ecore_Evas *ee2;
129 int rend = 0;
130
131 EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
132 {
133 if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
134 if (ee2->engine.func->fn_render)
135 rend |= ee2->engine.func->fn_render(ee2);
136 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
137 }
138 if (ee->engine.buffer.image)
139 {
140 int w, h;
141
142 evas_object_image_size_get(ee->engine.buffer.image, &w, &h);
143 if ((w != ee->w) || (h != ee->h))
144 _ecore_evas_resize(ee, w, h);
145 ee->engine.buffer.pixels = evas_object_image_data_get(ee->engine.buffer.image, 1);
146 }
147 if (ee->engine.buffer.pixels)
148 {
149 updates = evas_render_updates(ee->evas);
150 }
151 if (ee->engine.buffer.image)
152 {
153 Eina_Rectangle *r;
154
155 evas_object_image_data_set(ee->engine.buffer.image, ee->engine.buffer.pixels);
156 EINA_LIST_FOREACH(updates, l, r)
157 evas_object_image_data_update_add(ee->engine.buffer.image,
158 r->x, r->y, r->w, r->h);
159 }
160 if (updates)
161 {
162 evas_render_updates_free(updates);
163 _ecore_evas_idle_timeout_update(ee);
164 }
165
166 return updates ? 1 : rend;
167}
168
169// NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar!
170static void
171_ecore_evas_buffer_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y)
172{
173 Evas_Coord xx, yy, ww, hh, fx, fy, fw, fh;
174
175 evas_object_geometry_get(ee->engine.buffer.image, &xx, &yy, &ww, &hh);
176 evas_object_image_fill_get(ee->engine.buffer.image, &fx, &fy, &fw, &fh);
177
178 if (fw < 1) fw = 1;
179 if (fh < 1) fh = 1;
180
181 if (evas_object_map_get(ee->engine.buffer.image) &&
182 evas_object_map_enable_get(ee->engine.buffer.image))
183 {
184 fx = 0; fy = 0;
185 fw = ee->w; fh = ee->h;
186 ww = ee->w; hh = ee->h;
187 }
188
189 if ((fx == 0) && (fy == 0) && (fw == ww) && (fh == hh))
190 {
191 *x = (ee->w * (*x - xx)) / fw;
192 *y = (ee->h * (*y - yy)) / fh;
193 }
194 else
195 {
196 xx = (*x - xx) - fx;
197 while (xx < 0) xx += fw;
198 while (xx > fw) xx -= fw;
199 *x = (ee->w * xx) / fw;
200
201 yy = (*y - yy) - fy;
202 while (yy < 0) yy += fh;
203 while (yy > fh) yy -= fh;
204 *y = (ee->h * yy) / fh;
205 }
206}
207
208static void
209_ecore_evas_buffer_transfer_modifiers_locks(Evas *e, Evas *e2)
210{
211 const char *mods[] =
212 { "Shift", "Control", "Alt", "Meta", "Hyper", "Super", NULL };
213 const char *locks[] =
214 { "Scroll_Lock", "Num_Lock", "Caps_Lock", NULL };
215 int i;
216
217 for (i = 0; mods[i]; i++)
218 {
219 if (evas_key_modifier_is_set(evas_key_modifier_get(e), mods[i]))
220 evas_key_modifier_on(e2, mods[i]);
221 else
222 evas_key_modifier_off(e2, mods[i]);
223 }
224 for (i = 0; locks[i]; i++)
225 {
226 if (evas_key_lock_is_set(evas_key_lock_get(e), locks[i]))
227 evas_key_lock_on(e2, locks[i]);
228 else
229 evas_key_lock_off(e2, locks[i]);
230 }
231}
232
233static void
234_ecore_evas_buffer_cb_mouse_in(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
235{
236 Ecore_Evas *ee;
237 Evas_Event_Mouse_In *ev;
238
239 ee = data;
240 ev = event_info;
241 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
242 evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL);
243}
244
245static void
246_ecore_evas_buffer_cb_mouse_out(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
247{
248 Ecore_Evas *ee;
249 Evas_Event_Mouse_Out *ev;
250
251 ee = data;
252 ev = event_info;
253 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
254 evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL);
255}
256
257static void
258_ecore_evas_buffer_cb_mouse_down(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
259{
260 Ecore_Evas *ee;
261 Evas_Event_Mouse_Down *ev;
262
263 ee = data;
264 ev = event_info;
265 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
266 evas_event_feed_mouse_down(ee->evas, ev->button, ev->flags, ev->timestamp, NULL);
267}
268
269static void
270_ecore_evas_buffer_cb_mouse_up(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
271{
272 Ecore_Evas *ee;
273 Evas_Event_Mouse_Up *ev;
274
275 ee = data;
276 ev = event_info;
277 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
278 evas_event_feed_mouse_up(ee->evas, ev->button, ev->flags, ev->timestamp, NULL);
279}
280
281static void
282_ecore_evas_buffer_cb_mouse_move(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
283{
284 Ecore_Evas *ee;
285 Evas_Event_Mouse_Move *ev;
286 Evas_Coord x, y;
287
288 ee = data;
289 ev = event_info;
290 x = ev->cur.canvas.x;
291 y = ev->cur.canvas.y;
292 _ecore_evas_buffer_coord_translate(ee, &x, &y);
293 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
294 _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp);
295}
296
297static void
298_ecore_evas_buffer_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
299{
300 Ecore_Evas *ee;
301 Evas_Event_Mouse_Wheel *ev;
302
303 ee = data;
304 ev = event_info;
305 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
306 evas_event_feed_mouse_wheel(ee->evas, ev->direction, ev->z, ev->timestamp, NULL);
307}
308
309static void
310_ecore_evas_buffer_cb_multi_down(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
311{
312 Ecore_Evas *ee;
313 Evas_Event_Multi_Down *ev;
314 Evas_Coord x, y, xx, yy;
315 double xf, yf;
316
317 ee = data;
318 ev = event_info;
319 x = ev->canvas.x;
320 y = ev->canvas.y;
321 xx = x;
322 yy = y;
323 _ecore_evas_buffer_coord_translate(ee, &x, &y);
324 xf = (ev->canvas.xsub - (double)xx) + (double)x;
325 yf = (ev->canvas.ysub - (double)yy) + (double)y;
326 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
327 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);
328}
329
330static void
331_ecore_evas_buffer_cb_multi_up(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
332{
333 Ecore_Evas *ee;
334 Evas_Event_Multi_Up *ev;
335 Evas_Coord x, y, xx, yy;
336 double xf, yf;
337
338 ee = data;
339 ev = event_info;
340 x = ev->canvas.x;
341 y = ev->canvas.y;
342 xx = x;
343 yy = y;
344 _ecore_evas_buffer_coord_translate(ee, &x, &y);
345 xf = (ev->canvas.xsub - (double)xx) + (double)x;
346 yf = (ev->canvas.ysub - (double)yy) + (double)y;
347 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
348 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);
349}
350
351static void
352_ecore_evas_buffer_cb_multi_move(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
353{
354 Ecore_Evas *ee;
355 Evas_Event_Multi_Move *ev;
356 Evas_Coord x, y, xx, yy;
357 double xf, yf;
358
359 ee = data;
360 ev = event_info;
361 x = ev->cur.canvas.x;
362 y = ev->cur.canvas.y;
363 xx = x;
364 yy = y;
365 _ecore_evas_buffer_coord_translate(ee, &x, &y);
366 xf = (ev->cur.canvas.xsub - (double)xx) + (double)x;
367 yf = (ev->cur.canvas.ysub - (double)yy) + (double)y;
368 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
369 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);
370}
371
372static void
373_ecore_evas_buffer_cb_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
374{
375 Ecore_Evas *ee;
376
377 ee = data;
378 if (ee->driver) _ecore_evas_free(ee);
379}
380
381static void
382_ecore_evas_buffer_cb_key_down(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
383{
384 Ecore_Evas *ee;
385 Evas_Event_Key_Down *ev;
386
387 ee = data;
388 ev = event_info;
389 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
390 evas_event_feed_key_down(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL);
391}
392
393static void
394_ecore_evas_buffer_cb_key_up(void *data, Evas *e, Evas_Object *obj EINA_UNUSED, void *event_info)
395{
396 Ecore_Evas *ee;
397 Evas_Event_Key_Up *ev;
398
399 ee = data;
400 ev = event_info;
401 _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas);
402 evas_event_feed_key_up(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL);
403}
404
405static void
406_ecore_evas_buffer_cb_focus_in(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 = 1;
412 evas_focus_in(ee->evas);
413 if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
414}
415
416static void
417_ecore_evas_buffer_cb_focus_out(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->prop.focused = 0;
423 evas_focus_out(ee->evas);
424 if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
425}
426
427static void
428_ecore_evas_buffer_cb_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
429{
430 Ecore_Evas *ee;
431
432 ee = data;
433 ee->visible = 1;
434 if (ee->func.fn_show) ee->func.fn_show(ee);
435}
436
437static void
438_ecore_evas_buffer_cb_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
439{
440 Ecore_Evas *ee;
441
442 ee = data;
443 ee->visible = 0;
444 if (ee->func.fn_hide) ee->func.fn_hide(ee);
445}
446
447static void
448_ecore_evas_buffer_alpha_set(Ecore_Evas *ee, int alpha)
449{
450 if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha))) return;
451 ee->alpha = alpha;
452 if (ee->engine.buffer.image)
453 evas_object_image_alpha_set(ee->engine.buffer.image, ee->alpha);
454 else
455 {
456 Evas_Engine_Info_Buffer *einfo;
457
458 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
459 if (einfo)
460 {
461 if (ee->alpha)
462 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
463 else
464 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
465 evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
466 }
467 }
468}
469
470static void
471_ecore_evas_buffer_profile_set(Ecore_Evas *ee, const char *profile)
472{
473 _ecore_evas_window_profile_free(ee);
474 ee->prop.profile.name = NULL;
475
476 if (profile)
477 {
478 ee->prop.profile.name = (char *)eina_stringshare_add(profile);
479
480 /* just change ee's state.*/
481 if (ee->func.fn_state_change)
482 ee->func.fn_state_change(ee);
483 }
484}
485
486static Ecore_Evas_Engine_Func _ecore_buffer_engine_func =
487{
488 _ecore_evas_buffer_free,
489 NULL,
490 NULL,
491 NULL,
492 NULL,
493 NULL,
494 NULL,
495 NULL,
496 NULL,
497 NULL,
498 NULL,
499 NULL,
500 NULL,
501 NULL,
502 NULL,
503 NULL,
504 NULL,
505 _ecore_evas_resize,
506 _ecore_evas_move_resize,
507 NULL,
508 NULL,
509 _ecore_evas_show,
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 NULL,
523 NULL,
524 NULL,
525 NULL,
526 NULL,
527 NULL,
528 NULL,
529 NULL,
530 NULL,
531 NULL,
532 _ecore_evas_buffer_alpha_set,
533 NULL, //transparent
534 NULL, // profiles_set
535 _ecore_evas_buffer_profile_set,
536
537 NULL,
538 NULL,
539 NULL,
540 NULL,
541 NULL,
542 NULL,
543
544 _ecore_evas_buffer_render,
545 NULL, // screen_geometry_get
546 NULL // screen_dpi_get
547};
548#endif
549
550static void *
551_ecore_evas_buffer_pix_alloc(void *data EINA_UNUSED, int size)
552{
553 return malloc(size);
554}
555
556static void
557_ecore_evas_buffer_pix_free(void *data EINA_UNUSED, void *pix)
558{
559 free(pix);
560}
561
562EAPI Ecore_Evas *
563ecore_evas_buffer_new(int w, int h)
564{
565 return ecore_evas_buffer_allocfunc_new
566 (w, h, _ecore_evas_buffer_pix_alloc, _ecore_evas_buffer_pix_free, NULL);
567}
568
569EAPI Ecore_Evas *
570ecore_evas_buffer_allocfunc_new(int w, int h, void *(*alloc_func) (void *data, int size), void (*free_func) (void *data, void *pix), const void *data)
571{
572// NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar!
573#ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
574 Evas_Engine_Info_Buffer *einfo;
575 Ecore_Evas *ee;
576 int rmethod;
577
578 if ((!alloc_func) || (!free_func)) return NULL;
579 rmethod = evas_render_method_lookup("buffer");
580 if (!rmethod) return NULL;
581 ee = calloc(1, sizeof(Ecore_Evas));
582 if (!ee) return NULL;
583
584 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
585
586 _ecore_evas_buffer_init();
587
588 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func;
589 ee->engine.buffer.alloc_func = alloc_func;
590 ee->engine.buffer.free_func = free_func;
591 ee->engine.buffer.data = (void *)data;
592
593 ee->driver = "buffer";
594
595 if (w < 1) w = 1;
596 if (h < 1) h = 1;
597 ee->rotation = 0;
598 ee->visible = 1;
599 ee->w = w;
600 ee->h = h;
601 ee->req.w = ee->w;
602 ee->req.h = ee->h;
603 ee->profile_supported = 1;
604
605 ee->prop.max.w = 0;
606 ee->prop.max.h = 0;
607 ee->prop.layer = 0;
608 ee->prop.focused = 1;
609 ee->prop.borderless = 1;
610 ee->prop.override = 1;
611 ee->prop.maximized = 1;
612 ee->prop.fullscreen = 0;
613 ee->prop.withdrawn = 0;
614 ee->prop.sticky = 0;
615
616 /* init evas here */
617 ee->evas = evas_new();
618 evas_data_attach_set(ee->evas, ee);
619 evas_output_method_set(ee->evas, rmethod);
620 evas_output_size_set(ee->evas, w, h);
621 evas_output_viewport_set(ee->evas, 0, 0, w, h);
622
623 ee->engine.buffer.pixels =
624 ee->engine.buffer.alloc_func
625 (ee->engine.buffer.data, w * h * sizeof(int));
626
627 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
628 if (einfo)
629 {
630 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
631 einfo->info.dest_buffer = ee->engine.buffer.pixels;
632 einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int);
633 einfo->info.use_color_key = 0;
634 einfo->info.alpha_threshold = 0;
635 einfo->info.func.new_update_region = NULL;
636 einfo->info.func.free_update_region = NULL;
637 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
638 {
639 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
640 ecore_evas_free(ee);
641 return NULL;
642 }
643 }
644 else
645 {
646 ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
647 ecore_evas_free(ee);
648 return NULL;
649 }
650 evas_key_modifier_add(ee->evas, "Shift");
651 evas_key_modifier_add(ee->evas, "Control");
652 evas_key_modifier_add(ee->evas, "Alt");
653 evas_key_modifier_add(ee->evas, "Meta");
654 evas_key_modifier_add(ee->evas, "Hyper");
655 evas_key_modifier_add(ee->evas, "Super");
656 evas_key_lock_add(ee->evas, "Caps_Lock");
657 evas_key_lock_add(ee->evas, "Num_Lock");
658 evas_key_lock_add(ee->evas, "Scroll_Lock");
659
660 evas_event_feed_mouse_in(ee->evas, 0, NULL);
661
662 _ecore_evas_register(ee);
663
664 evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
665
666 return ee;
667#else
668 return NULL;
669#endif
670}
671
672EAPI const void *
673ecore_evas_buffer_pixels_get(Ecore_Evas *ee)
674{
675#ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
676 if (!ee)
677 {
678 CRIT("Ecore_Evas is missing");
679 return NULL;
680 }
681 _ecore_evas_buffer_render(ee);
682 return ee->engine.buffer.pixels;
683#else
684 return NULL;
685#endif
686}
687
688EAPI Evas *
689ecore_evas_object_evas_get(Evas_Object *obj)
690{
691 Ecore_Evas *ee;
692
693 ee = evas_object_data_get(obj, "Ecore_Evas");
694 if (!ee) return NULL;
695
696 return ecore_evas_get(ee);
697}
698
699EAPI Ecore_Evas *
700ecore_evas_object_ecore_evas_get(Evas_Object *obj)
701{
702 return evas_object_data_get(obj, "Ecore_Evas");
703}
704
705EAPI Evas_Object *
706ecore_evas_object_image_new(Ecore_Evas *ee_target)
707{
708// NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar!
709#ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
710 Evas_Object *o;
711 Evas_Engine_Info_Buffer *einfo;
712 Ecore_Evas *ee;
713 int rmethod;
714 int w = 1, h = 1;
715
716 if (!ee_target) return NULL;
717
718 rmethod = evas_render_method_lookup("buffer");
719 if (!rmethod) return NULL;
720 ee = calloc(1, sizeof(Ecore_Evas));
721 if (!ee) return NULL;
722
723 o = evas_object_image_add(ee_target->evas);
724 evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
725 evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888);
726 evas_object_image_alpha_set(o, 0);
727 evas_object_image_size_set(o, w, h);
728
729 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
730
731 _ecore_evas_buffer_init();
732
733 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func;
734
735 ee->driver = "buffer";
736
737 ee->rotation = 0;
738 ee->visible = 0;
739 ee->w = w;
740 ee->h = h;
741 ee->req.w = ee->w;
742 ee->req.h = ee->h;
743 ee->profile_supported = 1;
744
745 ee->prop.max.w = 0;
746 ee->prop.max.h = 0;
747 ee->prop.layer = 0;
748 ee->prop.focused = 0;
749 ee->prop.borderless = 1;
750 ee->prop.override = 1;
751 ee->prop.maximized = 0;
752 ee->prop.fullscreen = 0;
753 ee->prop.withdrawn = 0;
754 ee->prop.sticky = 0;
755
756 /* init evas here */
757 ee->evas = evas_new();
758 evas_data_attach_set(ee->evas, ee);
759 evas_output_method_set(ee->evas, rmethod);
760 evas_output_size_set(ee->evas, w, h);
761 evas_output_viewport_set(ee->evas, 0, 0, w, h);
762
763 ee->engine.buffer.image = o;
764 evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas", ee);
765 evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas_Parent", ee_target);
766 evas_object_event_callback_add(ee->engine.buffer.image,
767 EVAS_CALLBACK_MOUSE_IN,
768 _ecore_evas_buffer_cb_mouse_in, ee);
769 evas_object_event_callback_add(ee->engine.buffer.image,
770 EVAS_CALLBACK_MOUSE_OUT,
771 _ecore_evas_buffer_cb_mouse_out, ee);
772 evas_object_event_callback_add(ee->engine.buffer.image,
773 EVAS_CALLBACK_MOUSE_DOWN,
774 _ecore_evas_buffer_cb_mouse_down, ee);
775 evas_object_event_callback_add(ee->engine.buffer.image,
776 EVAS_CALLBACK_MOUSE_UP,
777 _ecore_evas_buffer_cb_mouse_up, ee);
778 evas_object_event_callback_add(ee->engine.buffer.image,
779 EVAS_CALLBACK_MOUSE_MOVE,
780 _ecore_evas_buffer_cb_mouse_move, ee);
781 evas_object_event_callback_add(ee->engine.buffer.image,
782 EVAS_CALLBACK_MOUSE_WHEEL,
783 _ecore_evas_buffer_cb_mouse_wheel, ee);
784 evas_object_event_callback_add(ee->engine.buffer.image,
785 EVAS_CALLBACK_MULTI_DOWN,
786 _ecore_evas_buffer_cb_multi_down, ee);
787 evas_object_event_callback_add(ee->engine.buffer.image,
788 EVAS_CALLBACK_MULTI_UP,
789 _ecore_evas_buffer_cb_multi_up, ee);
790 evas_object_event_callback_add(ee->engine.buffer.image,
791 EVAS_CALLBACK_MULTI_MOVE,
792 _ecore_evas_buffer_cb_multi_move, ee);
793 evas_object_event_callback_add(ee->engine.buffer.image,
794 EVAS_CALLBACK_FREE,
795 _ecore_evas_buffer_cb_free, ee);
796 evas_object_event_callback_add(ee->engine.buffer.image,
797 EVAS_CALLBACK_KEY_DOWN,
798 _ecore_evas_buffer_cb_key_down, ee);
799 evas_object_event_callback_add(ee->engine.buffer.image,
800 EVAS_CALLBACK_KEY_UP,
801 _ecore_evas_buffer_cb_key_up, ee);
802 evas_object_event_callback_add(ee->engine.buffer.image,
803 EVAS_CALLBACK_FOCUS_IN,
804 _ecore_evas_buffer_cb_focus_in, ee);
805 evas_object_event_callback_add(ee->engine.buffer.image,
806 EVAS_CALLBACK_FOCUS_OUT,
807 _ecore_evas_buffer_cb_focus_out, ee);
808 evas_object_event_callback_add(ee->engine.buffer.image,
809 EVAS_CALLBACK_SHOW,
810 _ecore_evas_buffer_cb_show, ee);
811 evas_object_event_callback_add(ee->engine.buffer.image,
812 EVAS_CALLBACK_HIDE,
813 _ecore_evas_buffer_cb_hide, ee);
814 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas);
815 if (einfo)
816 {
817 ee->engine.buffer.pixels = evas_object_image_data_get(o, 1);
818 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
819 einfo->info.dest_buffer = ee->engine.buffer.pixels;
820 einfo->info.dest_buffer_row_bytes = evas_object_image_stride_get(o);
821 einfo->info.use_color_key = 0;
822 einfo->info.alpha_threshold = 0;
823 einfo->info.func.new_update_region = NULL;
824 einfo->info.func.free_update_region = NULL;
825 evas_object_image_data_set(o, ee->engine.buffer.pixels);
826 if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
827 {
828 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
829 ecore_evas_free(ee);
830 return NULL;
831 }
832 }
833 else
834 {
835 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
836 ecore_evas_free(ee);
837 return NULL;
838 }
839 evas_key_modifier_add(ee->evas, "Shift");
840 evas_key_modifier_add(ee->evas, "Control");
841 evas_key_modifier_add(ee->evas, "Alt");
842 evas_key_modifier_add(ee->evas, "Meta");
843 evas_key_modifier_add(ee->evas, "Hyper");
844 evas_key_modifier_add(ee->evas, "Super");
845 evas_key_lock_add(ee->evas, "Caps_Lock");
846 evas_key_lock_add(ee->evas, "Num_Lock");
847 evas_key_lock_add(ee->evas, "Scroll_Lock");
848
849 ee_target->sub_ecore_evas = eina_list_append(ee_target->sub_ecore_evas, ee);
850
851 return o;
852#else
853 return NULL;
854#endif
855}