1 #include "evas_common.h"
2 #include "evas_private.h"
3 #include "evas_engine.h"
4 #include "Evas_Engine_Buffer.h"
6 /* function tables - filled in later (func and parent func) */
7 static Evas_Func func, pfunc;
9 /* engine struct data */
10 typedef struct _Render_Engine Render_Engine;
17 Evas_Object_List *cur_rect;
21 /* prototypes we will use here */
22 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));
24 static void *eng_info(Evas *e);
25 static void eng_info_free(Evas *e, void *info);
26 static void eng_setup(Evas *e, void *info);
27 static void eng_output_free(void *data);
28 static void eng_output_resize(void *data, int w, int h);
29 static void eng_output_tile_size_set(void *data, int w, int h);
30 static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
31 static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
32 static void eng_output_redraws_clear(void *data);
33 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);
34 static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
35 static void eng_output_flush(void *data);
36 static void eng_output_idle_flush(void *data);
38 /* internal engine routines */
43 int dest_buffer_row_bytes,
50 void *(*new_update_region) (int x, int y, int w, int h, int *row_bytes),
51 void (*free_update_region) (int x, int y, int w, int h, void *data)
56 re = calloc(1, sizeof(Render_Engine));
57 /* if we haven't initialized - init (automatic abort if already done) */
58 evas_common_cpu_init();
60 evas_common_blend_init();
61 evas_common_image_init();
62 evas_common_convert_init();
63 evas_common_scale_init();
64 evas_common_rectangle_init();
65 evas_common_gradient_init();
66 evas_common_polygon_init();
67 evas_common_line_init();
68 evas_common_font_init();
69 evas_common_draw_init();
70 evas_common_tilebuf_init();
72 evas_buffer_outbuf_buf_init();
78 dep = OUTBUF_DEPTH_BGR_24BPP_888_888;
79 if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_ARGB32)
80 dep = OUTBUF_DEPTH_ARGB_32BPP_8888_8888;
81 else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB32)
82 dep = OUTBUF_DEPTH_RGB_32BPP_888_8888;
83 else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGRA32)
84 dep = OUTBUF_DEPTH_BGRA_32BPP_8888_8888;
85 else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_RGB24)
86 dep = OUTBUF_DEPTH_RGB_24BPP_888_888;
87 else if (depth_type == EVAS_ENGINE_BUFFER_DEPTH_BGR24)
88 dep = OUTBUF_DEPTH_BGR_24BPP_888_888;
89 R_VAL(&color_key) = color_key_r;
90 G_VAL(&color_key) = color_key_g;
91 B_VAL(&color_key) = color_key_b;
92 A_VAL(&color_key) = 0;
93 re->ob = evas_buffer_outbuf_buf_setup_fb(w,
97 dest_buffer_row_bytes,
104 re->tb = evas_common_tilebuf_new(w, h);
105 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
109 /* engine api this module provides */
113 Evas_Engine_Info_Buffer *info;
115 info = calloc(1, sizeof(Evas_Engine_Info_Buffer));
116 if (!info) return NULL;
117 info->magic.magic = rand();
123 eng_info_free(Evas *e, void *info)
125 Evas_Engine_Info_Buffer *in;
127 in = (Evas_Engine_Info_Buffer *)info;
132 eng_setup(Evas *e, void *in)
135 Evas_Engine_Info_Buffer *info;
137 info = (Evas_Engine_Info_Buffer *)in;
138 if (e->engine.data.output)
139 eng_output_free(e->engine.data.output);
140 re = _output_setup(e->output.w,
142 info->info.dest_buffer,
143 info->info.dest_buffer_row_bytes,
144 info->info.depth_type,
145 info->info.use_color_key,
146 info->info.alpha_threshold,
147 info->info.color_key_r,
148 info->info.color_key_g,
149 info->info.color_key_b,
150 info->info.func.new_update_region,
151 info->info.func.free_update_region);
152 e->engine.data.output = re;
153 if (!e->engine.data.output) return;
154 if (!e->engine.data.context)
155 e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
159 eng_output_free(void *data)
163 re = (Render_Engine *)data;
164 evas_buffer_outbuf_buf_free(re->ob);
165 evas_common_tilebuf_free(re->tb);
166 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
169 evas_common_font_shutdown();
170 evas_common_image_shutdown();
174 eng_output_resize(void *data, int w, int h)
178 re = (Render_Engine *)data;
186 void * (*new_update_region) (int x, int y, int w, int h, int *row_bytes);
187 void (*free_update_region) (int x, int y, int w, int h, void *data);
189 depth = re->ob->depth;
191 dest_row_bytes = re->ob->dest_row_bytes;
192 alpha_level = re->ob->alpha_level;
193 color_key = re->ob->color_key;
194 use_color_key = re->ob->use_color_key;
195 new_update_region = re->ob->func.new_update_region;
196 free_update_region = re->ob->func.free_update_region;
197 evas_buffer_outbuf_buf_free(re->ob);
198 re->ob = evas_buffer_outbuf_buf_setup_fb(w,
209 evas_common_tilebuf_free(re->tb);
210 re->tb = evas_common_tilebuf_new(w, h);
212 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
216 eng_output_tile_size_set(void *data, int w, int h)
220 re = (Render_Engine *)data;
221 evas_common_tilebuf_set_tile_size(re->tb, w, h);
225 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
229 re = (Render_Engine *)data;
230 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
234 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
238 re = (Render_Engine *)data;
239 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
243 eng_output_redraws_clear(void *data)
247 re = (Render_Engine *)data;
248 evas_common_tilebuf_clear(re->tb);
252 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
259 re = (Render_Engine *)data;
267 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
268 re->cur_rect = (Evas_Object_List *)re->rects;
270 if (!re->cur_rect) return NULL;
271 rect = (Tilebuf_Rect *)re->cur_rect;
272 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
273 re->cur_rect = re->cur_rect->next;
276 evas_common_tilebuf_free_render_rects(re->rects);
281 if ((ux + uw) > re->ob->w) uw = re->ob->w - ux;
282 if ((uy + uh) > re->ob->h) uh = re->ob->h - uy;
283 if ((uw <= 0) || (uh <= 0)) return NULL;
284 surface = evas_buffer_outbuf_buf_new_region_for_update(re->ob,
287 *x = ux; *y = uy; *w = uw; *h = uh;
292 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
296 re = (Render_Engine *)data;
297 evas_common_pipe_begin(surface);
298 evas_common_pipe_flush(surface);
299 evas_buffer_outbuf_buf_push_updated_region(re->ob, surface, x, y, w, h);
300 evas_buffer_outbuf_buf_free_region_for_update(re->ob, surface);
301 evas_common_cpu_end_opt();
305 eng_output_flush(void *data)
309 re = (Render_Engine *)data;
313 eng_output_idle_flush(void *data)
317 re = (Render_Engine *)data;
320 /* module advertising code */
322 module_open(Evas_Module *em)
325 /* get whatever engine module we inherit from */
326 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
327 /* store it for later use */
329 /* now to override methods */
330 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
336 ORD(output_tile_size_set);
337 ORD(output_redraws_rect_add);
338 ORD(output_redraws_rect_del);
339 ORD(output_redraws_clear);
340 ORD(output_redraws_next_update_get);
341 ORD(output_redraws_next_update_push);
343 ORD(output_idle_flush);
344 /* now advertise out own api */
345 em->functions = (void *)(&func);
354 EAPI Evas_Module_Api evas_modapi =
356 EVAS_MODULE_API_VERSION,
357 EVAS_MODULE_TYPE_ENGINE,