diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/evas/src/modules/engines/direct3d/evas_engine.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/evas/src/modules/engines/direct3d/evas_engine.c')
-rw-r--r-- | libraries/evas/src/modules/engines/direct3d/evas_engine.c | 503 |
1 files changed, 0 insertions, 503 deletions
diff --git a/libraries/evas/src/modules/engines/direct3d/evas_engine.c b/libraries/evas/src/modules/engines/direct3d/evas_engine.c deleted file mode 100644 index f7722d8..0000000 --- a/libraries/evas/src/modules/engines/direct3d/evas_engine.c +++ /dev/null | |||
@@ -1,503 +0,0 @@ | |||
1 | #include "evas_common.h" /* Also includes international specific stuff */ | ||
2 | #include "evas_engine.h" | ||
3 | #include "evas_private.h" | ||
4 | #include "Evas_Engine_Direct3D.h" | ||
5 | |||
6 | #undef EAPI | ||
7 | #define EAPI __declspec(dllexport) | ||
8 | |||
9 | /* engine struct data */ | ||
10 | typedef struct _Render_Engine Render_Engine; | ||
11 | struct _Render_Engine | ||
12 | { | ||
13 | Direct3DDeviceHandler d3d; | ||
14 | int width, height; | ||
15 | int end : 1; | ||
16 | int in_redraw : 1; | ||
17 | }; | ||
18 | |||
19 | int _evas_engine_direct3d_log_dom = -1; | ||
20 | |||
21 | /* function tables - filled in later (func and parent func) */ | ||
22 | static Evas_Func func, pfunc; | ||
23 | |||
24 | ////////////////////////////////////////////////////////////////////////////// | ||
25 | // Prototypes | ||
26 | |||
27 | static void *eng_info(Evas *e); | ||
28 | static void eng_info_free(Evas *e, void *info); | ||
29 | static int eng_setup(Evas *e, void *info); | ||
30 | static void eng_output_free(void *data); | ||
31 | static void eng_output_resize(void *data, int width, int height); | ||
32 | |||
33 | ////////////////////////////////////////////////////////////////////////////// | ||
34 | // Init / shutdown methods | ||
35 | // | ||
36 | |||
37 | static void * | ||
38 | _output_setup(int width, int height, int rotation, HWND window, int depth, int fullscreen) | ||
39 | { | ||
40 | Render_Engine *re; | ||
41 | |||
42 | re = (Render_Engine *)calloc(1, sizeof(Render_Engine)); | ||
43 | if (!re) | ||
44 | return NULL; | ||
45 | |||
46 | /* if we haven't initialized - init (automatic abort if already done) */ | ||
47 | evas_common_cpu_init(); | ||
48 | |||
49 | evas_common_blend_init(); | ||
50 | evas_common_image_init(); | ||
51 | evas_common_convert_init(); | ||
52 | evas_common_scale_init(); | ||
53 | evas_common_rectangle_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(); | ||
59 | |||
60 | if ((re->d3d = evas_direct3d_init(window, depth, fullscreen)) == 0) | ||
61 | { | ||
62 | free(re); | ||
63 | return NULL; | ||
64 | } | ||
65 | |||
66 | re->width = width; | ||
67 | re->height = height; | ||
68 | |||
69 | return re; | ||
70 | } | ||
71 | |||
72 | static void * | ||
73 | eng_info(Evas *e) | ||
74 | { | ||
75 | Evas_Engine_Info_Direct3D *info; | ||
76 | info = (Evas_Engine_Info_Direct3D *)calloc(1, sizeof(Evas_Engine_Info_Direct3D)); | ||
77 | if (!info) return NULL; | ||
78 | info->magic.magic = rand(); | ||
79 | memset(&info->info, 0, sizeof(info->info)); | ||
80 | info->render_mode = EVAS_RENDER_MODE_BLOCKING; | ||
81 | return info; | ||
82 | e = NULL; | ||
83 | } | ||
84 | |||
85 | static void | ||
86 | eng_info_free(Evas *e, void *info) | ||
87 | { | ||
88 | Evas_Engine_Info_Direct3D *in; | ||
89 | in = (Evas_Engine_Info_Direct3D *)info; | ||
90 | free(in); | ||
91 | } | ||
92 | |||
93 | static int | ||
94 | eng_setup(Evas *e, void *info) | ||
95 | { | ||
96 | Render_Engine *re; | ||
97 | Evas_Engine_Info_Direct3D *in; | ||
98 | re = (Render_Engine *)e->engine.data.output; | ||
99 | in = (Evas_Engine_Info_Direct3D *)info; | ||
100 | if (!e->engine.data.output) | ||
101 | { | ||
102 | e->engine.data.output = _output_setup(e->output.w, | ||
103 | e->output.h, | ||
104 | in->info.rotation, | ||
105 | in->info.window, | ||
106 | in->info.depth, | ||
107 | in->info.fullscreen); | ||
108 | } | ||
109 | else if (in->info.fullscreen != 0) | ||
110 | { | ||
111 | if (re) | ||
112 | evas_direct3d_set_layered(re->d3d, 0, 0, 0, NULL); | ||
113 | evas_direct3d_set_fullscreen(re->d3d, -1, -1, 1); | ||
114 | } | ||
115 | else if (in->info.fullscreen == 0) | ||
116 | { | ||
117 | evas_direct3d_set_fullscreen(re->d3d, re->width, re->height, 0); | ||
118 | if (re && in->info.layered == 0) | ||
119 | evas_direct3d_set_layered(re->d3d, 0, 0, 0, NULL); | ||
120 | else if (re && in->info.layered != 0 && in->shape) | ||
121 | evas_direct3d_set_layered(re->d3d, 1, in->shape->width, in->shape->height, in->shape->mask); | ||
122 | } | ||
123 | |||
124 | if (!e->engine.data.output) | ||
125 | return 0; | ||
126 | if (!e->engine.data.context) | ||
127 | e->engine.data.context = e->engine.func->context_new(e->engine.data.output); | ||
128 | |||
129 | return 1; | ||
130 | } | ||
131 | |||
132 | static void | ||
133 | eng_output_free(void *data) | ||
134 | { | ||
135 | Render_Engine *re = (Render_Engine *)data; | ||
136 | |||
137 | evas_direct3d_free(re->d3d); | ||
138 | |||
139 | free(re); | ||
140 | |||
141 | evas_common_font_shutdown(); | ||
142 | evas_common_image_shutdown(); | ||
143 | } | ||
144 | |||
145 | ////////////////////////////////////////////////////////////////////////////// | ||
146 | // Context | ||
147 | // | ||
148 | |||
149 | static void | ||
150 | eng_context_color_set(void *data, void *context, int r, int g, int b, int a) | ||
151 | { | ||
152 | Render_Engine *re = (Render_Engine *)data; | ||
153 | evas_direct3d_context_color_set(re->d3d, r, g, b, a); | ||
154 | |||
155 | evas_common_draw_context_set_color(context, r, g, b, a); | ||
156 | } | ||
157 | |||
158 | static void | ||
159 | eng_context_multiplier_set(void *data, void *context, int r, int g, int b, int a) | ||
160 | { | ||
161 | Render_Engine *re = (Render_Engine *)data; | ||
162 | evas_direct3d_context_set_multiplier(re->d3d, 255, 255, 255, a); | ||
163 | |||
164 | evas_common_draw_context_set_multiplier(context, r, g, b, a); | ||
165 | } | ||
166 | |||
167 | static void | ||
168 | eng_context_multiplier_unset(void *data, void *context) | ||
169 | { | ||
170 | Render_Engine *re = (Render_Engine *)data; | ||
171 | evas_direct3d_context_set_multiplier(re->d3d, 255, 255, 255, 255); | ||
172 | |||
173 | evas_common_draw_context_unset_multiplier(context); | ||
174 | } | ||
175 | |||
176 | |||
177 | ////////////////////////////////////////////////////////////////////////////// | ||
178 | // Output manipulating | ||
179 | // | ||
180 | |||
181 | static void | ||
182 | eng_output_resize(void *data, int width, int height) | ||
183 | { | ||
184 | Render_Engine *re = (Render_Engine *)data; | ||
185 | re->width = width; | ||
186 | re->height = height; | ||
187 | evas_direct3d_resize(re->d3d, width, height); | ||
188 | } | ||
189 | |||
190 | static void | ||
191 | eng_output_redraws_rect_add(void *data, int x, int y, int width, int height) | ||
192 | { | ||
193 | Render_Engine *re = (Render_Engine *)data; | ||
194 | } | ||
195 | |||
196 | static void | ||
197 | eng_output_redraws_rect_del(void *data, int x, int y, int width, int height) | ||
198 | { | ||
199 | Render_Engine *re = (Render_Engine *)data; | ||
200 | } | ||
201 | |||
202 | static void | ||
203 | eng_output_redraws_clear(void *data) | ||
204 | { | ||
205 | Render_Engine *re = (Render_Engine *)data; | ||
206 | } | ||
207 | |||
208 | static void * | ||
209 | eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, | ||
210 | int *cx, int *cy, int *cw, int *ch) | ||
211 | { | ||
212 | Render_Engine *re; | ||
213 | |||
214 | re = (Render_Engine *)data; | ||
215 | if (re->end) | ||
216 | { | ||
217 | re->end = 0; | ||
218 | re->in_redraw = 0; | ||
219 | return NULL; | ||
220 | } | ||
221 | |||
222 | if (x) *x = 0; | ||
223 | if (y) *y = 0; | ||
224 | if (w) *w = 800; //re->d3d.width; | ||
225 | if (h) *h = 600; //re->d3d.height; | ||
226 | if (cx) *cx = 0; | ||
227 | if (cy) *cy = 0; | ||
228 | if (cw) *cw = 800; //re->d3d.width; | ||
229 | if (ch) *ch = 600; //re->d3d.height; | ||
230 | |||
231 | re->in_redraw = 1; | ||
232 | |||
233 | return re; | ||
234 | } | ||
235 | |||
236 | static void | ||
237 | eng_output_redraws_next_update_push(void *data, void *surface, | ||
238 | int x, int y, int w, int h) | ||
239 | { | ||
240 | Render_Engine *re = (Render_Engine *)data; | ||
241 | re->end = 1; | ||
242 | } | ||
243 | |||
244 | static void | ||
245 | eng_output_flush(void *data) | ||
246 | { | ||
247 | Render_Engine *re = (Render_Engine *)data; | ||
248 | evas_direct3d_render_all(re->d3d); | ||
249 | } | ||
250 | |||
251 | static void | ||
252 | eng_output_idle_flush(void *data) | ||
253 | { | ||
254 | Render_Engine *re = (Render_Engine *)data; | ||
255 | } | ||
256 | |||
257 | |||
258 | ////////////////////////////////////////////////////////////////////////////// | ||
259 | // Draw objects | ||
260 | // | ||
261 | |||
262 | static void | ||
263 | eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2) | ||
264 | { | ||
265 | Render_Engine *re = (Render_Engine *)data; | ||
266 | if (re->in_redraw == 0) | ||
267 | return; | ||
268 | evas_direct3d_line_draw(re->d3d, x1, y1, x2, y2); | ||
269 | } | ||
270 | |||
271 | static void | ||
272 | eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h) | ||
273 | { | ||
274 | Render_Engine *re = (Render_Engine *)data; | ||
275 | if (re->in_redraw == 0) | ||
276 | return; | ||
277 | evas_direct3d_rectangle_draw(re->d3d, x, y, w, h); | ||
278 | } | ||
279 | |||
280 | static void * | ||
281 | eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo) | ||
282 | { | ||
283 | Render_Engine *re = (Render_Engine *)data; | ||
284 | *error = 0; | ||
285 | return evas_direct3d_image_load(re->d3d, file, key, NULL, lo); | ||
286 | } | ||
287 | |||
288 | static void * | ||
289 | eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace) | ||
290 | { | ||
291 | Render_Engine *re = (Render_Engine *)data; | ||
292 | return evas_direct3d_image_new_from_data(re->d3d, w, h, image_data, alpha, cspace); | ||
293 | } | ||
294 | |||
295 | static void * | ||
296 | eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace) | ||
297 | { | ||
298 | Render_Engine *re = (Render_Engine *)data; | ||
299 | return evas_direct3d_image_new_from_copied_data(re->d3d, w, h, image_data, alpha, cspace); | ||
300 | } | ||
301 | |||
302 | static void | ||
303 | eng_image_free(void *data, void *image) | ||
304 | { | ||
305 | Render_Engine *re = (Render_Engine *)data; | ||
306 | evas_direct3d_image_free(re->d3d, image); | ||
307 | } | ||
308 | |||
309 | static void * | ||
310 | eng_image_data_put(void *data, void *image, DATA32 *image_data) | ||
311 | { | ||
312 | Render_Engine *re = (Render_Engine *)data; | ||
313 | evas_direct3d_image_data_put(re->d3d, image, image_data); | ||
314 | return image; | ||
315 | } | ||
316 | |||
317 | static void * | ||
318 | eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h) | ||
319 | { | ||
320 | return image; | ||
321 | } | ||
322 | |||
323 | static void * | ||
324 | eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err) | ||
325 | { | ||
326 | Render_Engine *re = (Render_Engine *)data; | ||
327 | evas_direct3d_image_data_get(re->d3d, image, to_write, image_data); | ||
328 | if (err) *err = EVAS_LOAD_ERROR_NONE; | ||
329 | return image; | ||
330 | } | ||
331 | |||
332 | static void | ||
333 | eng_image_draw(void *data, void *context, void *surface, void *image, | ||
334 | int src_x, int src_y, int src_w, int src_h, | ||
335 | int dst_x, int dst_y, int dst_w, int dst_h, int smooth) | ||
336 | { | ||
337 | Render_Engine *re = (Render_Engine *)data; | ||
338 | evas_direct3d_image_draw(re->d3d, image, | ||
339 | src_x, src_y, src_w, src_h, | ||
340 | dst_x, dst_y, dst_w, dst_h, smooth); | ||
341 | } | ||
342 | |||
343 | static void | ||
344 | eng_image_size_get(void *data, void *image, int *w, int *h) | ||
345 | { | ||
346 | evas_direct3d_image_size_get(image, w, h); | ||
347 | } | ||
348 | |||
349 | static int | ||
350 | eng_image_alpha_get(void *data, void *image) | ||
351 | { | ||
352 | // Hm:) | ||
353 | if (!image) | ||
354 | return 1; | ||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static int | ||
359 | eng_image_colorspace_get(void *data, void *image) | ||
360 | { | ||
361 | // Well, change that when you think about other colorspace | ||
362 | return EVAS_COLORSPACE_ARGB8888; | ||
363 | } | ||
364 | |||
365 | static void * | ||
366 | eng_image_border_set(void *data, void *image, int l, int r, int t, int b) | ||
367 | { | ||
368 | Render_Engine *re = (Render_Engine *)data; | ||
369 | evas_direct3d_image_border_set(re->d3d, image, l, t, r, b); | ||
370 | return image; | ||
371 | } | ||
372 | |||
373 | static void | ||
374 | eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b) | ||
375 | { | ||
376 | Render_Engine *re = (Render_Engine *)data; | ||
377 | evas_direct3d_image_border_get(re->d3d, image, l, t, r, b); | ||
378 | } | ||
379 | |||
380 | static void | ||
381 | eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint) | ||
382 | { | ||
383 | } | ||
384 | |||
385 | static int | ||
386 | eng_image_scale_hint_get(void *data __UNUSED__, void *image) | ||
387 | { | ||
388 | return EVAS_IMAGE_SCALE_HINT_NONE; | ||
389 | } | ||
390 | |||
391 | static void | ||
392 | eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w, int h, int ow, int oh, const Evas_Text_Props *intl_props) | ||
393 | { | ||
394 | Render_Engine *re = (Render_Engine *)data; | ||
395 | RGBA_Image im; | ||
396 | im.image.data = NULL; | ||
397 | im.cache_entry.w = re->width; | ||
398 | im.cache_entry.h = re->height; | ||
399 | |||
400 | evas_direct3d_select_or_create_font(re->d3d, font); | ||
401 | |||
402 | evas_common_draw_context_font_ext_set(context, re->d3d, | ||
403 | evas_direct3d_font_texture_new, | ||
404 | evas_direct3d_font_texture_free, | ||
405 | evas_direct3d_font_texture_draw); | ||
406 | evas_common_font_draw(&im, context, (RGBA_Font *) font, x, y, intl_props); | ||
407 | evas_common_draw_context_font_ext_set(context, NULL, NULL, NULL, NULL); | ||
408 | } | ||
409 | |||
410 | static void | ||
411 | eng_font_free(void *data, void *font) | ||
412 | { | ||
413 | Render_Engine *re = (Render_Engine *)data; | ||
414 | evas_common_font_free(font); | ||
415 | evas_direct3d_font_free(re->d3d, font); | ||
416 | } | ||
417 | |||
418 | /* module advertising code */ | ||
419 | static int | ||
420 | module_open(Evas_Module *em) | ||
421 | { | ||
422 | if (!em) return 0; | ||
423 | /* get whatever engine module we inherit from */ | ||
424 | if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0; | ||
425 | /* Initialize the log domain */ | ||
426 | _evas_engine_direct3d_log_dom = eina_log_domain_register | ||
427 | ("evas-direct3d", EVAS_DEFAULT_LOG_COLOR); | ||
428 | if (_evas_engine_direct3d_log_dom < 0) | ||
429 | { | ||
430 | EINA_LOG_ERR("Can not create a module log domain."); | ||
431 | return 0; | ||
432 | } | ||
433 | /* store it for later use */ | ||
434 | func = pfunc; | ||
435 | /* now to override methods */ | ||
436 | #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_) | ||
437 | ORD(info); | ||
438 | ORD(info_free); | ||
439 | ORD(setup); | ||
440 | ORD(context_color_set); | ||
441 | ORD(context_multiplier_set); | ||
442 | ORD(context_multiplier_unset); | ||
443 | ORD(output_free); | ||
444 | ORD(output_resize); | ||
445 | ORD(output_redraws_rect_add); | ||
446 | ORD(output_redraws_rect_del); | ||
447 | ORD(output_redraws_clear); | ||
448 | ORD(output_redraws_next_update_get); | ||
449 | ORD(output_redraws_next_update_push); | ||
450 | ORD(output_flush); | ||
451 | ORD(output_idle_flush); | ||
452 | ORD(line_draw); | ||
453 | ORD(rectangle_draw); | ||
454 | ORD(image_load); | ||
455 | ORD(image_new_from_data); | ||
456 | ORD(image_new_from_copied_data); | ||
457 | ORD(image_free); | ||
458 | ORD(image_data_put); | ||
459 | ORD(image_dirty_region); | ||
460 | ORD(image_data_get); | ||
461 | ORD(image_draw); | ||
462 | ORD(image_size_get); | ||
463 | ORD(image_alpha_get); | ||
464 | ORD(image_colorspace_get); | ||
465 | ORD(image_border_set); | ||
466 | ORD(image_border_get); | ||
467 | ORD(font_draw); | ||
468 | ORD(font_free); | ||
469 | |||
470 | ORD(image_scale_hint_set); | ||
471 | ORD(image_scale_hint_get); | ||
472 | |||
473 | // ORD(image_map_draw); | ||
474 | // ORD(image_map_surface_new); | ||
475 | // ORD(image_map_surface_free); | ||
476 | |||
477 | /* now advertise out own api */ | ||
478 | em->functions = (void *)(&func); | ||
479 | return 1; | ||
480 | } | ||
481 | |||
482 | static void | ||
483 | module_close(Evas_Module *em) | ||
484 | { | ||
485 | eina_log_domain_unregister(_evas_engine_direct3d_log_dom); | ||
486 | } | ||
487 | |||
488 | static Evas_Module_Api evas_modapi = | ||
489 | { | ||
490 | EVAS_MODULE_API_VERSION, | ||
491 | "direct3d", | ||
492 | "none", | ||
493 | { | ||
494 | module_open, | ||
495 | module_close | ||
496 | } | ||
497 | }; | ||
498 | |||
499 | EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, direct3d); | ||
500 | |||
501 | #ifndef EVAS_STATIC_BUILD_DIRECT3D | ||
502 | EVAS_EINA_MODULE_DEFINE(engine, direct3d); | ||
503 | #endif | ||