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_gradient_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();
63 evas_qtopia_outbuf_software_qtopia_init();
65 /* get any stored performance metrics from device (xserver) */
66 re->ob = evas_qtopia_outbuf_software_qtopia_setup_q(w, h, rot, OUTBUF_DEPTH_INHERIT, target);
72 evas_qtopia_outbuf_software_qtopia_set_have_backbuf(re->ob, 0);
73 re->tb = evas_common_tilebuf_new(w, h);
76 evas_qtopia_outbuf_software_qtopia_free(re->ob);
80 /* in preliminary tests 16x16 gave highest framerates */
81 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
85 /* engine api this module provides */
89 Evas_Engine_Info_Software_Qtopia *info;
90 info = calloc(1, sizeof(Evas_Engine_Info_Software_Qtopia));
91 if (!info) return NULL;
92 info->magic.magic = rand();
93 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
99 eng_info_free(Evas *e, void *info)
101 Evas_Engine_Info_Software_Qtopia *in;
102 in = (Evas_Engine_Info_Software_Qtopia *)info;
107 eng_setup(Evas *e, void *in)
110 Evas_Engine_Info_Software_Qtopia *info;
112 info = (Evas_Engine_Info_Software_Qtopia *)in;
113 if (!e->engine.data.output)
114 e->engine.data.output =
115 _output_setup(e->output.w,
119 if (!e->engine.data.output) return 0;
120 if (!e->engine.data.context)
121 e->engine.data.context =
122 e->engine.func->context_new(e->engine.data.output);
124 re = e->engine.data.output;
130 eng_output_free(void *data)
134 re = (Render_Engine *)data;
135 evas_qtopia_outbuf_software_qtopia_free(re->ob);
136 evas_common_tilebuf_free(re->tb);
137 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
140 evas_common_font_shutdown();
141 evas_common_image_shutdown();
145 eng_output_resize(void *data, int w, int h)
149 re = (Render_Engine *)data;
150 evas_qtopia_outbuf_software_qtopia_reconfigure(re->ob, w, h,
151 evas_qtopia_outbuf_software_qtopia_get_rot(re->ob),
152 OUTBUF_DEPTH_INHERIT);
153 evas_qtopia_outbuf_software_qtopia_set_have_backbuf(re->ob, 0);
154 evas_common_tilebuf_free(re->tb);
155 re->tb = evas_common_tilebuf_new(w, h);
157 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
161 eng_output_tile_size_set(void *data, int w, int h)
165 re = (Render_Engine *)data;
166 evas_common_tilebuf_set_tile_size(re->tb, w, h);
170 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
174 re = (Render_Engine *)data;
175 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
179 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
183 re = (Render_Engine *)data;
184 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
188 eng_output_redraws_clear(void *data)
192 re = (Render_Engine *)data;
193 evas_common_tilebuf_clear(re->tb);
197 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
204 re = (Render_Engine *)data;
212 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
213 re->cur_rect = EINA_INLIST_GET(re->rects);
215 if (!re->cur_rect) return NULL;
216 rect = (Tilebuf_Rect *)re->cur_rect;
217 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
218 re->cur_rect = re->cur_rect->next;
221 evas_common_tilebuf_free_render_rects(re->rects);
226 surface = evas_qtopia_outbuf_software_qtopia_new_region_for_update(re->ob,
229 *x = ux; *y = uy; *w = uw; *h = uh;
234 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
237 Evas_Engine_Info_Software_Qtopia *info;
239 re = (Render_Engine *)data;
240 #ifdef BUILD_PIPE_RENDER
241 evas_common_pipe_map4_begin(surface);
243 evas_qtopia_outbuf_software_qtopia_push_updated_region(re->ob, surface, x, y, w, h);
244 evas_qtopia_outbuf_software_qtopia_free_region_for_update(re->ob, surface);
245 evas_common_cpu_end_opt();
249 eng_output_flush(void *data)
253 re = (Render_Engine *)data;
257 eng_output_idle_flush(void *data)
261 re = (Render_Engine *)data;
265 eng_canvas_alpha_get(void *data, void *context)
270 /* module advertising code */
272 module_open(Evas_Module *em)
275 /* get whatever engine module we inherit from */
276 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
277 _evas_engine_soft_qtopia_log_dom = eina_log_domain_register("EvasSoftQtopia",EVAS_DEFAULT_LOG_COLOR);
278 if(_evas_engine_soft_qtopia_log_dom < 0)
280 EINA_LOG_ERR("Impossible to create a log domain for the qtopia engine.\n");
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);