evas: move to SDL2 and use GL_Generic infrastructure.

This commit is contained in:
Cedric BAIL 2014-07-25 20:23:42 +02:00
parent 9a9d78dfcb
commit 3c179cdb87
10 changed files with 657 additions and 1231 deletions

View File

@ -1239,7 +1239,7 @@ AC_ARG_ENABLE([sdl],
[want_sdl="no"])
if test "${want_sdl}" = "yes"; then
EFL_PKG_CHECK_STRICT([sdl >= 1.2.0])
EFL_PKG_CHECK_STRICT([sdl2 >= 2.0.0])
fi
# We only enable SDL with opengl if it is not the full version and not ES
@ -2734,10 +2734,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_SDL], [ecore])
EFL_INTERNAL_DEPEND_PKG([ECORE_SDL], [eo])
EFL_INTERNAL_DEPEND_PKG([ECORE_SDL], [eina])
EFL_DEPEND_PKG([ECORE_SDL], [SDL], [sdl >= 1.2.0])
PKG_CHECK_EXISTS([sdl >= 1.3.0],
[AC_DEFINE(BUILD_ECORE_EVAS_SDL_130, 1, [Support for SVN SDL])])
EFL_DEPEND_PKG([ECORE_SDL], [SDL], [sdl2 >= 2.0.0])
EFL_EVAL_PKGS([ECORE_SDL])

View File

@ -419,10 +419,10 @@ have_dep="no"
evas_engine_[]$1[]_cflags=""
evas_engine_[]$1[]_libs=""
PKG_CHECK_EXISTS([sdl >= 1.2.0],
PKG_CHECK_EXISTS([sdl2 >= 2.0.0],
[
have_dep="yes"
requirement="sdl >= 1.2.0"
requirement="sdl2 >= 2.0.0"
],
[have_dep="no"])

View File

@ -949,17 +949,11 @@ modules_evas_engines_gl_sdl_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/modules/evas/engines/gl_common \
@EVAS_CFLAGS@ \
@evas_engine_gl_sdl_cflags@
modules_evas_engines_gl_sdl_module_la_LIBADD =
if ! EVAS_STATIC_BUILD_GL_COMMON
modules_evas_engines_gl_sdl_module_la_LIBADD += \
modules/evas/engines/gl_common/libevas_engine_gl_common.la
endif
modules_evas_engines_gl_sdl_module_la_LIBADD += \
modules_evas_engines_gl_sdl_module_la_LIBADD = \
@USE_EVAS_LIBS@ \
@evas_engine_gl_sdl_libs@
modules_evas_engines_gl_sdl_module_la_DEPENDENCIES = \
@USE_EVAS_INTERNAL_LIBS@ \
modules/evas/engines/gl_common/libevas_engine_gl_common.la
@USE_EVAS_INTERNAL_LIBS@
modules_evas_engines_gl_sdl_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
modules_evas_engines_gl_sdl_module_la_LIBTOOLFLAGS = --tag=disable-static
endif

View File

@ -41,6 +41,26 @@ EAPI extern int ECORE_SDL_EVENT_LOST_FOCUS;
EAPI extern int ECORE_SDL_EVENT_RESIZE;
EAPI extern int ECORE_SDL_EVENT_EXPOSE;
typedef struct _Ecore_Sdl_Event_Video_Resize Ecore_Sdl_Event_Video_Resize;
struct _Ecore_Sdl_Event_Video_Resize
{
unsigned int windowID;
int w;
int h;
};
typedef struct _Ecore_Sdl_Event_Window Ecore_Sdl_Event_Window;
struct _Ecore_Sdl_Event_Window
{
unsigned int windowID;
};
EAPI int ecore_sdl_init(const char *name);
EAPI int ecore_sdl_shutdown(void);
EAPI void ecore_sdl_feed_events(void);
/* The following data structure have been deprecated since a long time */
typedef struct _Ecore_Sdl_Event_Key_Down Ecore_Sdl_Event_Key_Down;
struct _Ecore_Sdl_Event_Key_Down /** SDL Key Down event */
{
@ -96,17 +116,6 @@ struct _Ecore_Sdl_Event_Mouse_Wheel /** SDL Mouse Wheel event */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Video_Resize Ecore_Sdl_Event_Video_Resize;
struct _Ecore_Sdl_Event_Video_Resize
{
int w;
int h;
};
EAPI int ecore_sdl_init(const char *name);
EAPI int ecore_sdl_shutdown(void);
EAPI void ecore_sdl_feed_events(void);
#ifdef __cplusplus
}
#endif

View File

@ -3,7 +3,7 @@
struct _ecore_sdl_keys_s
{
unsigned int code;
SDL_Keycode code;
const char* name;
const char* compose;
};
@ -11,9 +11,6 @@ struct _ecore_sdl_keys_s
static const struct _ecore_sdl_keys_s keystable[] =
{
{ SDLK_UNKNOWN, "0x00", "" },
#ifndef BUILD_ECORE_EVAS_SDL_130
{ SDLK_FIRST, "First", "First" },
#endif
{ SDLK_BACKSPACE, "BackSpace", "\010" },
{ SDLK_TAB, "Tab", "\011" },
{ SDLK_CLEAR, "Clear", "Clear" },
@ -89,116 +86,17 @@ static const struct _ecore_sdl_keys_s keystable[] =
{ SDLK_DELETE, "Delete", "\177" },
/* End of ASCII mapped keysyms */
#ifndef BUILD_ECORE_EVAS_SDL_130
/* International keyboard syms */
{ SDLK_WORLD_0, "w0", "" }, /* 0xA0 */
{ SDLK_WORLD_1, "w1", "" },
{ SDLK_WORLD_2, "w2", "" },
{ SDLK_WORLD_3, "w3", "" },
{ SDLK_WORLD_4, "w4", "" },
{ SDLK_WORLD_5, "w5", "" },
{ SDLK_WORLD_6, "w6", "" },
{ SDLK_WORLD_7, "w7", "" },
{ SDLK_WORLD_8, "w8", "" },
{ SDLK_WORLD_9, "w9", "" },
{ SDLK_WORLD_10, "w10", "" },
{ SDLK_WORLD_11, "w11", "" },
{ SDLK_WORLD_12, "w12", "" },
{ SDLK_WORLD_13, "w13", "" },
{ SDLK_WORLD_14, "w14", "" },
{ SDLK_WORLD_15, "w15", "" },
{ SDLK_WORLD_16, "w16", "" },
{ SDLK_WORLD_17, "w17", "" },
{ SDLK_WORLD_18, "w18", "" },
{ SDLK_WORLD_19, "w19", "" },
{ SDLK_WORLD_20, "w20", "" },
{ SDLK_WORLD_21, "w21", "" },
{ SDLK_WORLD_22, "w22", "" },
{ SDLK_WORLD_23, "w23", "" },
{ SDLK_WORLD_24, "w24", "" },
{ SDLK_WORLD_25, "w25", "" },
{ SDLK_WORLD_26, "w26", "" },
{ SDLK_WORLD_27, "w27", "" },
{ SDLK_WORLD_28, "w28", "" },
{ SDLK_WORLD_29, "w29", "" },
{ SDLK_WORLD_30, "w30", "" },
{ SDLK_WORLD_31, "w31", "" },
{ SDLK_WORLD_32, "w32", "" },
{ SDLK_WORLD_33, "w33", "" },
{ SDLK_WORLD_34, "w34", "" },
{ SDLK_WORLD_35, "w35", "" },
{ SDLK_WORLD_36, "w36", "" },
{ SDLK_WORLD_37, "w37", "" },
{ SDLK_WORLD_38, "w38", "" },
{ SDLK_WORLD_39, "w39", "" },
{ SDLK_WORLD_40, "w40", "" },
{ SDLK_WORLD_41, "w41", "" },
{ SDLK_WORLD_42, "w42", "" },
{ SDLK_WORLD_43, "w43", "" },
{ SDLK_WORLD_44, "w44", "" },
{ SDLK_WORLD_45, "w45", "" },
{ SDLK_WORLD_46, "w46", "" },
{ SDLK_WORLD_47, "w47", "" },
{ SDLK_WORLD_48, "w48", "" },
{ SDLK_WORLD_49, "w49", "" },
{ SDLK_WORLD_50, "w50", "" },
{ SDLK_WORLD_51, "w51", "" },
{ SDLK_WORLD_52, "w52", "" },
{ SDLK_WORLD_53, "w53", "" },
{ SDLK_WORLD_54, "w54", "" },
{ SDLK_WORLD_55, "w55", "" },
{ SDLK_WORLD_56, "w56", "" },
{ SDLK_WORLD_57, "w57", "" },
{ SDLK_WORLD_58, "w58", "" },
{ SDLK_WORLD_59, "w59", "" },
{ SDLK_WORLD_60, "w60", "" },
{ SDLK_WORLD_61, "w61", "" },
{ SDLK_WORLD_62, "w62", "" },
{ SDLK_WORLD_63, "w63", "" },
{ SDLK_WORLD_64, "w64", "" },
{ SDLK_WORLD_65, "w65", "" },
{ SDLK_WORLD_66, "w66", "" },
{ SDLK_WORLD_67, "w67", "" },
{ SDLK_WORLD_68, "w68", "" },
{ SDLK_WORLD_69, "w69", "" },
{ SDLK_WORLD_70, "w70", "" },
{ SDLK_WORLD_71, "w71", "" },
{ SDLK_WORLD_72, "w72", "" },
{ SDLK_WORLD_73, "w73", "" },
{ SDLK_WORLD_74, "w74", "" },
{ SDLK_WORLD_75, "w75", "" },
{ SDLK_WORLD_76, "w76", "" },
{ SDLK_WORLD_77, "w77", "" },
{ SDLK_WORLD_78, "w78", "" },
{ SDLK_WORLD_79, "w79", "" },
{ SDLK_WORLD_80, "w80", "" },
{ SDLK_WORLD_81, "w81", "" },
{ SDLK_WORLD_82, "w82", "" },
{ SDLK_WORLD_83, "w83", "" },
{ SDLK_WORLD_84, "w84", "" },
{ SDLK_WORLD_85, "w85", "" },
{ SDLK_WORLD_86, "w86", "" },
{ SDLK_WORLD_87, "w87", "" },
{ SDLK_WORLD_88, "w88", "" },
{ SDLK_WORLD_89, "w89", "" },
{ SDLK_WORLD_90, "w90", "" },
{ SDLK_WORLD_91, "w91", "" },
{ SDLK_WORLD_92, "w92", "" },
{ SDLK_WORLD_93, "w93", "" },
{ SDLK_WORLD_94, "w94", "" },
{ SDLK_WORLD_95, "w95", "" },
#endif
/* Numeric keypad */
{ SDLK_KP0, "KP0", "0" },
{ SDLK_KP1, "KP1", "1" },
{ SDLK_KP2, "KP2", "2" },
{ SDLK_KP3, "KP3", "3" },
{ SDLK_KP4, "KP4", "4" },
{ SDLK_KP5, "KP5", "5" },
{ SDLK_KP6, "KP6", "6" },
{ SDLK_KP7, "KP7", "7" },
{ SDLK_KP8, "KP8", "8" },
{ SDLK_KP9, "KP9", "9" },
{ SDLK_KP_0, "KP0", "0" },
{ SDLK_KP_1, "KP1", "1" },
{ SDLK_KP_2, "KP2", "2" },
{ SDLK_KP_3, "KP3", "3" },
{ SDLK_KP_4, "KP4", "4" },
{ SDLK_KP_5, "KP5", "5" },
{ SDLK_KP_6, "KP6", "6" },
{ SDLK_KP_7, "KP7", "7" },
{ SDLK_KP_8, "KP8", "8" },
{ SDLK_KP_9, "KP9", "9" },
{ SDLK_KP_PERIOD, "period", "." },
{ SDLK_KP_DIVIDE, "KP_Divide", "/" },
{ SDLK_KP_MULTIPLY, "KP_Multiply", "*" },
@ -236,30 +134,25 @@ static const struct _ecore_sdl_keys_s keystable[] =
{ SDLK_F15, "F15", "F15" },
/* Key state modifier keys */
{ SDLK_NUMLOCK, "Num_Lock", "Num_Lock" },
{ SDLK_NUMLOCKCLEAR, "Num_Lock", "Num_Lock" },
{ SDLK_CAPSLOCK, "Caps_Lock", "Caps_Lock" },
{ SDLK_SCROLLOCK, "Scroll_Lock", "Scroll_Lock" },
{ SDLK_SCROLLLOCK, "Scroll_Lock", "Scroll_Lock" },
{ SDLK_RSHIFT, "Shift_R", "Shift_R" },
{ SDLK_LSHIFT, "Shift_L", "Shift_L" },
{ SDLK_RCTRL, "Control_R", "Control_R" },
{ SDLK_LCTRL, "Control_L", "Control_L" },
{ SDLK_RALT, "Alt_R", "Alt_R" },
{ SDLK_LALT, "Alt_L", "Alt_L" },
{ SDLK_RMETA, "Meta_R", "Meta_R" },
{ SDLK_LMETA, "Meta_L", "Meta_L" },
{ SDLK_LSUPER, "Super_L", "Super_L" }, /* Left "Windows" key */
{ SDLK_RSUPER, "Super_R", "Super_R" }, /* Right "Windows" key */
{ SDLK_LGUI, "Super_L", "Super_L" }, /* Left "Windows" key */
{ SDLK_RGUI, "Super_R", "Super_R" }, /* Right "Windows" key */
{ SDLK_MODE, "Mode", "Mode" }, /* "Alt Gr" key */
{ SDLK_COMPOSE, "Compose", "Compose" }, /* Multi-key compose key */
/* Miscellaneous function keys */
{ SDLK_HELP, "Help", "Help" },
{ SDLK_PRINT, "Print", "Print" },
{ SDLK_PRINTSCREEN, "Print", "Print" },
{ SDLK_SYSREQ, "SysReq", "SysReq" },
{ SDLK_BREAK, "Break", "Break" },
{ SDLK_MENU, "Menu", "Menu" },
{ SDLK_POWER, "Power", "Power" }, /* Power Macintosh power key */
{ SDLK_EURO, "Euro", "\200" }, /* Some european keyboards */
{ SDLK_UNDO, "Undo", "Undo" } /* Atari keyboard has Undo */
};

View File

@ -2,7 +2,7 @@
# include <config.h>
#endif
#include <SDL/SDL.h>
#include <SDL2/SDL.h>
#include <Eina.h>
#include <Ecore.h>
@ -19,7 +19,7 @@ struct _Ecore_SDL_Pressed
{
EINA_RBTREE;
SDLKey key;
SDL_Keycode key;
};
EAPI int ECORE_SDL_EVENT_GOT_FOCUS = 0;
@ -40,7 +40,7 @@ _ecore_sdl_pressed_key(const Ecore_SDL_Pressed *left,
static int
_ecore_sdl_pressed_node(const Ecore_SDL_Pressed *node,
const SDLKey *key,
const SDL_Keycode *key,
EINA_UNUSED int length,
EINA_UNUSED void *data)
{
@ -76,13 +76,13 @@ ecore_sdl_init(const char *name EINA_UNUSED)
if (!ecore_event_init())
return --_ecore_sdl_init_count;
SDL_Init(SDL_INIT_EVENTS);
ECORE_SDL_EVENT_GOT_FOCUS = ecore_event_type_new();
ECORE_SDL_EVENT_LOST_FOCUS = ecore_event_type_new();
ECORE_SDL_EVENT_RESIZE = ecore_event_type_new();
ECORE_SDL_EVENT_EXPOSE = ecore_event_type_new();
SDL_EnableKeyRepeat(200, 100);
return _ecore_sdl_init_count;
}
@ -98,6 +98,8 @@ ecore_sdl_shutdown(void)
if (--_ecore_sdl_init_count != 0)
return _ecore_sdl_init_count;
SDL_Quit();
ecore_event_shutdown();
eina_log_domain_unregister(_ecore_sdl_log_dom);
_ecore_sdl_log_dom = -1;
@ -131,7 +133,7 @@ _ecore_sdl_event_key(SDL_Event *event, double timestamp)
if (!ev) return NULL;
ev->timestamp = timestamp;
ev->window = 0;
ev->window = event->key.windowID;
ev->event_window = 0;
ev->modifiers = _ecore_sdl_event_modifiers(SDL_GetModState());
ev->key = NULL;
@ -169,8 +171,8 @@ ecore_sdl_feed_events(void)
if (!ev) return;
ev->timestamp = timestamp;
ev->window = 0;
ev->event_window = 0;
ev->window = event.motion.windowID;
ev->event_window = event.motion.windowID;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->x = event.motion.x;
ev->y = event.motion.y;
@ -188,46 +190,44 @@ ecore_sdl_feed_events(void)
}
case SDL_MOUSEBUTTONDOWN:
{
if (event.button.button == SDL_BUTTON_WHEELUP ||
event.button.button == SDL_BUTTON_WHEELDOWN)
{
Ecore_Event_Mouse_Wheel *ev;
Ecore_Event_Mouse_Button *ev;
ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
if (!ev) return;
ev = malloc(sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
ev->timestamp = timestamp;
ev->window = 0;
ev->event_window = 0;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->direction = 0;
ev->z = event.button.button == SDL_BUTTON_WHEELDOWN ? -1 : 1;
ev->timestamp = timestamp;
ev->window = event.button.windowID;
ev->event_window = event.button.windowID;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->buttons = event.button.button;
ev->double_click = 0;
ev->triple_click = 0;
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
}
else
{
Ecore_Event_Mouse_Button *ev;
/* Must set multi touch device to 0 or it will get ignored */
ev->multi.device = 0;
ev->multi.radius = ev->multi.radius_x = ev->multi.radius_y = 0;
ev->multi.pressure = ev->multi.angle = 0;
ev->multi.x = ev->multi.y = ev->multi.root.x = ev->multi.root.y = 0;
ev = malloc(sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
break;
}
case SDL_MOUSEWHEEL:
{
Ecore_Event_Mouse_Wheel *ev;
ev->timestamp = timestamp;
ev->window = 0;
ev->event_window = 0;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->buttons = event.button.button;
ev->double_click = 0;
ev->triple_click = 0;
ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
if (!ev) return;
/* Must set multi touch device to 0 or it will get ignored */
ev->multi.device = 0;
ev->multi.radius = ev->multi.radius_x = ev->multi.radius_y = 0;
ev->multi.pressure = ev->multi.angle = 0;
ev->multi.x = ev->multi.y = ev->multi.root.x = ev->multi.root.y = 0;
ev->timestamp = timestamp;
ev->window = event.wheel.windowID;
ev->event_window = event.wheel.windowID;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->direction = 0;
ev->z = event.wheel.x != 0 ? event.wheel.x : event.wheel.y;
ev->direction = event.wheel.x != 0 ? 0 : 1;
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
}
ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
break;
}
case SDL_MOUSEBUTTONUP:
@ -237,8 +237,8 @@ ecore_sdl_feed_events(void)
ev = malloc(sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
ev->timestamp = timestamp;
ev->window = 0;
ev->event_window = 0;
ev->window = event.button.windowID;
ev->event_window = event.button.windowID;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ev->buttons = event.button.button;
ev->double_click = 0;
@ -253,20 +253,6 @@ ecore_sdl_feed_events(void)
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
break;
}
case SDL_VIDEORESIZE:
{
Ecore_Sdl_Event_Video_Resize *ev;
ev = malloc(sizeof (Ecore_Sdl_Event_Video_Resize));
ev->w = event.resize.w;
ev->h = event.resize.h;
ecore_event_add(ECORE_SDL_EVENT_RESIZE, ev, NULL, NULL);
break;
}
case SDL_VIDEOEXPOSE:
ecore_event_add(ECORE_SDL_EVENT_EXPOSE, NULL, NULL, NULL);
break;
case SDL_QUIT:
ecore_main_loop_quit();
break;
@ -317,8 +303,59 @@ ecore_sdl_feed_events(void)
if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
break;
}
case SDL_ACTIVEEVENT:
/* FIXME: Focus gain. */
case SDL_WINDOWEVENT:
switch (event.window.event)
{
case SDL_WINDOWEVENT_RESIZED:
{
Ecore_Sdl_Event_Video_Resize *ev;
ev = calloc(1, sizeof (Ecore_Sdl_Event_Video_Resize));
ev->windowID = event.window.windowID;
ev->w = event.window.data1;
ev->h = event.window.data2;
ecore_event_add(ECORE_SDL_EVENT_RESIZE, ev, NULL, NULL);
break;
}
case SDL_WINDOWEVENT_EXPOSED:
{
Ecore_Sdl_Event_Window *ev;
ev = calloc(1, sizeof (Ecore_Sdl_Event_Window));
ev->windowID = event.window.windowID;
ecore_event_add(ECORE_SDL_EVENT_EXPOSE, ev, NULL, NULL);
break;
}
case SDL_WINDOWEVENT_ENTER:
case SDL_WINDOWEVENT_LEAVE:
{
Ecore_Event_Mouse_IO *ev;
ev = calloc(1, sizeof (Ecore_Event_Mouse_IO));
ev->window = event.window.windowID;
ev->event_window = event.window.windowID;
ecore_event_add(event.window.event == SDL_WINDOWEVENT_ENTER ?
ECORE_EVENT_MOUSE_IN : ECORE_EVENT_MOUSE_OUT,
ev, NULL, NULL);
break;
}
case SDL_WINDOWEVENT_FOCUS_GAINED:
case SDL_WINDOWEVENT_FOCUS_LOST:
{
Ecore_Sdl_Event_Window *ev;
ev = calloc(1, sizeof (Ecore_Sdl_Event_Window));
ev->windowID = event.window.windowID;
ecore_event_add(event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED ?
ECORE_SDL_EVENT_GOT_FOCUS : ECORE_SDL_EVENT_LOST_FOCUS,
ev, NULL, NULL);
break;
}
}
break;
case SDL_SYSWMEVENT:
case SDL_USEREVENT:

View File

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL2/SDL.h>
#include <Ecore.h>
#include "ecore_private.h"
@ -27,9 +27,18 @@
/* static char *ecore_evas_default_display = "0"; */
/* static Ecore_List *ecore_evas_input_devices = NULL; */
typedef struct _Ecore_Evas_SDL_Switch_Data Ecore_Evas_SDL_Switch_Data;
struct _Ecore_Evas_SDL_Switch_Data
{
SDL_Texture *pages[2];
SDL_Renderer *r;
SDL_Window *w;
unsigned char current;
};
static int _ecore_evas_init_count = 0;
static Ecore_Evas *sdl_ee = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[4] = {
NULL, NULL, NULL, NULL
};
@ -40,24 +49,38 @@ static int _ecore_evas_fps_debug = 0;
static int ecore_evas_sdl_count = 0;
static Ecore_Evas *
_ecore_evas_sdl_match(void)
_ecore_evas_sdl_match(unsigned int windowID)
{
return sdl_ee;
return SDL_GetWindowData(SDL_GetWindowFromID(windowID), "_Ecore_Evas");
}
static void *
_ecore_evas_sdl_switch_buffer(void *data, void *dest EINA_UNUSED)
{
SDL_Flip(data);
return ((SDL_Surface*)data)->pixels;
Ecore_Evas_SDL_Switch_Data *swd = data;
void *pixels;
int pitch;
/* Push current buffer to screen */
SDL_UnlockTexture(swd->pages[swd->current]);
SDL_RenderCopy(swd->r, swd->pages[swd->current], NULL, NULL);
SDL_RenderPresent(swd->r);
/* Switch to next buffer for rendering */
swd->current = (swd->current + 1) % 2;
if (SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch) < 0)
return NULL;
return pixels;
}
static Eina_Bool
_ecore_evas_sdl_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
_ecore_evas_sdl_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Evas *ee;
Ecore_Sdl_Event_Window *ev = event;
Ecore_Evas *ee;
ee = _ecore_evas_sdl_match();
ee = _ecore_evas_sdl_match(ev->windowID);
if (!ee) return ECORE_CALLBACK_PASS_ON;
/* pass on event */
@ -70,9 +93,10 @@ _ecore_evas_sdl_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, vo
static Eina_Bool
_ecore_evas_sdl_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
{
Ecore_Evas *ee;
Ecore_Sdl_Event_Window *ev = event;
Ecore_Evas *ee;
ee = _ecore_evas_sdl_match();
ee = _ecore_evas_sdl_match(ev->windowID);
if (!ee) return ECORE_CALLBACK_PASS_ON;
/* pass on event */
@ -86,11 +110,11 @@ static Eina_Bool
_ecore_evas_sdl_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Sdl_Event_Video_Resize *e;
Ecore_Evas *ee;
int rmethod;
Ecore_Evas *ee;
int rmethod;
e = event;
ee = _ecore_evas_sdl_match();
ee = _ecore_evas_sdl_match(e->windowID);
if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
@ -102,22 +126,26 @@ _ecore_evas_sdl_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED,
einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
if (einfo)
{
Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
void *pixels;
int pitch;
SDL_UnlockTexture(swd->pages[swd->current]);
SDL_DestroyTexture(swd->pages[0]);
SDL_DestroyTexture(swd->pages[1]);
SDL_RenderClear(swd->r);
swd->pages[0] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, e->w, e->h);
swd->pages[1] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, e->w, e->h);
SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch);
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
einfo->info.switch_data = SDL_SetVideoMode(e->w, e->h, 32,
(ee->prop.hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE)
| (ee->prop.fullscreen ? SDL_FULLSCREEN : 0)
| (ee->alpha ? SDL_SRCALPHA : 0)
| SDL_DOUBLEBUF);
if (!einfo->info.switch_data)
{
return EINA_FALSE;
}
SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0);
SDL_FillRect(einfo->info.switch_data, NULL, 0);
einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels;
einfo->info.dest_buffer_row_bytes = e->w * sizeof (int);
einfo->info.switch_data = swd;
einfo->info.dest_buffer = pixels;
einfo->info.dest_buffer_row_bytes = pitch;
einfo->info.use_color_key = 0;
einfo->info.alpha_threshold = 0;
einfo->info.func.new_update_region = NULL;
@ -142,13 +170,14 @@ _ecore_evas_sdl_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED,
}
static Eina_Bool
_ecore_evas_sdl_event_video_expose(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
_ecore_evas_sdl_event_video_expose(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Evas *ee;
int w;
int h;
Ecore_Sdl_Event_Window *ev = event;
Ecore_Evas *ee;
int w;
int h;
ee = _ecore_evas_sdl_match();
ee = _ecore_evas_sdl_match(ev->windowID);
if (!ee) return ECORE_CALLBACK_PASS_ON;
evas_output_size_get(ee->evas, &w, &h);
@ -260,12 +289,27 @@ _ecore_evas_sdl_shutdown(void)
static void
_ecore_evas_sdl_free(Ecore_Evas *ee)
{
if (sdl_ee == ee) sdl_ee = NULL;
Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*) (ee + 1);
ecore_event_window_unregister(SDL_GetWindowID(swd->w));
if (swd->pages[swd->current])
SDL_UnlockTexture(swd->pages[swd->current]);
if (swd->pages[0])
SDL_DestroyTexture(swd->pages[0]);
if (swd->pages[1])
SDL_DestroyTexture(swd->pages[1]);
if (swd->r)
SDL_DestroyRenderer(swd->r);
if (swd->w)
SDL_DestroyWindow(swd->w);
ecore_event_window_unregister(0);
_ecore_evas_sdl_shutdown();
ecore_sdl_shutdown();
ecore_evas_sdl_count--;
SDL_VideoQuit();
}
static void
@ -287,22 +331,26 @@ _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
if (einfo)
{
Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
void *pixels;
int pitch;
SDL_UnlockTexture(swd->pages[swd->current]);
SDL_DestroyTexture(swd->pages[0]);
SDL_DestroyTexture(swd->pages[1]);
SDL_RenderClear(swd->r);
swd->pages[0] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
swd->pages[1] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch);
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
einfo->info.switch_data = SDL_SetVideoMode(w, h, 32,
(ee->prop.hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE)
| (ee->prop.fullscreen ? SDL_FULLSCREEN : 0)
| (ee->alpha ? SDL_SRCALPHA : 0)
| SDL_DOUBLEBUF);
if (!einfo->info.switch_data)
{
return;
}
SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0);
SDL_FillRect(einfo->info.switch_data, NULL, 0);
einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels;
einfo->info.dest_buffer_row_bytes = w * sizeof (int);
einfo->info.switch_data = swd;
einfo->info.dest_buffer = pixels;
einfo->info.dest_buffer_row_bytes = pitch;
einfo->info.use_color_key = 0;
einfo->info.alpha_threshold = 0;
einfo->info.func.new_update_region = NULL;
@ -476,15 +524,27 @@ static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
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)
{
Ecore_Evas *ee;
Ecore_Evas_SDL_Switch_Data *swd;
Ecore_Evas *ee;
Eina_Bool gl = EINA_FALSE;
if (ecore_evas_sdl_count > 0) return NULL;
if (!name)
name = ecore_evas_sdl_default;
ee = calloc(1, sizeof(Ecore_Evas));
if (!ecore_sdl_init(name)) return NULL;
if (SDL_VideoInit(NULL) != 0)
{
ERR("SDL Video initialization failed !");
return NULL;
}
ee = calloc(1, sizeof(Ecore_Evas) + sizeof (Ecore_Evas_SDL_Switch_Data));
if (!ee) return NULL;
swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_sdl_engine_func;
@ -522,41 +582,51 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fu
evas_output_size_set(ee->evas, w, h);
evas_output_viewport_set(ee->evas, 0, 0, w, h);
if (rmethod == evas_render_method_lookup("buffer"))
gl = !(rmethod == evas_render_method_lookup("buffer"));
swd->w = SDL_CreateWindow(name,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
w, h,
SDL_WINDOW_RESIZABLE | (gl ? SDL_WINDOW_OPENGL : 0));
if (!swd->w)
{
ERR("SDL_CreateWindow failed.");
goto on_error;
}
if (!gl)
{
Evas_Engine_Info_Buffer *einfo;
einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
if (einfo)
{
SDL_Init(SDL_INIT_NOPARACHUTE);
void *pixels;
int pitch;
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
swd->r = SDL_CreateRenderer(swd->w, -1, 0);
if (!swd->r)
{
ERR("SDL_Init failed with %s", SDL_GetError());
SDL_Quit();
return NULL;
ERR("SDL_CreateRenderer failed.");
goto on_error;
}
swd->pages[0] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
swd->pages[1] = SDL_CreateTexture(swd->r, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
einfo->info.switch_data = SDL_SetVideoMode(w, h, 32,
(hwsurface ? SDL_HWSURFACE : SDL_SWSURFACE)
| (fullscreen ? SDL_FULLSCREEN : 0)
| (noframe ? SDL_NOFRAME : 0)
| (alpha ? SDL_SRCALPHA : 0)
| SDL_DOUBLEBUF);
if (!einfo->info.switch_data)
einfo->info.switch_data = swd;
SDL_RenderClear(swd->r);
if (SDL_LockTexture(swd->pages[0], NULL, &pixels, &pitch) < 0)
{
ERR("SDL_SetVideoMode failed !");
ecore_evas_free(ee);
return NULL;
ERR("SDL_LockTexture failed.");
goto on_error;
}
SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0);
SDL_FillRect(einfo->info.switch_data, NULL, 0);
einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels;
einfo->info.dest_buffer_row_bytes = w * sizeof (int);
einfo->info.dest_buffer = pixels;
einfo->info.dest_buffer_row_bytes = pitch;
einfo->info.use_color_key = 0;
einfo->info.alpha_threshold = 0;
einfo->info.func.new_update_region = NULL;
@ -576,8 +646,9 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fu
return NULL;
}
}
else if (rmethod == evas_render_method_lookup("gl_sdl"))
else
{
/* FIXME */
#ifdef BUILD_ECORE_EVAS_OPENGL_SDL
Evas_Engine_Info_GL_SDL *einfo;
@ -586,6 +657,7 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fu
{
einfo->flags.fullscreen = fullscreen;
einfo->flags.noframe = noframe;
einfo->window = swd->w;
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
{
ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
@ -601,42 +673,32 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fu
}
#endif
}
else
{
ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
ecore_evas_free(ee);
return NULL;
}
if (!ecore_sdl_init(name))
{
evas_free(ee->evas);
if (ee->name) free(ee->name);
free(ee);
return NULL;
}
_ecore_evas_sdl_init(w, h);
ecore_event_window_register(0, ee, ee->evas,
ecore_event_window_register(SDL_GetWindowID(swd->w), ee, ee->evas,
(Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
(Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
(Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
(Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
SDL_SetWindowData(swd->w, "_Ecore_Evas", ee);
SDL_ShowCursor(SDL_ENABLE);
ee->engine.func->fn_render = _ecore_evas_sdl_render;
_ecore_evas_register(ee);
sdl_ee = ee;
ecore_evas_sdl_count++;
return ee;
on_error:
ecore_evas_free(ee);
return NULL;
}
EAPI Ecore_Evas *
ecore_evas_sdl_new_internal(const char* name, int w, int h, int fullscreen,
int hwsurface, int noframe, int alpha)
int hwsurface, int noframe, int alpha)
{
Ecore_Evas *ee;
int rmethod;
@ -670,4 +732,3 @@ ecore_evas_gl_sdl_new_internal(const char* name, int w, int h, int fullscreen, i
return ee;
}
#endif

View File

@ -11,14 +11,13 @@ struct _Evas_Engine_Info_GL_SDL
/* at you and make nasty noises */
Evas_Engine_Info magic;
SDL_Window *window;
/* engine specific data & parameters it needs to set up */
struct {
int rotation;
int fullscreen : 1;
int noframe : 1;
} flags;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -4,17 +4,16 @@
#define _EVAS_ENGINE_SDL_H
#include "config.h"
#include <SDL/SDL.h>
#include <SDL2/SDL.h>
#ifdef GL_GLES
# include <EGL/egl.h>
# include <SDL/SDL_opengles.h>
# include <SDL2/SDL_opengles.h>
# ifdef HAVE_SDL_FLAG_OPENGLES
# define EVAS_SDL_GL_FLAG SDL_OPENGLES
# else
# define EVAS_SDL_GL_FLAG SDL_OPENGL /* This probably won't work? */
# endif
#else
# include <SDL/SDL_opengl.h>
# include <SDL2/SDL_opengl.h>
# define EVAS_SDL_GL_FLAG SDL_OPENGL
#endif
#include "evas_common_private.h"
@ -23,6 +22,8 @@
#include "Evas.h"
#include "Evas_Engine_GL_SDL.h"
#include "../gl_generic/Evas_Engine_GL_Generic.h"
extern int _evas_engine_GL_SDL_log_dom ;
#ifdef ERR
# undef ERR
@ -50,10 +51,12 @@ extern int _evas_engine_GL_SDL_log_dom ;
#define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_GL_SDL_log_dom, __VA_ARGS__)
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
struct _Outbuf
{
Evas_Engine_Info_GL_SDL *info;
int w, h;
Evas_Engine_Info_GL_SDL *info;
SDL_Window *window;
SDL_GLContext *context;
Evas_Engine_GL_Context *gl_context;
struct {
@ -68,6 +71,12 @@ struct _Render_Engine
EGLDisplay egl_disp;
#endif
int w, h;
};
struct _Render_Engine
{
Render_Engine_GL_Generic generic;
};
#endif