1 #include "evas_engine.h"
2 #include "evas_private.h"
3 #include "Evas_Engine_Direct3D.h"
5 /* engine struct data */
6 typedef struct _Render_Engine Render_Engine;
13 Evas_Object_List *cur_rect;
18 /* function tables - filled in later (func and parent func) */
19 static Evas_Func func, pfunc;
21 /* prototypes we will use here */
22 static void *_output_setup(int width,
27 LPDIRECT3DDEVICE9 device,
29 LPDIRECT3DTEXTURE9 texture,
32 static void *eng_info(Evas *e);
33 static void eng_info_free(Evas *e,
35 static void eng_setup(Evas *e,
37 static void eng_output_free(void *data);
38 static void eng_output_resize(void *data,
41 static void eng_output_tile_size_set(void *data,
44 static void eng_output_redraws_rect_add(void *data,
49 static void eng_output_redraws_rect_del(void *data,
54 static void eng_output_redraws_clear(void *data);
56 /* internal engine routines */
58 _output_setup(int width,
63 LPDIRECT3DDEVICE9 device,
65 LPDIRECT3DTEXTURE9 texture,
70 re = (Render_Engine *)calloc(1, sizeof(Render_Engine));
73 /* if we haven't initialized - init (automatic abort if already done) */
74 evas_common_cpu_init();
76 evas_common_blend_init();
77 evas_common_image_init();
78 evas_common_convert_init();
79 evas_common_scale_init();
80 evas_common_rectangle_init();
81 evas_common_gradient_init();
82 evas_common_polygon_init();
83 evas_common_line_init();
84 evas_common_font_init();
85 evas_common_draw_init();
86 evas_common_tilebuf_init();
88 evas_direct3d_outbuf_init();
90 /* get any stored performance metrics from device */
91 re->ob = evas_direct3d_outbuf_setup_d3d(width, height, rotation, OUTBUF_DEPTH_INHERIT, window, object, device, sprite, texture, w_depth);
98 re->tb = evas_common_tilebuf_new(width, height);
101 evas_direct3d_outbuf_free(re->ob);
106 /* FIXME: that comment :) */
107 /* in preliminary tests 16x16 gave highest framerates */
108 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
113 /* engine api this module provides */
117 Evas_Engine_Info_Direct3D *info;
119 info = (Evas_Engine_Info_Direct3D *)calloc(1, sizeof(Evas_Engine_Info_Direct3D));
120 if (!info) return NULL;
121 info->magic.magic = rand();
127 eng_info_free(Evas *e,
130 Evas_Engine_Info_Direct3D *in;
132 in = (Evas_Engine_Info_Direct3D *)info;
141 Evas_Engine_Info_Direct3D *in;
143 in = (Evas_Engine_Info_Direct3D *)info;
144 if (!e->engine.data.output)
145 e->engine.data.output =
146 _output_setup(e->output.w,
155 if (!e->engine.data.output) return;
156 if (!e->engine.data.context)
157 e->engine.data.context =
158 e->engine.func->context_new(e->engine.data.output);
160 re = (Render_Engine *)e->engine.data.output;
164 eng_output_free(void *data)
168 re = (Render_Engine *)data;
169 evas_direct3d_outbuf_free(re->ob);
170 evas_common_tilebuf_free(re->tb);
171 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
174 evas_common_font_shutdown();
175 evas_common_image_shutdown();
179 eng_output_resize(void *data,
185 re = (Render_Engine *)data;
186 evas_direct3d_outbuf_reconfigure(re->ob,
189 evas_direct3d_outbuf_rot_get(re->ob),
190 OUTBUF_DEPTH_INHERIT);
191 evas_common_tilebuf_free(re->tb);
192 re->tb = evas_common_tilebuf_new(width, height);
194 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
198 eng_output_tile_size_set(void *data,
204 re = (Render_Engine *)data;
205 evas_common_tilebuf_set_tile_size(re->tb, width, height);
209 eng_output_redraws_rect_add(void *data,
217 re = (Render_Engine *)data;
218 evas_common_tilebuf_add_redraw(re->tb, x, y, width, height);
222 eng_output_redraws_rect_del(void *data,
230 re = (Render_Engine *)data;
231 evas_common_tilebuf_del_redraw(re->tb, x, y, width, height);
235 eng_output_redraws_clear(void *data)
239 re = (Render_Engine *)data;
240 evas_common_tilebuf_clear(re->tb);
244 eng_output_redraws_next_update_get(void *data,
262 re = (Render_Engine *)data;
270 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
271 re->cur_rect = (Evas_Object_List *)re->rects;
273 if (!re->cur_rect) return NULL;
274 rect = (Tilebuf_Rect *)re->cur_rect;
275 ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
276 re->cur_rect = re->cur_rect->next;
279 evas_common_tilebuf_free_render_rects(re->rects);
284 surface = evas_direct3d_outbuf_new_region_for_update(re->ob,
289 *x = ux; *y = uy; *w = uw; *h = uh;
295 eng_output_redraws_next_update_push(void *data,
304 re = (Render_Engine *)data;
305 evas_common_pipe_begin((RGBA_Image *)surface);
306 evas_common_pipe_flush((RGBA_Image *)surface);
307 evas_direct3d_outbuf_push_updated_region(re->ob, (RGBA_Image *)surface, x, y, w, h);
308 evas_direct3d_outbuf_free_region_for_update(re->ob, (RGBA_Image *)surface);
309 evas_common_cpu_end_opt();
313 eng_output_flush(void *data)
317 re = (Render_Engine *)data;
318 evas_direct3d_outbuf_flush(re->ob);
322 eng_output_idle_flush(void *data)
326 re = (Render_Engine *)data;
329 /* module advertising code */
331 module_open(Evas_Module *em)
334 /* get whatever engine module we inherit from */
335 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
336 /* store it for later use */
338 /* now to override methods */
339 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
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);
363 EAPI Evas_Module_Api evas_modapi =
365 EVAS_MODULE_API_VERSION,
366 EVAS_MODULE_TYPE_ENGINE,