1 #include "evas_common.h"
2 #include "evas_private.h"
3 #include "evas_engine.h"
4 #include "Evas_Engine_Software_DDraw.h"
6 int _evas_engine_soft_ddraw_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;
23 /* log domain variable */
24 int _evas_log_dom_module = -1;
28 _output_setup(int width,
37 re = calloc(1, sizeof(Render_Engine));
41 /* if we haven't initialized - init (automatic abort if already done) */
42 evas_common_cpu_init();
44 evas_common_blend_init();
45 evas_common_image_init();
46 evas_common_convert_init();
47 evas_common_scale_init();
48 evas_common_rectangle_init();
49 evas_common_gradient_init();
50 evas_common_polygon_init();
51 evas_common_line_init();
52 evas_common_font_init();
53 evas_common_draw_init();
54 evas_common_tilebuf_init();
56 evas_software_ddraw_outbuf_init();
58 re->ob = evas_software_ddraw_outbuf_setup(width, height, rot,
60 window, depth, fullscreen);
67 /* for updates return 1 big buffer, but only use portions of it, also cache
68 it and keep it around until an idle_flush */
69 /* disable for now - i am hunting down why some expedite tests are slower,
70 * as well as shaped stuff is broken and probable non-32bpp is broken as
71 * convert funcs dont do the right thing
76 re->tb = evas_common_tilebuf_new(width, height);
79 evas_software_ddraw_outbuf_free(re->ob);
83 /* in preliminary tests 16x16 gave highest framerates */
84 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
90 /* engine api this module provides */
95 Evas_Engine_Info_Software_DDraw *info;
97 info = calloc(1, sizeof(Evas_Engine_Info_Software_DDraw));
98 if (!info) return NULL;
99 info->magic.magic = rand();
100 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
106 eng_info_free(Evas *e, void *info)
108 Evas_Engine_Info_Software_DDraw *in;
109 in = (Evas_Engine_Info_Software_DDraw *)info;
114 eng_setup(Evas *e, void *in)
117 Evas_Engine_Info_Software_DDraw *info;
119 info = (Evas_Engine_Info_Software_DDraw *)in;
120 if (!e->engine.data.output)
121 e->engine.data.output = _output_setup(e->output.w,
126 info->info.fullscreen);
131 re = e->engine.data.output;
132 ponebuf = re->ob->onebuf;
133 evas_software_ddraw_outbuf_free(re->ob);
134 re->ob = evas_software_ddraw_outbuf_setup(e->output.w,
137 OUTBUF_DEPTH_INHERIT,
140 info->info.fullscreen);
141 re->ob->onebuf = ponebuf;
143 if (!e->engine.data.output) return 0;
144 if (!e->engine.data.context)
145 e->engine.data.context = e->engine.func->context_new(e->engine.data.output);
147 re = e->engine.data.output;
153 eng_output_free(void *data)
159 re = (Render_Engine *)data;
160 evas_software_ddraw_outbuf_free(re->ob);
161 evas_common_tilebuf_free(re->tb);
162 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
165 evas_common_font_shutdown();
166 evas_common_image_shutdown();
170 eng_output_resize(void *data, int width, int height)
174 re = (Render_Engine *)data;
175 evas_software_ddraw_outbuf_reconfigure(re->ob,
178 evas_software_ddraw_outbuf_rot_get(re->ob),
179 OUTBUF_DEPTH_INHERIT);
180 evas_common_tilebuf_free(re->tb);
181 re->tb = evas_common_tilebuf_new(width, height);
183 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
187 eng_output_tile_size_set(void *data, int w, int h)
191 re = (Render_Engine *)data;
192 evas_common_tilebuf_set_tile_size(re->tb, w, h);
196 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
200 re = (Render_Engine *)data;
201 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
205 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
209 re = (Render_Engine *)data;
210 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
214 eng_output_redraws_clear(void *data)
218 re = (Render_Engine *)data;
219 evas_common_tilebuf_clear(re->tb);
223 eng_output_redraws_next_update_get(void *data,
241 re = (Render_Engine *)data;
249 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
250 re->cur_rect = EINA_INLIST_GET(re->rects);
252 if (!re->cur_rect) return NULL;
253 rect = (Tilebuf_Rect *)re->cur_rect;
258 re->cur_rect = re->cur_rect->next;
261 evas_common_tilebuf_free_render_rects(re->rects);
266 surface = evas_software_ddraw_outbuf_new_region_for_update(re->ob,
285 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
289 re = (Render_Engine *)data;
290 #ifdef BUILD_PIPE_RENDER
291 evas_common_pipe_map4_begin(surface);
293 evas_software_ddraw_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
294 evas_software_ddraw_outbuf_free_region_for_update(re->ob, surface);
295 evas_common_cpu_end_opt();
299 eng_output_flush(void *data)
303 re = (Render_Engine *)data;
304 evas_software_ddraw_outbuf_flush(re->ob);
308 eng_output_idle_flush(void *data)
312 re = (Render_Engine *)data;
313 evas_software_ddraw_outbuf_idle_flush(re->ob);
317 eng_canvas_alpha_get(void *data, void *context)
322 /* module advertising code */
324 module_open(Evas_Module *em)
327 /* get whatever engine module we inherit from */
328 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
329 _evas_log_dom_module = eina_log_domain_register("Software_DDraw", EVAS_DEFAULT_LOG_COLOR);
330 if(_evas_log_dom_module < 0)
332 EINA_LOG_ERR("Can not create a module log domain.");
335 /* store it for later use */
337 /* now to override methods */
338 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
342 ORD(canvas_alpha_get);
345 ORD(output_tile_size_set);
346 ORD(output_redraws_rect_add);
347 ORD(output_redraws_rect_del);
348 ORD(output_redraws_clear);
349 ORD(output_redraws_next_update_get);
350 ORD(output_redraws_next_update_push);
352 ORD(output_idle_flush);
353 /* now advertise out own api */
354 em->functions = (void *)(&func);
359 module_close(Evas_Module *em)
361 eina_log_domain_unregister(_evas_log_dom_module);
364 static Evas_Module_Api evas_modapi =
366 EVAS_MODULE_API_VERSION,
375 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_ddraw);
377 #ifndef EVAS_STATIC_BUILD_SOFTWARE_DDRAW
378 EVAS_EINA_MODULE_DEFINE(engine, software_ddraw);