[SDL_Tizen] Add pre-rotation environment variable 16/108016/2
authorhuiyu.eun <huiyu.eun@samsung.com>
Mon, 2 Jan 2017 10:12:02 +0000 (19:12 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Mon, 2 Jan 2017 10:23:07 +0000 (19:23 +0900)
Add pre-rotation environment variable.
If you want to change pre-rotation option, add environment variable below.

path : in /etc/profile.d/*.sh file
export SDL_ROTATION=normal or pre_rotation

Change-Id: Icf4abaae95bd083fd6ddf4fe722a0df8ed8ce488
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/video/tizen/SDL_tizenwindow.c

index 608bb74..a831a90 100755 (executable)
 #include "../SDL_sysvideo.h"
 #include "../../events/SDL_windowevents_c.h"
 
+enum {
+    ROTATION_TYPE_NORMAL_ROTATION = 0,
+    ROTATION_TYPE_PRE_ROTATION,      /* use pre-rotation */
+};
+
 #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) \
@@ -54,6 +59,30 @@ if (!_this->tizen_pre_rotation_data->NAME) \
     return SDL_FALSE; \
 }
 
+static int
+_tizen_rotation_type_get()
+{
+    static int type = ROTATION_TYPE_PRE_ROTATION;
+    static int checked = 0;
+    char *engine = NULL;
+
+    if (checked) return type;
+
+    engine = getenv("SDL_ROTATION");
+
+    if (engine)
+      {
+         if ((!strcasecmp(engine, "normal")))
+            type = ROTATION_TYPE_NORMAL_ROTATION;
+         else if ((!strcasecmp(engine, "pre_rotation")))
+            type = ROTATION_TYPE_PRE_ROTATION;
+         else
+            type = ROTATION_TYPE_PRE_ROTATION;
+      }
+    checked = 1;
+    return type;
+}
+
 int
 _tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path)
 {
@@ -293,7 +322,7 @@ Tizen_CreateWindow(_THIS, SDL_Window *window)
 
         //Support PreRotation
         wind->support_pre_rotation = 0;
-        if (_tizen_PreRotatotion_LoadLibrary(wind, "libwayland-egl.so")) {
+        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 ) {
                 wind->support_pre_rotation = 1;
             }