summaryrefslogtreecommitdiff
path: root/src/bin/e_canvas.c
blob: f6a46516a79eaa07aa54bb64a529557c1dbde497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

/* local subsystem functions */
static int _e_canvas_cb_flush(void *data);

/* local subsystem globals */
static Evas_List *_e_canvases = NULL;
static Ecore_Timer *_e_canvas_cache_flush_timer = NULL;

/* externally accessible functions */
EAPI void
e_canvas_add(Ecore_Evas *ee)
{
   Evas *e;
   
   _e_canvases = evas_list_prepend(_e_canvases, ee);
   e = ecore_evas_get(ee);
   evas_image_cache_set(e, e_config->image_cache * 1024);
   evas_font_cache_set(e, e_config->font_cache * 1024);
   e_path_evas_append(path_fonts, e);
   if (e_config->font_hinting == 0)
     evas_font_hinting_set(e, EVAS_FONT_HINTING_BYTECODE);
   else if (e_config->font_hinting == 1)
     evas_font_hinting_set(e, EVAS_FONT_HINTING_AUTO);
   else if (e_config->font_hinting == 2)
     evas_font_hinting_set(e, EVAS_FONT_HINTING_NONE);
   
//   evas_image_cache_flush(e);
//   evas_image_cache_reload(e);
}

EAPI void
e_canvas_del(Ecore_Evas *ee)
{
   _e_canvases = evas_list_remove(_e_canvases, ee);
}

EAPI int
e_canvas_engine_decide(int engine)
{
   /* if use default - use it */
   if (engine == E_EVAS_ENGINE_DEFAULT)
     engine = e_config->evas_engine_default;
   /* if engine is gl - do we support it? */
   if (engine == E_EVAS_ENGINE_GL_X11)
     {
	/* if we dont - fall back to software x11 */
	if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_GL_X11))
	  engine = E_EVAS_ENGINE_SOFTWARE_X11;
     }
   if (engine == E_EVAS_ENGINE_XRENDER_X11)
     {
	/* if we dont - fall back to software x11 */
	if (!ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_XRENDER_X11))
	  engine = E_EVAS_ENGINE_SOFTWARE_X11;
     }
   return engine;
}

EAPI void
e_canvas_recache(void)
{
   Evas_List *l;
   
   for (l = _e_canvases; l; l = l->next)
     {
	Ecore_Evas *ee;
	Evas *e;
	
	ee = l->data;
	e = ecore_evas_get(ee);
	evas_image_cache_set(e, e_config->image_cache * 1024);
	evas_font_cache_set(e, e_config->font_cache * 1024);
     }
   edje_file_cache_set(e_config->edje_cache);
   edje_collection_cache_set(e_config->edje_cache);
   if (_e_canvas_cache_flush_timer)
     {
	ecore_timer_del(_e_canvas_cache_flush_timer);
	_e_canvas_cache_flush_timer = NULL;
     }
   if (e_config->cache_flush_interval > 0.0)
     {
	_e_canvas_cache_flush_timer = 
	  ecore_timer_add(e_config->cache_flush_interval, _e_canvas_cb_flush,
			  NULL);
     }
}

EAPI void
e_canvas_cache_flush(void)
{
   Evas_List *l;
   
   for (l = _e_canvases; l; l = l->next)
     {
	Ecore_Evas *ee;
	Evas *e;
	
	ee = l->data;
	e = ecore_evas_get(ee);
	evas_image_cache_flush(e);
	evas_font_cache_flush(e);
     }
   edje_file_cache_flush();
   edje_collection_cache_flush();
}

EAPI void
e_canvas_cache_reload(void)
{
   Evas_List *l;
   
   for (l = _e_canvases; l; l = l->next)
     {
	Ecore_Evas *ee;
	Evas *e;
	
	ee = l->data;
	e = ecore_evas_get(ee);
	evas_image_cache_reload(e);
     }
}

EAPI Ecore_Evas *
e_canvas_new(int engine_hint, Ecore_X_Window win, int x, int y, int w, int h,
	     int direct_resize, int override, Ecore_X_Window *win_ret,
	     Ecore_X_Window *subwin_ret)
{
   Ecore_Evas *ee;
   int engine;
   
   engine = e_canvas_engine_decide(engine_hint);
   if (engine == E_EVAS_ENGINE_GL_X11)
     {
	ee = ecore_evas_gl_x11_new(NULL, win, x, y, w, h);
	if (ee)
	  {
	     ecore_evas_override_set(ee, override);
	     if (direct_resize) ecore_evas_gl_x11_direct_resize_set(ee, 1);
	     if (win_ret) *win_ret = ecore_evas_gl_x11_window_get(ee);
	     if (subwin_ret) *subwin_ret = ecore_evas_gl_x11_subwindow_get(ee);
	  }
	else
	  goto try2;
     }
   else if (engine == E_EVAS_ENGINE_XRENDER_X11)
     {
	ee = ecore_evas_xrender_x11_new(NULL, win, x, y, w, h);
	if (ee)
	  {
	     ecore_evas_override_set(ee, override);
	     if (direct_resize) ecore_evas_xrender_x11_direct_resize_set(ee, 1);
	     if (win_ret) *win_ret = ecore_evas_xrender_x11_window_get(ee);
	     if (subwin_ret) *subwin_ret = ecore_evas_xrender_x11_subwindow_get(ee);
	  }
	else
	  goto try2;
     }
   else
     {
	try2:
	ee = ecore_evas_software_x11_new(NULL, win, x, y, w, h);
	if (ee)
	  {
	     ecore_evas_override_set(ee, override);
	     if (direct_resize) ecore_evas_software_x11_direct_resize_set(ee, 1);
	     if (win_ret) *win_ret = ecore_evas_software_x11_window_get(ee);
	     if (subwin_ret) *subwin_ret = ecore_evas_software_x11_subwindow_get(ee);
	  }
     }
   return ee;
}

/* local subsystem functions */
static int
_e_canvas_cb_flush(void *data)
{
   e_canvas_cache_flush();
   return 1;
}