2009-01-31 10:33:39 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2009-01-31 10:56:17 -08:00
|
|
|
# include <config.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
#endif
|
|
|
|
|
2013-03-11 13:11:44 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2012-12-05 13:15:42 -08:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
#include <SDL2/SDL.h>
|
2012-12-05 13:15:42 -08:00
|
|
|
|
2009-04-14 13:04:16 -07:00
|
|
|
#include <Ecore.h>
|
2013-03-11 13:11:44 -07:00
|
|
|
#include "ecore_private.h"
|
2009-04-14 13:04:16 -07:00
|
|
|
#include <Ecore_Input.h>
|
2010-01-07 11:26:52 -08:00
|
|
|
#include <Ecore_Input_Evas.h>
|
2012-12-05 13:15:42 -08:00
|
|
|
#include <Ecore_Sdl.h>
|
2013-01-16 11:47:03 -08:00
|
|
|
#include <Evas_Engine_Buffer.h>
|
2012-12-05 13:15:42 -08:00
|
|
|
#ifdef BUILD_ECORE_EVAS_OPENGL_SDL
|
2013-03-11 13:11:44 -07:00
|
|
|
# include <Evas_Engine_GL_SDL.h>
|
2007-07-16 00:23:11 -07:00
|
|
|
#endif
|
|
|
|
|
2013-03-11 13:11:44 -07:00
|
|
|
#include <Ecore_Evas.h>
|
|
|
|
#include "ecore_evas_private.h"
|
2015-04-28 05:24:48 -07:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
# ifndef EFL_MODULE_STATIC
|
|
|
|
# define EMODAPI __declspec(dllexport)
|
2015-04-28 05:24:48 -07:00
|
|
|
# else
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
# define EMODAPI
|
|
|
|
# endif
|
2015-04-28 05:24:48 -07:00
|
|
|
#else
|
|
|
|
# ifdef __GNUC__
|
|
|
|
# if __GNUC__ >= 4
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
# define EMODAPI __attribute__ ((visibility("default")))
|
2015-04-28 05:24:48 -07:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif /* ! _WIN32 */
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
|
|
|
|
#ifndef EMODAPI
|
|
|
|
# define EMODAPI
|
|
|
|
#endif
|
|
|
|
|
2012-04-23 13:09:48 -07:00
|
|
|
/*
|
|
|
|
* SDL only handle one window at a time. That's by definition, there is nothing wrong here.
|
|
|
|
*
|
|
|
|
*/
|
2007-07-16 00:23:11 -07:00
|
|
|
|
|
|
|
/* static char *ecore_evas_default_display = "0"; */
|
|
|
|
/* static Ecore_List *ecore_evas_input_devices = NULL; */
|
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2007-07-16 00:23:11 -07:00
|
|
|
static int _ecore_evas_init_count = 0;
|
2010-01-06 21:29:06 -08:00
|
|
|
|
2009-03-16 09:24:43 -07:00
|
|
|
static Ecore_Event_Handler *ecore_evas_event_handlers[4] = {
|
|
|
|
NULL, NULL, NULL, NULL
|
2007-07-16 00:23:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *ecore_evas_sdl_default = "EFL SDL";
|
2010-01-09 11:38:34 -08:00
|
|
|
static Ecore_Poller *ecore_evas_event;
|
2014-02-18 00:52:16 -08:00
|
|
|
static int _ecore_evas_fps_debug = 0;
|
|
|
|
static int ecore_evas_sdl_count = 0;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
|
|
|
static Ecore_Evas *
|
2014-07-25 11:23:42 -07:00
|
|
|
_ecore_evas_sdl_match(unsigned int windowID)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
return SDL_GetWindowData(SDL_GetWindowFromID(windowID), "_Ecore_Evas");
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
2012-02-23 07:39:18 -08:00
|
|
|
static void *
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_evas_sdl_switch_buffer(void *data, void *dest EINA_UNUSED)
|
2012-02-23 07:39:18 -08:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
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;
|
2012-02-23 07:39:18 -08:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2014-07-25 11:23:42 -07:00
|
|
|
_ecore_evas_sdl_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
Ecore_Sdl_Event_Window *ev = event;
|
|
|
|
Ecore_Evas *ee;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
ee = _ecore_evas_sdl_match(ev->windowID);
|
2007-07-16 00:23:11 -07:00
|
|
|
/* pass on event */
|
2016-11-03 07:07:40 -07:00
|
|
|
if (!ee) return ECORE_CALLBACK_PASS_ON;
|
|
|
|
_ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
|
2011-11-21 21:51:06 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_evas_sdl_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
Ecore_Sdl_Event_Window *ev = event;
|
|
|
|
Ecore_Evas *ee;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
ee = _ecore_evas_sdl_match(ev->windowID);
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
if (!ee) return ECORE_CALLBACK_PASS_ON;
|
2007-07-16 00:23:11 -07:00
|
|
|
/* pass on event */
|
2016-11-03 07:07:40 -07:00
|
|
|
_ecore_evas_focus_device_set(ee, NULL, EINA_FALSE);
|
2011-11-21 21:51:06 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_evas_sdl_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
|
|
|
Ecore_Sdl_Event_Video_Resize *e;
|
2014-07-25 11:23:42 -07:00
|
|
|
Ecore_Evas *ee;
|
|
|
|
int rmethod;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
|
|
|
e = event;
|
2014-07-25 11:23:42 -07:00
|
|
|
ee = _ecore_evas_sdl_match(e->windowID);
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
if (!ee) return ECORE_CALLBACK_PASS_ON; /* pass on event */
|
2012-02-23 07:39:18 -08:00
|
|
|
|
|
|
|
rmethod = evas_output_method_get(ee->evas);
|
|
|
|
if (rmethod == evas_render_method_lookup("buffer"))
|
|
|
|
{
|
|
|
|
Evas_Engine_Info_Buffer *einfo;
|
|
|
|
|
|
|
|
einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
|
|
|
|
if (einfo)
|
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
Ecore_Evas_SDL_Switch_Data *swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
|
|
|
|
void *pixels;
|
|
|
|
int pitch;
|
|
|
|
|
|
|
|
SDL_UnlockTexture(swd->pages[swd->current]);
|
2012-02-23 07:39:18 -08:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
SDL_DestroyTexture(swd->pages[0]);
|
|
|
|
SDL_DestroyTexture(swd->pages[1]);
|
2012-02-23 07:39:18 -08:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
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 = swd;
|
|
|
|
einfo->info.dest_buffer = pixels;
|
|
|
|
einfo->info.dest_buffer_row_bytes = pitch;
|
2012-02-23 07:39:18 -08:00
|
|
|
einfo->info.use_color_key = 0;
|
|
|
|
einfo->info.alpha_threshold = 0;
|
|
|
|
einfo->info.func.new_update_region = NULL;
|
|
|
|
einfo->info.func.free_update_region = NULL;
|
|
|
|
einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer;
|
|
|
|
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo))
|
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ee->w = e->w;
|
|
|
|
ee->h = e->h;
|
2012-11-26 22:39:46 -08:00
|
|
|
ee->req.w = e->w;
|
|
|
|
ee->req.h = e->h;
|
2012-02-23 07:39:18 -08:00
|
|
|
|
2007-07-16 00:23:11 -07:00
|
|
|
evas_output_size_set(ee->evas, e->w, e->h);
|
2012-02-23 07:39:18 -08:00
|
|
|
evas_output_viewport_set(ee->evas, 0, 0, e->w, e->h);
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2011-11-21 21:51:06 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2014-07-25 11:23:42 -07:00
|
|
|
_ecore_evas_sdl_event_video_expose(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
Ecore_Sdl_Event_Window *ev = event;
|
|
|
|
Ecore_Evas *ee;
|
|
|
|
int w;
|
|
|
|
int h;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
ee = _ecore_evas_sdl_match(ev->windowID);
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
if (!ee) return ECORE_CALLBACK_PASS_ON;
|
2007-07-16 00:23:11 -07:00
|
|
|
evas_output_size_get(ee->evas, &w, &h);
|
|
|
|
evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
|
|
|
|
|
2011-11-21 21:51:06 -08:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:15:56 -07:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_evas_sdl_event(void *data EINA_UNUSED)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
|
|
|
ecore_sdl_feed_events();
|
2010-06-24 09:15:56 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_evas_sdl_init(int w EINA_UNUSED, int h EINA_UNUSED)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
|
|
|
_ecore_evas_init_count++;
|
|
|
|
if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
|
|
|
|
|
2007-08-26 04:17:21 -07:00
|
|
|
#ifndef _WIN32
|
2007-07-16 00:23:11 -07:00
|
|
|
if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
|
2007-08-26 04:17:21 -07:00
|
|
|
#endif /* _WIN32 */
|
2011-04-20 07:15:33 -07:00
|
|
|
// this is pretty bad: poller? and set poll time? pol time is meant to be
|
2010-01-06 21:29:06 -08:00
|
|
|
// adjustable for things like polling battery state, or amoutn of spare
|
|
|
|
// memory etc.
|
2011-04-20 07:15:33 -07:00
|
|
|
//
|
2009-03-16 09:24:43 -07:00
|
|
|
ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_sdl_event, NULL);
|
|
|
|
ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006);
|
2007-08-26 04:17:21 -07:00
|
|
|
#ifndef _WIN32
|
2007-07-16 00:23:11 -07:00
|
|
|
if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
|
2007-08-26 04:17:21 -07:00
|
|
|
#endif /* _WIN32 */
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2009-03-19 06:06:16 -07:00
|
|
|
ecore_event_evas_init();
|
2009-03-16 09:24:43 -07:00
|
|
|
|
|
|
|
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_SDL_EVENT_GOT_FOCUS, _ecore_evas_sdl_event_got_focus, NULL);
|
|
|
|
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_SDL_EVENT_LOST_FOCUS, _ecore_evas_sdl_event_lost_focus, NULL);
|
|
|
|
ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_SDL_EVENT_RESIZE, _ecore_evas_sdl_event_video_resize, NULL);
|
|
|
|
ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_SDL_EVENT_EXPOSE, _ecore_evas_sdl_event_video_expose, NULL);
|
2007-07-16 00:23:11 -07:00
|
|
|
|
|
|
|
return _ecore_evas_init_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_ecore_evas_sdl_shutdown(void)
|
|
|
|
{
|
|
|
|
_ecore_evas_init_count--;
|
|
|
|
if (_ecore_evas_init_count == 0)
|
|
|
|
{
|
2012-02-23 07:39:18 -08:00
|
|
|
unsigned int i;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++)
|
2010-09-29 10:03:38 -07:00
|
|
|
ecore_event_handler_del(ecore_evas_event_handlers[i]);
|
|
|
|
ecore_event_evas_shutdown();
|
2009-03-16 09:24:43 -07:00
|
|
|
ecore_poller_del(ecore_evas_event);
|
2007-07-16 00:23:11 -07:00
|
|
|
ecore_evas_event = NULL;
|
2007-08-26 04:17:21 -07:00
|
|
|
#ifndef _WIN32
|
2010-09-29 10:03:38 -07:00
|
|
|
if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
|
2007-08-26 04:17:21 -07:00
|
|
|
#endif /* _WIN32 */
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
|
|
|
|
return _ecore_evas_init_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_evas_sdl_free(Ecore_Evas *ee)
|
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
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);
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2007-07-16 00:23:11 -07:00
|
|
|
_ecore_evas_sdl_shutdown();
|
|
|
|
ecore_sdl_shutdown();
|
2014-02-18 00:52:16 -08:00
|
|
|
ecore_evas_sdl_count--;
|
2014-07-25 11:23:42 -07:00
|
|
|
|
|
|
|
SDL_VideoQuit();
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
|
|
|
|
{
|
2012-02-23 07:39:18 -08:00
|
|
|
int rmethod;
|
|
|
|
|
2007-07-16 00:23:11 -07:00
|
|
|
if ((w == ee->w) && (h == ee->h)) return;
|
2012-11-26 22:39:46 -08:00
|
|
|
ee->req.w = w;
|
|
|
|
ee->req.h = h;
|
2007-07-16 00:23:11 -07:00
|
|
|
ee->w = w;
|
|
|
|
ee->h = h;
|
|
|
|
|
2012-02-23 07:39:18 -08:00
|
|
|
rmethod = evas_output_method_get(ee->evas);
|
|
|
|
if (rmethod == evas_render_method_lookup("buffer"))
|
|
|
|
{
|
|
|
|
Evas_Engine_Info_Buffer *einfo;
|
|
|
|
|
|
|
|
einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
|
|
|
|
if (einfo)
|
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
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);
|
2012-02-23 07:39:18 -08:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
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);
|
2012-02-23 07:39:18 -08:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
SDL_LockTexture(swd->pages[swd->current], NULL, &pixels, &pitch);
|
|
|
|
|
|
|
|
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
|
|
|
|
einfo->info.switch_data = swd;
|
|
|
|
einfo->info.dest_buffer = pixels;
|
|
|
|
einfo->info.dest_buffer_row_bytes = pitch;
|
2012-02-23 07:39:18 -08:00
|
|
|
einfo->info.use_color_key = 0;
|
|
|
|
einfo->info.alpha_threshold = 0;
|
|
|
|
einfo->info.func.new_update_region = NULL;
|
|
|
|
einfo->info.func.free_update_region = NULL;
|
|
|
|
einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer;
|
|
|
|
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo))
|
|
|
|
{
|
2013-06-20 04:28:18 -07:00
|
|
|
return;
|
2012-02-23 07:39:18 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-16 00:23:11 -07:00
|
|
|
evas_output_size_set(ee->evas, ee->w, ee->h);
|
|
|
|
evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
|
|
|
|
evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
|
|
|
|
|
|
|
|
if (ee->func.fn_resize) ee->func.fn_resize(ee);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-18 00:52:16 -08:00
|
|
|
_ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
2014-02-18 00:52:16 -08:00
|
|
|
if ((ee->x != x) || (ee->y != y))
|
|
|
|
{
|
|
|
|
ee->req.x = x;
|
|
|
|
ee->req.y = y;
|
|
|
|
ee->x = x;
|
|
|
|
ee->y = y;
|
|
|
|
if (ee->func.fn_move) ee->func.fn_move(ee);
|
|
|
|
}
|
|
|
|
_ecore_evas_resize(ee, w, h);
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
|
|
|
|
2011-11-21 21:51:06 -08:00
|
|
|
static void
|
|
|
|
_ecore_evas_show(Ecore_Evas *ee)
|
|
|
|
{
|
2014-10-29 03:33:16 -07:00
|
|
|
ee->prop.withdrawn = EINA_FALSE;
|
|
|
|
if (ee->func.fn_state_change) ee->func.fn_state_change(ee);
|
2016-11-03 07:07:40 -07:00
|
|
|
if (ecore_evas_focus_device_get(ee, NULL)) return;
|
|
|
|
_ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
|
2011-11-21 21:51:06 -08:00
|
|
|
evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
|
|
|
|
}
|
|
|
|
|
2010-01-06 21:29:06 -08:00
|
|
|
static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
|
|
|
_ecore_evas_sdl_free,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
_ecore_evas_resize,
|
|
|
|
_ecore_evas_move_resize,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-11-21 21:51:06 -08:00
|
|
|
_ecore_evas_show,
|
2007-07-16 00:23:11 -07:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-06-30 01:39:36 -07:00
|
|
|
NULL,
|
2016-11-22 10:14:03 -08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2007-07-16 00:23:11 -07:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2007-11-19 10:27:11 -08:00
|
|
|
NULL,
|
2008-12-22 03:16:26 -08:00
|
|
|
NULL,
|
2010-01-06 21:29:06 -08:00
|
|
|
NULL,
|
2010-02-11 21:31:26 -08:00
|
|
|
NULL, //transparent
|
2012-07-03 00:44:17 -07:00
|
|
|
NULL, // profiles_set
|
2012-12-04 22:48:46 -08:00
|
|
|
NULL, // profile_set
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2012-02-27 22:43:59 -08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
|
2011-05-27 12:31:11 -07:00
|
|
|
NULL, // render
|
2012-07-05 05:51:05 -07:00
|
|
|
NULL, // screen_geometry_get
|
2013-02-15 01:32:40 -08:00
|
|
|
NULL, // screen_dpi_get
|
|
|
|
NULL,
|
2014-02-08 16:46:51 -08:00
|
|
|
NULL, // msg_send
|
|
|
|
|
|
|
|
NULL, // pointer_xy_get
|
|
|
|
NULL, // pointer_warp
|
|
|
|
|
|
|
|
NULL, // wm_rot_preferred_rotation_set
|
|
|
|
NULL, // wm_rot_available_rotations_set
|
|
|
|
NULL, // wm_rot_manual_rotation_done_set
|
2014-02-27 14:20:01 -08:00
|
|
|
NULL, // wm_rot_manual_rotation_done
|
|
|
|
|
2016-01-25 15:18:28 -08:00
|
|
|
NULL, // aux_hints_set
|
|
|
|
|
|
|
|
NULL, // fn_animator_register
|
2016-08-30 13:47:17 -07:00
|
|
|
NULL, // fn_animator_unregister
|
|
|
|
|
|
|
|
NULL, // fn_evas_changed
|
2016-11-03 07:07:40 -07:00
|
|
|
NULL, //fn_focus_device_set
|
|
|
|
NULL, //fn_callback_focus_device_in_set
|
|
|
|
NULL, //fn_callback_focus_device_out_set
|
2016-11-09 11:54:55 -08:00
|
|
|
NULL, //fn_callback_device_mouse_in_set
|
|
|
|
NULL, //fn_callback_device_mouse_out_set
|
2016-11-21 09:11:08 -08:00
|
|
|
NULL, //fn_pointer_device_xy_get
|
2017-07-12 14:24:09 -07:00
|
|
|
NULL, //fn_prepare
|
2017-07-12 14:29:17 -07:00
|
|
|
NULL, //fn_last_tick_get
|
2020-01-05 06:05:36 -08:00
|
|
|
NULL, //fn_selection_claim
|
|
|
|
NULL, //fn_selection_has_owner
|
|
|
|
NULL, //fn_selection_request
|
2007-07-16 00:23:11 -07:00
|
|
|
};
|
|
|
|
|
2008-09-11 06:26:40 -07:00
|
|
|
static Ecore_Evas*
|
2023-12-06 07:03:11 -08:00
|
|
|
_ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fullscreen, int hwsurface, int noframe EINA_UNUSED, int alpha)
|
2007-07-16 00:23:11 -07:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
Ecore_Evas_SDL_Switch_Data *swd;
|
|
|
|
Ecore_Evas *ee;
|
|
|
|
Eina_Bool gl = EINA_FALSE;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2014-02-18 00:52:16 -08:00
|
|
|
if (ecore_evas_sdl_count > 0) return NULL;
|
2007-07-16 00:23:11 -07:00
|
|
|
if (!name)
|
|
|
|
name = ecore_evas_sdl_default;
|
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
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));
|
2007-07-16 00:23:11 -07:00
|
|
|
if (!ee) return NULL;
|
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
swd = (Ecore_Evas_SDL_Switch_Data*)(ee + 1);
|
|
|
|
|
2007-07-16 00:23:11 -07:00
|
|
|
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
|
|
|
|
|
|
|
|
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_sdl_engine_func;
|
|
|
|
|
|
|
|
ee->driver = "sdl";
|
|
|
|
if (name) ee->name = strdup(name);
|
|
|
|
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
ee->visible = 1;
|
2012-11-26 22:39:46 -08:00
|
|
|
ee->req.w = w;
|
|
|
|
ee->req.h = h;
|
2007-07-16 00:23:11 -07:00
|
|
|
ee->w = w;
|
|
|
|
ee->h = h;
|
|
|
|
|
|
|
|
ee->prop.max.w = 0;
|
|
|
|
ee->prop.max.h = 0;
|
|
|
|
ee->prop.layer = 0;
|
2014-01-12 21:26:36 -08:00
|
|
|
ee->prop.borderless = EINA_TRUE;
|
|
|
|
ee->prop.override = EINA_TRUE;
|
|
|
|
ee->prop.maximized = EINA_TRUE;
|
2007-07-16 00:23:11 -07:00
|
|
|
ee->prop.fullscreen = fullscreen;
|
2014-10-29 03:33:16 -07:00
|
|
|
ee->prop.withdrawn = EINA_TRUE;
|
2014-01-12 21:26:36 -08:00
|
|
|
ee->prop.sticky = EINA_FALSE;
|
2009-03-16 09:24:43 -07:00
|
|
|
ee->prop.window = 0;
|
2012-02-23 07:39:18 -08:00
|
|
|
ee->alpha = alpha;
|
|
|
|
ee->prop.hwsurface = hwsurface;
|
2007-07-16 00:23:11 -07:00
|
|
|
|
|
|
|
/* init evas here */
|
2018-04-02 14:55:57 -07:00
|
|
|
if (!ecore_evas_evas_new(ee, w, h))
|
|
|
|
{
|
|
|
|
ERR("Can not create Canvas.");
|
|
|
|
goto on_error;
|
|
|
|
}
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2018-04-02 14:55:57 -07:00
|
|
|
evas_output_method_set(ee->evas, rmethod);
|
2007-07-16 00:23:11 -07:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
gl = !(rmethod == evas_render_method_lookup("buffer"));
|
2017-05-08 15:03:31 -07:00
|
|
|
ee->can_async_render = gl ? EINA_FALSE : EINA_TRUE;
|
2014-07-25 11:23:42 -07:00
|
|
|
|
|
|
|
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)
|
2012-02-23 07:39:18 -08:00
|
|
|
{
|
|
|
|
Evas_Engine_Info_Buffer *einfo;
|
|
|
|
|
|
|
|
einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(ee->evas);
|
|
|
|
if (einfo)
|
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
void *pixels;
|
|
|
|
int pitch;
|
2012-02-23 07:39:18 -08:00
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
swd->r = SDL_CreateRenderer(swd->w, -1, 0);
|
|
|
|
if (!swd->r)
|
2012-02-23 07:39:18 -08:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
ERR("SDL_CreateRenderer failed.");
|
|
|
|
goto on_error;
|
2012-02-23 07:39:18 -08:00
|
|
|
}
|
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
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);
|
|
|
|
|
2012-02-23 07:39:18 -08:00
|
|
|
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
|
2014-07-25 11:23:42 -07:00
|
|
|
einfo->info.switch_data = swd;
|
|
|
|
|
|
|
|
SDL_RenderClear(swd->r);
|
|
|
|
if (SDL_LockTexture(swd->pages[0], NULL, &pixels, &pitch) < 0)
|
2012-02-23 07:39:18 -08:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
ERR("SDL_LockTexture failed.");
|
|
|
|
goto on_error;
|
2012-02-23 07:39:18 -08:00
|
|
|
}
|
|
|
|
|
2014-07-25 11:23:42 -07:00
|
|
|
einfo->info.dest_buffer = pixels;
|
|
|
|
einfo->info.dest_buffer_row_bytes = pitch;
|
2012-02-23 07:39:18 -08:00
|
|
|
einfo->info.use_color_key = 0;
|
|
|
|
einfo->info.alpha_threshold = 0;
|
|
|
|
einfo->info.func.new_update_region = NULL;
|
|
|
|
einfo->info.func.free_update_region = NULL;
|
|
|
|
einfo->info.func.switch_buffer = _ecore_evas_sdl_switch_buffer;
|
|
|
|
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *) einfo))
|
|
|
|
{
|
|
|
|
ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
|
|
|
|
ecore_evas_free(ee);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
|
|
|
|
ecore_evas_free(ee);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2014-07-25 11:23:42 -07:00
|
|
|
else
|
2010-01-30 02:23:54 -08:00
|
|
|
{
|
2014-07-25 11:23:42 -07:00
|
|
|
/* FIXME */
|
2010-01-30 02:23:54 -08:00
|
|
|
#ifdef BUILD_ECORE_EVAS_OPENGL_SDL
|
2012-02-23 07:39:18 -08:00
|
|
|
Evas_Engine_Info_GL_SDL *einfo;
|
|
|
|
|
|
|
|
einfo = (Evas_Engine_Info_GL_SDL *) evas_engine_info_get(ee->evas);
|
2010-09-29 10:03:38 -07:00
|
|
|
if (einfo)
|
|
|
|
{
|
2012-02-23 07:39:18 -08:00
|
|
|
einfo->flags.fullscreen = fullscreen;
|
|
|
|
einfo->flags.noframe = noframe;
|
2014-07-25 11:23:42 -07:00
|
|
|
einfo->window = swd->w;
|
2010-09-29 09:45:49 -07:00
|
|
|
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
|
|
|
|
{
|
|
|
|
ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
|
2011-07-28 23:20:55 -07:00
|
|
|
ecore_evas_free(ee);
|
|
|
|
return NULL;
|
2010-09-29 09:45:49 -07:00
|
|
|
}
|
2010-09-29 10:03:38 -07:00
|
|
|
}
|
2011-07-28 23:20:55 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
|
|
|
|
ecore_evas_free(ee);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-30 02:23:54 -08:00
|
|
|
#endif
|
2007-07-16 00:23:11 -07:00
|
|
|
}
|
2009-03-16 09:24:43 -07:00
|
|
|
|
2008-12-22 03:16:26 -08:00
|
|
|
_ecore_evas_sdl_init(w, h);
|
2018-04-02 14:55:57 -07:00
|
|
|
ee->prop.window = SDL_GetWindowID(swd->w);
|
2008-12-22 03:16:26 -08:00
|
|
|
|
2018-04-02 14:55:57 -07:00
|
|
|
ecore_evas_done(ee, EINA_FALSE);
|
2009-03-19 06:06:16 -07:00
|
|
|
|
2018-04-02 14:55:57 -07:00
|
|
|
SDL_SetWindowData(swd->w, "_Ecore_Evas", ee);
|
2012-02-23 07:39:18 -08:00
|
|
|
SDL_ShowCursor(SDL_ENABLE);
|
2008-09-11 06:26:40 -07:00
|
|
|
|
2016-11-03 07:07:40 -07:00
|
|
|
_ecore_evas_focus_device_set(ee, NULL, EINA_TRUE);
|
2014-02-18 00:52:16 -08:00
|
|
|
ecore_evas_sdl_count++;
|
2007-07-16 00:23:11 -07:00
|
|
|
return ee;
|
2014-07-25 11:23:42 -07:00
|
|
|
|
|
|
|
on_error:
|
|
|
|
ecore_evas_free(ee);
|
|
|
|
return NULL;
|
2008-09-11 06:26:40 -07:00
|
|
|
}
|
|
|
|
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
EMODAPI Ecore_Evas *
|
2012-12-05 13:15:42 -08:00
|
|
|
ecore_evas_sdl_new_internal(const char* name, int w, int h, int fullscreen,
|
2014-07-25 11:23:42 -07:00
|
|
|
int hwsurface, int noframe, int alpha)
|
2008-09-11 06:26:40 -07:00
|
|
|
{
|
2008-10-29 12:31:05 -07:00
|
|
|
Ecore_Evas *ee;
|
2008-09-11 06:26:40 -07:00
|
|
|
int rmethod;
|
|
|
|
|
2012-02-23 07:39:18 -08:00
|
|
|
rmethod = evas_render_method_lookup("buffer");
|
2008-09-11 06:26:40 -07:00
|
|
|
if (!rmethod) return NULL;
|
|
|
|
|
2008-10-29 12:31:05 -07:00
|
|
|
ee = _ecore_evas_internal_sdl_new(rmethod, name, w, h, fullscreen, hwsurface, noframe, alpha);
|
|
|
|
return ee;
|
2009-04-11 03:31:42 -07:00
|
|
|
}
|
2008-09-11 06:26:40 -07:00
|
|
|
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
EMODAPI Ecore_Evas*
|
2012-12-05 13:15:42 -08:00
|
|
|
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)
|
2009-04-11 03:31:42 -07:00
|
|
|
{
|
2017-08-17 07:45:35 -07:00
|
|
|
ERR("OUCH !");
|
2007-07-16 00:23:11 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-30 02:23:54 -08:00
|
|
|
|
|
|
|
#ifdef BUILD_ECORE_EVAS_OPENGL_SDL
|
modules: Rename EAPI macro to MODAPI for modules
Summary:
Patch from a series of patches to rename EAPI symbols to specific
library DSOs.
= The Rationale =
EAPI was designed to be able to pass
`__attribute__ ((visibility ("default")))` for symbols with
GCC, which would mean that even if -fvisibility=hidden was used
when compiling the library, the needed symbols would get exported.
MSVC __almost__ works like GCC (or mingw) in which you can
declare everything as export and it will just work (slower, but
it will work). But there's a caveat: global variables will not
work the same way for MSVC, but works for mingw and GCC.
For global variables (as opposed to functions), MSVC requires
correct DSO visibility for MSVC: instead of declaring a symbol as
export for everything, you need to declare it as import when
importing from another DSO and export when defining it locally.
With current EAPI definitions, we get the following example
working in mingw and MSVC (observe it doesn't define any global
variables as exported symbols).
Example 1:
dll1:
```
EAPI void foo(void);
EAPI void bar()
{
foo();
}
```
dll2:
```
EAPI void foo()
{
printf ("foo\n");
}
```
This works fine with API defined as __declspec(dllexport) in both
cases and for gcc defining as
`__atttribute__((visibility("default")))`.
However, the following:
Example 2:
dll1:
```
EAPI extern int foo;
EAPI void foobar(void);
EAPI void bar()
{
foo = 5;
foobar();
}
```
dll2:
```
EAPI int foo = 0;
EAPI void foobar()
{
printf ("foo %d\n", foo);
}
```
This will work on mingw but will not work for MSVC. And that's why
EAPI is the only solution that worked for MSVC.
Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>
Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev>
Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
Reviewers: vtorri, jptiz, woohyun, lucas, SPAM-smith78899
Reviewed By: vtorri, SPAM-smith78899
Subscribers: SPAM-smith78899, raster, SPAM-cabanacatalogs, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12228
2021-04-17 12:07:55 -07:00
|
|
|
EMODAPI Ecore_Evas *
|
2012-12-05 13:15:42 -08:00
|
|
|
ecore_evas_gl_sdl_new_internal(const char* name, int w, int h, int fullscreen, int noframe)
|
2010-01-30 02:23:54 -08:00
|
|
|
{
|
|
|
|
Ecore_Evas *ee;
|
|
|
|
int rmethod;
|
|
|
|
|
|
|
|
rmethod = evas_render_method_lookup("gl_sdl");
|
|
|
|
if (!rmethod) return NULL;
|
|
|
|
|
|
|
|
ee = _ecore_evas_internal_sdl_new(rmethod, name, w, h, fullscreen, 0, noframe, 0);
|
2012-07-06 01:16:03 -07:00
|
|
|
if (ee) ee->driver = "gl_sdl";
|
2010-01-30 02:23:54 -08:00
|
|
|
return ee;
|
|
|
|
}
|
|
|
|
#endif
|