From 622d25b1aa7172d1f78eddd3576c0abf46b6c77c Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Fri, 9 Dec 2016 15:32:19 +0900 Subject: [PATCH] [SDL_Tizen] Load 'libwayland-egl.so' using dlopen. Change-Id: I7f603846833c383551161e19599bf62e88a5a94d Signed-off-by: huiyu.eun --- src/video/tizen/SDL_tizenwindow.c | 84 +++++++++++++++++++++++++++++---------- src/video/tizen/SDL_tizenwindow.h | 8 ++++ 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/src/video/tizen/SDL_tizenwindow.c b/src/video/tizen/SDL_tizenwindow.c index d314de0..2724946 100755 --- a/src/video/tizen/SDL_tizenwindow.c +++ b/src/video/tizen/SDL_tizenwindow.c @@ -40,6 +40,46 @@ #include "../../joystick/tizen/SDL_sysjoystick_c.h" #include +int +_tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path) +{ + void *lib_dll_handle = NULL; + char *path = NULL; + + if (_this->isLoaded_pre_rotation) + return SDL_TRUE; + + _this->tizen_pre_rotation_data = (struct Tizen_Prerotation_Data *) SDL_calloc(1, sizeof(Tizen_Prerotation_Data)); + if (!_this->tizen_pre_rotation_data) { + return SDL_OutOfMemory(); + } + + if (!lib_path) + lib_dll_handle = SDL_LoadObject(lib_path); + + if (!lib_dll_handle) { + path = "libwayland-egl.so"; + lib_dll_handle = SDL_LoadObject(path); + } + + _this->tizen_pre_rotation_data->prerotation_dll_handle = lib_dll_handle; + + if (lib_dll_handle == NULL) + return SDL_FALSE; + + _this->tizen_pre_rotation_data->wl_egl_window_set_rotation = SDL_LoadFunction(lib_dll_handle, "wl_egl_window_set_rotation"); + if (!_this->tizen_pre_rotation_data->wl_egl_window_set_rotation) + return SDL_FALSE; + + _this->tizen_pre_rotation_data->wl_egl_window_get_capabilities = SDL_LoadFunction(lib_dll_handle, "wl_egl_window_get_capabilities"); \ + if (!_this->tizen_pre_rotation_data->wl_egl_window_get_capabilities) + return SDL_FALSE; + + _this->isLoaded_pre_rotation = 1; + + return SDL_TRUE; +} + SDL_bool Tizen_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) { @@ -78,13 +118,13 @@ Tizen_SetWindowFullscreen(_THIS, SDL_Window *window, } void -_tizen_pre_rotation_set(struct wl_egl_window *win, int angle) +_tizen_pre_rotation_set(SDL_WindowData *_this) { wl_egl_window_rotation rot; - if (!win) return; + if (!_this->egl_window) return; - SDL_Log("%s with angle %d",__FUNCTION__, angle); - switch (angle) { + SDL_Log("%s with angle %d",__FUNCTION__, _this->rotation); + switch (_this->rotation) { case 90: rot = ROTATION_270; break; @@ -103,7 +143,7 @@ _tizen_pre_rotation_set(struct wl_egl_window *win, int angle) } SDL_SetError("call wl_egl_win_set_rotation with rot %d",rot); - wl_egl_window_set_rotation(win, rot); + _this->tizen_pre_rotation_data->wl_egl_window_set_rotation(_this->egl_window, rot); } void @@ -165,7 +205,7 @@ _tizen_window_orientaiton_hint_callback(void *userdata, const char *name, const SDL_Log("SDL %s: support pre_rotation %d", __FUNCTION__,wind->support_pre_rotation); if (wind->support_pre_rotation) { SDL_Log("SDL %s: set pre rotation %d", __FUNCTION__,wind->rotation); - _tizen_pre_rotation_set(wind->egl_window, wind->rotation); + _tizen_pre_rotation_set(wind); } } ecore_wl_window_rotation_available_rotations_set(window, (const int*)checked, j); @@ -239,10 +279,15 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) //Support PreRotation wind->support_pre_rotation = 0; - SDL_Log("SDL %s: call wl_egl_window_get_capabilities()", __FUNCTION__); - if (wl_egl_window_get_capabilities(wind->egl_window) == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { - wind->support_pre_rotation = 1; - SDL_Log("Can support PreRotation"); + if (_tizen_PreRotatotion_LoadLibrary(wind, "libwayland-egl.so")) { + SDL_Log("SDL %s: call wl_egl_window_get_capabilities()", __FUNCTION__); + if (wind->tizen_pre_rotation_data->wl_egl_window_get_capabilities(wind->egl_window) == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { + wind->support_pre_rotation = 1; + SDL_Log("Can support PreRotation"); + } + else { + SDL_Log("can not support PreRotation !!"); + } } else { SDL_Log("can not support PreRotation !!"); @@ -254,7 +299,6 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) eina_hash_add(data->windows, &wind->id, window); Tizen_InitKeyboard(_this); - SDL_SetMouseFocus(window); if (window->flags & 0x00008000) { @@ -468,18 +512,18 @@ _tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event) ecore_wl_window_rotation_set(ew, ev->angle); if(wind->support_pre_rotation) { - _tizen_pre_rotation_set(wind->egl_window, (int)ev->angle); + _tizen_pre_rotation_set(wind); - int aw, ah; - wl_egl_window_get_attached_size(wind->egl_window, &aw, &ah); - wl_egl_window_resize(wind->egl_window, aw, ah, 0, 0); + int aw, ah; + wl_egl_window_get_attached_size(wind->egl_window, &aw, &ah); + wl_egl_window_resize(wind->egl_window, aw, ah, 0, 0); - if(wind->rotation == 90 || wind->rotation == 270) - SDL_SetWindowSize(window, ah, aw); - else - SDL_SetWindowSize(window, aw, ah);//->call wl_egl_window_resize() + if(wind->rotation == 90 || wind->rotation == 270) + SDL_SetWindowSize(window, ah, aw); + else + SDL_SetWindowSize(window, aw, ah);//->call wl_egl_window_resize() - SDL_Log("[SDL_Size] * _tizen_cb_event_window_rotate aw ah : %d, %d", window->w, window->h); + SDL_Log("[SDL_Size] * _tizen_cb_event_window_rotate aw ah : %d, %d", window->w, window->h); } // Send Rotation Event diff --git a/src/video/tizen/SDL_tizenwindow.h b/src/video/tizen/SDL_tizenwindow.h index abc14dc..8e051f4 100755 --- a/src/video/tizen/SDL_tizenwindow.h +++ b/src/video/tizen/SDL_tizenwindow.h @@ -31,6 +31,12 @@ #include "SDL_tizenvideo.h" +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; Ecore_Wl_Window *window; @@ -47,6 +53,8 @@ typedef struct { Uint32 last_indicator_showtime; int support_pre_rotation; + SDL_bool isLoaded_pre_rotation; + Tizen_Prerotation_Data * tizen_pre_rotation_data; } SDL_WindowData; -- 2.7.4