diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/ecore/src/lib/ecore_evas/ecore_evas_buffer.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/ecore/src/lib/ecore_evas/ecore_evas_buffer.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_evas/ecore_evas_buffer.c | 824 |
1 files changed, 0 insertions, 824 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_buffer.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_buffer.c deleted file mode 100644 index 4c81db7..0000000 --- a/libraries/ecore/src/lib/ecore_evas/ecore_evas_buffer.c +++ /dev/null | |||
@@ -1,824 +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 | ||
16 | static int _ecore_evas_init_count = 0; | ||
17 | |||
18 | static int | ||
19 | _ecore_evas_buffer_init(void) | ||
20 | { | ||
21 | _ecore_evas_init_count++; | ||
22 | return _ecore_evas_init_count; | ||
23 | } | ||
24 | |||
25 | static 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 | |||
44 | static 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 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
81 | einfo->info.dest_buffer = ee->engine.buffer.pixels; | ||
82 | einfo->info.dest_buffer_row_bytes = stride; | ||
83 | einfo->info.use_color_key = 0; | ||
84 | einfo->info.alpha_threshold = 0; | ||
85 | einfo->info.func.new_update_region = NULL; | ||
86 | einfo->info.func.free_update_region = NULL; | ||
87 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
88 | { | ||
89 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
90 | } | ||
91 | } | ||
92 | if (ee->engine.buffer.image) | ||
93 | evas_object_image_data_set(ee->engine.buffer.image, ee->engine.buffer.pixels); | ||
94 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
95 | } | ||
96 | |||
97 | static void | ||
98 | _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h) | ||
99 | { | ||
100 | _ecore_evas_resize(ee, w, h); | ||
101 | } | ||
102 | |||
103 | int | ||
104 | _ecore_evas_buffer_shutdown(void) | ||
105 | { | ||
106 | _ecore_evas_init_count--; | ||
107 | if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; | ||
108 | return _ecore_evas_init_count; | ||
109 | } | ||
110 | |||
111 | static void | ||
112 | _ecore_evas_show(Ecore_Evas *ee) | ||
113 | { | ||
114 | if (ee->engine.buffer.image) return; | ||
115 | if (ee->prop.focused) return; | ||
116 | ee->prop.focused = 1; | ||
117 | evas_focus_in(ee->evas); | ||
118 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
119 | } | ||
120 | |||
121 | int | ||
122 | _ecore_evas_buffer_render(Ecore_Evas *ee) | ||
123 | { | ||
124 | Eina_List *updates = NULL, *l, *ll; | ||
125 | Ecore_Evas *ee2; | ||
126 | int rend = 0; | ||
127 | |||
128 | EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) | ||
129 | { | ||
130 | if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); | ||
131 | if (ee2->engine.func->fn_render) | ||
132 | rend |= ee2->engine.func->fn_render(ee2); | ||
133 | if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); | ||
134 | } | ||
135 | if (ee->engine.buffer.image) | ||
136 | { | ||
137 | int w, h; | ||
138 | |||
139 | evas_object_image_size_get(ee->engine.buffer.image, &w, &h); | ||
140 | if ((w != ee->w) || (h != ee->h)) | ||
141 | _ecore_evas_resize(ee, w, h); | ||
142 | ee->engine.buffer.pixels = evas_object_image_data_get(ee->engine.buffer.image, 1); | ||
143 | } | ||
144 | if (ee->engine.buffer.pixels) | ||
145 | { | ||
146 | updates = evas_render_updates(ee->evas); | ||
147 | } | ||
148 | if (ee->engine.buffer.image) | ||
149 | { | ||
150 | Eina_Rectangle *r; | ||
151 | |||
152 | evas_object_image_data_set(ee->engine.buffer.image, ee->engine.buffer.pixels); | ||
153 | EINA_LIST_FOREACH(updates, l, r) | ||
154 | evas_object_image_data_update_add(ee->engine.buffer.image, | ||
155 | r->x, r->y, r->w, r->h); | ||
156 | } | ||
157 | if (updates) | ||
158 | { | ||
159 | evas_render_updates_free(updates); | ||
160 | _ecore_evas_idle_timeout_update(ee); | ||
161 | } | ||
162 | |||
163 | return updates ? 1 : rend; | ||
164 | } | ||
165 | |||
166 | // NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar! | ||
167 | static void | ||
168 | _ecore_evas_buffer_coord_translate(Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y) | ||
169 | { | ||
170 | Evas_Coord xx, yy, ww, hh, fx, fy, fw, fh; | ||
171 | |||
172 | evas_object_geometry_get(ee->engine.buffer.image, &xx, &yy, &ww, &hh); | ||
173 | evas_object_image_fill_get(ee->engine.buffer.image, &fx, &fy, &fw, &fh); | ||
174 | |||
175 | if (fw < 1) fw = 1; | ||
176 | if (fh < 1) fh = 1; | ||
177 | |||
178 | if (evas_object_map_get(ee->engine.buffer.image) && | ||
179 | evas_object_map_enable_get(ee->engine.buffer.image)) | ||
180 | { | ||
181 | fx = 0; fy = 0; | ||
182 | fw = ee->w; fh = ee->h; | ||
183 | ww = ee->w; hh = ee->h; | ||
184 | } | ||
185 | |||
186 | if ((fx == 0) && (fy == 0) && (fw == ww) && (fh == hh)) | ||
187 | { | ||
188 | *x = (ee->w * (*x - xx)) / fw; | ||
189 | *y = (ee->h * (*y - yy)) / fh; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | xx = (*x - xx) - fx; | ||
194 | while (xx < 0) xx += fw; | ||
195 | while (xx > fw) xx -= fw; | ||
196 | *x = (ee->w * xx) / fw; | ||
197 | |||
198 | yy = (*y - yy) - fy; | ||
199 | while (yy < 0) yy += fh; | ||
200 | while (yy > fh) yy -= fh; | ||
201 | *y = (ee->h * yy) / fh; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | static void | ||
206 | _ecore_evas_buffer_transfer_modifiers_locks(Evas *e, Evas *e2) | ||
207 | { | ||
208 | const char *mods[] = | ||
209 | { "Shift", "Control", "Alt", "Meta", "Hyper", "Super", NULL }; | ||
210 | const char *locks[] = | ||
211 | { "Scroll_Lock", "Num_Lock", "Caps_Lock", NULL }; | ||
212 | int i; | ||
213 | |||
214 | for (i = 0; mods[i]; i++) | ||
215 | { | ||
216 | if (evas_key_modifier_is_set(evas_key_modifier_get(e), mods[i])) | ||
217 | evas_key_modifier_on(e2, mods[i]); | ||
218 | else | ||
219 | evas_key_modifier_off(e2, mods[i]); | ||
220 | } | ||
221 | for (i = 0; locks[i]; i++) | ||
222 | { | ||
223 | if (evas_key_lock_is_set(evas_key_lock_get(e), locks[i])) | ||
224 | evas_key_lock_on(e2, locks[i]); | ||
225 | else | ||
226 | evas_key_lock_off(e2, locks[i]); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | static void | ||
231 | _ecore_evas_buffer_cb_mouse_in(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
232 | { | ||
233 | Ecore_Evas *ee; | ||
234 | Evas_Event_Mouse_In *ev; | ||
235 | |||
236 | ee = data; | ||
237 | ev = event_info; | ||
238 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
239 | evas_event_feed_mouse_in(ee->evas, ev->timestamp, NULL); | ||
240 | } | ||
241 | |||
242 | static void | ||
243 | _ecore_evas_buffer_cb_mouse_out(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
244 | { | ||
245 | Ecore_Evas *ee; | ||
246 | Evas_Event_Mouse_Out *ev; | ||
247 | |||
248 | ee = data; | ||
249 | ev = event_info; | ||
250 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
251 | evas_event_feed_mouse_out(ee->evas, ev->timestamp, NULL); | ||
252 | } | ||
253 | |||
254 | static void | ||
255 | _ecore_evas_buffer_cb_mouse_down(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
256 | { | ||
257 | Ecore_Evas *ee; | ||
258 | Evas_Event_Mouse_Down *ev; | ||
259 | |||
260 | ee = data; | ||
261 | ev = event_info; | ||
262 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
263 | evas_event_feed_mouse_down(ee->evas, ev->button, ev->flags, ev->timestamp, NULL); | ||
264 | } | ||
265 | |||
266 | static void | ||
267 | _ecore_evas_buffer_cb_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
268 | { | ||
269 | Ecore_Evas *ee; | ||
270 | Evas_Event_Mouse_Up *ev; | ||
271 | |||
272 | ee = data; | ||
273 | ev = event_info; | ||
274 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
275 | evas_event_feed_mouse_up(ee->evas, ev->button, ev->flags, ev->timestamp, NULL); | ||
276 | } | ||
277 | |||
278 | static void | ||
279 | _ecore_evas_buffer_cb_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
280 | { | ||
281 | Ecore_Evas *ee; | ||
282 | Evas_Event_Mouse_Move *ev; | ||
283 | Evas_Coord x, y; | ||
284 | |||
285 | ee = data; | ||
286 | ev = event_info; | ||
287 | x = ev->cur.canvas.x; | ||
288 | y = ev->cur.canvas.y; | ||
289 | _ecore_evas_buffer_coord_translate(ee, &x, &y); | ||
290 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
291 | _ecore_evas_mouse_move_process(ee, x, y, ev->timestamp); | ||
292 | } | ||
293 | |||
294 | static void | ||
295 | _ecore_evas_buffer_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
296 | { | ||
297 | Ecore_Evas *ee; | ||
298 | Evas_Event_Mouse_Wheel *ev; | ||
299 | |||
300 | ee = data; | ||
301 | ev = event_info; | ||
302 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
303 | evas_event_feed_mouse_wheel(ee->evas, ev->direction, ev->z, ev->timestamp, NULL); | ||
304 | } | ||
305 | |||
306 | static void | ||
307 | _ecore_evas_buffer_cb_multi_down(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
308 | { | ||
309 | Ecore_Evas *ee; | ||
310 | Evas_Event_Multi_Down *ev; | ||
311 | Evas_Coord x, y, xx, yy; | ||
312 | double xf, yf; | ||
313 | |||
314 | ee = data; | ||
315 | ev = event_info; | ||
316 | x = ev->canvas.x; | ||
317 | y = ev->canvas.y; | ||
318 | xx = x; | ||
319 | yy = y; | ||
320 | _ecore_evas_buffer_coord_translate(ee, &x, &y); | ||
321 | xf = (ev->canvas.xsub - (double)xx) + (double)x; | ||
322 | yf = (ev->canvas.ysub - (double)yy) + (double)y; | ||
323 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
324 | 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); | ||
325 | } | ||
326 | |||
327 | static void | ||
328 | _ecore_evas_buffer_cb_multi_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
329 | { | ||
330 | Ecore_Evas *ee; | ||
331 | Evas_Event_Multi_Up *ev; | ||
332 | Evas_Coord x, y, xx, yy; | ||
333 | double xf, yf; | ||
334 | |||
335 | ee = data; | ||
336 | ev = event_info; | ||
337 | x = ev->canvas.x; | ||
338 | y = ev->canvas.y; | ||
339 | xx = x; | ||
340 | yy = y; | ||
341 | _ecore_evas_buffer_coord_translate(ee, &x, &y); | ||
342 | xf = (ev->canvas.xsub - (double)xx) + (double)x; | ||
343 | yf = (ev->canvas.ysub - (double)yy) + (double)y; | ||
344 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
345 | 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); | ||
346 | } | ||
347 | |||
348 | static void | ||
349 | _ecore_evas_buffer_cb_multi_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
350 | { | ||
351 | Ecore_Evas *ee; | ||
352 | Evas_Event_Multi_Move *ev; | ||
353 | Evas_Coord x, y, xx, yy; | ||
354 | double xf, yf; | ||
355 | |||
356 | ee = data; | ||
357 | ev = event_info; | ||
358 | x = ev->cur.canvas.x; | ||
359 | y = ev->cur.canvas.y; | ||
360 | xx = x; | ||
361 | yy = y; | ||
362 | _ecore_evas_buffer_coord_translate(ee, &x, &y); | ||
363 | xf = (ev->cur.canvas.xsub - (double)xx) + (double)x; | ||
364 | yf = (ev->cur.canvas.ysub - (double)yy) + (double)y; | ||
365 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
366 | 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); | ||
367 | } | ||
368 | |||
369 | static void | ||
370 | _ecore_evas_buffer_cb_free(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
371 | { | ||
372 | Ecore_Evas *ee; | ||
373 | |||
374 | ee = data; | ||
375 | if (ee->driver) _ecore_evas_free(ee); | ||
376 | } | ||
377 | |||
378 | static void | ||
379 | _ecore_evas_buffer_cb_key_down(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
380 | { | ||
381 | Ecore_Evas *ee; | ||
382 | Evas_Event_Key_Down *ev; | ||
383 | |||
384 | ee = data; | ||
385 | ev = event_info; | ||
386 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
387 | evas_event_feed_key_down(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL); | ||
388 | } | ||
389 | |||
390 | static void | ||
391 | _ecore_evas_buffer_cb_key_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info) | ||
392 | { | ||
393 | Ecore_Evas *ee; | ||
394 | Evas_Event_Key_Up *ev; | ||
395 | |||
396 | ee = data; | ||
397 | ev = event_info; | ||
398 | _ecore_evas_buffer_transfer_modifiers_locks(e, ee->evas); | ||
399 | evas_event_feed_key_up(ee->evas, ev->keyname, ev->key, ev->string, ev->compose, ev->timestamp, NULL); | ||
400 | } | ||
401 | |||
402 | static void | ||
403 | _ecore_evas_buffer_cb_focus_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
404 | { | ||
405 | Ecore_Evas *ee; | ||
406 | |||
407 | ee = data; | ||
408 | ee->prop.focused = 1; | ||
409 | evas_focus_in(ee->evas); | ||
410 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
411 | } | ||
412 | |||
413 | static void | ||
414 | _ecore_evas_buffer_cb_focus_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
415 | { | ||
416 | Ecore_Evas *ee; | ||
417 | |||
418 | ee = data; | ||
419 | ee->prop.focused = 0; | ||
420 | evas_focus_out(ee->evas); | ||
421 | if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee); | ||
422 | } | ||
423 | |||
424 | static void | ||
425 | _ecore_evas_buffer_cb_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
426 | { | ||
427 | Ecore_Evas *ee; | ||
428 | |||
429 | ee = data; | ||
430 | ee->visible = 1; | ||
431 | if (ee->func.fn_show) ee->func.fn_show(ee); | ||
432 | } | ||
433 | |||
434 | static void | ||
435 | _ecore_evas_buffer_cb_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
436 | { | ||
437 | Ecore_Evas *ee; | ||
438 | |||
439 | ee = data; | ||
440 | ee->visible = 0; | ||
441 | if (ee->func.fn_hide) ee->func.fn_hide(ee); | ||
442 | } | ||
443 | |||
444 | static void | ||
445 | _ecore_evas_buffer_alpha_set(Ecore_Evas *ee, int alpha) | ||
446 | { | ||
447 | if (((ee->alpha) && (alpha)) || ((!ee->alpha) && (!alpha))) return; | ||
448 | ee->alpha = alpha; | ||
449 | if (ee->engine.buffer.image) | ||
450 | evas_object_image_alpha_set(ee->engine.buffer.image, ee->alpha); | ||
451 | else | ||
452 | { | ||
453 | Evas_Engine_Info_Buffer *einfo; | ||
454 | |||
455 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
456 | if (einfo) | ||
457 | { | ||
458 | if (ee->alpha) | ||
459 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
460 | else | ||
461 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
462 | evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | |||
467 | static Ecore_Evas_Engine_Func _ecore_buffer_engine_func = | ||
468 | { | ||
469 | _ecore_evas_buffer_free, | ||
470 | NULL, | ||
471 | NULL, | ||
472 | NULL, | ||
473 | NULL, | ||
474 | NULL, | ||
475 | NULL, | ||
476 | NULL, | ||
477 | NULL, | ||
478 | NULL, | ||
479 | NULL, | ||
480 | NULL, | ||
481 | NULL, | ||
482 | NULL, | ||
483 | NULL, | ||
484 | NULL, | ||
485 | NULL, | ||
486 | _ecore_evas_resize, | ||
487 | _ecore_evas_move_resize, | ||
488 | NULL, | ||
489 | NULL, | ||
490 | _ecore_evas_show, | ||
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 | NULL, | ||
506 | NULL, | ||
507 | NULL, | ||
508 | NULL, | ||
509 | NULL, | ||
510 | NULL, | ||
511 | NULL, | ||
512 | NULL, | ||
513 | _ecore_evas_buffer_alpha_set, | ||
514 | NULL, //transparent | ||
515 | |||
516 | NULL, | ||
517 | NULL, | ||
518 | NULL, | ||
519 | NULL, | ||
520 | NULL, | ||
521 | NULL, | ||
522 | |||
523 | _ecore_evas_buffer_render, | ||
524 | NULL // screen_geometry_get | ||
525 | }; | ||
526 | #endif | ||
527 | |||
528 | static void * | ||
529 | _ecore_evas_buffer_pix_alloc(void *data __UNUSED__, int size) | ||
530 | { | ||
531 | return malloc(size); | ||
532 | } | ||
533 | |||
534 | static void | ||
535 | _ecore_evas_buffer_pix_free(void *data __UNUSED__, void *pix) | ||
536 | { | ||
537 | free(pix); | ||
538 | } | ||
539 | |||
540 | EAPI Ecore_Evas * | ||
541 | ecore_evas_buffer_new(int w, int h) | ||
542 | { | ||
543 | return ecore_evas_buffer_allocfunc_new | ||
544 | (w, h, _ecore_evas_buffer_pix_alloc, _ecore_evas_buffer_pix_free, NULL); | ||
545 | } | ||
546 | |||
547 | EAPI Ecore_Evas * | ||
548 | ecore_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) | ||
549 | { | ||
550 | // NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar! | ||
551 | #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER | ||
552 | Evas_Engine_Info_Buffer *einfo; | ||
553 | Ecore_Evas *ee; | ||
554 | int rmethod; | ||
555 | |||
556 | if ((!alloc_func) || (!free_func)) return NULL; | ||
557 | rmethod = evas_render_method_lookup("buffer"); | ||
558 | if (!rmethod) return NULL; | ||
559 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
560 | if (!ee) return NULL; | ||
561 | |||
562 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
563 | |||
564 | _ecore_evas_buffer_init(); | ||
565 | |||
566 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func; | ||
567 | ee->engine.buffer.alloc_func = alloc_func; | ||
568 | ee->engine.buffer.free_func = free_func; | ||
569 | ee->engine.buffer.data = (void *)data; | ||
570 | |||
571 | ee->driver = "buffer"; | ||
572 | |||
573 | if (w < 1) w = 1; | ||
574 | if (h < 1) h = 1; | ||
575 | ee->rotation = 0; | ||
576 | ee->visible = 1; | ||
577 | ee->w = w; | ||
578 | ee->h = h; | ||
579 | ee->req.w = ee->w; | ||
580 | ee->req.h = ee->h; | ||
581 | |||
582 | ee->prop.max.w = 0; | ||
583 | ee->prop.max.h = 0; | ||
584 | ee->prop.layer = 0; | ||
585 | ee->prop.focused = 1; | ||
586 | ee->prop.borderless = 1; | ||
587 | ee->prop.override = 1; | ||
588 | ee->prop.maximized = 1; | ||
589 | ee->prop.fullscreen = 0; | ||
590 | ee->prop.withdrawn = 0; | ||
591 | ee->prop.sticky = 0; | ||
592 | |||
593 | /* init evas here */ | ||
594 | ee->evas = evas_new(); | ||
595 | evas_data_attach_set(ee->evas, ee); | ||
596 | evas_output_method_set(ee->evas, rmethod); | ||
597 | evas_output_size_set(ee->evas, w, h); | ||
598 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
599 | |||
600 | ee->engine.buffer.pixels = | ||
601 | ee->engine.buffer.alloc_func | ||
602 | (ee->engine.buffer.data, w * h * sizeof(int)); | ||
603 | |||
604 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
605 | if (einfo) | ||
606 | { | ||
607 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
608 | einfo->info.dest_buffer = ee->engine.buffer.pixels; | ||
609 | einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int); | ||
610 | einfo->info.use_color_key = 0; | ||
611 | einfo->info.alpha_threshold = 0; | ||
612 | einfo->info.func.new_update_region = NULL; | ||
613 | einfo->info.func.free_update_region = NULL; | ||
614 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
615 | { | ||
616 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
617 | ecore_evas_free(ee); | ||
618 | return NULL; | ||
619 | } | ||
620 | } | ||
621 | else | ||
622 | { | ||
623 | ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); | ||
624 | ecore_evas_free(ee); | ||
625 | return NULL; | ||
626 | } | ||
627 | evas_key_modifier_add(ee->evas, "Shift"); | ||
628 | evas_key_modifier_add(ee->evas, "Control"); | ||
629 | evas_key_modifier_add(ee->evas, "Alt"); | ||
630 | evas_key_modifier_add(ee->evas, "Meta"); | ||
631 | evas_key_modifier_add(ee->evas, "Hyper"); | ||
632 | evas_key_modifier_add(ee->evas, "Super"); | ||
633 | evas_key_lock_add(ee->evas, "Caps_Lock"); | ||
634 | evas_key_lock_add(ee->evas, "Num_Lock"); | ||
635 | evas_key_lock_add(ee->evas, "Scroll_Lock"); | ||
636 | |||
637 | evas_event_feed_mouse_in(ee->evas, 0, NULL); | ||
638 | |||
639 | _ecore_evas_register(ee); | ||
640 | |||
641 | evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); | ||
642 | |||
643 | return ee; | ||
644 | #else | ||
645 | return NULL; | ||
646 | #endif | ||
647 | } | ||
648 | |||
649 | EAPI const void * | ||
650 | ecore_evas_buffer_pixels_get(Ecore_Evas *ee) | ||
651 | { | ||
652 | #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER | ||
653 | _ecore_evas_buffer_render(ee); | ||
654 | return ee->engine.buffer.pixels; | ||
655 | #else | ||
656 | return NULL; | ||
657 | #endif | ||
658 | } | ||
659 | |||
660 | EAPI Evas * | ||
661 | ecore_evas_object_evas_get(Evas_Object *obj) | ||
662 | { | ||
663 | Ecore_Evas *ee; | ||
664 | |||
665 | ee = evas_object_data_get(obj, "Ecore_Evas"); | ||
666 | if (!ee) return NULL; | ||
667 | |||
668 | return ecore_evas_get(ee); | ||
669 | } | ||
670 | |||
671 | EAPI Ecore_Evas * | ||
672 | ecore_evas_object_ecore_evas_get(Evas_Object *obj) | ||
673 | { | ||
674 | return evas_object_data_get(obj, "Ecore_Evas"); | ||
675 | } | ||
676 | |||
677 | EAPI Evas_Object * | ||
678 | ecore_evas_object_image_new(Ecore_Evas *ee_target) | ||
679 | { | ||
680 | // NOTE: if you fix this, consider fixing ecore_evas_ews.c as it is similar! | ||
681 | #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER | ||
682 | Evas_Object *o; | ||
683 | Evas_Engine_Info_Buffer *einfo; | ||
684 | Ecore_Evas *ee; | ||
685 | int rmethod; | ||
686 | int w = 1, h = 1; | ||
687 | |||
688 | rmethod = evas_render_method_lookup("buffer"); | ||
689 | if (!rmethod) return NULL; | ||
690 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
691 | if (!ee) return NULL; | ||
692 | |||
693 | o = evas_object_image_add(ee_target->evas); | ||
694 | evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); | ||
695 | evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888); | ||
696 | evas_object_image_alpha_set(o, 0); | ||
697 | evas_object_image_size_set(o, w, h); | ||
698 | |||
699 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
700 | |||
701 | _ecore_evas_buffer_init(); | ||
702 | |||
703 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_buffer_engine_func; | ||
704 | |||
705 | ee->driver = "buffer"; | ||
706 | |||
707 | ee->rotation = 0; | ||
708 | ee->visible = 0; | ||
709 | ee->w = w; | ||
710 | ee->h = h; | ||
711 | ee->req.w = ee->w; | ||
712 | ee->req.h = ee->h; | ||
713 | |||
714 | ee->prop.max.w = 0; | ||
715 | ee->prop.max.h = 0; | ||
716 | ee->prop.layer = 0; | ||
717 | ee->prop.focused = 0; | ||
718 | ee->prop.borderless = 1; | ||
719 | ee->prop.override = 1; | ||
720 | ee->prop.maximized = 0; | ||
721 | ee->prop.fullscreen = 0; | ||
722 | ee->prop.withdrawn = 0; | ||
723 | ee->prop.sticky = 0; | ||
724 | |||
725 | /* init evas here */ | ||
726 | ee->evas = evas_new(); | ||
727 | evas_data_attach_set(ee->evas, ee); | ||
728 | evas_output_method_set(ee->evas, rmethod); | ||
729 | evas_output_size_set(ee->evas, w, h); | ||
730 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
731 | |||
732 | ee->engine.buffer.image = o; | ||
733 | evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas", ee); | ||
734 | evas_object_data_set(ee->engine.buffer.image, "Ecore_Evas_Parent", ee_target); | ||
735 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
736 | EVAS_CALLBACK_MOUSE_IN, | ||
737 | _ecore_evas_buffer_cb_mouse_in, ee); | ||
738 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
739 | EVAS_CALLBACK_MOUSE_OUT, | ||
740 | _ecore_evas_buffer_cb_mouse_out, ee); | ||
741 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
742 | EVAS_CALLBACK_MOUSE_DOWN, | ||
743 | _ecore_evas_buffer_cb_mouse_down, ee); | ||
744 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
745 | EVAS_CALLBACK_MOUSE_UP, | ||
746 | _ecore_evas_buffer_cb_mouse_up, ee); | ||
747 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
748 | EVAS_CALLBACK_MOUSE_MOVE, | ||
749 | _ecore_evas_buffer_cb_mouse_move, ee); | ||
750 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
751 | EVAS_CALLBACK_MOUSE_WHEEL, | ||
752 | _ecore_evas_buffer_cb_mouse_wheel, ee); | ||
753 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
754 | EVAS_CALLBACK_MULTI_DOWN, | ||
755 | _ecore_evas_buffer_cb_multi_down, ee); | ||
756 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
757 | EVAS_CALLBACK_MULTI_UP, | ||
758 | _ecore_evas_buffer_cb_multi_up, ee); | ||
759 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
760 | EVAS_CALLBACK_MULTI_MOVE, | ||
761 | _ecore_evas_buffer_cb_multi_move, ee); | ||
762 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
763 | EVAS_CALLBACK_FREE, | ||
764 | _ecore_evas_buffer_cb_free, ee); | ||
765 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
766 | EVAS_CALLBACK_KEY_DOWN, | ||
767 | _ecore_evas_buffer_cb_key_down, ee); | ||
768 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
769 | EVAS_CALLBACK_KEY_UP, | ||
770 | _ecore_evas_buffer_cb_key_up, ee); | ||
771 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
772 | EVAS_CALLBACK_FOCUS_IN, | ||
773 | _ecore_evas_buffer_cb_focus_in, ee); | ||
774 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
775 | EVAS_CALLBACK_FOCUS_OUT, | ||
776 | _ecore_evas_buffer_cb_focus_out, ee); | ||
777 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
778 | EVAS_CALLBACK_SHOW, | ||
779 | _ecore_evas_buffer_cb_show, ee); | ||
780 | evas_object_event_callback_add(ee->engine.buffer.image, | ||
781 | EVAS_CALLBACK_HIDE, | ||
782 | _ecore_evas_buffer_cb_hide, ee); | ||
783 | einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); | ||
784 | if (einfo) | ||
785 | { | ||
786 | ee->engine.buffer.pixels = evas_object_image_data_get(o, 1); | ||
787 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; | ||
788 | einfo->info.dest_buffer = ee->engine.buffer.pixels; | ||
789 | einfo->info.dest_buffer_row_bytes = evas_object_image_stride_get(o); | ||
790 | einfo->info.use_color_key = 0; | ||
791 | einfo->info.alpha_threshold = 0; | ||
792 | einfo->info.func.new_update_region = NULL; | ||
793 | einfo->info.func.free_update_region = NULL; | ||
794 | evas_object_image_data_set(o, ee->engine.buffer.pixels); | ||
795 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
796 | { | ||
797 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
798 | ecore_evas_free(ee); | ||
799 | return NULL; | ||
800 | } | ||
801 | } | ||
802 | else | ||
803 | { | ||
804 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
805 | ecore_evas_free(ee); | ||
806 | return NULL; | ||
807 | } | ||
808 | evas_key_modifier_add(ee->evas, "Shift"); | ||
809 | evas_key_modifier_add(ee->evas, "Control"); | ||
810 | evas_key_modifier_add(ee->evas, "Alt"); | ||
811 | evas_key_modifier_add(ee->evas, "Meta"); | ||
812 | evas_key_modifier_add(ee->evas, "Hyper"); | ||
813 | evas_key_modifier_add(ee->evas, "Super"); | ||
814 | evas_key_lock_add(ee->evas, "Caps_Lock"); | ||
815 | evas_key_lock_add(ee->evas, "Num_Lock"); | ||
816 | evas_key_lock_add(ee->evas, "Scroll_Lock"); | ||
817 | |||
818 | ee_target->sub_ecore_evas = eina_list_append(ee_target->sub_ecore_evas, ee); | ||
819 | |||
820 | return o; | ||
821 | #else | ||
822 | return NULL; | ||
823 | #endif | ||
824 | } | ||