From 96dbf2150c8d9f1adff79329ebb2fcd507e6e115 Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Mon, 3 Jul 2017 16:53:15 +0900 Subject: [PATCH] [SDL_Tizen] Move prerotation data to SDL_VideoData SDL_WindowData->SDL_VideoData Change-Id: I31a255a11a6d1e4e441af4fcae985fe12b8ac338 Signed-off-by: huiyu.eun --- src/video/tizen/SDL_tizenmouse.c | 2 +- src/video/tizen/SDL_tizenvideo.h | 11 +++++++ src/video/tizen/SDL_tizenwindow.c | 62 +++++++++++++++++++++------------------ src/video/tizen/SDL_tizenwindow.h | 20 ++++--------- 4 files changed, 52 insertions(+), 43 deletions(-) diff --git a/src/video/tizen/SDL_tizenmouse.c b/src/video/tizen/SDL_tizenmouse.c index f9cb8d8..21c416d 100755 --- a/src/video/tizen/SDL_tizenmouse.c +++ b/src/video/tizen/SDL_tizenmouse.c @@ -248,7 +248,7 @@ Tizen_FiniMouse(void) void _tizen_get_mouseXY(SDL_Window* window, int x, int y, int* retX, int* retY) { SDL_WindowData *wind = window->driverdata; - if(!wind->support_pre_rotation || wind->rotation==0) + if((wind->output_rotation + wind->rotation) % 360 == 0) { *retX = x; *retY = y; diff --git a/src/video/tizen/SDL_tizenvideo.h b/src/video/tizen/SDL_tizenvideo.h index aeb0491..b9c37ad 100755 --- a/src/video/tizen/SDL_tizenvideo.h +++ b/src/video/tizen/SDL_tizenvideo.h @@ -29,10 +29,21 @@ #include #include +#include + +typedef struct Tizen_PreRotation_Data{ + void *prerotation_dll_handle; + int (*wl_egl_window_get_capabilities) (struct wl_egl_window *egl_window); + void (*wl_egl_window_set_rotation) (struct wl_egl_window *egl_window, int rotation); +} Tizen_Prerotation_Data; typedef struct { struct wl_display *display; Eina_Hash *windows; + Tizen_Prerotation_Data tizen_pre_rotation_data; + + SDL_bool indicator_on; + } SDL_VideoData; /* Initialization/Query functions */ diff --git a/src/video/tizen/SDL_tizenwindow.c b/src/video/tizen/SDL_tizenwindow.c index 6764bcd..d259673 100755 --- a/src/video/tizen/SDL_tizenwindow.c +++ b/src/video/tizen/SDL_tizenwindow.c @@ -55,8 +55,8 @@ enum { }; #define LOAD_FUNC(NAME) \ -_this->tizen_pre_rotation_data->NAME = SDL_LoadFunction(_this->tizen_pre_rotation_data->prerotation_dll_handle, #NAME); \ -if (!_this->tizen_pre_rotation_data->NAME) \ +_this->tizen_pre_rotation_data.NAME = SDL_LoadFunction(_this->tizen_pre_rotation_data.prerotation_dll_handle, #NAME); \ +if (!_this->tizen_pre_rotation_data.NAME) \ { \ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Could not retrieve pre-rotation function " #NAME); \ return SDL_FALSE; \ @@ -70,7 +70,7 @@ Ecore_Ipc_Server *ipc = NULL; if (ecore_ipc_client_server_get(e->client) != ipc) \ return ECORE_CALLBACK_PASS_ON -void SDL_ExecuteIndicatorProcess() +void Tizen_ExecuteIndicatorProcess() { _tizen_init_ecore_ipc(); unsigned int childPID = fork(); @@ -78,13 +78,13 @@ void SDL_ExecuteIndicatorProcess() { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] child process : %d", getpid()); int ret = execl("/usr/apps/org.tizen.sdl_indicator/bin/sdl_indicator", "/usr/apps/org.tizen.sdl_indicator/bin/sdl_indicator", NULL); - if(ret==-1) + if(ret == -1) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] Failed indicator process error:%s", strerror(errno)); kill(getpid(), SIGKILL); } } - else if(childPID==-1) + else if(childPID == -1) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] Failed fork"); } @@ -108,9 +108,12 @@ static Eina_Bool _cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, vo IPC_HEAD(Add); SDL_Log("[SDL]_cb_client_add"); + + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + videoData->indicator_on = SDL_TRUE; + SDL_Window * window = SDL_GetVideoDevice()->windows; SDL_WindowData *wind = window->driverdata; - wind->indicator = SDL_TRUE; int window_w, window_h; ecore_wl_screen_size_get(&window_w, &window_h); @@ -131,9 +134,9 @@ static Eina_Bool _cb_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, vo ecore_ipc_client_del(cl); } - SDL_Window * window = SDL_GetVideoDevice()->windows; - SDL_WindowData *wind = window->driverdata; - wind->indicator = SDL_FALSE; + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + videoData->indicator_on = SDL_FALSE; + return ECORE_CALLBACK_DONE; } @@ -191,18 +194,19 @@ _tizen_rotation_type_get() } int -_tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path) +_tizen_PreRotatotion_LoadLibrary(SDL_VideoData *_this, const char *lib_path) { void *lib_dll_handle = NULL; char *path = NULL; - if (_this->isLoaded_pre_rotation) + if (_this->tizen_pre_rotation_data.prerotation_dll_handle + && _this->tizen_pre_rotation_data.wl_egl_window_set_rotation + && _this->tizen_pre_rotation_data.wl_egl_window_get_capabilities) return SDL_TRUE; - _this->tizen_pre_rotation_data = (Tizen_Prerotation_Data *) SDL_calloc(1, sizeof(Tizen_Prerotation_Data)); - if (!_this->tizen_pre_rotation_data) { - return SDL_OutOfMemory(); - } + _this->tizen_pre_rotation_data.prerotation_dll_handle = NULL; + _this->tizen_pre_rotation_data.wl_egl_window_set_rotation = NULL; + _this->tizen_pre_rotation_data.wl_egl_window_get_capabilities = NULL; if (!lib_path) lib_dll_handle = SDL_LoadObject(lib_path); @@ -212,14 +216,13 @@ _tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path) lib_dll_handle = SDL_LoadObject(path); } - _this->tizen_pre_rotation_data->prerotation_dll_handle = lib_dll_handle; + _this->tizen_pre_rotation_data.prerotation_dll_handle = lib_dll_handle; if (lib_dll_handle == NULL) return SDL_FALSE; LOAD_FUNC(wl_egl_window_set_rotation); LOAD_FUNC(wl_egl_window_get_capabilities); - _this->isLoaded_pre_rotation = 1; return SDL_TRUE; } @@ -257,12 +260,14 @@ Tizen_SetWindowTitle(_THIS, SDL_Window * window) void Tizen_ShowWindow(_THIS, SDL_Window *window) { - SDL_WindowData *wind = window->driverdata; + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; - if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && !wind->indicator) + if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && !videoData->indicator_on) { - SDL_ExecuteIndicatorProcess(); + Tizen_ExecuteIndicatorProcess(); } + + SDL_WindowData *wind = window->driverdata; ecore_wl_window_show(wind->window); } @@ -288,10 +293,10 @@ Tizen_SetWindowFullscreen(_THIS, SDL_Window *window, } void -Tizen_pre_rotation_set(SDL_WindowData *_this, int rotation) +Tizen_pre_rotation_set(SDL_WindowData *wind, int rotation) { tizen_wl_egl_window_rotation rot; - if (!_this->egl_window) return; + if (!wind->egl_window) return; switch (rotation) { case 90: @@ -311,7 +316,8 @@ Tizen_pre_rotation_set(SDL_WindowData *_this, int rotation) break; } - _this->tizen_pre_rotation_data->wl_egl_window_set_rotation(_this->egl_window, rot); + SDL_VideoData* _this = SDL_GetVideoDevice()->driverdata; + _this->tizen_pre_rotation_data.wl_egl_window_set_rotation(wind->egl_window, rot); } void @@ -643,8 +649,8 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) //Support PreRotation wind->support_pre_rotation = 0; - if (_tizen_rotation_type_get() && _tizen_PreRotatotion_LoadLibrary(wind, "libwayland-egl.so")) { - if (wind->tizen_pre_rotation_data->wl_egl_window_get_capabilities(wind->egl_window) == TIZEN_WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { + if (_tizen_rotation_type_get() && _tizen_PreRotatotion_LoadLibrary(data, "libwayland-egl.so")) { + if (data->tizen_pre_rotation_data.wl_egl_window_get_capabilities(wind->egl_window) == TIZEN_WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { wind->support_pre_rotation = 1; } } @@ -684,9 +690,9 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) void Tizen_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) { - SDL_WindowData *wind = window->driverdata; - if(!wind->indicator) - SDL_ExecuteIndicatorProcess(); + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + if(!videoData->indicator_on) + Tizen_ExecuteIndicatorProcess(); } void diff --git a/src/video/tizen/SDL_tizenwindow.h b/src/video/tizen/SDL_tizenwindow.h index 680536b..0193e3a 100755 --- a/src/video/tizen/SDL_tizenwindow.h +++ b/src/video/tizen/SDL_tizenwindow.h @@ -32,28 +32,20 @@ #include #include -typedef struct Tizen_PreRotation_Data{ - void *prerotation_dll_handle; - int (*wl_egl_window_get_capabilities) (struct wl_egl_window *egl_window); - void (*wl_egl_window_set_rotation) (struct wl_egl_window *egl_window, int rotation); -} Tizen_Prerotation_Data; - typedef struct { - uint32_t id; + uint32_t id; /* Ecore wayland window id */ + Ecore_Wl_Window *window; struct wl_surface *surface; struct wl_egl_window *egl_window; - EGLSurface egl_surface; + int rotation; + int output_rotation; int rotation_supported; int received_rotation; - int output_rotation; - SDL_bool indicator; - int support_pre_rotation; - SDL_bool isLoaded_pre_rotation; - Tizen_Prerotation_Data * tizen_pre_rotation_data; + SDL_bool support_pre_rotation; } SDL_WindowData; @@ -108,7 +100,7 @@ enum OP_TERMINATE }; -extern void SDL_ExecuteIndicatorProcess(); +extern void Tizen_ExecuteIndicatorProcess(); #endif /* _SDL_tizenwindow_h */ -- 2.7.4