1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4 
5 #include <stdlib.h>
6 #include <string.h>
7 
8 #include <SDL2/SDL.h>
9 
10 #include <Ecore.h>
11 #include "ecore_private.h"
12 #include <Ecore_Input.h>
13 #include <Ecore_Input_Evas.h>
14 #include <Ecore_Sdl.h>
15 #include <Evas_Engine_Buffer.h>
16 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
17 # include <Evas_Engine_GL_SDL.h>
18 #endif
19 
20 #include <Ecore_Evas.h>
21 #include "ecore_evas_private.h"
22 
23 #ifdef EAPI
24 # undef EAPI
25 #endif
26 
27 #ifdef _WIN32
28 # ifdef DLL_EXPORT
29 #  define EAPI __declspec(dllexport)
30 # else
31 #  define EAPI
32 # endif /* ! DLL_EXPORT */
33 #else
34 # ifdef __GNUC__
35 #  if __GNUC__ >= 4
36 #   define EAPI __attribute__ ((visibility("default")))
37 #  else
38 #   define EAPI
39 #  endif
40 # else
41 #  define EAPI
42 # endif
43 #endif /* ! _WIN32 */
44 /*
45  * SDL only handle one window at a time. That's by definition, there is nothing wrong here.
46  *
47  */
48 
49 /* static char *ecore_evas_default_display = "0"; */
50 /* static Ecore_List *ecore_evas_input_devices = NULL; */
51 
52 typedef struct _Ecore_Evas_SDL_Switch_Data Ecore_Evas_SDL_Switch_Data;
53 struct _Ecore_Evas_SDL_Switch_Data
54 {
55    SDL_Texture *pages[2];
56    SDL_Renderer *r;
57    SDL_Window *w;
58 
59    unsigned char current;
60 };
61 
62 static int                      _ecore_evas_init_count = 0;
63 
64 static Ecore_Event_Handler      *ecore_evas_event_handlers[4] = {
65    NULL, NULL, NULL, NULL
66 };
67 
68 static const char               *ecore_evas_sdl_default = "EFL SDL";
69 static Ecore_Poller             *ecore_evas_event;
70 static int                      _ecore_evas_fps_debug = 0;
71 static int                       ecore_evas_sdl_count = 0;
72 
73 static Ecore_Evas *
_ecore_evas_sdl_match(unsigned int windowID)74 _ecore_evas_sdl_match(unsigned int windowID)
75 {
76    return SDL_GetWindowData(SDL_GetWindowFromID(windowID), "_Ecore_Evas");
77 }
78 
79 static void *
_ecore_evas_sdl_switch_buffer(void * data,void * dest EINA_UNUSED)80 _ecore_evas_sdl_switch_buffer(void *data, void *dest EINA_UNUSED)
81 {
82    Ecore_Evas_SDL_Switch_Data *swd = data;
83    void *pixels;
84    int pitch;
85 
86    /* Push current buffer to screen */
87    SDL_UnlockTexture(swd->pages[swd->current]);
88    SDL_RenderCopy(swd->r, swd->pages[swd->current], NULL, NULL);
89    SDL_RenderPresent(swd->r);
90 
91    /* Switch to next buffer for rendering */
92    swd->current = (swd->current + 1) % 2;
93    if (SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch) < 0)
94      return NULL;
95 
96    return pixels;
97 }
98 
99 static Eina_Bool
_ecore_evas_sdl_event_got_focus(void * data EINA_UNUSED,int type EINA_UNUSED,void * event)100 _ecore_evas_sdl_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
101 {
102    Ecore_Sdl_Event_Window *ev = event;
103    Ecore_Evas *ee;
104 
105    ee = _ecore_evas_sdl_match(ev->windowID);
106    /* pass on event */
107    if (!ee) return ECORE_CALLBACK_PASS_ON;
108    _ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
109    return ECORE_CALLBACK_PASS_ON;
110 }
111 
112 static Eina_Bool
_ecore_evas_sdl_event_lost_focus(void * data EINA_UNUSED,int type EINA_UNUSED,void * event EINA_UNUSED)113 _ecore_evas_sdl_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
114 {
115    Ecore_Sdl_Event_Window *ev = event;
116    Ecore_Evas *ee;
117 
118    ee = _ecore_evas_sdl_match(ev->windowID);
119 
120    if (!ee) return ECORE_CALLBACK_PASS_ON;
121    /* pass on event */
122    _ecore_evas_focus_device_set(ee, NULL, EINA_FALSE);
123    return ECORE_CALLBACK_PASS_ON;
124 }
125 
126 static Eina_Bool
_ecore_evas_sdl_event_video_resize(void * data EINA_UNUSED,int type EINA_UNUSED,void * event)127 _ecore_evas_sdl_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
128 {
129    Ecore_Sdl_Event_Video_Resize *e;
130    Ecore_Evas *ee;
131    int rmethod;
132 
133    e = event;
134    ee = _ecore_evas_sdl_match(e->windowID);
135 
136    if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
137 
138    rmethod = evas_output_method_get(ee->evas);
139    if (rmethod == evas_render_method_lookup("buffer"))
140      {
141         Evas_Engine_Info_Buffer *einfo;
142 
143         einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
144         if (einfo)
145           {
146              Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
147              void *pixels;
148              int pitch;
149 
150              SDL_UnlockTexture(swd->pages[swd->current]);
151 
152              SDL_DestroyTexture(swd->pages[0]);
153              SDL_DestroyTexture(swd->pages[1]);
154 
155              SDL_RenderClear(swd->r);
156 
157              swd->pages[0] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, e->w, e->h);
158              swd->pages[1] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, e->w, e->h);
159 
160              SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch);
161 
162              einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
163              einfo->info.switch_data = swd;
164              einfo->info.dest_buffer = pixels;
165              einfo->info.dest_buffer_row_bytes = pitch;
166              einfo->info.use_color_key = 0;
167              einfo->info.alpha_threshold = 0;
168              einfo->info.func.new_update_region = NULL;
169              einfo->info.func.free_update_region = NULL;
170              einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer;
171              if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo))
172                {
173                   return EINA_FALSE;
174                }
175           }
176      }
177 
178    ee->w = e->w;
179    ee->h = e->h;
180    ee->req.w = e->w;
181    ee->req.h = e->h;
182 
183    evas_output_size_set(ee->evas, e->w, e->h);
184    evas_output_viewport_set(ee->evas, 0, 0, e->w, e->h);
185 
186    return ECORE_CALLBACK_PASS_ON;
187 }
188 
189 static Eina_Bool
_ecore_evas_sdl_event_video_expose(void * data EINA_UNUSED,int type EINA_UNUSED,void * event)190 _ecore_evas_sdl_event_video_expose(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
191 {
192    Ecore_Sdl_Event_Window *ev = event;
193    Ecore_Evas *ee;
194    int w;
195    int h;
196 
197    ee = _ecore_evas_sdl_match(ev->windowID);
198 
199    if (!ee) return ECORE_CALLBACK_PASS_ON;
200    evas_output_size_get(ee->evas, &w, &h);
201    evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
202 
203    return ECORE_CALLBACK_PASS_ON;
204 }
205 
206 static Eina_Bool
_ecore_evas_sdl_event(void * data EINA_UNUSED)207 _ecore_evas_sdl_event(void *data EINA_UNUSED)
208 {
209    ecore_sdl_feed_events();
210    return ECORE_CALLBACK_RENEW;
211 }
212 
213 static int
_ecore_evas_sdl_init(int w EINA_UNUSED,int h EINA_UNUSED)214 _ecore_evas_sdl_init(int w EINA_UNUSED, int h EINA_UNUSED)
215 {
216    _ecore_evas_init_count++;
217    if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
218 
219 #ifndef _WIN32
220    if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
221 #endif /* _WIN32 */
222    // this is pretty bad: poller? and set poll time? pol time is meant to be
223    // adjustable for things like polling battery state, or amoutn of spare
224    // memory etc.
225    //
226    ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_sdl_event, NULL);
227    ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006);
228 #ifndef _WIN32
229    if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
230 #endif /* _WIN32 */
231 
232    ecore_event_evas_init();
233 
234    ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_SDL_EVENT_GOT_FOCUS, _ecore_evas_sdl_event_got_focus, NULL);
235    ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_SDL_EVENT_LOST_FOCUS, _ecore_evas_sdl_event_lost_focus, NULL);
236    ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_SDL_EVENT_RESIZE, _ecore_evas_sdl_event_video_resize, NULL);
237    ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_SDL_EVENT_EXPOSE, _ecore_evas_sdl_event_video_expose, NULL);
238 
239    return _ecore_evas_init_count;
240 }
241 
242 static int
_ecore_evas_sdl_shutdown(void)243 _ecore_evas_sdl_shutdown(void)
244 {
245    _ecore_evas_init_count--;
246    if (_ecore_evas_init_count == 0)
247      {
248         unsigned int i;
249 
250         for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++)
251           ecore_event_handler_del(ecore_evas_event_handlers[i]);
252         ecore_event_evas_shutdown();
253         ecore_poller_del(ecore_evas_event);
254         ecore_evas_event = NULL;
255 #ifndef _WIN32
256         if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
257 #endif /* _WIN32 */
258      }
259    if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
260    return _ecore_evas_init_count;
261 }
262 
263 static void
_ecore_evas_sdl_free(Ecore_Evas * ee)264 _ecore_evas_sdl_free(Ecore_Evas *ee)
265 {
266    Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*) (ee + 1);
267 
268    ecore_event_window_unregister(SDL_GetWindowID(swd->w));
269 
270    if (swd->pages[swd->current])
271      SDL_UnlockTexture(swd->pages[swd->current]);
272 
273    if (swd->pages[0])
274      SDL_DestroyTexture(swd->pages[0]);
275    if (swd->pages[1])
276      SDL_DestroyTexture(swd->pages[1]);
277    if (swd->r)
278      SDL_DestroyRenderer(swd->r);
279    if (swd->w)
280      SDL_DestroyWindow(swd->w);
281 
282    _ecore_evas_sdl_shutdown();
283    ecore_sdl_shutdown();
284    ecore_evas_sdl_count--;
285 
286    SDL_VideoQuit();
287 }
288 
289 static void
_ecore_evas_resize(Ecore_Evas * ee,int w,int h)290 _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
291 {
292    int rmethod;
293 
294    if ((w == ee->w) && (h == ee->h)) return;
295    ee->req.w = w;
296    ee->req.h = h;
297    ee->w = w;
298    ee->h = h;
299 
300    rmethod = evas_output_method_get(ee->evas);
301    if (rmethod == evas_render_method_lookup("buffer"))
302      {
303         Evas_Engine_Info_Buffer *einfo;
304 
305         einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
306         if (einfo)
307           {
308              Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
309              void *pixels;
310              int pitch;
311 
312              SDL_UnlockTexture(swd->pages[swd->current]);
313 
314              SDL_DestroyTexture(swd->pages[0]);
315              SDL_DestroyTexture(swd->pages[1]);
316 
317              SDL_RenderClear(swd->r);
318 
319              swd->pages[0] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
320              swd->pages[1] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
321 
322              SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch);
323 
324              einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
325              einfo->info.switch_data = swd;
326              einfo->info.dest_buffer = pixels;
327              einfo->info.dest_buffer_row_bytes = pitch;
328              einfo->info.use_color_key = 0;
329              einfo->info.alpha_threshold = 0;
330              einfo->info.func.new_update_region = NULL;
331              einfo->info.func.free_update_region = NULL;
332              einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer;
333              if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo))
334                {
335                   return;
336                }
337           }
338      }
339 
340    evas_output_size_set(ee->evas, ee->w, ee->h);
341    evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
342    evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
343 
344    if (ee->func.fn_resize) ee->func.fn_resize(ee);
345 }
346 
347 static void
_ecore_evas_move_resize(Ecore_Evas * ee,int x,int y,int w,int h)348 _ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
349 {
350    if ((ee->x != x) || (ee->y != y))
351      {
352         ee->req.x = x;
353         ee->req.y = y;
354         ee->x = x;
355         ee->y = y;
356         if (ee->func.fn_move) ee->func.fn_move(ee);
357      }
358    _ecore_evas_resize(ee, w, h);
359 }
360 
361 static void
_ecore_evas_show(Ecore_Evas * ee)362 _ecore_evas_show(Ecore_Evas *ee)
363 {
364    ee->prop.withdrawn = EINA_FALSE;
365    if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
366    if (ecore_evas_focus_device_get(ee, NULL)) return;
367    _ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
368    evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
369 }
370 
371 static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
372 {
373    _ecore_evas_sdl_free,
374    NULL,
375    NULL,
376    NULL,
377    NULL,
378    NULL,
379    NULL,
380    NULL,
381    NULL,
382    NULL,
383    NULL,
384    NULL,
385    NULL,
386    NULL,
387    NULL,
388    NULL,
389    NULL,
390    _ecore_evas_resize,
391    _ecore_evas_move_resize,
392    NULL,
393    NULL,
394    _ecore_evas_show,
395    NULL,
396    NULL,
397    NULL,
398    NULL,
399    NULL,
400    NULL,
401    NULL,
402    NULL,
403    NULL,
404    NULL,
405    NULL,
406    NULL,
407    NULL,
408    NULL,
409    NULL,
410    NULL,
411    NULL,
412    NULL,
413    NULL,
414    NULL,
415    NULL,
416    NULL,
417    NULL,
418    NULL,
419    NULL, //transparent
420    NULL, // profiles_set
421    NULL, // profile_set
422 
423    NULL,
424    NULL,
425    NULL,
426    NULL,
427    NULL,
428    NULL,
429 
430    NULL, // render
431    NULL, // screen_geometry_get
432    NULL, // screen_dpi_get
433    NULL,
434    NULL,  // msg_send
435 
436    NULL, // pointer_xy_get
437    NULL, // pointer_warp
438 
439    NULL, // wm_rot_preferred_rotation_set
440    NULL, // wm_rot_available_rotations_set
441    NULL, // wm_rot_manual_rotation_done_set
442    NULL, // wm_rot_manual_rotation_done
443 
444    NULL, // aux_hints_set
445 
446    NULL, // fn_animator_register
447    NULL, // fn_animator_unregister
448 
449    NULL, // fn_evas_changed
450    NULL, //fn_focus_device_set
451    NULL, //fn_callback_focus_device_in_set
452    NULL, //fn_callback_focus_device_out_set
453    NULL, //fn_callback_device_mouse_in_set
454    NULL, //fn_callback_device_mouse_out_set
455    NULL, //fn_pointer_device_xy_get
456    NULL, //fn_prepare
457    NULL, //fn_last_tick_get
458    NULL, //fn_selection_claim
459    NULL, //fn_selection_has_owner
460    NULL, //fn_selection_request
461 };
462 
463 static Ecore_Evas*
_ecore_evas_internal_sdl_new(int rmethod,const char * name,int w,int h,int fullscreen,int hwsurface,int noframe,int alpha)464 _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha)
465 {
466    Ecore_Evas_SDL_Switch_Data *swd;
467    Ecore_Evas *ee;
468    Eina_Bool gl = EINA_FALSE;
469 
470    if (ecore_evas_sdl_count > 0) return NULL;
471    if (!name)
472      name = ecore_evas_sdl_default;
473 
474    if (!ecore_sdl_init(name)) return NULL;
475 
476    if (SDL_VideoInit(NULL) != 0)
477      {
478         ERR("SDL Video initialization failed !");
479         return NULL;
480      }
481 
482    ee = calloc(1, sizeof(Ecore_Evas) + sizeof (Ecore_Evas_SDL_Switch_Data));
483    if (!ee) return NULL;
484 
485    swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
486 
487    ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
488 
489    ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_sdl_engine_func;
490 
491    ee->driver = "sdl";
492    if (name) ee->name = strdup(name);
493 
494    if (w < 1) w = 1;
495    if (h < 1) h = 1;
496    ee->visible = 1;
497    ee->req.w = w;
498    ee->req.h = h;
499    ee->w = w;
500    ee->h = h;
501 
502    ee->prop.max.w = 0;
503    ee->prop.max.h = 0;
504    ee->prop.layer = 0;
505    ee->prop.borderless = EINA_TRUE;
506    ee->prop.override = EINA_TRUE;
507    ee->prop.maximized = EINA_TRUE;
508    ee->prop.fullscreen = fullscreen;
509    ee->prop.withdrawn = EINA_TRUE;
510    ee->prop.sticky = EINA_FALSE;
511    ee->prop.window = 0;
512    ee->alpha = alpha;
513    ee->prop.hwsurface = hwsurface;
514 
515    /* init evas here */
516    if (!ecore_evas_evas_new(ee, w, h))
517      {
518         ERR("Can not create Canvas.");
519         goto on_error;
520      }
521 
522    evas_output_method_set(ee->evas, rmethod);
523 
524    gl = !(rmethod == evas_render_method_lookup("buffer"));
525    ee->can_async_render = gl ? EINA_FALSE : EINA_TRUE;
526 
527    swd->w = SDL_CreateWindow(name,
528                              SDL_WINDOWPOS_UNDEFINED,
529                              SDL_WINDOWPOS_UNDEFINED,
530                              w, h,
531                              SDL_WINDOW_RESIZABLE | (gl ? SDL_WINDOW_OPENGL : 0));
532    if (!swd->w)
533      {
534         ERR("SDL_CreateWindow failed.");
535         goto on_error;
536      }
537 
538    if (!gl)
539      {
540         Evas_Engine_Info_Buffer *einfo;
541 
542         einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
543         if (einfo)
544           {
545              void *pixels;
546              int pitch;
547 
548              swd->r = SDL_CreateRenderer(swd->w, -1, 0);
549              if (!swd->r)
550                {
551                   ERR("SDL_CreateRenderer failed.");
552                   goto on_error;
553                }
554 
555              swd->pages[0] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
556              swd->pages[1] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
557 
558              einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
559              einfo->info.switch_data = swd;
560 
561              SDL_RenderClear(swd->r);
562              if (SDL_LockTexture(swd->pages[0], NULL, &pixels, &pitch) < 0)
563                {
564                   ERR("SDL_LockTexture failed.");
565                   goto on_error;
566                }
567 
568              einfo->info.dest_buffer = pixels;
569              einfo->info.dest_buffer_row_bytes = pitch;
570              einfo->info.use_color_key = 0;
571              einfo->info.alpha_threshold = 0;
572              einfo->info.func.new_update_region = NULL;
573              einfo->info.func.free_update_region = NULL;
574              einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer;
575              if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo))
576                {
577                   ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
578                   ecore_evas_free(ee);
579                   return NULL;
580                }
581           }
582         else
583           {
584              ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
585              ecore_evas_free(ee);
586              return NULL;
587           }
588      }
589    else
590      {
591         /* FIXME */
592 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
593         Evas_Engine_Info_GL_SDL *einfo;
594 
595         einfo = (Evas_Engine_Info_GL_SDL *) evas_engine_info_get(ee->evas);
596         if (einfo)
597           {
598              einfo->flags.fullscreen = fullscreen;
599              einfo->flags.noframe = noframe;
600              einfo->window = swd->w;
601              if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
602                {
603                   ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
604                   ecore_evas_free(ee);
605                   return NULL;
606                }
607           }
608         else
609           {
610              ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
611              ecore_evas_free(ee);
612              return NULL;
613           }
614 #endif
615      }
616 
617    _ecore_evas_sdl_init(w, h);
618    ee->prop.window = SDL_GetWindowID(swd->w);
619 
620    ecore_evas_done(ee, EINA_FALSE);
621 
622    SDL_SetWindowData(swd->w, "_Ecore_Evas", ee);
623    SDL_ShowCursor(SDL_ENABLE);
624 
625    _ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
626    ecore_evas_sdl_count++;
627    return ee;
628 
629  on_error:
630    ecore_evas_free(ee);
631    return NULL;
632 }
633 
634 EAPI Ecore_Evas *
ecore_evas_sdl_new_internal(const char * name,int w,int h,int fullscreen,int hwsurface,int noframe,int alpha)635 ecore_evas_sdl_new_internal(const char* name, int w, int h, int fullscreen,
636                             int hwsurface, int noframe, int alpha)
637 {
638    Ecore_Evas          *ee;
639    int                  rmethod;
640 
641    rmethod = evas_render_method_lookup("buffer");
642    if (!rmethod) return NULL;
643 
644    ee = _ecore_evas_internal_sdl_new(rmethod, name, w, h, fullscreen, hwsurface, noframe, alpha);
645    return ee;
646 }
647 
648 EAPI Ecore_Evas*
ecore_evas_sdl16_new_internal(const char * name EINA_UNUSED,int w EINA_UNUSED,int h EINA_UNUSED,int fullscreen EINA_UNUSED,int hwsurface EINA_UNUSED,int noframe EINA_UNUSED,int alpha EINA_UNUSED)649 ecore_evas_sdl16_new_internal(const char* name EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, int fullscreen EINA_UNUSED, int hwsurface EINA_UNUSED, int noframe EINA_UNUSED, int alpha EINA_UNUSED)
650 {
651    ERR("OUCH !");
652    return NULL;
653 }
654 
655 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
656 EAPI Ecore_Evas *
ecore_evas_gl_sdl_new_internal(const char * name,int w,int h,int fullscreen,int noframe)657 ecore_evas_gl_sdl_new_internal(const char* name, int w, int h, int fullscreen, int noframe)
658 {
659    Ecore_Evas          *ee;
660    int                  rmethod;
661 
662    rmethod = evas_render_method_lookup("gl_sdl");
663    if (!rmethod) return NULL;
664 
665    ee = _ecore_evas_internal_sdl_new(rmethod, name, w, h, fullscreen, 0, noframe, 0);
666    if (ee) ee->driver = "gl_sdl";
667    return ee;
668 }
669 #endif
670