1 #include "evas_common.h"
2 #include "evas_private.h"
3 #include "evas_engine.h"
4 #include "Evas_Engine_Software_Qtopia.h"
6 int _evas_engine_soft_qtopia_log_dom = -1;
7 /* function tables - filled in later (func and parent func) */
8 static Evas_Func func, pfunc;
10 /* engine struct data */
11 typedef struct _Render_Engine Render_Engine;
18 Eina_Inlist *cur_rect;
22 /* prototypes we will use here */
23 static void *_output_setup(int w, int h, int rot, QWidget *target);
25 static void *eng_info(Evas *e);
26 static void eng_info_free(Evas *e, void *info);
27 static int eng_setup(Evas *e, void *info);
28 static void eng_output_free(void *data);
29 static void eng_output_resize(void *data, int w, int h);
30 static void eng_output_tile_size_set(void *data, int w, int h);
31 static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
32 static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
33 static void eng_output_redraws_clear(void *data);
34 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);
35 static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
36 static void eng_output_flush(void *data);
37 static void eng_output_idle_flush(void *data);
39 /* internal engine routines */
41 _output_setup(int w, int h, int rot, QWidget *target)
45 re = calloc(1, sizeof(Render_Engine));
48 /* if we haven't initialized - init (automatic abort if already done) */
49 evas_common_cpu_init();
51 evas_common_blend_init();
52 evas_common_image_init();
53 evas_common_convert_init();
54 evas_common_scale_init();
55 evas_common_rectangle_init();
56 evas_common_polygon_init();
57 evas_common_line_init();
58 evas_common_font_init();
59 evas_common_draw_init();
60 evas_common_tilebuf_init();
62 evas_qtopia_outbuf_software_qtopia_init();
64 /* get any stored performance metrics from device (xserver) */
65 re->ob = evas_qtopia_outbuf_software_qtopia_setup_q(w, h, rot, OUTBUF_DEPTH_INHERIT, target);
71 evas_qtopia_outbuf_software_qtopia_set_have_backbuf(re->ob, 0);
72 re->tb = evas_common_tilebuf_new(w, h);
75 evas_qtopia_outbuf_software_qtopia_free(re->ob);
79 /* in preliminary tests 16x16 gave highest framerates */
80 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
84 /* engine api this module provides */
88 Evas_Engine_Info_Software_Qtopia *info;
89 info = calloc(1, sizeof(Evas_Engine_Info_Software_Qtopia));
90 if (!info) return NULL;
91 info->magic.magic = rand();
92 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
98 eng_info_free(Evas *e, void *info)
100 Evas_Engine_Info_Software_Qtopia *in;
101 in = (Evas_Engine_Info_Software_Qtopia *)info;
106 eng_setup(Evas *e, void *in)
109 Evas_Engine_Info_Software_Qtopia *info;
111 info = (Evas_Engine_Info_Software_Qtopia *)in;
112 if (!e->engine.data.output)
113 e->engine.data.output =
114 _output_setup(e->output.w,
118 if (!e->engine.data.output) return 0;
119 if (!e->engine.data.context)
120 e->engine.data.context =
121 e->engine.func->context_new(e->engine.data.output);
123 re = e->engine.data.output;
129 eng_output_free(void *data)
133 re = (Render_Engine *)data;
134 evas_qtopia_outbuf_software_qtopia_free(re->ob);
135 evas_common_tilebuf_free(re->tb);
136 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
139 evas_common_font_shutdown();
140 evas_common_image_shutdown();
144 eng_output_resize(void *data, int w, int h)
148 re = (Render_Engine *)data;
149 evas_qtopia_outbuf_software_qtopia_reconfigure(re->ob, w, h,
150 evas_qtopia_outbuf_software_qtopia_get_rot(re->ob),
151 OUTBUF_DEPTH_INHERIT);
152 evas_qtopia_outbuf_software_qtopia_set_have_backbuf(re->ob, 0);
153 evas_common_tilebuf_free(re->tb);
154 re->tb = evas_common_tilebuf_new(w, h);
156 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
160 eng_output_tile_size_set(void *data, int w, int h)
164 re = (Render_Engine *)data;
165 evas_common_tilebuf_set_tile_size(re->tb, w, h);
169 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
173 re = (Render_Engine *)data;
174 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
178 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
182 re = (Render_Engine *)data;
183 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
187 eng_output_redraws_clear(void *data)
191 re = (Render_Engine *)data;
192 evas_common_tilebuf_clear(re->tb);
196 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
203 re = (Render_Engine *)data;
211 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
212 re->cur_rect = EINA_INLIST_GET(re->rects);
214 if (!re->cur_rect) return NULL;
215 rect = (Tilebuf_Rect *)re->cur_rect;
216 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
217 re->cur_rect = re->cur_rect->next;
220 evas_common_tilebuf_free_render_rects(re->rects);
225 surface = evas_qtopia_outbuf_software_qtopia_new_region_for_update(re->ob,
228 *x = ux; *y = uy; *w = uw; *h = uh;
233 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
236 Evas_Engine_Info_Software_Qtopia *info;
238 re = (Render_Engine *)data;
239 #ifdef BUILD_PIPE_RENDER
240 evas_common_pipe_map_begin(surface);
242 evas_qtopia_outbuf_software_qtopia_push_updated_region(re->ob, surface, x, y, w, h);
243 evas_qtopia_outbuf_software_qtopia_free_region_for_update(re->ob, surface);
244 evas_common_cpu_end_opt();
248 eng_output_flush(void *data)
252 re = (Render_Engine *)data;
256 eng_output_idle_flush(void *data)
260 re = (Render_Engine *)data;
264 eng_canvas_alpha_get(void *data, void *context)
269 /* module advertising code */
271 module_open(Evas_Module *em)
274 /* get whatever engine module we inherit from */
275 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
276 _evas_engine_soft_qtopia_log_dom = eina_log_domain_register
277 ("evas-software_qtopia", EVAS_DEFAULT_LOG_COLOR);
278 if(_evas_engine_soft_qtopia_log_dom < 0)
280 EINA_LOG_ERR("Can not create a module log domain.");
283 /* store it for later use */
285 /* now to override methods */
286 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
290 ORD(canvas_alpha_get);
293 ORD(output_tile_size_set);
294 ORD(output_redraws_rect_add);
295 ORD(output_redraws_rect_del);
296 ORD(output_redraws_clear);
297 ORD(output_redraws_next_update_get);
298 ORD(output_redraws_next_update_push);
300 ORD(output_idle_flush);
301 /* now advertise out own api */
302 em->functions = (void *)(&func);
307 module_close(Evas_Module *em)
309 eina_log_domain_unregister(_evas_engine_soft_qtopia_log_dom);
312 static Evas_Module_Api evas_modapi =
314 EVAS_MODULE_API_VERSION,
323 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_qtopia);
325 #ifndef EVAS_STATIC_BUILD_SOFTWARE_QTOPIA
326 EVAS_EINA_MODULE_DEFINE(engine, software_qtopia);