1 #include "evas_common.h"
2 #include "evas_private.h"
3 #include "evas_engine.h"
4 #include "Evas_Engine_FB.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, int rot, int vt, int dev, int refresh);
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 */
40 _output_setup(int w, int h, int rot, int vt, int dev, int refresh)
44 re = calloc(1, sizeof(Render_Engine));
45 /* if we haven't initialized - init (automatic abort if already done) */
46 evas_common_cpu_init();
48 evas_common_blend_init();
49 evas_common_image_init();
50 evas_common_convert_init();
51 evas_common_scale_init();
52 evas_common_rectangle_init();
53 evas_common_gradient_init();
54 evas_common_polygon_init();
55 evas_common_line_init();
56 evas_common_font_init();
57 evas_common_draw_init();
58 evas_common_tilebuf_init();
60 evas_fb_outbuf_fb_init();
62 /* get any stored performance metrics from device (xserver) */
63 re->ob = evas_fb_outbuf_fb_setup_fb(w, h, rot, OUTBUF_DEPTH_INHERIT, vt, dev, refresh);
64 re->tb = evas_common_tilebuf_new(evas_fb_outbuf_fb_get_width(re->ob), evas_fb_outbuf_fb_get_height(re->ob));
66 evas_fb_outbuf_fb_set_have_backbuf(re->ob, 0);
67 /* in preliminary tests 16x16 gave highest framerates */
68 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
72 /* engine api this module provides */
76 Evas_Engine_Info_FB *info;
78 info = calloc(1, sizeof(Evas_Engine_Info_FB));
79 if (!info) return NULL;
80 info->magic.magic = rand();
86 eng_info_free(Evas *e, void *info)
88 Evas_Engine_Info_FB *in;
90 in = (Evas_Engine_Info_FB *)info;
95 eng_setup(Evas *e, void *in)
98 Evas_Engine_Info_FB *info;
100 info = (Evas_Engine_Info_FB *)in;
101 re = _output_setup(e->output.w,
104 info->info.virtual_terminal,
105 info->info.device_number,
107 e->engine.data.output = re;
108 if (!e->engine.data.output) return;
109 e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
113 eng_output_free(void *data)
117 re = (Render_Engine *)data;
118 evas_fb_outbuf_fb_free(re->ob);
119 evas_common_tilebuf_free(re->tb);
120 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
123 evas_common_font_shutdown();
124 evas_common_image_shutdown();
128 eng_output_resize(void *data, int w, int h)
132 re = (Render_Engine *)data;
133 evas_fb_outbuf_fb_reconfigure(re->ob, w, h,
134 evas_fb_outbuf_fb_get_rot(re->ob),
135 OUTBUF_DEPTH_INHERIT);
136 evas_common_tilebuf_free(re->tb);
137 re->tb = evas_common_tilebuf_new(w, h);
139 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
143 eng_output_tile_size_set(void *data, int w, int h)
147 re = (Render_Engine *)data;
148 evas_common_tilebuf_set_tile_size(re->tb, w, h);
152 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
156 re = (Render_Engine *)data;
157 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
161 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
165 re = (Render_Engine *)data;
166 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
170 eng_output_redraws_clear(void *data)
174 re = (Render_Engine *)data;
175 evas_common_tilebuf_clear(re->tb);
179 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
186 re = (Render_Engine *)data;
194 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
195 re->cur_rect = (Evas_Object_List *)re->rects;
197 if (!re->cur_rect) return NULL;
198 rect = (Tilebuf_Rect *)re->cur_rect;
199 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
200 re->cur_rect = re->cur_rect->next;
203 evas_common_tilebuf_free_render_rects(re->rects);
208 surface = evas_fb_outbuf_fb_new_region_for_update(re->ob,
211 *x = ux; *y = uy; *w = uw; *h = uh;
216 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
220 re = (Render_Engine *)data;
221 evas_common_pipe_begin(surface);
222 evas_common_pipe_flush(surface);
223 evas_fb_outbuf_fb_push_updated_region(re->ob, surface, x, y, w, h);
224 evas_fb_outbuf_fb_free_region_for_update(re->ob, surface);
225 evas_common_cpu_end_opt();
229 eng_output_flush(void *data)
233 re = (Render_Engine *)data;
237 eng_output_idle_flush(void *data)
241 re = (Render_Engine *)data;
244 /* module advertising code */
246 module_open(Evas_Module *em)
249 /* get whatever engine module we inherit from */
250 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
251 /* store it for later use */
253 /* now to override methods */
254 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
260 ORD(output_tile_size_set);
261 ORD(output_redraws_rect_add);
262 ORD(output_redraws_rect_del);
263 ORD(output_redraws_clear);
264 ORD(output_redraws_next_update_get);
265 ORD(output_redraws_next_update_push);
267 ORD(output_idle_flush);
268 /* now advertise out own api */
269 em->functions = (void *)(&func);
278 EAPI Evas_Module_Api evas_modapi =
280 EVAS_MODULE_API_VERSION,
281 EVAS_MODULE_TYPE_ENGINE,