diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/modules/engines/fb/evas_engine.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/evas/src/modules/engines/fb/evas_engine.c')
-rw-r--r-- | libraries/evas/src/modules/engines/fb/evas_engine.c | 317 |
1 files changed, 317 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/fb/evas_engine.c b/libraries/evas/src/modules/engines/fb/evas_engine.c new file mode 100644 index 0000000..7681b00 --- /dev/null +++ b/libraries/evas/src/modules/engines/fb/evas_engine.c | |||
@@ -0,0 +1,317 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_private.h" | ||
3 | #include "evas_engine.h" | ||
4 | #include "Evas_Engine_FB.h" | ||
5 | |||
6 | int _evas_engine_fb_log_dom = -1; | ||
7 | |||
8 | /* function tables - filled in later (func and parent func) */ | ||
9 | static Evas_Func func, pfunc; | ||
10 | |||
11 | /* engine struct data */ | ||
12 | typedef struct _Render_Engine Render_Engine; | ||
13 | |||
14 | struct _Render_Engine | ||
15 | { | ||
16 | Tilebuf *tb; | ||
17 | Outbuf *ob; | ||
18 | Tilebuf_Rect *rects; | ||
19 | Eina_Inlist *cur_rect; | ||
20 | int end : 1; | ||
21 | }; | ||
22 | |||
23 | /* prototypes we will use here */ | ||
24 | static void *_output_setup(int w, int h, int rot, int vt, int dev, int refresh); | ||
25 | |||
26 | static void *eng_info(Evas *e); | ||
27 | static void eng_info_free(Evas *e, void *info); | ||
28 | static int eng_setup(Evas *e, void *info); | ||
29 | static void eng_output_free(void *data); | ||
30 | static void eng_output_resize(void *data, int w, int h); | ||
31 | static void eng_output_tile_size_set(void *data, int w, int h); | ||
32 | static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h); | ||
33 | static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h); | ||
34 | static void eng_output_redraws_clear(void *data); | ||
35 | static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch); | ||
36 | static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h); | ||
37 | static void eng_output_flush(void *data); | ||
38 | static void eng_output_idle_flush(void *data); | ||
39 | |||
40 | /* internal engine routines */ | ||
41 | static void * | ||
42 | _output_setup(int w, int h, int rot, int vt, int dev, int refresh) | ||
43 | { | ||
44 | Render_Engine *re; | ||
45 | |||
46 | re = calloc(1, sizeof(Render_Engine)); | ||
47 | if (!re) | ||
48 | return NULL; | ||
49 | /* if we haven't initialized - init (automatic abort if already done) */ | ||
50 | evas_common_cpu_init(); | ||
51 | |||
52 | evas_common_blend_init(); | ||
53 | evas_common_image_init(); | ||
54 | evas_common_convert_init(); | ||
55 | evas_common_scale_init(); | ||
56 | evas_common_rectangle_init(); | ||
57 | evas_common_polygon_init(); | ||
58 | evas_common_line_init(); | ||
59 | evas_common_font_init(); | ||
60 | evas_common_draw_init(); | ||
61 | evas_common_tilebuf_init(); | ||
62 | |||
63 | evas_fb_outbuf_fb_init(); | ||
64 | |||
65 | /* get any stored performance metrics from device (xserver) */ | ||
66 | re->ob = evas_fb_outbuf_fb_setup_fb(w, h, rot, OUTBUF_DEPTH_INHERIT, vt, dev, refresh); | ||
67 | re->tb = evas_common_tilebuf_new(evas_fb_outbuf_fb_get_width(re->ob), evas_fb_outbuf_fb_get_height(re->ob)); | ||
68 | /* no backbuf! */ | ||
69 | evas_fb_outbuf_fb_set_have_backbuf(re->ob, 0); | ||
70 | /* in preliminary tests 16x16 gave highest framerates */ | ||
71 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
72 | return re; | ||
73 | } | ||
74 | |||
75 | /* engine api this module provides */ | ||
76 | static void * | ||
77 | eng_info(Evas *e) | ||
78 | { | ||
79 | Evas_Engine_Info_FB *info; | ||
80 | info = calloc(1, sizeof(Evas_Engine_Info_FB)); | ||
81 | if (!info) return NULL; | ||
82 | info->magic.magic = rand(); | ||
83 | info->render_mode = EVAS_RENDER_MODE_BLOCKING; | ||
84 | return info; | ||
85 | e = NULL; | ||
86 | } | ||
87 | |||
88 | static void | ||
89 | eng_info_free(Evas *e __UNUSED__, void *info) | ||
90 | { | ||
91 | Evas_Engine_Info_FB *in; | ||
92 | in = (Evas_Engine_Info_FB *)info; | ||
93 | free(in); | ||
94 | } | ||
95 | |||
96 | static int | ||
97 | eng_setup(Evas *e, void *in) | ||
98 | { | ||
99 | Render_Engine *re; | ||
100 | Evas_Engine_Info_FB *info; | ||
101 | |||
102 | info = (Evas_Engine_Info_FB *)in; | ||
103 | re = _output_setup(e->output.w, | ||
104 | e->output.h, | ||
105 | info->info.rotation, | ||
106 | info->info.virtual_terminal, | ||
107 | info->info.device_number, | ||
108 | info->info.refresh); | ||
109 | e->engine.data.output = re; | ||
110 | if (!e->engine.data.output) return 0; | ||
111 | e->engine.data.context = e->engine.func->context_new(e->engine.data.output); | ||
112 | |||
113 | return 1; | ||
114 | } | ||
115 | |||
116 | static void | ||
117 | eng_output_free(void *data) | ||
118 | { | ||
119 | Render_Engine *re; | ||
120 | |||
121 | re = (Render_Engine *)data; | ||
122 | evas_fb_outbuf_fb_free(re->ob); | ||
123 | evas_common_tilebuf_free(re->tb); | ||
124 | if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); | ||
125 | free(re); | ||
126 | |||
127 | evas_common_font_shutdown(); | ||
128 | evas_common_image_shutdown(); | ||
129 | } | ||
130 | |||
131 | static void | ||
132 | eng_output_resize(void *data, int w, int h) | ||
133 | { | ||
134 | Render_Engine *re; | ||
135 | |||
136 | re = (Render_Engine *)data; | ||
137 | evas_fb_outbuf_fb_reconfigure(re->ob, w, h, | ||
138 | evas_fb_outbuf_fb_get_rot(re->ob), | ||
139 | OUTBUF_DEPTH_INHERIT); | ||
140 | evas_common_tilebuf_free(re->tb); | ||
141 | re->tb = evas_common_tilebuf_new(w, h); | ||
142 | if (re->tb) | ||
143 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
144 | } | ||
145 | |||
146 | static void | ||
147 | eng_output_tile_size_set(void *data, int w, int h) | ||
148 | { | ||
149 | Render_Engine *re; | ||
150 | |||
151 | re = (Render_Engine *)data; | ||
152 | evas_common_tilebuf_set_tile_size(re->tb, w, h); | ||
153 | } | ||
154 | |||
155 | static void | ||
156 | eng_output_redraws_rect_add(void *data, int x, int y, int w, int h) | ||
157 | { | ||
158 | Render_Engine *re; | ||
159 | |||
160 | re = (Render_Engine *)data; | ||
161 | evas_common_tilebuf_add_redraw(re->tb, x, y, w, h); | ||
162 | } | ||
163 | |||
164 | static void | ||
165 | eng_output_redraws_rect_del(void *data, int x, int y, int w, int h) | ||
166 | { | ||
167 | Render_Engine *re; | ||
168 | |||
169 | re = (Render_Engine *)data; | ||
170 | evas_common_tilebuf_del_redraw(re->tb, x, y, w, h); | ||
171 | } | ||
172 | |||
173 | static void | ||
174 | eng_output_redraws_clear(void *data) | ||
175 | { | ||
176 | Render_Engine *re; | ||
177 | |||
178 | re = (Render_Engine *)data; | ||
179 | evas_common_tilebuf_clear(re->tb); | ||
180 | } | ||
181 | |||
182 | static void * | ||
183 | eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch) | ||
184 | { | ||
185 | Render_Engine *re; | ||
186 | RGBA_Image *surface; | ||
187 | Tilebuf_Rect *rect; | ||
188 | int ux, uy, uw, uh; | ||
189 | |||
190 | re = (Render_Engine *)data; | ||
191 | if (re->end) | ||
192 | { | ||
193 | re->end = 0; | ||
194 | return NULL; | ||
195 | } | ||
196 | if (!re->rects) | ||
197 | { | ||
198 | re->rects = evas_common_tilebuf_get_render_rects(re->tb); | ||
199 | re->cur_rect = EINA_INLIST_GET(re->rects); | ||
200 | } | ||
201 | if (!re->cur_rect) return NULL; | ||
202 | rect = (Tilebuf_Rect *)re->cur_rect; | ||
203 | ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h; | ||
204 | re->cur_rect = re->cur_rect->next; | ||
205 | if (!re->cur_rect) | ||
206 | { | ||
207 | evas_common_tilebuf_free_render_rects(re->rects); | ||
208 | re->rects = NULL; | ||
209 | re->end = 1; | ||
210 | } | ||
211 | |||
212 | surface = evas_fb_outbuf_fb_new_region_for_update(re->ob, | ||
213 | ux, uy, uw, uh, | ||
214 | cx, cy, cw, ch); | ||
215 | *x = ux; *y = uy; *w = uw; *h = uh; | ||
216 | return surface; | ||
217 | } | ||
218 | |||
219 | static void | ||
220 | eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h) | ||
221 | { | ||
222 | Render_Engine *re; | ||
223 | |||
224 | re = (Render_Engine *)data; | ||
225 | #ifdef BUILD_PIPE_RENDER | ||
226 | evas_common_pipe_map_begin(surface); | ||
227 | #endif | ||
228 | evas_fb_outbuf_fb_push_updated_region(re->ob, surface, x, y, w, h); | ||
229 | evas_fb_outbuf_fb_free_region_for_update(re->ob, surface); | ||
230 | evas_common_cpu_end_opt(); | ||
231 | } | ||
232 | |||
233 | static void | ||
234 | eng_output_flush(void *data) | ||
235 | { | ||
236 | Render_Engine *re; | ||
237 | |||
238 | re = (Render_Engine *)data; | ||
239 | } | ||
240 | |||
241 | static void | ||
242 | eng_output_idle_flush(void *data) | ||
243 | { | ||
244 | Render_Engine *re; | ||
245 | |||
246 | re = (Render_Engine *)data; | ||
247 | } | ||
248 | |||
249 | static Eina_Bool | ||
250 | eng_canvas_alpha_get(void *data, void *context __UNUSED__) | ||
251 | { | ||
252 | Render_Engine *re; | ||
253 | |||
254 | re = (Render_Engine *)data; | ||
255 | return (re->ob->priv.fb.fb->fb_var.transp.length > 0); | ||
256 | } | ||
257 | |||
258 | /* module advertising code */ | ||
259 | static int | ||
260 | module_open(Evas_Module *em) | ||
261 | { | ||
262 | if (!em) return 0; | ||
263 | /* get whatever engine module we inherit from */ | ||
264 | if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0; | ||
265 | _evas_engine_fb_log_dom = eina_log_domain_register | ||
266 | ("evas-fb", EVAS_DEFAULT_LOG_COLOR); | ||
267 | if (_evas_engine_fb_log_dom < 0) | ||
268 | { | ||
269 | EINA_LOG_ERR("Can not create a module log domain."); | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | /* store it for later use */ | ||
274 | func = pfunc; | ||
275 | /* now to override methods */ | ||
276 | #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_) | ||
277 | ORD(info); | ||
278 | ORD(info_free); | ||
279 | ORD(setup); | ||
280 | ORD(canvas_alpha_get); | ||
281 | ORD(output_free); | ||
282 | ORD(output_resize); | ||
283 | ORD(output_tile_size_set); | ||
284 | ORD(output_redraws_rect_add); | ||
285 | ORD(output_redraws_rect_del); | ||
286 | ORD(output_redraws_clear); | ||
287 | ORD(output_redraws_next_update_get); | ||
288 | ORD(output_redraws_next_update_push); | ||
289 | ORD(output_flush); | ||
290 | ORD(output_idle_flush); | ||
291 | /* now advertise out own api */ | ||
292 | em->functions = (void *)(&func); | ||
293 | return 1; | ||
294 | } | ||
295 | |||
296 | static void | ||
297 | module_close(Evas_Module *em __UNUSED__) | ||
298 | { | ||
299 | eina_log_domain_unregister(_evas_engine_fb_log_dom); | ||
300 | } | ||
301 | |||
302 | static Evas_Module_Api evas_modapi = | ||
303 | { | ||
304 | EVAS_MODULE_API_VERSION, | ||
305 | "fb", | ||
306 | "none", | ||
307 | { | ||
308 | module_open, | ||
309 | module_close | ||
310 | } | ||
311 | }; | ||
312 | |||
313 | EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, fb); | ||
314 | |||
315 | #ifndef EVAS_STATIC_BUILD_FB | ||
316 | EVAS_EINA_MODULE_DEFINE(engine, fb); | ||
317 | #endif | ||