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/ecore/src/lib/ecore_evas/ecore_evas_sdl.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/ecore/src/lib/ecore_evas/ecore_evas_sdl.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_evas/ecore_evas_sdl.c | 656 |
1 files changed, 0 insertions, 656 deletions
diff --git a/libraries/ecore/src/lib/ecore_evas/ecore_evas_sdl.c b/libraries/ecore/src/lib/ecore_evas/ecore_evas_sdl.c deleted file mode 100644 index b246a26..0000000 --- a/libraries/ecore/src/lib/ecore_evas/ecore_evas_sdl.c +++ /dev/null | |||
@@ -1,656 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <Ecore.h> | ||
6 | #include <Ecore_Input.h> | ||
7 | #include <Ecore_Input_Evas.h> | ||
8 | #if defined(BUILD_ECORE_EVAS_SOFTWARE_SDL) || defined(BUILD_ECORE_EVAS_OPENGL_SDL) | ||
9 | # include <Ecore_Sdl.h> | ||
10 | # ifdef BUILD_ECORE_EVAS_OPENGL_SDL | ||
11 | # include <Evas_Engine_GL_SDL.h> | ||
12 | # endif | ||
13 | #endif | ||
14 | |||
15 | #include <stdlib.h> | ||
16 | #include <string.h> | ||
17 | |||
18 | #if defined(BUILD_ECORE_EVAS_SOFTWARE_SDL) || defined(BUILD_ECORE_EVAS_OPENGL_SDL) | ||
19 | #include <SDL/SDL.h> | ||
20 | #endif | ||
21 | |||
22 | #include "ecore_evas_private.h" | ||
23 | #include "Ecore_Evas.h" | ||
24 | |||
25 | /** | ||
26 | ** SDL only handle one window at a time. That's by definition, there is nothing wrong here. | ||
27 | ** | ||
28 | **/ | ||
29 | |||
30 | #if defined(BUILD_ECORE_EVAS_SOFTWARE_SDL) || defined(BUILD_ECORE_EVAS_OPENGL_SDL) | ||
31 | |||
32 | /* static char *ecore_evas_default_display = "0"; */ | ||
33 | /* static Ecore_List *ecore_evas_input_devices = NULL; */ | ||
34 | |||
35 | static int _ecore_evas_init_count = 0; | ||
36 | |||
37 | static Ecore_Evas *sdl_ee = NULL; | ||
38 | static Ecore_Event_Handler *ecore_evas_event_handlers[4] = { | ||
39 | NULL, NULL, NULL, NULL | ||
40 | }; | ||
41 | |||
42 | static const char *ecore_evas_sdl_default = "EFL SDL"; | ||
43 | static int _ecore_evas_fps_debug = 0; | ||
44 | static Ecore_Poller *ecore_evas_event; | ||
45 | |||
46 | static Ecore_Evas * | ||
47 | _ecore_evas_sdl_match(void) | ||
48 | { | ||
49 | return sdl_ee; | ||
50 | } | ||
51 | |||
52 | static void * | ||
53 | _ecore_evas_sdl_switch_buffer(void *data, void *dest __UNUSED__) | ||
54 | { | ||
55 | SDL_Flip(data); | ||
56 | return ((SDL_Surface*)data)->pixels; | ||
57 | } | ||
58 | |||
59 | static Eina_Bool | ||
60 | _ecore_evas_sdl_event_got_focus(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) | ||
61 | { | ||
62 | Ecore_Evas *ee; | ||
63 | |||
64 | ee = _ecore_evas_sdl_match(); | ||
65 | |||
66 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
67 | /* pass on event */ | ||
68 | ee->prop.focused = 1; | ||
69 | evas_focus_in(ee->evas); | ||
70 | if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee); | ||
71 | return ECORE_CALLBACK_PASS_ON; | ||
72 | } | ||
73 | |||
74 | static Eina_Bool | ||
75 | _ecore_evas_sdl_event_lost_focus(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) | ||
76 | { | ||
77 | Ecore_Evas *ee; | ||
78 | |||
79 | ee = _ecore_evas_sdl_match(); | ||
80 | |||
81 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
82 | /* pass on event */ | ||
83 | ee->prop.focused = 0; | ||
84 | evas_focus_out(ee->evas); | ||
85 | if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee); | ||
86 | return ECORE_CALLBACK_PASS_ON; | ||
87 | } | ||
88 | |||
89 | static Eina_Bool | ||
90 | _ecore_evas_sdl_event_video_resize(void *data __UNUSED__, int type __UNUSED__, void *event) | ||
91 | { | ||
92 | Ecore_Sdl_Event_Video_Resize *e; | ||
93 | Ecore_Evas *ee; | ||
94 | int rmethod; | ||
95 | |||
96 | e = event; | ||
97 | ee = _ecore_evas_sdl_match(); | ||
98 | |||
99 | if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */ | ||
100 | |||
101 | rmethod = evas_output_method_get(ee->evas); | ||
102 | if (rmethod == evas_render_method_lookup("buffer")) | ||
103 | { | ||
104 | Evas_Engine_Info_Buffer *einfo; | ||
105 | |||
106 | einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas); | ||
107 | if (einfo) | ||
108 | { | ||
109 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
110 | einfo->info.switch_data = SDL_SetVideoMode(e->w, e->h, 32, | ||
111 | (ee->prop.hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE) | ||
112 | | (ee->prop.fullscreen ? SDL_FULLSCREEN : 0) | ||
113 | | (ee->alpha ? SDL_SRCALPHA : 0) | ||
114 | | SDL_DOUBLEBUF); | ||
115 | if (!einfo->info.switch_data) | ||
116 | { | ||
117 | return EINA_FALSE; | ||
118 | } | ||
119 | |||
120 | SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0); | ||
121 | SDL_FillRect(einfo->info.switch_data, NULL, 0); | ||
122 | |||
123 | einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels; | ||
124 | einfo->info.dest_buffer_row_bytes = e->w * sizeof (int); | ||
125 | einfo->info.use_color_key = 0; | ||
126 | einfo->info.alpha_threshold = 0; | ||
127 | einfo->info.func.new_update_region = NULL; | ||
128 | einfo->info.func.free_update_region = NULL; | ||
129 | einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer; | ||
130 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo)) | ||
131 | { | ||
132 | return EINA_FALSE; | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | ee->w = e->w; | ||
138 | ee->h = e->h; | ||
139 | |||
140 | evas_output_size_set(ee->evas, e->w, e->h); | ||
141 | evas_output_viewport_set(ee->evas, 0, 0, e->w, e->h); | ||
142 | |||
143 | return ECORE_CALLBACK_PASS_ON; | ||
144 | } | ||
145 | |||
146 | static Eina_Bool | ||
147 | _ecore_evas_sdl_event_video_expose(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) | ||
148 | { | ||
149 | Ecore_Evas *ee; | ||
150 | int w; | ||
151 | int h; | ||
152 | |||
153 | ee = _ecore_evas_sdl_match(); | ||
154 | |||
155 | if (!ee) return ECORE_CALLBACK_PASS_ON; | ||
156 | evas_output_size_get(ee->evas, &w, &h); | ||
157 | evas_damage_rectangle_add(ee->evas, 0, 0, w, h); | ||
158 | |||
159 | return ECORE_CALLBACK_PASS_ON; | ||
160 | } | ||
161 | |||
162 | static int | ||
163 | _ecore_evas_render(Ecore_Evas *ee) | ||
164 | { | ||
165 | Eina_List *updates; | ||
166 | |||
167 | updates = evas_render_updates(ee->evas); | ||
168 | if (updates) | ||
169 | { | ||
170 | evas_render_updates_free(updates); | ||
171 | _ecore_evas_idle_timeout_update(ee); | ||
172 | } | ||
173 | return updates ? 1 : 0; | ||
174 | } | ||
175 | |||
176 | static int | ||
177 | _ecore_evas_sdl_render(Ecore_Evas *ee) | ||
178 | { | ||
179 | int rend = 0; | ||
180 | Eina_List *ll; | ||
181 | Ecore_Evas *ee2; | ||
182 | |||
183 | EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) | ||
184 | { | ||
185 | if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); | ||
186 | if (ee2->engine.func->fn_render) | ||
187 | rend |= ee2->engine.func->fn_render(ee2); | ||
188 | if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); | ||
189 | } | ||
190 | |||
191 | if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); | ||
192 | |||
193 | if (ee->prop.avoid_damage) rend = _ecore_evas_render(ee); | ||
194 | else if ((ee->visible) || | ||
195 | ((ee->should_be_visible) && (ee->prop.fullscreen)) || | ||
196 | ((ee->should_be_visible) && (ee->prop.override))) | ||
197 | rend |= _ecore_evas_render(ee); | ||
198 | else | ||
199 | evas_norender(ee->evas); | ||
200 | |||
201 | if (ee->func.fn_post_render) ee->func.fn_post_render(ee); | ||
202 | return rend; | ||
203 | } | ||
204 | |||
205 | static Eina_Bool | ||
206 | _ecore_evas_sdl_event(void *data __UNUSED__) | ||
207 | { | ||
208 | ecore_sdl_feed_events(); | ||
209 | return ECORE_CALLBACK_RENEW; | ||
210 | } | ||
211 | |||
212 | static int | ||
213 | _ecore_evas_sdl_init(int w __UNUSED__, int h __UNUSED__) | ||
214 | { | ||
215 | _ecore_evas_init_count++; | ||
216 | if (_ecore_evas_init_count > 1) return _ecore_evas_init_count; | ||
217 | |||
218 | #ifndef _WIN32 | ||
219 | if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1; | ||
220 | #endif /* _WIN32 */ | ||
221 | // this is pretty bad: poller? and set poll time? pol time is meant to be | ||
222 | // adjustable for things like polling battery state, or amoutn of spare | ||
223 | // memory etc. | ||
224 | // | ||
225 | ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_sdl_event, NULL); | ||
226 | ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006); | ||
227 | #ifndef _WIN32 | ||
228 | if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init(); | ||
229 | #endif /* _WIN32 */ | ||
230 | |||
231 | ecore_event_evas_init(); | ||
232 | |||
233 | ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_SDL_EVENT_GOT_FOCUS, _ecore_evas_sdl_event_got_focus, NULL); | ||
234 | ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_SDL_EVENT_LOST_FOCUS, _ecore_evas_sdl_event_lost_focus, NULL); | ||
235 | ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_SDL_EVENT_RESIZE, _ecore_evas_sdl_event_video_resize, NULL); | ||
236 | ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_SDL_EVENT_EXPOSE, _ecore_evas_sdl_event_video_expose, NULL); | ||
237 | |||
238 | return _ecore_evas_init_count; | ||
239 | } | ||
240 | |||
241 | static int | ||
242 | _ecore_evas_sdl_shutdown(void) | ||
243 | { | ||
244 | _ecore_evas_init_count--; | ||
245 | if (_ecore_evas_init_count == 0) | ||
246 | { | ||
247 | unsigned int i; | ||
248 | |||
249 | for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++) | ||
250 | ecore_event_handler_del(ecore_evas_event_handlers[i]); | ||
251 | ecore_event_evas_shutdown(); | ||
252 | ecore_poller_del(ecore_evas_event); | ||
253 | ecore_evas_event = NULL; | ||
254 | #ifndef _WIN32 | ||
255 | if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown(); | ||
256 | #endif /* _WIN32 */ | ||
257 | } | ||
258 | if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; | ||
259 | return _ecore_evas_init_count; | ||
260 | } | ||
261 | |||
262 | static void | ||
263 | _ecore_evas_sdl_free(Ecore_Evas *ee) | ||
264 | { | ||
265 | if (sdl_ee == ee) sdl_ee = NULL; | ||
266 | |||
267 | ecore_event_window_unregister(0); | ||
268 | _ecore_evas_sdl_shutdown(); | ||
269 | ecore_sdl_shutdown(); | ||
270 | } | ||
271 | |||
272 | static void | ||
273 | _ecore_evas_resize(Ecore_Evas *ee, int w, int h) | ||
274 | { | ||
275 | int rmethod; | ||
276 | |||
277 | if ((w == ee->w) && (h == ee->h)) return; | ||
278 | ee->w = w; | ||
279 | ee->h = h; | ||
280 | |||
281 | rmethod = evas_output_method_get(ee->evas); | ||
282 | if (rmethod == evas_render_method_lookup("buffer")) | ||
283 | { | ||
284 | Evas_Engine_Info_Buffer *einfo; | ||
285 | |||
286 | einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas); | ||
287 | if (einfo) | ||
288 | { | ||
289 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
290 | einfo->info.switch_data = SDL_SetVideoMode(w, h, 32, | ||
291 | (ee->prop.hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE) | ||
292 | | (ee->prop.fullscreen ? SDL_FULLSCREEN : 0) | ||
293 | | (ee->alpha ? SDL_SRCALPHA : 0) | ||
294 | | SDL_DOUBLEBUF); | ||
295 | if (!einfo->info.switch_data) | ||
296 | { | ||
297 | return ; | ||
298 | } | ||
299 | |||
300 | SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0); | ||
301 | SDL_FillRect(einfo->info.switch_data, NULL, 0); | ||
302 | |||
303 | einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels; | ||
304 | einfo->info.dest_buffer_row_bytes = w * sizeof (int); | ||
305 | einfo->info.use_color_key = 0; | ||
306 | einfo->info.alpha_threshold = 0; | ||
307 | einfo->info.func.new_update_region = NULL; | ||
308 | einfo->info.func.free_update_region = NULL; | ||
309 | einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer; | ||
310 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo)) | ||
311 | { | ||
312 | return ; | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | |||
317 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
318 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
319 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
320 | |||
321 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
322 | } | ||
323 | |||
324 | static void | ||
325 | _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h) | ||
326 | { | ||
327 | if ((w == ee->w) && (h == ee->h)) return; | ||
328 | ee->w = w; | ||
329 | ee->h = h; | ||
330 | |||
331 | evas_output_size_set(ee->evas, ee->w, ee->h); | ||
332 | evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); | ||
333 | evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); | ||
334 | |||
335 | if (ee->func.fn_resize) ee->func.fn_resize(ee); | ||
336 | } | ||
337 | |||
338 | static void | ||
339 | _ecore_evas_show(Ecore_Evas *ee) | ||
340 | { | ||
341 | if (ee->prop.focused) return; | ||
342 | ee->prop.focused = 1; | ||
343 | evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL); | ||
344 | } | ||
345 | |||
346 | static void | ||
347 | _ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
348 | { | ||
349 | Ecore_Evas *ee; | ||
350 | |||
351 | ee = data; | ||
352 | if (ee) ee->prop.cursor.object = NULL; | ||
353 | } | ||
354 | |||
355 | static void | ||
356 | _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) | ||
357 | { | ||
358 | int x, y; | ||
359 | |||
360 | if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object); | ||
361 | |||
362 | if (!obj) | ||
363 | { | ||
364 | ee->prop.cursor.object = NULL; | ||
365 | ee->prop.cursor.layer = 0; | ||
366 | ee->prop.cursor.hot.x = 0; | ||
367 | ee->prop.cursor.hot.y = 0; | ||
368 | return; | ||
369 | } | ||
370 | |||
371 | ee->prop.cursor.object = obj; | ||
372 | ee->prop.cursor.layer = layer; | ||
373 | ee->prop.cursor.hot.x = hot_x; | ||
374 | ee->prop.cursor.hot.y = hot_y; | ||
375 | evas_pointer_output_xy_get(ee->evas, &x, &y); | ||
376 | evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); | ||
377 | evas_object_move(ee->prop.cursor.object, | ||
378 | x - ee->prop.cursor.hot.x, | ||
379 | y - ee->prop.cursor.hot.y); | ||
380 | evas_object_pass_events_set(ee->prop.cursor.object, 1); | ||
381 | if (evas_pointer_inside_get(ee->evas)) | ||
382 | evas_object_show(ee->prop.cursor.object); | ||
383 | |||
384 | evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); | ||
385 | } | ||
386 | |||
387 | static Ecore_Evas_Engine_Func _ecore_sdl_engine_func = | ||
388 | { | ||
389 | _ecore_evas_sdl_free, | ||
390 | NULL, | ||
391 | NULL, | ||
392 | NULL, | ||
393 | NULL, | ||
394 | NULL, | ||
395 | NULL, | ||
396 | NULL, | ||
397 | NULL, | ||
398 | NULL, | ||
399 | NULL, | ||
400 | NULL, | ||
401 | NULL, | ||
402 | NULL, | ||
403 | NULL, | ||
404 | NULL, | ||
405 | NULL, | ||
406 | _ecore_evas_resize, | ||
407 | _ecore_evas_move_resize, | ||
408 | NULL, | ||
409 | NULL, | ||
410 | _ecore_evas_show, | ||
411 | NULL, | ||
412 | NULL, | ||
413 | NULL, | ||
414 | NULL, | ||
415 | NULL, | ||
416 | NULL, | ||
417 | NULL, | ||
418 | NULL, | ||
419 | NULL, | ||
420 | NULL, | ||
421 | _ecore_evas_object_cursor_set, | ||
422 | NULL, | ||
423 | NULL, | ||
424 | NULL, | ||
425 | NULL, | ||
426 | NULL, | ||
427 | NULL, | ||
428 | NULL, | ||
429 | NULL, | ||
430 | NULL, | ||
431 | NULL, | ||
432 | NULL, | ||
433 | NULL, | ||
434 | NULL, //transparent | ||
435 | |||
436 | NULL, | ||
437 | NULL, | ||
438 | NULL, | ||
439 | NULL, | ||
440 | NULL, | ||
441 | NULL, | ||
442 | |||
443 | NULL, // render | ||
444 | NULL // screen_geometry_get | ||
445 | }; | ||
446 | |||
447 | static Ecore_Evas* | ||
448 | _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha) | ||
449 | { | ||
450 | Ecore_Evas *ee; | ||
451 | |||
452 | if (!name) | ||
453 | name = ecore_evas_sdl_default; | ||
454 | |||
455 | ee = calloc(1, sizeof(Ecore_Evas)); | ||
456 | if (!ee) return NULL; | ||
457 | |||
458 | ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); | ||
459 | |||
460 | ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_sdl_engine_func; | ||
461 | |||
462 | ee->driver = "sdl"; | ||
463 | if (name) ee->name = strdup(name); | ||
464 | |||
465 | if (w < 1) w = 1; | ||
466 | if (h < 1) h = 1; | ||
467 | ee->visible = 1; | ||
468 | ee->w = w; | ||
469 | ee->h = h; | ||
470 | |||
471 | ee->prop.max.w = 0; | ||
472 | ee->prop.max.h = 0; | ||
473 | ee->prop.layer = 0; | ||
474 | ee->prop.focused = 1; | ||
475 | ee->prop.borderless = 1; | ||
476 | ee->prop.override = 1; | ||
477 | ee->prop.maximized = 1; | ||
478 | ee->prop.fullscreen = fullscreen; | ||
479 | ee->prop.withdrawn = 0; | ||
480 | ee->prop.sticky = 0; | ||
481 | ee->prop.window = 0; | ||
482 | ee->alpha = alpha; | ||
483 | ee->prop.hwsurface = hwsurface; | ||
484 | |||
485 | /* init evas here */ | ||
486 | ee->evas = evas_new(); | ||
487 | evas_data_attach_set(ee->evas, ee); | ||
488 | evas_output_method_set(ee->evas, rmethod); | ||
489 | |||
490 | evas_output_size_set(ee->evas, w, h); | ||
491 | evas_output_viewport_set(ee->evas, 0, 0, w, h); | ||
492 | |||
493 | if (rmethod == evas_render_method_lookup("buffer")) | ||
494 | { | ||
495 | Evas_Engine_Info_Buffer *einfo; | ||
496 | |||
497 | einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas); | ||
498 | if (einfo) | ||
499 | { | ||
500 | SDL_Init(SDL_INIT_NOPARACHUTE); | ||
501 | |||
502 | if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) | ||
503 | { | ||
504 | ERR("SDL_Init failed with %s", SDL_GetError()); | ||
505 | SDL_Quit(); | ||
506 | return NULL; | ||
507 | } | ||
508 | |||
509 | einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32; | ||
510 | einfo->info.switch_data = SDL_SetVideoMode(w, h, 32, | ||
511 | (hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE) | ||
512 | | (fullscreen ? SDL_FULLSCREEN : 0) | ||
513 | | (noframe ? SDL_NOFRAME : 0) | ||
514 | | (alpha ? SDL_SRCALPHA : 0) | ||
515 | | SDL_DOUBLEBUF); | ||
516 | if (!einfo->info.switch_data) | ||
517 | { | ||
518 | ERR("SDL_SetVideoMode failed !"); | ||
519 | ecore_evas_free(ee); | ||
520 | return NULL; | ||
521 | } | ||
522 | |||
523 | SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0); | ||
524 | SDL_FillRect(einfo->info.switch_data, NULL, 0); | ||
525 | |||
526 | einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels; | ||
527 | einfo->info.dest_buffer_row_bytes = w * sizeof (int); | ||
528 | einfo->info.use_color_key = 0; | ||
529 | einfo->info.alpha_threshold = 0; | ||
530 | einfo->info.func.new_update_region = NULL; | ||
531 | einfo->info.func.free_update_region = NULL; | ||
532 | einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer; | ||
533 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo)) | ||
534 | { | ||
535 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
536 | ecore_evas_free(ee); | ||
537 | return NULL; | ||
538 | } | ||
539 | } | ||
540 | else | ||
541 | { | ||
542 | ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); | ||
543 | ecore_evas_free(ee); | ||
544 | return NULL; | ||
545 | } | ||
546 | } | ||
547 | else if (rmethod == evas_render_method_lookup("gl_sdl")) | ||
548 | { | ||
549 | #ifdef BUILD_ECORE_EVAS_OPENGL_SDL | ||
550 | Evas_Engine_Info_GL_SDL *einfo; | ||
551 | |||
552 | einfo = (Evas_Engine_Info_GL_SDL *) evas_engine_info_get(ee->evas); | ||
553 | if (einfo) | ||
554 | { | ||
555 | einfo->flags.fullscreen = fullscreen; | ||
556 | einfo->flags.noframe = noframe; | ||
557 | if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) | ||
558 | { | ||
559 | ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); | ||
560 | ecore_evas_free(ee); | ||
561 | return NULL; | ||
562 | } | ||
563 | } | ||
564 | else | ||
565 | { | ||
566 | ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); | ||
567 | ecore_evas_free(ee); | ||
568 | return NULL; | ||
569 | } | ||
570 | #endif | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); | ||
575 | ecore_evas_free(ee); | ||
576 | return NULL; | ||
577 | } | ||
578 | |||
579 | if (!ecore_sdl_init(name)) | ||
580 | { | ||
581 | evas_free(ee->evas); | ||
582 | if (ee->name) free(ee->name); | ||
583 | free(ee); | ||
584 | return NULL; | ||
585 | } | ||
586 | |||
587 | _ecore_evas_sdl_init(w, h); | ||
588 | |||
589 | ecore_event_window_register(0, ee, ee->evas, | ||
590 | (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process, | ||
591 | (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process, | ||
592 | (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process, | ||
593 | (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process); | ||
594 | |||
595 | SDL_ShowCursor(SDL_ENABLE); | ||
596 | |||
597 | ee->engine.func->fn_render = _ecore_evas_sdl_render; | ||
598 | _ecore_evas_register(ee); | ||
599 | |||
600 | sdl_ee = ee; | ||
601 | return ee; | ||
602 | } | ||
603 | #endif | ||
604 | |||
605 | #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL | ||
606 | EAPI Ecore_Evas* | ||
607 | ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha) | ||
608 | { | ||
609 | Ecore_Evas *ee; | ||
610 | int rmethod; | ||
611 | |||
612 | rmethod = evas_render_method_lookup("buffer"); | ||
613 | if (!rmethod) return NULL; | ||
614 | |||
615 | ee = _ecore_evas_internal_sdl_new(rmethod, name, w, h, fullscreen, hwsurface, noframe, alpha); | ||
616 | return ee; | ||
617 | } | ||
618 | #else | ||
619 | EAPI Ecore_Evas* | ||
620 | ecore_evas_sdl_new(const char* name __UNUSED__, int w __UNUSED__, int h __UNUSED__, int fullscreen __UNUSED__, int hwsurface __UNUSED__, int noframe __UNUSED__, int alpha __UNUSED__) | ||
621 | { | ||
622 | ERR("OUTCH !"); | ||
623 | return NULL; | ||
624 | } | ||
625 | #endif | ||
626 | |||
627 | EAPI Ecore_Evas* | ||
628 | ecore_evas_sdl16_new(const char* name __UNUSED__, int w __UNUSED__, int h __UNUSED__, int fullscreen __UNUSED__, int hwsurface __UNUSED__, int noframe __UNUSED__, int alpha __UNUSED__) | ||
629 | { | ||
630 | ERR("OUTCH !"); | ||
631 | return NULL; | ||
632 | } | ||
633 | |||
634 | #ifdef BUILD_ECORE_EVAS_OPENGL_SDL | ||
635 | EAPI Ecore_Evas* | ||
636 | ecore_evas_gl_sdl_new(const char* name, int w, int h, int fullscreen, int noframe) | ||
637 | { | ||
638 | Ecore_Evas *ee; | ||
639 | int rmethod; | ||
640 | |||
641 | rmethod = evas_render_method_lookup("gl_sdl"); | ||
642 | if (!rmethod) return NULL; | ||
643 | |||
644 | ee = _ecore_evas_internal_sdl_new(rmethod, name, w, h, fullscreen, 0, noframe, 0); | ||
645 | ee->driver = "gl_sdl"; | ||
646 | return ee; | ||
647 | } | ||
648 | #else | ||
649 | EAPI Ecore_Evas* | ||
650 | ecore_evas_gl_sdl_new(const char* name __UNUSED__, int w __UNUSED__, int h __UNUSED__, int fullscreen __UNUSED__, int noframe __UNUSED__) | ||
651 | { | ||
652 | ERR("OUTCH !"); | ||
653 | return NULL; | ||
654 | } | ||
655 | #endif | ||
656 | |||