diff options
Diffstat (limited to 'libraries/evas/src/modules/engines/buffer/evas_engine.c')
-rw-r--r-- | libraries/evas/src/modules/engines/buffer/evas_engine.c | 444 |
1 files changed, 0 insertions, 444 deletions
diff --git a/libraries/evas/src/modules/engines/buffer/evas_engine.c b/libraries/evas/src/modules/engines/buffer/evas_engine.c deleted file mode 100644 index 758ef10..0000000 --- a/libraries/evas/src/modules/engines/buffer/evas_engine.c +++ /dev/null | |||
@@ -1,444 +0,0 @@ | |||
1 | #include "evas_common.h" | ||
2 | #include "evas_private.h" | ||
3 | #include "evas_engine.h" | ||
4 | #include "Evas_Engine_Buffer.h" | ||
5 | |||
6 | /* domain for eina_log */ | ||
7 | /* the log macros are defined in evas_common.h */ | ||
8 | /* theirs names are EVAS_ERR, EVAS_DBG, EVAS_CRIT, EVAS_WRN and EVAS_INF */ | ||
9 | /* although we can use the EVAS_ERROR, etc... macros it will not work | ||
10 | when the -fvisibility=hidden option is passed to gcc */ | ||
11 | |||
12 | int _evas_engine_buffer_log_dom = -1; | ||
13 | |||
14 | /* function tables - filled in later (func and parent func) */ | ||
15 | |||
16 | static Evas_Func func, pfunc; | ||
17 | |||
18 | |||
19 | /* engine struct data */ | ||
20 | typedef struct _Render_Engine Render_Engine; | ||
21 | |||
22 | struct _Render_Engine | ||
23 | { | ||
24 | Tilebuf *tb; | ||
25 | Outbuf *ob; | ||
26 | Tilebuf_Rect *rects; | ||
27 | Eina_Inlist *cur_rect; | ||
28 | Eina_Inarray previous_rects; | ||
29 | int end : 1; | ||
30 | }; | ||
31 | |||
32 | /* prototypes we will use here */ | ||
33 | static void *_output_setup(int w, int h, void *dest_buffer, int dest_buffer_row_bytes, int depth_type, int use_color_key, int alpha_threshold, int color_key_r, int color_key_g, int color_key_b, void *(*new_update_region) (int x, int y, int w, int h, int *row_bytes), void (*free_update_region) (int x, int y, int w, int h, void *data), void *(*switch_buffer) (void *data, void *dest_buffer), void *switch_data); | ||
34 | |||
35 | static void *eng_info(Evas *e __UNUSED__); | ||
36 | static void eng_info_free(Evas *e __UNUSED__, void *info); | ||
37 | static int eng_setup(Evas *e, void *info); | ||
38 | static void eng_output_free(void *data); | ||
39 | static void eng_output_resize(void *data, int w, int h); | ||
40 | static void eng_output_tile_size_set(void *data, int w, int h); | ||
41 | static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h); | ||
42 | static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h); | ||
43 | static void eng_output_redraws_clear(void *data); | ||
44 | 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); | ||
45 | static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h); | ||
46 | static void eng_output_flush(void *data); | ||
47 | static void eng_output_idle_flush(void *data); | ||
48 | |||
49 | /* internal engine routines */ | ||
50 | static void * | ||
51 | _output_setup(int w, | ||
52 | int h, | ||
53 | void *dest_buffer, | ||
54 | int dest_buffer_row_bytes, | ||
55 | int depth_type, | ||
56 | int use_color_key, | ||
57 | int alpha_threshold, | ||
58 | int color_key_r, | ||
59 | int color_key_g, | ||
60 | int color_key_b, | ||
61 | void *(*new_update_region) (int x, int y, int w, int h, int *row_bytes), | ||
62 | void (*free_update_region) (int x, int y, int w, int h, void *data), | ||
63 | void *(*switch_buffer) (void *data, void *dest_buffer), | ||
64 | void *switch_data | ||
65 | ) | ||
66 | { | ||
67 | Render_Engine *re; | ||
68 | |||
69 | re = calloc(1, sizeof(Render_Engine)); | ||
70 | if (!re) | ||
71 | return NULL; | ||
72 | /* if we haven't initialized - init (automatic abort if already done) */ | ||
73 | evas_common_cpu_init(); | ||
74 | |||
75 | evas_common_blend_init(); | ||
76 | evas_common_image_init(); | ||
77 | evas_common_convert_init(); | ||
78 | evas_common_scale_init(); | ||
79 | evas_common_rectangle_init(); | ||
80 | evas_common_polygon_init(); | ||
81 | evas_common_line_init(); | ||
82 | evas_common_font_init(); | ||
83 | evas_common_draw_init(); | ||
84 | evas_common_tilebuf_init(); | ||
85 | |||
86 | evas_buffer_outbuf_buf_init(); | ||
87 | |||
88 | { | ||
89 | Outbuf_Depth dep; | ||
90 | DATA32 color_key = 0; | ||
91 | |||
92 | dep = OUTBUF_DEPTH_BGR_24BPP_888_888; | ||
93 | if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_ARGB32) | ||
94 | dep = OUTBUF_DEPTH_ARGB_32BPP_8888_8888; | ||
95 | else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB32) | ||
96 | dep = OUTBUF_DEPTH_RGB_32BPP_888_8888; | ||
97 | else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGRA32) | ||
98 | dep = OUTBUF_DEPTH_BGRA_32BPP_8888_8888; | ||
99 | else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB24) | ||
100 | dep = OUTBUF_DEPTH_RGB_24BPP_888_888; | ||
101 | else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGR24) | ||
102 | dep = OUTBUF_DEPTH_BGR_24BPP_888_888; | ||
103 | R_VAL(&color_key) = color_key_r; | ||
104 | G_VAL(&color_key) = color_key_g; | ||
105 | B_VAL(&color_key) = color_key_b; | ||
106 | A_VAL(&color_key) = 0; | ||
107 | re->ob = evas_buffer_outbuf_buf_setup_fb(w, | ||
108 | h, | ||
109 | dep, | ||
110 | dest_buffer, | ||
111 | dest_buffer_row_bytes, | ||
112 | use_color_key, | ||
113 | color_key, | ||
114 | alpha_threshold, | ||
115 | new_update_region, | ||
116 | free_update_region, | ||
117 | switch_buffer, | ||
118 | switch_data); | ||
119 | } | ||
120 | re->tb = evas_common_tilebuf_new(w, h); | ||
121 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
122 | eina_inarray_setup(&re->previous_rects, sizeof (Eina_Rectangle), 8); | ||
123 | return re; | ||
124 | } | ||
125 | |||
126 | /* engine api this module provides */ | ||
127 | static void * | ||
128 | eng_info(Evas *e __UNUSED__) | ||
129 | { | ||
130 | Evas_Engine_Info_Buffer *info; | ||
131 | info = calloc(1, sizeof(Evas_Engine_Info_Buffer)); | ||
132 | if (!info) return NULL; | ||
133 | info->magic.magic = rand(); | ||
134 | info->render_mode = EVAS_RENDER_MODE_BLOCKING; | ||
135 | return info; | ||
136 | } | ||
137 | |||
138 | static void | ||
139 | eng_info_free(Evas *e __UNUSED__, void *info) | ||
140 | { | ||
141 | Evas_Engine_Info_Buffer *in; | ||
142 | in = (Evas_Engine_Info_Buffer *)info; | ||
143 | free(in); | ||
144 | } | ||
145 | |||
146 | static int | ||
147 | eng_setup(Evas *e, void *in) | ||
148 | { | ||
149 | Render_Engine *re; | ||
150 | Evas_Engine_Info_Buffer *info; | ||
151 | |||
152 | info = (Evas_Engine_Info_Buffer *)in; | ||
153 | re = _output_setup(e->output.w, | ||
154 | e->output.h, | ||
155 | info->info.dest_buffer, | ||
156 | info->info.dest_buffer_row_bytes, | ||
157 | info->info.depth_type, | ||
158 | info->info.use_color_key, | ||
159 | info->info.alpha_threshold, | ||
160 | info->info.color_key_r, | ||
161 | info->info.color_key_g, | ||
162 | info->info.color_key_b, | ||
163 | info->info.func.new_update_region, | ||
164 | info->info.func.free_update_region, | ||
165 | info->info.func.switch_buffer, | ||
166 | info->info.switch_data); | ||
167 | if (e->engine.data.output) | ||
168 | eng_output_free(e->engine.data.output); | ||
169 | e->engine.data.output = re; | ||
170 | if (!e->engine.data.output) return 0; | ||
171 | if (!e->engine.data.context) | ||
172 | e->engine.data.context = e->engine.func->context_new(e->engine.data.output); | ||
173 | return 1; | ||
174 | } | ||
175 | |||
176 | static void | ||
177 | eng_output_free(void *data) | ||
178 | { | ||
179 | Render_Engine *re; | ||
180 | |||
181 | re = (Render_Engine *)data; | ||
182 | evas_buffer_outbuf_buf_free(re->ob); | ||
183 | evas_common_tilebuf_free(re->tb); | ||
184 | if (re->rects) evas_common_tilebuf_free_render_rects(re->rects); | ||
185 | free(re); | ||
186 | |||
187 | evas_common_font_shutdown(); | ||
188 | evas_common_image_shutdown(); | ||
189 | } | ||
190 | |||
191 | static void | ||
192 | eng_output_resize(void *data, int w, int h) | ||
193 | { | ||
194 | Render_Engine *re; | ||
195 | |||
196 | re = (Render_Engine *)data; | ||
197 | { | ||
198 | int depth; | ||
199 | void *dest; | ||
200 | int dest_row_bytes; | ||
201 | int alpha_level; | ||
202 | DATA32 color_key; | ||
203 | char use_color_key; | ||
204 | void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes); | ||
205 | void (*free_update_region) (int x, int y, int w, int h, void *data); | ||
206 | void * (*switch_buffer) (void *switch_data, void *dest); | ||
207 | void *switch_data; | ||
208 | |||
209 | depth = re->ob->depth; | ||
210 | dest = re->ob->dest; | ||
211 | dest_row_bytes = re->ob->dest_row_bytes; | ||
212 | alpha_level = re->ob->alpha_level; | ||
213 | color_key = re->ob->color_key; | ||
214 | use_color_key = re->ob->use_color_key; | ||
215 | new_update_region = re->ob->func.new_update_region; | ||
216 | free_update_region = re->ob->func.free_update_region; | ||
217 | switch_buffer = re->ob->func.switch_buffer; | ||
218 | switch_data = re->ob->switch_data; | ||
219 | evas_buffer_outbuf_buf_free(re->ob); | ||
220 | re->ob = evas_buffer_outbuf_buf_setup_fb(w, | ||
221 | h, | ||
222 | depth, | ||
223 | dest, | ||
224 | dest_row_bytes, | ||
225 | use_color_key, | ||
226 | color_key, | ||
227 | alpha_level, | ||
228 | new_update_region, | ||
229 | free_update_region, | ||
230 | switch_buffer, | ||
231 | switch_data); | ||
232 | } | ||
233 | evas_common_tilebuf_free(re->tb); | ||
234 | re->tb = evas_common_tilebuf_new(w, h); | ||
235 | if (re->tb) | ||
236 | evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); | ||
237 | } | ||
238 | |||
239 | static void | ||
240 | eng_output_tile_size_set(void *data, int w, int h) | ||
241 | { | ||
242 | Render_Engine *re; | ||
243 | |||
244 | re = (Render_Engine *)data; | ||
245 | evas_common_tilebuf_set_tile_size(re->tb, w, h); | ||
246 | } | ||
247 | |||
248 | static void | ||
249 | eng_output_redraws_rect_add(void *data, int x, int y, int w, int h) | ||
250 | { | ||
251 | Render_Engine *re; | ||
252 | |||
253 | re = (Render_Engine *)data; | ||
254 | evas_common_tilebuf_add_redraw(re->tb, x, y, w, h); | ||
255 | } | ||
256 | |||
257 | static void | ||
258 | eng_output_redraws_rect_del(void *data, int x, int y, int w, int h) | ||
259 | { | ||
260 | Render_Engine *re; | ||
261 | |||
262 | re = (Render_Engine *)data; | ||
263 | evas_common_tilebuf_del_redraw(re->tb, x, y, w, h); | ||
264 | } | ||
265 | |||
266 | static void | ||
267 | eng_output_redraws_clear(void *data) | ||
268 | { | ||
269 | Render_Engine *re; | ||
270 | |||
271 | re = (Render_Engine *)data; | ||
272 | evas_common_tilebuf_clear(re->tb); | ||
273 | } | ||
274 | |||
275 | static void * | ||
276 | eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch) | ||
277 | { | ||
278 | Render_Engine *re; | ||
279 | RGBA_Image *surface; | ||
280 | Tilebuf_Rect *rect; | ||
281 | int ux, uy, uw, uh; | ||
282 | |||
283 | re = (Render_Engine *)data; | ||
284 | if (re->end) | ||
285 | { | ||
286 | re->end = 0; | ||
287 | return NULL; | ||
288 | } | ||
289 | if (!re->rects) | ||
290 | { | ||
291 | re->rects = evas_common_tilebuf_get_render_rects(re->tb); | ||
292 | |||
293 | /* handle double buffering */ | ||
294 | if (re->ob->func.switch_buffer) | ||
295 | { | ||
296 | Eina_Rectangle *pushing; | ||
297 | |||
298 | if (re->ob->first_frame && !re->previous_rects.len) | ||
299 | { | ||
300 | evas_common_tilebuf_add_redraw(re->tb, 0, 0, re->ob->w, re->ob->h); | ||
301 | re->ob->first_frame = 0; | ||
302 | } | ||
303 | |||
304 | /* push previous frame */ | ||
305 | EINA_INARRAY_FOREACH(&re->previous_rects, pushing) | ||
306 | evas_common_tilebuf_add_redraw(re->tb, pushing->x, pushing->y, pushing->w, pushing->h); | ||
307 | eina_inarray_flush(&re->previous_rects); | ||
308 | |||
309 | /* save current list of damage */ | ||
310 | EINA_INLIST_FOREACH(re->rects, rect) | ||
311 | { | ||
312 | Eina_Rectangle local; | ||
313 | |||
314 | EINA_RECTANGLE_SET(&local, rect->x, rect->y, rect->w, rect->h); | ||
315 | eina_inarray_append(&re->previous_rects, &local); | ||
316 | } | ||
317 | |||
318 | /* and regenerate the damage list by tacking into account the damage over two frames */ | ||
319 | evas_common_tilebuf_free_render_rects(re->rects); | ||
320 | re->rects = evas_common_tilebuf_get_render_rects(re->tb); | ||
321 | } | ||
322 | |||
323 | re->cur_rect = EINA_INLIST_GET(re->rects); | ||
324 | } | ||
325 | if (!re->cur_rect) return NULL; | ||
326 | rect = (Tilebuf_Rect *)re->cur_rect; | ||
327 | ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h; | ||
328 | re->cur_rect = re->cur_rect->next; | ||
329 | if (!re->cur_rect) | ||
330 | { | ||
331 | evas_common_tilebuf_free_render_rects(re->rects); | ||
332 | re->rects = NULL; | ||
333 | re->end = 1; | ||
334 | } | ||
335 | |||
336 | if ((ux + uw) > re->ob->w) uw = re->ob->w - ux; | ||
337 | if ((uy + uh) > re->ob->h) uh = re->ob->h - uy; | ||
338 | if ((uw <= 0) || (uh <= 0)) return NULL; | ||
339 | surface = evas_buffer_outbuf_buf_new_region_for_update(re->ob, | ||
340 | ux, uy, uw, uh, | ||
341 | cx, cy, cw, ch); | ||
342 | *x = ux; *y = uy; *w = uw; *h = uh; | ||
343 | return surface; | ||
344 | } | ||
345 | |||
346 | static void | ||
347 | eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h) | ||
348 | { | ||
349 | Render_Engine *re; | ||
350 | |||
351 | re = (Render_Engine *)data; | ||
352 | #ifdef BUILD_PIPE_RENDER | ||
353 | evas_common_pipe_map_begin(surface); | ||
354 | #endif | ||
355 | evas_buffer_outbuf_buf_push_updated_region(re->ob, surface, x, y, w, h); | ||
356 | evas_buffer_outbuf_buf_free_region_for_update(re->ob, surface); | ||
357 | evas_common_cpu_end_opt(); | ||
358 | } | ||
359 | |||
360 | static void | ||
361 | eng_output_flush(void *data) | ||
362 | { | ||
363 | Render_Engine *re = (Render_Engine *)data; | ||
364 | evas_buffer_outbuf_buf_switch_buffer(re->ob); | ||
365 | } | ||
366 | |||
367 | static void | ||
368 | eng_output_idle_flush(void *data __UNUSED__) | ||
369 | { | ||
370 | } | ||
371 | |||
372 | static Eina_Bool | ||
373 | eng_canvas_alpha_get(void *data, void *context __UNUSED__) | ||
374 | { | ||
375 | Render_Engine *re; | ||
376 | |||
377 | re = (Render_Engine *)data; | ||
378 | if (re->ob->priv.back_buf) | ||
379 | return re->ob->priv.back_buf->cache_entry.flags.alpha; | ||
380 | return EINA_TRUE; | ||
381 | } | ||
382 | |||
383 | /* module advertising code */ | ||
384 | static int | ||
385 | module_open(Evas_Module *em) | ||
386 | { | ||
387 | if (!em) return 0; | ||
388 | /* get whatever engine module we inherit from */ | ||
389 | if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0; | ||
390 | |||
391 | _evas_engine_buffer_log_dom = eina_log_domain_register | ||
392 | ("evas-buffer", EINA_COLOR_BLUE); | ||
393 | if (_evas_engine_buffer_log_dom < 0) | ||
394 | { | ||
395 | EINA_LOG_ERR("Can not create a module log domain."); | ||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | /* store it for later use */ | ||
400 | func = pfunc; | ||
401 | /* now to override methods */ | ||
402 | #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_) | ||
403 | ORD(info); | ||
404 | ORD(info_free); | ||
405 | ORD(setup); | ||
406 | ORD(canvas_alpha_get); | ||
407 | ORD(output_free); | ||
408 | ORD(output_resize); | ||
409 | ORD(output_tile_size_set); | ||
410 | ORD(output_redraws_rect_add); | ||
411 | ORD(output_redraws_rect_del); | ||
412 | ORD(output_redraws_clear); | ||
413 | ORD(output_redraws_next_update_get); | ||
414 | ORD(output_redraws_next_update_push); | ||
415 | ORD(output_flush); | ||
416 | ORD(output_idle_flush); | ||
417 | /* now advertise out own api */ | ||
418 | em->functions = (void *)(&func); | ||
419 | return 1; | ||
420 | } | ||
421 | |||
422 | static void | ||
423 | module_close(Evas_Module *em __UNUSED__) | ||
424 | { | ||
425 | eina_log_domain_unregister(_evas_engine_buffer_log_dom); | ||
426 | } | ||
427 | |||
428 | static Evas_Module_Api evas_modapi = | ||
429 | { | ||
430 | EVAS_MODULE_API_VERSION, | ||
431 | "buffer", | ||
432 | "none", | ||
433 | { | ||
434 | module_open, | ||
435 | module_close | ||
436 | } | ||
437 | }; | ||
438 | |||
439 | EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, buffer); | ||
440 | |||
441 | #ifndef EVAS_STATIC_BUILD_BUFFER | ||
442 | EVAS_EINA_MODULE_DEFINE(engine, buffer); | ||
443 | #endif | ||
444 | |||