aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/canvas/evas_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/lib/canvas/evas_main.c')
-rw-r--r--libraries/evas/src/lib/canvas/evas_main.c710
1 files changed, 0 insertions, 710 deletions
diff --git a/libraries/evas/src/lib/canvas/evas_main.c b/libraries/evas/src/lib/canvas/evas_main.c
deleted file mode 100644
index 687744f..0000000
--- a/libraries/evas/src/lib/canvas/evas_main.c
+++ /dev/null
@@ -1,710 +0,0 @@
1#include "evas_common.h"
2#include "evas_private.h"
3#include "evas_cs.h"
4
5#ifdef LKDEBUG
6EAPI Eina_Bool lockdebug = EINA_FALSE;
7EAPI int lockmax = 0;
8#endif
9
10static int _evas_init_count = 0;
11int _evas_log_dom_global = -1;
12EAPI int
13evas_init(void)
14{
15 if (++_evas_init_count != 1)
16 return _evas_init_count;
17
18#ifdef LKDEBUG
19 if (getenv("EVAS_LOCK_DEBUG"))
20 {
21 lockdebug = EINA_TRUE;
22 lockmax = atoi(getenv("EVAS_LOCK_DEBUG"));
23 }
24#endif
25
26#ifdef HAVE_EVIL
27 if (!evil_init())
28 return --_evas_init_count;
29#endif
30
31 if (!eina_init())
32 goto shutdown_evil;
33
34 _evas_log_dom_global = eina_log_domain_register
35 ("evas_main", EVAS_DEFAULT_LOG_COLOR);
36 if (_evas_log_dom_global < 0)
37 {
38 EINA_LOG_ERR("Can not create a module log domain.");
39 goto shutdown_eina;
40 }
41
42 evas_module_init();
43#ifdef BUILD_ASYNC_EVENTS
44 if (!evas_async_events_init())
45 goto shutdown_module;
46#endif
47#ifdef EVAS_CSERVE
48 if (getenv("EVAS_CSERVE")) evas_cserve_init();
49#endif
50#ifdef BUILD_ASYNC_PRELOAD
51 _evas_preload_thread_init();
52#endif
53#ifdef EVAS_FRAME_QUEUING
54 evas_common_frameq_init();
55#endif
56
57 return _evas_init_count;
58
59#ifdef BUILD_ASYNC_EVENTS
60 shutdown_module:
61 evas_module_shutdown();
62 eina_log_domain_unregister(_evas_log_dom_global);
63#endif
64 shutdown_eina:
65 eina_shutdown();
66 shutdown_evil:
67#ifdef HAVE_EVIL
68 evil_shutdown();
69#endif
70
71 return --_evas_init_count;
72}
73
74EAPI int
75evas_shutdown(void)
76{
77 if (--_evas_init_count != 0)
78 return _evas_init_count;
79
80#ifdef EVAS_FRAME_QUEUING
81 if (evas_common_frameq_enabled())
82 {
83 evas_common_frameq_finish();
84 evas_common_frameq_destroy();
85 }
86#endif
87#ifdef BUILD_ASYNC_EVENTS
88 _evas_preload_thread_shutdown();
89#endif
90#ifdef EVAS_CSERVE
91 if (getenv("EVAS_CSERVE")) evas_cserve_shutdown();
92#endif
93#ifdef BUILD_ASYNC_EVENTS
94 evas_async_events_shutdown();
95#endif
96 evas_font_dir_cache_free();
97 evas_common_shutdown();
98 evas_module_shutdown();
99 eina_log_domain_unregister(_evas_log_dom_global);
100 eina_shutdown();
101#ifdef HAVE_EVIL
102 evil_shutdown();
103#endif
104
105 return _evas_init_count;
106}
107
108
109EAPI Evas *
110evas_new(void)
111{
112 Evas *e;
113
114 e = calloc(1, sizeof(Evas));
115 if (!e) return NULL;
116
117 e->magic = MAGIC_EVAS;
118 e->output.render_method = RENDER_METHOD_INVALID;
119 e->viewport.w = 1;
120 e->viewport.h = 1;
121 e->framespace.x = 0;
122 e->framespace.y = 0;
123 e->framespace.w = 0;
124 e->framespace.h = 0;
125 e->hinting = EVAS_FONT_HINTING_BYTECODE;
126 e->name_hash = eina_hash_string_superfast_new(NULL);
127 eina_clist_init(&e->calc_list);
128 eina_clist_init(&e->calc_done);
129
130#define EVAS_ARRAY_SET(E, Array) \
131 eina_array_step_set(&E->Array, sizeof (E->Array), 4096);
132
133 EVAS_ARRAY_SET(e, delete_objects);
134 EVAS_ARRAY_SET(e, active_objects);
135 EVAS_ARRAY_SET(e, restack_objects);
136 EVAS_ARRAY_SET(e, render_objects);
137 EVAS_ARRAY_SET(e, pending_objects);
138 EVAS_ARRAY_SET(e, obscuring_objects);
139 EVAS_ARRAY_SET(e, temporary_objects);
140 EVAS_ARRAY_SET(e, calculate_objects);
141 EVAS_ARRAY_SET(e, clip_changes);
142
143#undef EVAS_ARRAY_SET
144
145 return e;
146}
147
148EAPI void
149evas_free(Evas *e)
150{
151 Eina_Rectangle *r;
152 Evas_Coord_Touch_Point *touch_point;
153 Evas_Layer *lay;
154 int i;
155 int del;
156
157 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
158 return;
159 MAGIC_CHECK_END();
160
161#ifdef EVAS_FRAME_QUEUING
162 evas_common_frameq_flush();
163#endif
164
165 if (e->walking_list == 0) evas_render_idle_flush(e);
166
167 if (e->walking_list > 0) return;
168
169 if (e->callbacks)
170 {
171 if (e->callbacks->deletions_waiting) return;
172
173 e->callbacks->deletions_waiting = 0;
174 evas_event_callback_list_post_free(&e->callbacks->callbacks);
175 if (!e->callbacks->callbacks)
176 {
177 free(e->callbacks);
178 e->callbacks = NULL;
179 }
180
181 _evas_post_event_callback_free(e);
182 }
183
184 del = 1;
185 e->walking_list++;
186 e->cleanup = 1;
187 while (del)
188 {
189 del = 0;
190 EINA_INLIST_FOREACH(e->layers, lay)
191 {
192 Evas_Object *o;
193
194 evas_layer_pre_free(lay);
195
196 EINA_INLIST_FOREACH(lay->objects, o)
197 {
198 if ((o->callbacks) && (o->callbacks->walking_list))
199 {
200 /* Defer free */
201 e->delete_me = 1;
202 e->walking_list--;
203 return;
204 }
205 if (!o->delete_me)
206 del = 1;
207 }
208 }
209 }
210 EINA_INLIST_FOREACH(e->layers, lay)
211 evas_layer_free_objects(lay);
212 evas_layer_clean(e);
213
214 e->walking_list--;
215
216 evas_font_path_clear(e);
217 e->pointer.object.in = eina_list_free(e->pointer.object.in);
218
219 if (e->name_hash) eina_hash_free(e->name_hash);
220 e->name_hash = NULL;
221
222 EINA_LIST_FREE(e->damages, r)
223 eina_rectangle_free(r);
224 EINA_LIST_FREE(e->obscures, r)
225 eina_rectangle_free(r);
226
227 evas_fonts_zero_free(e);
228
229 evas_event_callback_all_del(e);
230 evas_event_callback_cleanup(e);
231
232 if (e->engine.func)
233 {
234 e->engine.func->context_free(e->engine.data.output, e->engine.data.context);
235 e->engine.func->output_free(e->engine.data.output);
236 e->engine.func->info_free(e, e->engine.info);
237 }
238
239 for (i = 0; i < e->modifiers.mod.count; i++)
240 free(e->modifiers.mod.list[i]);
241 if (e->modifiers.mod.list) free(e->modifiers.mod.list);
242
243 for (i = 0; i < e->locks.lock.count; i++)
244 free(e->locks.lock.list[i]);
245 if (e->locks.lock.list) free(e->locks.lock.list);
246
247 if (e->engine.module) evas_module_unref(e->engine.module);
248
249 eina_array_flush(&e->delete_objects);
250 eina_array_flush(&e->active_objects);
251 eina_array_flush(&e->restack_objects);
252 eina_array_flush(&e->render_objects);
253 eina_array_flush(&e->pending_objects);
254 eina_array_flush(&e->obscuring_objects);
255 eina_array_flush(&e->temporary_objects);
256 eina_array_flush(&e->calculate_objects);
257 eina_array_flush(&e->clip_changes);
258
259 EINA_LIST_FREE(e->touch_points, touch_point)
260 free(touch_point);
261
262 e->magic = 0;
263 free(e);
264}
265
266EAPI void
267evas_output_method_set(Evas *e, int render_method)
268{
269 Evas_Module *em;
270
271 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
272 return;
273 MAGIC_CHECK_END();
274
275 /* if our engine to set it to is invalid - abort */
276 if (render_method == RENDER_METHOD_INVALID) return;
277 /* if the engine is already set up - abort */
278 if (e->output.render_method != RENDER_METHOD_INVALID) return;
279 /* Request the right engine. */
280 em = evas_module_engine_get(render_method);
281 if (!em) return ;
282 if (em->id_engine != render_method) return;
283 if (!evas_module_load(em)) return;
284
285 /* set the correct render */
286 e->output.render_method = render_method;
287 e->engine.func = (em->functions);
288 evas_module_use(em);
289 if (e->engine.module) evas_module_unref(e->engine.module);
290 e->engine.module = em;
291 evas_module_ref(em);
292 /* get the engine info struct */
293 if (e->engine.func->info) e->engine.info = e->engine.func->info(e);
294 return;
295}
296
297EAPI int
298evas_output_method_get(const Evas *e)
299{
300 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
301 return RENDER_METHOD_INVALID;
302 MAGIC_CHECK_END();
303
304 return e->output.render_method;
305}
306
307EAPI Evas_Engine_Info *
308evas_engine_info_get(const Evas *e)
309{
310 Evas_Engine_Info *info;
311
312 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
313 return NULL;
314 MAGIC_CHECK_END();
315
316 if (!e->engine.info) return NULL;
317
318 info = e->engine.info;
319 ((Evas *)e)->engine.info_magic = info->magic;
320
321 return info;
322}
323
324EAPI Eina_Bool
325evas_engine_info_set(Evas *e, Evas_Engine_Info *info)
326{
327 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
328 return EINA_FALSE;
329 MAGIC_CHECK_END();
330 if (!info) return EINA_FALSE;
331 if (info != e->engine.info) return EINA_FALSE;
332 if (info->magic != e->engine.info_magic) return EINA_FALSE;
333 return (Eina_Bool)e->engine.func->setup(e, info);
334}
335
336EAPI void
337evas_output_size_set(Evas *e, int w, int h)
338{
339 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
340 return;
341 MAGIC_CHECK_END();
342
343 if ((w == e->output.w) && (h == e->output.h)) return;
344 if (w < 1) w = 1;
345 if (h < 1) h = 1;
346
347#ifdef EVAS_FRAME_QUEUING
348 evas_common_frameq_flush();
349#endif
350
351 e->output.w = w;
352 e->output.h = h;
353 e->output.changed = 1;
354 e->output_validity++;
355 e->changed = 1;
356 evas_render_invalidate(e);
357}
358
359EAPI void
360evas_output_size_get(const Evas *e, int *w, int *h)
361{
362 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
363 if (w) *w = 0;
364 if (h) *h = 0;
365 return;
366 MAGIC_CHECK_END();
367
368 if (w) *w = e->output.w;
369 if (h) *h = e->output.h;
370}
371
372EAPI void
373evas_output_viewport_set(Evas *e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
374{
375 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
376 return;
377 MAGIC_CHECK_END();
378
379 if ((x == e->viewport.x) && (y == e->viewport.y) &&
380 (w == e->viewport.w) && (h == e->viewport.h)) return;
381 if (w <= 0) return;
382 if (h <= 0) return;
383 if ((x != 0) || (y != 0))
384 {
385 ERR("Compat error. viewport x,y != 0,0 not supported");
386 x = 0;
387 y = 0;
388 }
389 e->viewport.x = x;
390 e->viewport.y = y;
391 e->viewport.w = w;
392 e->viewport.h = h;
393 e->viewport.changed = 1;
394 e->output_validity++;
395 e->changed = 1;
396}
397
398EAPI void
399evas_output_viewport_get(const Evas *e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
400{
401 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
402 if (x) *x = 0;
403 if (y) *y = 0;
404 if (w) *w = 0;
405 if (h) *h = 0;
406 return;
407 MAGIC_CHECK_END();
408
409 if (x) *x = e->viewport.x;
410 if (y) *y = e->viewport.y;
411 if (w) *w = e->viewport.w;
412 if (h) *h = e->viewport.h;
413}
414
415EAPI void
416evas_output_framespace_set(Evas *e, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
417{
418 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
419 return;
420 MAGIC_CHECK_END();
421
422 if ((x == e->framespace.x) && (y == e->framespace.y) &&
423 (w == e->framespace.w) && (h == e->framespace.h)) return;
424 e->framespace.x = x;
425 e->framespace.y = y;
426 e->framespace.w = w;
427 e->framespace.h = h;
428 e->framespace.changed = 1;
429 e->output_validity++;
430 e->changed = 1;
431}
432
433EAPI void
434evas_output_framespace_get(const Evas *e, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
435{
436 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
437 if (x) *x = 0;
438 if (y) *y = 0;
439 if (w) *w = 0;
440 if (h) *h = 0;
441 return;
442 MAGIC_CHECK_END();
443
444 if (x) *x = e->framespace.x;
445 if (y) *y = e->framespace.y;
446 if (w) *w = e->framespace.w;
447 if (h) *h = e->framespace.h;
448}
449
450EAPI Evas_Coord
451evas_coord_screen_x_to_world(const Evas *e, int x)
452{
453 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
454 return 0;
455 MAGIC_CHECK_END();
456 if (e->output.w == e->viewport.w) return e->viewport.x + x;
457 return (long long)e->viewport.x + (((long long)x * (long long)e->viewport.w) / (long long)e->output.w);
458}
459
460EAPI Evas_Coord
461evas_coord_screen_y_to_world(const Evas *e, int y)
462{
463 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
464 return 0;
465 MAGIC_CHECK_END();
466 if (e->output.h == e->viewport.h) return e->viewport.y + y;
467 return (long long)e->viewport.y + (((long long)y * (long long)e->viewport.h) / (long long)e->output.h);
468}
469
470EAPI int
471evas_coord_world_x_to_screen(const Evas *e, Evas_Coord x)
472{
473 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
474 return 0;
475 MAGIC_CHECK_END();
476 if (e->output.w == e->viewport.w) return x - e->viewport.x;
477 return (int)((((long long)x - (long long)e->viewport.x) * (long long)e->output.w) / (long long)e->viewport.w);
478}
479
480EAPI int
481evas_coord_world_y_to_screen(const Evas *e, Evas_Coord y)
482{
483 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
484 return 0;
485 MAGIC_CHECK_END();
486 if (e->output.h == e->viewport.h) return y - e->viewport.y;
487 return (int)((((long long)y - (long long)e->viewport.y) * (long long)e->output.h) / (long long)e->viewport.h);
488}
489
490EAPI int
491evas_render_method_lookup(const char *name)
492{
493 Evas_Module *em;
494
495 if (!name) return RENDER_METHOD_INVALID;
496 /* search on the engines list for the name */
497 em = evas_module_find_type(EVAS_MODULE_TYPE_ENGINE, name);
498 if (!em) return RENDER_METHOD_INVALID;
499
500 return em->id_engine;
501}
502
503EAPI Eina_List *
504evas_render_method_list(void)
505{
506 return evas_module_engine_list();
507}
508
509EAPI void
510evas_render_method_list_free(Eina_List *list)
511{
512 eina_list_free(list);
513}
514
515EAPI Eina_Bool
516evas_object_image_extension_can_load_get(const char *file)
517{
518 const char *tmp;
519 Eina_Bool result;
520
521 tmp = eina_stringshare_add(file);
522 result = evas_common_extension_can_load_get(tmp);
523 eina_stringshare_del(tmp);
524
525 return result;
526}
527
528EAPI Eina_Bool
529evas_object_image_extension_can_load_fast_get(const char *file)
530{
531 return evas_common_extension_can_load_get(file);
532}
533
534EAPI void
535evas_pointer_output_xy_get(const Evas *e, int *x, int *y)
536{
537 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
538 if (x) *x = 0;
539 if (y) *y = 0;
540 return;
541 MAGIC_CHECK_END();
542 if (x) *x = e->pointer.x;
543 if (y) *y = e->pointer.y;
544}
545
546EAPI void
547evas_pointer_canvas_xy_get(const Evas *e, Evas_Coord *x, Evas_Coord *y)
548{
549 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
550 if (x) *x = 0;
551 if (y) *y = 0;
552 return;
553 MAGIC_CHECK_END();
554 if (x) *x = e->pointer.x;
555 if (y) *y = e->pointer.y;
556}
557
558EAPI int
559evas_pointer_button_down_mask_get(const Evas *e)
560{
561 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
562 return 0;
563 MAGIC_CHECK_END();
564 return (int)e->pointer.button;
565}
566
567EAPI Eina_Bool
568evas_pointer_inside_get(const Evas *e)
569{
570 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
571 return 0;
572 MAGIC_CHECK_END();
573 return (int)e->pointer.inside;
574}
575
576EAPI void
577evas_data_attach_set(Evas *e, void *data)
578{
579 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
580 return;
581 MAGIC_CHECK_END();
582 e->attach_data = data;
583}
584
585EAPI void *
586evas_data_attach_get(const Evas *e)
587{
588 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
589 return NULL;
590 MAGIC_CHECK_END();
591 return e->attach_data;
592}
593
594EAPI void
595evas_focus_in(Evas *e)
596{
597 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
598 return;
599 MAGIC_CHECK_END();
600 if (e->focus) return;
601 e->focus = 1;
602 evas_event_callback_call(e, EVAS_CALLBACK_CANVAS_FOCUS_IN, NULL);
603}
604
605EAPI void
606evas_focus_out(Evas *e)
607{
608 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
609 return;
610 MAGIC_CHECK_END();
611 if (!e->focus) return;
612 e->focus = 0;
613 evas_event_callback_call(e, EVAS_CALLBACK_CANVAS_FOCUS_OUT, NULL);
614}
615
616EAPI Eina_Bool
617evas_focus_state_get(const Evas *e)
618{
619 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
620 return 0;
621 MAGIC_CHECK_END();
622 return e->focus;
623}
624
625EAPI void
626evas_nochange_push(Evas *e)
627{
628 e->nochange++;
629}
630
631EAPI void
632evas_nochange_pop(Evas *e)
633{
634 e->nochange--;
635}
636
637void
638_evas_walk(Evas *e)
639{
640 e->walking_list++;
641}
642
643void
644_evas_unwalk(Evas *e)
645{
646 e->walking_list--;
647 if ((e->walking_list == 0) && (e->delete_me)) evas_free(e);
648}
649
650EAPI const char *
651evas_load_error_str(Evas_Load_Error error)
652{
653 switch (error)
654 {
655 case EVAS_LOAD_ERROR_NONE:
656 return "No error on load";
657 case EVAS_LOAD_ERROR_GENERIC:
658 return "A non-specific error occurred";
659 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
660 return "File (or file path) does not exist";
661 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
662 return "Permission deinied to an existing file (or path)";
663 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
664 return "Allocation of resources failure prevented load";
665 case EVAS_LOAD_ERROR_CORRUPT_FILE:
666 return "File corrupt (but was detected as a known format)";
667 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
668 return "File is not a known format";
669 default:
670 return "Unknown error";
671 }
672}
673
674EAPI void
675evas_color_hsv_to_rgb(float h, float s, float v, int *r, int *g, int *b)
676{
677 evas_common_convert_color_hsv_to_rgb(h, s, v, r, g, b);
678}
679
680EAPI void
681evas_color_rgb_to_hsv(int r, int g, int b, float *h, float *s, float *v)
682{
683 evas_common_convert_color_rgb_to_hsv(r, g, b, h, s, v);
684}
685
686EAPI void
687evas_color_argb_premul(int a, int *r, int *g, int *b)
688{
689 evas_common_convert_color_argb_premul(a, r, g, b);
690}
691
692EAPI void
693evas_color_argb_unpremul(int a, int *r, int *g, int *b)
694{
695 evas_common_convert_color_argb_unpremul(a, r, g, b);
696}
697
698EAPI void
699evas_data_argb_premul(unsigned int *data, unsigned int len)
700{
701 if (!data || (len < 1)) return;
702 evas_common_convert_argb_premul(data, len);
703}
704
705EAPI void
706evas_data_argb_unpremul(unsigned int *data, unsigned int len)
707{
708 if (!data || (len < 1)) return;
709 evas_common_convert_argb_unpremul(data, len);
710}