From 82f18f23bb43214e37b65e4fa469f22ee98df2da Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Tue, 1 Aug 2017 14:31:36 +0900 Subject: [PATCH] [SDL_Tizen] Load rotation function from shared object - wl_egl_window_set_buffer_transform - wl_egl_window_set_window_transform Change-Id: Iddd7297c765d135304a619a9f66c65891ad3ccef Signed-off-by: huiyu.eun --- src/video/tizen/SDL_tizenvideo.h | 12 ++++--- src/video/tizen/SDL_tizenwindow.c | 73 +++++++++++++++------------------------ 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/src/video/tizen/SDL_tizenvideo.h b/src/video/tizen/SDL_tizenvideo.h index 699c168..45acdb6 100755 --- a/src/video/tizen/SDL_tizenvideo.h +++ b/src/video/tizen/SDL_tizenvideo.h @@ -31,16 +31,20 @@ #include #include -typedef struct Tizen_PreRotation_Data{ - void *prerotation_dll_handle; +typedef struct Tizen_Rotation_Data{ + void *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; + + void (*wl_egl_window_set_buffer_transform) (struct wl_egl_window *egl_window, int wl_output_transform); + void (*wl_egl_window_set_window_transform) (struct wl_egl_window *egl_window, int window_transform); + +} Tizen_Rotation_Data; typedef struct { struct wl_display *display; Eina_Hash *windows; - Tizen_Prerotation_Data tizen_pre_rotation_data; + Tizen_Rotation_Data tizen_rotation_data; int indicator_mode; int indicator_height; diff --git a/src/video/tizen/SDL_tizenwindow.c b/src/video/tizen/SDL_tizenwindow.c index 1ac2464..b6925b3 100755 --- a/src/video/tizen/SDL_tizenwindow.c +++ b/src/video/tizen/SDL_tizenwindow.c @@ -50,8 +50,8 @@ #include #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_rotation_data.NAME = SDL_LoadFunction(_this->tizen_rotation_data.dll_handle, #NAME); \ +if (!_this->tizen_rotation_data.NAME) \ { \ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Could not retrieve pre-rotation function " #NAME); \ return SDL_FALSE; \ @@ -274,19 +274,24 @@ _tizen_init_ecore_ipc() } int -_tizen_PreRotatotion_LoadLibrary(SDL_VideoData *_this, const char *lib_path) +_tizen_Rotatotion_LoadLibrary(SDL_VideoData *_this, const char *lib_path) { void *lib_dll_handle = NULL; char *path = NULL; - 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) + if (_this->tizen_rotation_data.dll_handle + && _this->tizen_rotation_data.wl_egl_window_set_rotation + && _this->tizen_rotation_data.wl_egl_window_get_capabilities + && _this->tizen_rotation_data.wl_egl_window_set_buffer_transform + && _this->tizen_rotation_data.wl_egl_window_set_window_transform) return SDL_TRUE; - _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; + _this->tizen_rotation_data.dll_handle = NULL; + _this->tizen_rotation_data.wl_egl_window_set_rotation = NULL; + _this->tizen_rotation_data.wl_egl_window_get_capabilities = NULL; + + _this->tizen_rotation_data.wl_egl_window_set_buffer_transform = NULL; + _this->tizen_rotation_data.wl_egl_window_set_window_transform = NULL; if (!lib_path) lib_dll_handle = SDL_LoadObject(lib_path); @@ -296,7 +301,7 @@ _tizen_PreRotatotion_LoadLibrary(SDL_VideoData *_this, const char *lib_path) lib_dll_handle = SDL_LoadObject(path); } - _this->tizen_pre_rotation_data.prerotation_dll_handle = lib_dll_handle; + _this->tizen_rotation_data.dll_handle = lib_dll_handle; if (lib_dll_handle == NULL) return SDL_FALSE; @@ -304,6 +309,9 @@ _tizen_PreRotatotion_LoadLibrary(SDL_VideoData *_this, const char *lib_path) LOAD_FUNC(wl_egl_window_set_rotation); LOAD_FUNC(wl_egl_window_get_capabilities); + LOAD_FUNC(wl_egl_window_set_buffer_transform); + LOAD_FUNC(wl_egl_window_set_window_transform); + return SDL_TRUE; } @@ -383,34 +391,6 @@ Tizen_SetWindowFullscreen(_THIS, SDL_Window *window, } void -Tizen_pre_rotation_set(SDL_WindowData *wind, int rotation) -{ - tizen_wl_egl_window_rotation rot; - if (!wind->egl_window) return; - - switch (rotation) { - case 90: - rot = TIZEN_ROTATION_270; - break; - case 180: - rot = TIZEN_ROTATION_180; - break; - case 270: - rot = TIZEN_ROTATION_90; - break; - case 0: - rot = TIZEN_ROTATION_0; - break; - default: - rot = TIZEN_ROTATION_0; - break; - } - - SDL_VideoData* _this = SDL_GetVideoDevice()->driverdata; - _this->tizen_pre_rotation_data.wl_egl_window_set_rotation(wind->egl_window, rot); -} - -void _tizen_set_window_size(SDL_Window * window, int w, int h) { if(!window) @@ -506,20 +486,21 @@ _tizen_rotation_do(SDL_Window *window, SDL_WindowData* wind, int rotation) _tizen_set_window_size(window, window_w, window_h); + SDL_VideoData* _this = SDL_GetVideoDevice()->driverdata; + if(wind->support_pre_rotation) { - Tizen_pre_rotation_set(wind, rotation); - wl_egl_window_set_buffer_transform(wind->egl_window, _tizen_get_rotation_idx(rotation)); - wl_egl_window_set_window_transform(wind->egl_window, _tizen_get_rotation_idx(wind->rotation)); + _this->tizen_rotation_data.wl_egl_window_set_rotation(wind->egl_window, 360 - rotation); + _this->tizen_rotation_data.wl_egl_window_set_buffer_transform(wind->egl_window, _tizen_get_rotation_idx(rotation)); + _this->tizen_rotation_data.wl_egl_window_set_window_transform(wind->egl_window, _tizen_get_rotation_idx(wind->rotation)); } else { wl_egl_window_resize(wind->egl_window, window_w, window_h, 0, 0); - wl_egl_window_set_buffer_transform(wind->egl_window, _tizen_get_rotation_idx((360 - wind->rotation))); - wl_egl_window_set_window_transform(wind->egl_window, _tizen_get_rotation_idx(0)); + _this->tizen_rotation_data.wl_egl_window_set_buffer_transform(wind->egl_window, _tizen_get_rotation_idx((360 - wind->rotation))); + _this->tizen_rotation_data.wl_egl_window_set_window_transform(wind->egl_window, _tizen_get_rotation_idx(0)); } - _tizen_send_rotation_event(window, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h); @@ -786,8 +767,8 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) //Support PreRotation wind->support_pre_rotation = 0; - if (_tizen_PreRotatotion_LoadLibrary(data, "libwayland-egl.so.1")) { - if (data->tizen_pre_rotation_data.wl_egl_window_get_capabilities(wind->egl_window) == TIZEN_WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { + if (_tizen_Rotatotion_LoadLibrary(data, "libwayland-egl.so.1")) { + if (data->tizen_rotation_data.wl_egl_window_get_capabilities(wind->egl_window) == TIZEN_WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { wind->support_pre_rotation = 1; } } -- 2.7.4