[SDL_tizen] Fix Indicator issue and build warnings 33/105433/3
authorhuiyu.eun <huiyu.eun@samsung.com>
Fri, 16 Dec 2016 12:09:47 +0000 (21:09 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Mon, 19 Dec 2016 08:40:54 +0000 (17:40 +0900)
- Indicator issue : Couldn't draw indicator using EGL_ext sample.
                    EGL-Image moved with indicator.
- Fix build-warnings. 'implicit declaration of function'
- Clean-up code.

Change-Id: I69f7ba29b1eb55575b6cc51ccbf4452a5822df64
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
23 files changed:
src/core/tizen/SDL_tizen.c
src/events/SDL_events.c
src/main/tizen/SDL_tizen_main.c
src/test/SDL_test_harness.c
src/video/tizen/SDL_ecore_ipc.c
src/video/tizen/SDL_ecore_ipc.h
src/video/tizen/SDL_tizenevents.c
src/video/tizen/SDL_tizenevents_c.h
src/video/tizen/SDL_tizenindicator.c [new file with mode: 0644]
src/video/tizen/SDL_tizenindicator.h [new file with mode: 0644]
src/video/tizen/SDL_tizenkeyboard.c
src/video/tizen/SDL_tizenkeyboard.h
src/video/tizen/SDL_tizenmouse.c
src/video/tizen/SDL_tizenmouse.h
src/video/tizen/SDL_tizenopengles.c
src/video/tizen/SDL_tizenopengles.h
src/video/tizen/SDL_tizentouch.c
src/video/tizen/SDL_tizenvideo.c
src/video/tizen/SDL_tizenvideo.h
src/video/tizen/SDL_tizenvulkan.c
src/video/tizen/SDL_tizenvulkan.h
src/video/tizen/SDL_tizenwindow.c
src/video/tizen/SDL_tizenwindow.h

index c8a04c2..ae8f9ed 100644 (file)
 #include "../../SDL_internal.h"
 
 #if __TIZEN__
-#include "SDL_tizen.h"
-#include "SDL_log.h"
-#include "SDL_events.h"
-#include "../../events/SDL_events_c.h"
 #include <app_internal.h>
 #include <app_extension.h>
 #include <system_settings.h>
 #include <aul.h>
 
+#include "SDL_log.h"
+#include "SDL_events.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_tizen.h"
+
 static int tizen_appcore_initialized = 0;
 static appcore_context_h appcore_handle = NULL;
 static ui_app_lifecycle_callback_s event_callback = {0,};
@@ -223,14 +225,14 @@ SDL_tizen_app_init(int argc, char *argv[])
     }
 
     event_callback.create = _tizen_sdl_create;
-//    event_callback.terminate = _tizen_sdl_terminate;
+    event_callback.terminate = _tizen_sdl_terminate;
     event_callback.pause = _tizen_sdl_pause;
     event_callback.resume = _tizen_sdl_resume;
     event_callback.app_control = _tizen_sdl_control;
 
     ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, _tizen_app_low_battery, NULL);
     ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, _tizen_app_low_memory, NULL);
-//    ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, _tizen_app_orient_changed, NULL);
+    ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, _tizen_app_orient_changed, NULL);
     ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _tizen_app_lang_changed, NULL);
     ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, _tizen_app_region_changed, NULL);
 
index 583c6f3..e6c39fc 100755 (executable)
@@ -470,7 +470,6 @@ SDL_PushEvent(SDL_Event * event)
         return -1;
     }
 
-    SDL_VideoDevice *_this = SDL_GetVideoDevice();
     SDL_GestureProcessEvent(event);
 
     return 1;
index aeb1d7c..2619f03 100644 (file)
@@ -6,6 +6,7 @@
 #ifdef __TIZEN__
 #include <stdlib.h>
 #include <stdio.h>
+
 #include "SDL.h"
 #include "SDL_main.h"
 
index 19f8891..f12e817 100644 (file)
@@ -374,7 +374,7 @@ void SDLTest_writeLogFile(SDL_RWops *rwops, SDL_PRINTF_FORMAT_STRING const char
     char *text = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
     if(text)
     {
-        SDL_snprintf(text, SDLTEST_MAX_LOGMESSAGE_LENGTH,  " INFO: %s: %s\n", SDLTest_TimestampToString(time(0)), message);
+        SDL_snprintf(text, SDLTEST_MAX_LOGMESSAGE_LENGTH, " INFO: %s\n", message);
         SDL_RWwrite(rwops, text, 1, SDL_strlen(text));
         SDL_stack_free(text);
     }
index e8a7f02..958e38b 100755 (executable)
@@ -1,9 +1,11 @@
 #include "SDL_ecore_ipc.h"
+#include "SDL_tizenindicator.h"
 
 #include <sys/mman.h>
 #include <fcntl.h>
+#include <unistd.h>
+#include <SDL_log.h>
 
-#include "SDL_tizenopengles.h"
 
 SharedFile* CreateSharedFile(char* SharedFileName, int size)
 {
@@ -18,7 +20,6 @@ SharedFile* CreateSharedFile(char* SharedFileName, int size)
     mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
 
     sharedFile->fileDescriptor= shm_open( SharedFileName, O_RDONLY, mode );
-    SDL_Log("[SDL]sharedFile->fileDescriptor == %d", sharedFile->fileDescriptor);
     if(sharedFile->fileDescriptor >= 0)
     {
         sharedFile->fileName = SharedFileName;
@@ -42,17 +43,15 @@ LockFile* CreateLockeFile(char* LockFileName)
     lockFile->fileDescriptor = open(LockFileName, O_RDWR);
     if(lockFile->fileDescriptor == -1)
     {
-        SDL_Log("[SDL]Fail to open lock file!");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"[SDL]Fail to open lock file!");
         return NULL;
 
     }
     lockFile->fileName = LockFileName;
 
     return lockFile;
-
 }
 
-
 void SetSharedImageInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedIndicatorInfo* shared_info)
 {
     if ( (epcEvent->data) && (epcEvent->size > 0) && (((unsigned char *)epcEvent->data)[epcEvent->size - 1] == 0) )
@@ -63,8 +62,6 @@ void SetSharedImageInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedIndicatorIn
             shared_info->fileInfo[n].SharedFileName = (char*)epcEvent->data;
             shared_info->fileInfo[n].SharedFileID = epcEvent->ref;
             shared_info->fileInfo[n].SharedFileNumber = epcEvent->ref_to;
-            SDL_Log("[SDL]SetSharedImageInfo: shared file name: %s, shared file id: %d, shared file number: %d", shared_info->fileInfo[n].SharedFileName, shared_info->fileInfo[n].SharedFileID, shared_info->fileInfo[n].SharedFileNumber);
-            SDL_Log("[SDL]epcEvent->response: %d", n);
         }
     }
 }
@@ -79,8 +76,6 @@ void SetLockFileInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedIndicatorInfo
             shared_info->fileInfo[n].ImageWidth = epcEvent->ref;
             shared_info->fileInfo[n].ImageHeight = epcEvent->ref_to;
             shared_info->fileInfo[n].LockFileName = epcEvent->data;
-            SDL_Log("[SDL]SetLockFileInfo: width %d, height %d, filename %s", shared_info->fileInfo[n].ImageWidth, shared_info->fileInfo[n].ImageHeight, shared_info->fileInfo[n].LockFileName);
-            SDL_Log("[SDL]epcEvent->response: %d", n);
         }
     }
 }
@@ -97,7 +92,7 @@ void Tizen_Indicator_SharedFile_Free(SharedIndicatorInfo *shared_info, int n)
         if(lockFile->fileDescriptor>=0) {
             if(lockf(lockFile->fileDescriptor, F_ULOCK, 0) <0 )
             {
-               SDL_Log("[SDL] Lock release fail");
+               SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"[SDL] Lock release fail");
                return;
             }
         }
@@ -180,16 +175,6 @@ void DataReceived(void* event, SharedIndicatorInfo* shared_info)
             if( n < SHARED_FILE_NUMBER)
             {
                 shared_info->cur_idx = n;
-                if(shared_info->fileInfo[n].sharedFile
-                   && shared_info->fileInfo[n].ImageWidth != 0
-                   && shared_info->fileInfo[n].ImageHeight != 0)
-                {
-                    Tizen_glTexImage2D(n);
-                }
-                else
-                {
-                    SDL_Log("[SDL] OP_UPDATE_DONE Fail");
-                }
             }
             break;
         }
@@ -210,23 +195,22 @@ void DataReceived(void* event, SharedIndicatorInfo* shared_info)
     }
 }
 
-int handler_server_add(void *data, int ev_type, void *ev)
+Eina_Bool handler_server_add(void *data, int ev_type EINA_UNUSED, void *ev)
 {
     Ecore_Ipc_Event_Server_Add *e = (Ecore_Ipc_Event_Server_Add *)ev;
     SDL_Log("Got a server add %p", e->server);
     return 1;
 }
 
-int handler_server_del(void *data, int ev_type, void *ev)
+Eina_Bool handler_server_del(void *data, int ev_type EINA_UNUSED, void *ev)
 {
     Ecore_Ipc_Event_Server_Del *e = (Ecore_Ipc_Event_Server_Del *)ev;
     SDL_Log("Got a server del %p", e->server);
     return 1;
 }
 
-int handler_server_data(void *data, int ev_type, void *ev)
+Eina_Bool handler_server_data(void *data, int ev_type EINA_UNUSED, void *ev)
 {
-    Ecore_Ipc_Event_Server_Data *e = (Ecore_Ipc_Event_Server_Data *)ev;
     SharedIndicatorInfo* shared_info = (SharedIndicatorInfo*)data;
     DataReceived(ev, shared_info);
     return 1;
index 09a27ae..e7302db 100755 (executable)
@@ -81,7 +81,6 @@ enum // opcodes
    OP_GL_REF,
 };
 
-
 unsigned char* CopyBuffer(SharedFileInfo* fileInfo);
 Ecore_Ipc_Server* serverConnection(const char* serviceName, SharedIndicatorInfo* shared_info);
 void Tizen_Indicator_SharedFile_Free(SharedIndicatorInfo *shared_info, int n);
index 447281f..c1363bd 100755 (executable)
 
 #include "SDL_stdinc.h"
 #include "SDL_assert.h"
+#include "SDL_log.h"
+
+#include "SDL_tizenevents_c.h"
+#include "SDL_tizenkeyboard.h"
 
 #include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 #include "../../events/scancodes_xfree86.h"
-
-#include "SDL_tizenvideo.h"
-#include "SDL_tizenevents_c.h"
-#include "SDL_tizenwindow.h"
-#include "SDL_log.h"
-
 #include "../../events/scancodes_tizen.h"
-#include "SDL_tizenkeyboard.h"
 
 extern TizenKeyboard tizen_keyboard;
 
index f98c7d3..a7e81d9 100755 (executable)
 
 extern void Tizen_PumpEvents(_THIS);
 
-
 extern Eina_Bool _tizen_cb_event_keyup_change(void *data, int type, void *event);
-
 extern Eina_Bool _tizen_cb_event_keydown_change(void *data, int type, void *event);
-
 extern Eina_Bool _tizen_cb_event_focus_in(void *data, int type EINA_UNUSED, void *event);
-
 extern Eina_Bool _tizen_cb_event_focus_out(void *data, int type EINA_UNUSED, void *event);
 
 #endif /* _SDL_tizenevents_h */
diff --git a/src/video/tizen/SDL_tizenindicator.c b/src/video/tizen/SDL_tizenindicator.c
new file mode 100644 (file)
index 0000000..572f68c
--- /dev/null
@@ -0,0 +1,622 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_OPENGL_EGL
+
+#include <wayland-extension/tizen-remote-surface-client-protocol.h>
+#include <wayland-tbm-client.h>
+
+#include "SDL_egl.h"
+#include "SDL_log.h"
+#include "SDL_timer.h"
+
+#include "../SDL_egl_c.h"
+
+#include "SDL_tizenindicator.h"
+#include "SDL_tizenwindow.h"
+
+#if SDL_VIDEO_OPENGL
+#include "SDL_opengl.h"
+#endif /* SDL_VIDEO_OPENGL */
+
+#if SDL_VIDEO_OPENGL_ES
+#include "SDL_opengles.h"
+#endif /* SDL_VIDEO_OPENGL_ES */
+
+/* GL and GLES2 headers conflict on Linux 32 bits */
+#if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL
+#include "SDL_opengles2.h"
+#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
+
+/* EGL implementation of SDL OpenGL ES support */
+typedef struct GLES2_Context
+{
+    #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
+    #include "../../render/opengles2/SDL_gles2funcs.h"
+    #undef SDL_PROC
+} GLES2_Context;
+
+static int LoadContext(GLES2_Context * data)
+{
+    #define SDL_PROC(ret,func,params) \
+    do { \
+        data->func = SDL_GL_GetProcAddress(#func); \
+        if ( ! data->func ) { \
+            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
+        } \
+    } while ( 0 );
+
+    #include "../../render/opengles2/SDL_gles2funcs.h"
+    #undef SDL_PROC
+
+    return 0;
+}
+
+#define IINDICATOR_HEIGHT 52
+
+typedef struct
+{
+    GLfloat   m[4][4];
+}ModelMatrix;
+ModelMatrix mMatrix;
+
+GLfloat vVertices[12]={
+     1.0f,  1.0f,
+    -1.0f, -1.0f,
+     1.0f, -1.0f,
+     1.0f,  1.0f,
+    -1.0f,  1.0f,
+    -1.0f, -1.0f
+    };
+
+GLfloat vCoord[12] = {
+    1.0f, 0.0f,
+    0.0f, 1.0f,
+    1.0f, 1.0f,
+    1.0f, 0.0f,
+    0.0f, 0.0f,
+    0.0f, 1.0f
+    };
+
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = NULL;
+PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = NULL;
+PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = NULL;
+
+SharedIndicatorInfo shared_info;
+GLuint textureID;
+GLuint indicator_vbo, indicator_ibo;
+
+GLuint programObject;
+GLuint vIndex;
+GLuint cIndex;
+
+Eina_Bool _tizen_timer_callback_indicator(void *data)
+{
+    SDL_VideoDevice *_this = SDL_GetVideoDevice();
+
+    Tizen_DrawIndicator(_this->windows);
+    SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) _this->windows->driverdata)->egl_surface);
+
+    return  ECORE_CALLBACK_RENEW;
+}
+
+int
+Tizen_indicator_event_filter()
+{
+    SDL_Window *window = SDL_GetVideoDevice()->windows;
+    SDL_WindowData *wind = window->driverdata;
+
+    if(wind->indicator_show && wind->indicator_timer == NULL)
+    {
+        wind->indicator_timer = ecore_timer_add(0.02, _tizen_timer_callback_indicator, NULL);
+    }
+    else if(!wind->indicator_show && wind->indicator_timer != NULL)
+    {
+        ecore_timer_del(wind ->indicator_timer);
+        wind->indicator_timer = NULL;
+    }
+
+    return 1;
+}
+
+static GLuint LoadShader(GLES2_Context* Mainctx, const char *shaderSrc, GLenum type)
+{
+    GLuint shader;
+    GLint compiled;
+
+    shader = Mainctx->glCreateShader(type);
+    SDL_Log("shader == %d", shader);
+    if(shader == 0)
+        return 0;
+    Mainctx->glShaderSource(shader, 1, &shaderSrc, NULL);
+    Mainctx->glCompileShader(shader);
+    Mainctx->glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
+    if(!compiled)
+    {
+        GLint infoLen = 0;
+        Mainctx->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
+        if(infoLen > 1)
+        {
+            char* infoLog = (char*)(malloc(sizeof(char) * infoLen));
+            Mainctx->glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
+            SDL_Log("Error compiling shader: %s", infoLog );
+            free(infoLog);
+        }
+        Mainctx->glDeleteShader(shader);
+        return 0;
+    }
+    return shader;
+
+}
+
+extern void ModelMatrixLoadIdentity(ModelMatrix* matrix)
+{
+    matrix->m[0][0] = 1.0f;
+    matrix->m[0][1] = 0.0f;
+    matrix->m[0][2] = 0.0f;
+    matrix->m[0][3] = 0.0f;
+
+    matrix->m[1][0] = 0.0f;
+    matrix->m[1][1] = 1.0f;
+    matrix->m[1][2] = 0.0f;
+    matrix->m[1][3] = 0.0f;
+
+    matrix->m[2][0] = 0.0f;
+    matrix->m[2][1] = 0.0f;
+    matrix->m[2][2] = 1.0f;
+    matrix->m[2][3] = 0.0f;
+
+    matrix->m[3][0] = 0.0f;
+    matrix->m[3][1] = 0.0f;
+    matrix->m[3][2] = 0.0f;
+    matrix->m[3][3] = 1.0f;
+}
+
+/*
+static void ModelMatrixTranslate(ModelMatrix* matrix, GLfloat x, GLfloat y, GLfloat z)
+{
+    matrix->m[3][0] += (matrix->m[0][0] * x + matrix->m[1][0] * y + matrix->m[2][0] * z);
+    matrix->m[3][1] += (matrix->m[0][1] * x + matrix->m[1][1] * y + matrix->m[2][1] * z);
+    matrix->m[3][2] += (matrix->m[0][2] * x + matrix->m[1][2] * y + matrix->m[2][2] * z);
+    matrix->m[3][3] += (matrix->m[0][3] * x + matrix->m[1][3] * y + matrix->m[2][3] * z);
+}
+*/
+
+void ModelMatrixTranslateInit(SDL_Window *window, int rot)
+{
+    //vVertices count
+    int i=1;
+    for( ; i<12; i+=2)
+        vVertices[i] = 1.0f;
+
+    GLfloat ratio = 1 - (GLfloat)(IINDICATOR_HEIGHT*2) / window->h;
+    vVertices[3] = vVertices[5] = vVertices[11] = ratio;
+}
+
+void ModelMatrixMultiply(ModelMatrix *lhs, ModelMatrix *rhs, ModelMatrix *r)
+{
+    int i, j, k;
+    float tmp[4][4];
+
+    for (i = 0; i < 4; i++) {
+        for (j = 0; j < 4; j++) {
+            tmp[j][i] = 0.0;
+
+            for (k = 0; k < 4; k++) {
+                tmp[j][i] += lhs->m[k][i] * rhs->m[j][k];
+            }
+        }
+    }
+    for (i = 0; i < 4; i++) {
+       for (j=0; j<4; j++) {
+           r->m[i][j] = tmp[i][j];
+       }
+    }
+}
+
+void rotate_indicator(ModelMatrix* matrix, const float anglex, const float angley, const float anglez)
+{
+    const float pi = 3.141592f;
+    ModelMatrix* temp = (ModelMatrix*)malloc(sizeof(ModelMatrix));
+    float rz = 2.0f * pi * anglez / 360.0f;
+    float rx = 2.0f * pi * anglex / 360.0f;
+    float ry = 2.0f * pi * angley / 360.0f;
+    float sy = SDL_sinf(ry);
+    float cy = SDL_cosf(ry);
+    float sx = SDL_sinf(rx);
+    float cx = SDL_cosf(rx);
+    float sz = SDL_sinf(rz);
+    float cz = SDL_cosf(rz);
+
+    ModelMatrixLoadIdentity(temp);
+
+    temp->m[0][0] = cy * cz - sx * sy * sz;
+    temp->m[0][1] = cz * sx * sy + cy * sz;
+    temp->m[0][2] = -cx * sy;
+    temp->m[1][0] = -cx * sz;
+    temp->m[1][1] = cx * cz;
+    temp->m[1][2] = sx;
+
+    temp->m[2][0] = cz * sy + cy * sx * sz;
+    temp->m[2][1] = -cy * cz * sx + sy * sz;
+    temp->m[2][2] = cx * cy;
+
+    ModelMatrixMultiply(matrix, temp, matrix);
+    free(temp);
+}
+
+void Tizen_UploadIndicatorImage(int idx)
+{
+    if(!shared_info.fileInfo[idx].sharedFile
+    || shared_info.fileInfo[idx].ImageWidth == 0
+    || shared_info.fileInfo[idx].ImageHeight == 0)
+    return ;
+
+    GLES2_Context Mainctx;
+    LoadContext(&Mainctx);
+
+    Mainctx.glActiveTexture(GL_TEXTURE0);
+
+    Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
+    Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shared_info.fileInfo[idx].ImageWidth, shared_info.fileInfo[idx].ImageHeight,
+                      0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)(shared_info.fileInfo[idx].sharedFile->address));
+}
+
+SDL_bool Tizen_isTouchIndicator(SDL_Window *window, int rot, int x, int y)
+{
+    if(x > window->x && x <  window->x + window->w && y > window->y && y < window->y + IINDICATOR_HEIGHT)
+         return SDL_TRUE;
+
+    return SDL_FALSE;
+}
+
+int Tizen_Indicator_GLES_Init(SDL_Window* window)
+{
+    SDL_WindowData *wind = window->driverdata;
+    ecore_wl_indicator_visible_type_set(wind->window, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
+    ecore_wl_window_indicator_opacity_set(wind->window, ECORE_WL_INDICATOR_OPAQUE);
+    ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_ON);
+
+    Ecore_Ipc_Server* IpcServer = serverConnection("elm_indicator", &shared_info);
+    if(!IpcServer)
+    {
+        SDL_Log("Fail to connect elm_indicator!\n");
+        return 0;
+    }
+
+    GLchar vShaderStr[] =
+        "attribute vec4 vVertices;\n"
+        "attribute vec2 vCoord;\n"
+        "uniform mat4 modelMatrix;\n"
+        "varying vec2 Coord;\n"
+        "void main()\n"
+        "{\n"
+        "    gl_Position = modelMatrix * vVertices;\n"
+        "    Coord = vCoord;\n"
+        "}\n";
+
+    GLchar fShaderStr[] =
+        "precision mediump float;\n"
+        "varying vec2 Coord;\n"
+        "uniform sampler2D s_texture;\n"
+        "void main()\n"
+        "{\n"
+        " gl_FragColor = texture2D(s_texture,Coord);\n"
+        "}\n";
+
+    GLuint vertexShader;
+    GLuint fragmentShader;
+
+    GLint linked;
+
+    GLES2_Context Mainctx;
+    LoadContext(&Mainctx);
+
+    vertexShader = LoadShader(&Mainctx, vShaderStr, GL_VERTEX_SHADER);
+    fragmentShader = LoadShader(&Mainctx, fShaderStr, GL_FRAGMENT_SHADER);
+    SDL_Log("The vertex shader is %d", vertexShader);
+    SDL_Log("The fragment shader is %d", fragmentShader);
+
+    programObject = Mainctx.glCreateProgram();
+    if(programObject == 0)
+        return 0;
+
+    Mainctx.glUseProgram(programObject);
+
+    Mainctx.glAttachShader(programObject, vertexShader);
+    Mainctx.glAttachShader(programObject, fragmentShader);
+
+    Mainctx.glLinkProgram(programObject);
+    Mainctx.glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
+
+    if(!linked)
+    {
+        GLint infoLen = 0;
+        Mainctx.glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);
+        if(infoLen > 1)
+        {
+            char* infoLog = (char*)(malloc(sizeof(char) * infoLen));
+            Mainctx.glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
+            SDL_Log("Error linking program: %s", infoLog);
+            free(infoLog);
+        }
+        Mainctx.glDeleteProgram(programObject);
+        return 0;
+    }
+
+    Mainctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    Mainctx.glEnable(GL_DEPTH_TEST);
+
+    vIndex = Mainctx.glGetAttribLocation(programObject, "vVertices");
+    cIndex = Mainctx.glGetAttribLocation(programObject, "vCoord");
+
+    Mainctx.glBindAttribLocation(programObject, vIndex, "vVertices");
+    Mainctx.glBindAttribLocation(programObject, cIndex, "vCoord");
+
+    ModelMatrixLoadIdentity(&mMatrix);
+
+    Mainctx.glGenTextures(1, &textureID);
+    Mainctx.glActiveTexture(GL_TEXTURE0);
+    Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
+
+    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+    wind->indicator_show = SDL_TRUE;
+    wind->last_indicator_showtime = SDL_GetTicks();
+
+    ecore_main_loop_iterate();
+    Tizen_IndicatorProcessEvent(window, wind->rotation);
+    Tizen_indicator_event_filter();
+
+    return 1;
+}
+
+void Tizen_DrawIndicator(SDL_Window *window)
+{
+    SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
+    if (wdata->received_rotation == 1) {
+        ecore_wl_window_rotation_change_done_send(wdata->window);
+        wdata->received_rotation = 0;
+    }
+    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && wdata->indicator_show)
+    {
+        if(wdata->last_indicator_showtime + 3000< SDL_GetTicks())
+        {
+            int i=1;
+            for( ; i<12; i+=2)
+                vVertices[i] += 0.02;
+        }
+        if(wdata->last_indicator_showtime + 3500 <SDL_GetTicks())
+        {
+            wdata->indicator_show = SDL_FALSE;
+            Tizen_indicator_event_filter();
+        }
+        GLES2_Context Mainctx;
+        LoadContext(&Mainctx);
+        Mainctx.glViewport(0, 0, window->w, window->h);
+        Mainctx.glUseProgram(programObject);
+
+        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
+        Mainctx.glVertexAttribPointer(vIndex, 2, GL_FLOAT, GL_FALSE, 0, vVertices);
+        Mainctx.glVertexAttribPointer(cIndex, 2, GL_FLOAT, GL_FALSE, 0, vCoord);
+
+        GLint uniformLocation = Mainctx.glGetUniformLocation(programObject, "modelMatrix");
+        Mainctx.glUniformMatrix4fv(uniformLocation, 1, GL_FALSE, (GLfloat *)mMatrix.m);
+
+        Mainctx.glEnableVertexAttribArray(vIndex);
+        Mainctx.glEnableVertexAttribArray(cIndex);
+        Tizen_UploadIndicatorImage(shared_info.cur_idx);
+
+        GLboolean isDepthTest = Mainctx.glIsEnabled(GL_DEPTH_TEST);
+        if(isDepthTest) Mainctx.glDisable(GL_DEPTH_TEST);
+        Mainctx.glDrawArrays(GL_TRIANGLES, 0, 6);
+
+        if(isDepthTest) Mainctx.glEnable(GL_DEPTH_TEST);
+        Mainctx.glDisableVertexAttribArray(vIndex);
+        Mainctx.glDisableVertexAttribArray(cIndex);
+    }
+}
+
+void
+Tizen_IndicatorProcessEvent(SDL_Window *window, int rot)
+{
+    SDL_WindowData *wind = window->driverdata;
+    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && wind->indicator_show)
+    {
+        GLES2_Context Mainctx;
+        LoadContext(&Mainctx);
+
+        GLfloat ratio = 1 - (GLfloat)(52*2) / window->h;
+        vVertices[3] = vVertices[5] = vVertices[11] = ratio;
+
+        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo);
+        Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vVertices, GL_STATIC_DRAW);
+        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo);
+        Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW);
+
+        ModelMatrixLoadIdentity(&mMatrix);
+
+        if (!wind->support_pre_rotation)
+            rotate_indicator(&mMatrix, 0, 0, rot);
+
+        wind->indicator_show = SDL_TRUE;
+        wind->last_indicator_showtime = SDL_GetTicks();
+
+        Tizen_indicator_event_filter();
+    }
+}
+
+int Tizen_FiniIndicator()
+{
+    int n;
+    for (n=0; n < SHARED_FILE_NUMBER; n++)
+        Tizen_Indicator_SharedFile_Free(&shared_info, n);
+
+    if(shared_info.eglImage_Indicator != NULL)
+        eglDestroyImageKHR(SDL_GetVideoDevice()->egl_data->egl_display, shared_info.eglImage_Indicator);
+
+    if (shared_info.tizen_rs)
+        tizen_remote_surface_destroy(shared_info.tizen_rs);
+    if (shared_info.tbm_client)
+        wayland_tbm_client_deinit(shared_info.tbm_client);
+    if (shared_info.tizen_rsm)
+        tizen_remote_surface_manager_destroy(shared_info.tizen_rsm);
+
+    GLES2_Context Mainctx;
+    LoadContext(&Mainctx);
+    Mainctx.glDeleteProgram(programObject);
+    return SDL_TRUE;
+}
+
+SDL_bool Tizen_remote_surface_init(void)
+{
+    Eina_Inlist *globals;
+    Ecore_Wl_Global *global;
+    struct wl_registry *registry;
+    if (!shared_info.tizen_rsm)
+    {
+        registry = ecore_wl_registry_get();
+        globals = ecore_wl_globals_get();
+
+        if (!registry || !globals)
+          {
+             SDL_Log( "Could not get registry(%p) or global list(%p)\n", registry, globals);
+             return SDL_FALSE;
+          }
+
+        EINA_INLIST_FOREACH(globals, global)
+          {
+             if (!strcmp(global->interface, "tizen_remote_surface_manager"))
+               {
+                  shared_info.tizen_rsm = wl_registry_bind(registry, global->id,
+                                      &tizen_remote_surface_manager_interface, 1);
+                   SDL_Log("[SDL] Create tizen_rsm : %p",shared_info.tizen_rsm);
+               }
+          }
+        shared_info.tizen_rs = NULL;
+    }
+    if (!shared_info.tizen_rsm)
+    {
+        SDL_Log("Could not bind tizen_remote_surface_manager");
+        return SDL_FALSE;
+    }
+
+    if(!shared_info.tbm_client)
+    {
+        shared_info.tbm_client = (struct wayland_tbm_client *)wayland_tbm_client_init(ecore_wl_display_get());
+        shared_info.wl_tbm = (struct wl_tbm *)wayland_tbm_client_get_wl_tbm(shared_info.tbm_client);
+        if (!shared_info.wl_tbm)
+        {
+            SDL_Log("[SDL]wl_tbm is NULL");
+            return SDL_FALSE;
+        }
+    }
+
+    eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("eglCreateImageKHR");
+    eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("eglDestroyImageKHR");
+    glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("glEGLImageTargetTexture2DOES");
+
+    return SDL_TRUE;
+}
+
+
+static void
+_tizen_rs_cb_buffer_update(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time)
+{
+    tizen_remote_surface_transfer_visibility(trs, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
+    tbm_surface_h tbmSurface= wl_buffer_get_user_data(buffer);
+
+    if(eglCreateImageKHR != NULL && glEGLImageTargetTexture2DOES != NULL && eglDestroyImageKHR != NULL)
+    {
+        SDL_VideoDevice *_this = SDL_GetVideoDevice();
+
+        if(shared_info.eglImage_Indicator != NULL)
+            eglDestroyImageKHR(_this->egl_data->egl_display, shared_info.eglImage_Indicator);
+
+        shared_info.eglImage_Indicator = eglCreateImageKHR(_this->egl_data->egl_display,
+                            EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN, tbmSurface, NULL);
+
+        if(shared_info.eglImage_Indicator == NULL)
+        {
+            SDL_Log("[SDL] eglImage is NULL");
+            return;
+        }
+        SDL_Log("[SDL] eglImage : %p", shared_info.eglImage_Indicator);
+        glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, shared_info.eglImage_Indicator);
+    }
+    else
+    {
+        tbm_surface_info_s info;
+        tbm_surface_map(tbmSurface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
+
+        SDL_Log("[SDL] Buffer Update %p %p (%dx%d), format:%d", buffer, tbmSurface, info.width, info.height, info.format);
+        SDL_Log("[SDL] Info size:%d, offset:%d, stride:%d", info.planes[0].size, info.planes[0].offset, info.planes[0].stride);
+
+        GLES2_Context Mainctx;
+        LoadContext(&Mainctx);
+
+        Mainctx.glActiveTexture(GL_TEXTURE0);
+
+        Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
+        Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, info.planes[0].stride/4, info.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned int*)info.planes[0].ptr);
+
+        if (tbm_surface_unmap (tbmSurface) != TBM_SURFACE_ERROR_NONE)
+            SDL_Log("Failed to unmap tbm_surface\n");
+    }
+
+    if (tbm_surface_destroy (tbmSurface) != TBM_SURFACE_ERROR_NONE)
+        SDL_Log("Failed to destroy tbm_surface\n");
+
+}
+
+static void
+_tizen_rs_cb_missing(void *data, struct tizen_remote_surface *trs)
+{
+    SDL_Log("Plug is missing...! ");
+}
+
+static const struct tizen_remote_surface_listener _extn_gl_plug_listener =
+{
+    _tizen_rs_cb_buffer_update,
+    _tizen_rs_cb_missing,
+};
+
+void Tizen_remote_indicator(int res_id)
+{
+    if(!shared_info.tizen_rs) {
+        //create tizen_remote_surface
+        shared_info.tizen_rs = tizen_remote_surface_manager_create_surface(shared_info.tizen_rsm, res_id, shared_info.wl_tbm);
+        if(!shared_info.tizen_rs)
+        {
+            SDL_Log("tizen_rs is NULL");
+            return;
+        }
+        tizen_remote_surface_add_listener(shared_info.tizen_rs, &_extn_gl_plug_listener, NULL);
+        tizen_remote_surface_redirect(shared_info.tizen_rs);
+    }
+}
+#endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
+
diff --git a/src/video/tizen/SDL_tizenindicator.h b/src/video/tizen/SDL_tizenindicator.h
new file mode 100644 (file)
index 0000000..7da31a0
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_tizenindicator_h
+#define _SDL_tizenindicator_h
+
+#if SDL_VIDEO_OPENGL_EGL
+
+#include "../SDL_sysvideo.h"
+
+#include "SDL_ecore_ipc.h"
+
+extern void ModelMatrixTranslateInit(SDL_Window *window, int rot);
+
+extern SDL_bool Tizen_isTouchIndicator(SDL_Window *window, int rot, int x, int y);
+
+extern int Tizen_Indicator_GLES_Init(SDL_Window* window);
+extern int Tizen_indicator_event_filter(void);
+extern int Tizen_FiniIndicator(void);
+
+extern void Tizen_DrawIndicator(SDL_Window *window);
+extern void Tizen_IndicatorProcessEvent(SDL_Window* window, int rot);
+
+/* Tizen remote-surface indicator */
+extern SDL_bool Tizen_remote_surface_init(void);
+extern void Tizen_remote_indicator(int res_id);
+
+
+#endif
+
+#endif /* _SDL_tizenindicator_h */
+
index 9c48a6a..506d40f 100755 (executable)
@@ -26,9 +26,7 @@
 #include "SDL_log.h"
 #include "../../events/SDL_keyboard_c.h"
 
-/*
-    Tizen Keyboard
-*/
+/* Tizen Keyboard */
 TizenKeyboard tizen_keyboard;
 
 void
index cb0b3c3..8beb408 100755 (executable)
 #include <Ecore_Wayland.h>
 #include <Ecore_IMF.h>
 
-/*
-#include "SDL_tizenvideo.h"
-#include "SDL_tizenwindow.h"
-#include "SDL_events.h"
-*/
 typedef struct _TizenKeyboard TizenKeyboard;
 struct _TizenKeyboard
 {
index 9d6fccf..ba18f4d 100755 (executable)
 #define _GNU_SOURCE
 #endif
 
-#include "../../events/SDL_mouse_c.h"
-
-#include "SDL_tizenmouse.h"
-#include "SDL_log.h"
-#include "SDL_tizentouch.h"
-#include "SDL_tizenopengles.h"
-
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
 
+#include "../../events/SDL_mouse_c.h"
+
+#include "SDL_log.h"
+#include "SDL_timer.h"
+#include "SDL_tizenindicator.h"
+#include "SDL_tizenmouse.h"
+#include "SDL_tizentouch.h"
+
+#include "SDL_tizenvideo.h"
 
 typedef struct {
     struct wl_buffer   *buffer;
@@ -93,8 +95,6 @@ static const struct wl_buffer_listener mouse_buffer_listener = {
 static int
 create_buffer_from_shm(Tizen_CursorData *d, int width, int height, uint32_t format)
 {
-    //SDL_VideoDevice *vd = SDL_GetVideoDevice();
-    //SDL_VideoData *data = (SDL_VideoData *) vd->driverdata;
     struct wl_shm_pool *shm_pool;
 
     int stride = width * 4;
@@ -246,17 +246,6 @@ Tizen_FiniMouse(void)
     mouse->SetRelativeMouseMode = NULL;
 }
 
-ModelMatrix mMatrix;
-
-SDL_bool isTouchIndicator(SDL_Window *window, int rot, int x, int y)
-{
-
-    if(x > window->x && x <  window->x + window->w && y > window->y && y < window->y + 52)
-         return SDL_TRUE;
-
-    return SDL_FALSE;
-}
-
 void _tizen_get_mouseXY(SDL_Window* window, int x, int y, int* retX, int* retY)
 {
     SDL_WindowData *wind = window->driverdata;
@@ -300,12 +289,12 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event)
     int x, y;
     _tizen_get_mouseXY(window, (int)e->x, (int)e->y, &x, &y);
     SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)", x, y);
-    if(isTouchIndicator(window, wind->rotation, x, y))
+    if(Tizen_isTouchIndicator(window, wind->rotation, x, y))
     {
-         ModelMatrixTranslateInit(&mMatrix);
-         wind->indicator_show = SDL_TRUE;
-         wind->last_indicator_showtime = SDL_GetTicks();
-         _tizen_indicator_event_filter();
+        ModelMatrixTranslateInit(window, wind->rotation);
+        wind->indicator_show = SDL_TRUE;
+        wind->last_indicator_showtime = SDL_GetTicks();
+        Tizen_indicator_event_filter();
     }
 
     SDL_SendMouseMotion(window, 0, 0, x, y);
index 17b18c0..734139a 100755 (executable)
 */
 
 #include "../../SDL_internal.h"
+
 #include "SDL_mouse.h"
-#include "SDL_tizenvideo.h"
-#include "SDL_tizenwindow.h"
 #include "SDL_events.h"
-
 #include "SDL_assert.h"
 
+#include "SDL_tizenvideo.h"
+#include "SDL_tizenwindow.h"
+
 extern void Tizen_InitMouse(void);
 extern void Tizen_FiniMouse(void);
 
index 89a4164..c7c4158 100755 (executable)
 
 #if SDL_VIDEO_OPENGL_EGL
 
-#include "SDL_tizenvideo.h"
+#include "SDL_log.h"
 #include "SDL_tizenopengles.h"
-#include "SDL_tizenwindow.h"
-#include "SDL_tizenevents_c.h"
-
-#include "SDL_ecore_ipc.h"
+#include "SDL_tizenindicator.h"
 #include "SDL_tizenvideo.h"
-
-#include <wayland-extension/tizen-remote-surface-client-protocol.h>
-#include <wayland-tbm-client.h>
-#include <Ecore_Wayland.h>
-#include <SDL_egl.h>
+#include "SDL_tizenwindow.h"
 
 #if SDL_VIDEO_OPENGL
 #include "SDL_opengl.h"
 #include "SDL_opengles2.h"
 #endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
 
-/* EGL implementation of SDL OpenGL ES support */
-typedef struct GLES2_Context
-{
-    #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-    #include "../../render/opengles2/SDL_gles2funcs.h"
-    #undef SDL_PROC
-} GLES2_Context;
-
-GLfloat vVertices[18]={
-     1.0f, 1.0f,  0.0f,
-    -1.0f, 0.92f, 0.0f,
-     1.0f, 0.92f, 0.0f,
-     1.0f, 1.0f,  0.0f,
-    -1.0f, 1.0f,  0.0f,
-    -1.0f, 0.92f, 0.0f
-    };
-
-GLfloat vCoord[12] = {
-    1.0f, 0.0f,
-    0.0f, 1.0f,
-    1.0f, 1.0f,
-    1.0f, 0.0f,
-    0.0f, 0.0f,
-    0.0f, 1.0f};
-
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = NULL;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = NULL;
-PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = NULL;
-
-SharedIndicatorInfo shared_info;
-unsigned int textureID;
-unsigned int indicator_vbo[4], indicator_ibo[4];
-ModelMatrix mMatrix;
-
-
-GLuint programObject;
-GLuint vIndex;
-GLuint cIndex;
-
-
-static int LoadContext(GLES2_Context * data)
-{
-    #define SDL_PROC(ret,func,params) \
-    do { \
-        data->func = SDL_GL_GetProcAddress(#func); \
-        if ( ! data->func ) { \
-            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
-        } \
-    } while ( 0 );
-
-    #include "../../render/opengles2/SDL_gles2funcs.h"
-    #undef SDL_PROC
-
-    return 0;
-}
-
-static void
-_tizen_rs_cb_buffer_update(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time)
-{
-    tizen_remote_surface_transfer_visibility(trs, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
-    tbm_surface_h tbmSurface= wl_buffer_get_user_data(buffer);
-
-    if(eglCreateImageKHR != NULL && glEGLImageTargetTexture2DOES != NULL && eglDestroyImageKHR != NULL)
-    {
-        SDL_VideoDevice *_this = SDL_GetVideoDevice();
-
-        if(shared_info.eglImage_Indicator != NULL)
-            eglDestroyImageKHR(_this->egl_data->egl_display, shared_info.eglImage_Indicator);
-
-        shared_info.eglImage_Indicator = eglCreateImageKHR(_this->egl_data->egl_display,
-                            EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN, tbmSurface, NULL);
-
-        if(shared_info.eglImage_Indicator == NULL)
-        {
-            SDL_Log("[SDL] eglImage is NULL");
-            return;
-        }
-        SDL_Log("[SDL] eglImage : %p", shared_info.eglImage_Indicator);
-        glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, shared_info.eglImage_Indicator);
-    }
-    else
-    {
-        tbm_surface_info_s info;
-        tbm_surface_map(tbmSurface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info);
-
-        SDL_Log("[SDL] Buffer Update %p %p (%dx%d), format:%d", buffer, tbmSurface, info.width, info.height, info.format);
-        SDL_Log("[SDL] Info size:%d, offset:%d, stride:%d", info.planes[0].size, info.planes[0].offset, info.planes[0].stride);
-
-        GLES2_Context Mainctx;
-        LoadContext(&Mainctx);
-
-        Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
-        Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, info.planes[0].stride/4, info.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned int*)info.planes[0].ptr);
-
-        if (tbm_surface_unmap (tbmSurface) != TBM_SURFACE_ERROR_NONE)
-            SDL_Log("Failed to unmap tbm_surface\n");
-    }
-
-    if (tbm_surface_destroy (tbmSurface) != TBM_SURFACE_ERROR_NONE)
-        SDL_Log("Failed to destroy tbm_surface\n");
-
-}
-
-static void
-_tizen_rs_cb_missing(void *data, struct tizen_remote_surface *trs)
-{
-    SDL_Log("Plug is missing...! ");
-}
-
-static const struct tizen_remote_surface_listener _extn_gl_plug_listener =
-{
-    _tizen_rs_cb_buffer_update,
-    _tizen_rs_cb_missing,
-};
-
-Uint32 _tizen_timer_callback_indicator(void *data)
-{
-    SDL_VideoDevice *_this = SDL_GetVideoDevice();
-
-    Tizen_DrawIndicator(_this->windows);
-    SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) _this->windows->driverdata)->egl_surface);
-
-    return  ECORE_CALLBACK_RENEW;
-}
-
-int
-_tizen_indicator_event_filter()
-{
-    SDL_Window *window = SDL_GetVideoDevice()->windows;
-    SDL_WindowData *wind = window->driverdata;
-
-    if(wind->indicator_show && wind->indicator_timer == NULL)
-    {
-        wind->indicator_timer = ecore_timer_add(0.02, _tizen_timer_callback_indicator, NULL);
-    }
-    else if(!wind->indicator_show && wind->indicator_timer != NULL)
-    {
-        ecore_timer_del(wind ->indicator_timer);
-        wind->indicator_timer = NULL;
-    }
-
-    return 1;
-}
-
 int
 Tizen_GLES_LoadLibrary(_THIS, const char *path)
 {
@@ -202,365 +51,6 @@ Tizen_GLES_LoadLibrary(_THIS, const char *path)
     return ret;
 }
 
-static GLuint LoadShader(GLES2_Context* Mainctx, const char *shaderSrc, GLenum type)
-{
-    GLuint shader;
-    GLint compiled;
-
-    shader = Mainctx->glCreateShader(type);
-    SDL_Log("shader == %d", shader);
-    if(shader == 0)
-        return 0;
-    Mainctx->glShaderSource(shader, 1, &shaderSrc, NULL);
-    Mainctx->glCompileShader(shader);
-    Mainctx->glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
-    if(!compiled)
-    {
-        GLint infoLen = 0;
-        Mainctx->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
-        if(infoLen > 1)
-        {
-            char* infoLog = (char*)(malloc(sizeof(char) * infoLen));
-            Mainctx->glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
-            SDL_Log("Error compiling shader: %s", infoLog );
-            free(infoLog);
-        }
-        Mainctx->glDeleteShader(shader);
-        return 0;
-    }
-    return shader;
-
-}
-
-extern void ModelMatrixLoadIdentity(ModelMatrix* matrix)
-{
-    matrix->m[0][0] = 1.0f;
-    matrix->m[0][1] = 0.0f;
-    matrix->m[0][2] = 0.0f;
-    matrix->m[0][3] = 0.0f;
-
-    matrix->m[1][0] = 0.0f;
-    matrix->m[1][1] = 1.0f;
-    matrix->m[1][2] = 0.0f;
-    matrix->m[1][3] = 0.0f;
-
-    matrix->m[2][0] = 0.0f;
-    matrix->m[2][1] = 0.0f;
-    matrix->m[2][2] = 1.0f;
-    matrix->m[2][3] = 0.0f;
-
-    matrix->m[3][0] = 0.0f;
-    matrix->m[3][1] = 0.0f;
-    matrix->m[3][2] = 0.0f;
-    matrix->m[3][3] = 1.0f;
-}
-
-static void ModelMatrixTranslate(ModelMatrix* matrix, GLfloat x, GLfloat y, GLfloat z)
-{
-    matrix->m[3][0] += (matrix->m[0][0] * x + matrix->m[1][0] * y + matrix->m[2][0] * z);
-    matrix->m[3][1] += (matrix->m[0][1] * x + matrix->m[1][1] * y + matrix->m[2][1] * z);
-    matrix->m[3][2] += (matrix->m[0][2] * x + matrix->m[1][2] * y + matrix->m[2][2] * z);
-    matrix->m[3][3] += (matrix->m[0][3] * x + matrix->m[1][3] * y + matrix->m[2][3] * z);
-}
-
-void ModelMatrixTranslateInit(ModelMatrix* matrix)
-{
-    matrix->m[3][0] = matrix->m[3][1] = matrix->m[3][2] =0;
-    matrix->m[3][3] = 1;
-}
-
-void multiply_matrix(ModelMatrix *lhs, ModelMatrix *rhs, ModelMatrix *r)
-{
-    int i, j, k;
-    float tmp[4][4];
-
-    for (i = 0; i < 4; i++) {
-        for (j = 0; j < 4; j++) {
-            tmp[j][i] = 0.0;
-
-            for (k = 0; k < 4; k++) {
-                tmp[j][i] += lhs->m[k][i] * rhs->m[j][k];
-            }
-        }
-    }
-    for (i = 0; i < 4; i++) {
-       for (j=0; j<4; j++) {
-           r->m[i][j] = tmp[i][j];
-       }
-    }
-}
-
-void rotate_indicator(ModelMatrix* matrix, const float anglex, const float angley, const float anglez)
-{
-    const float pi = 3.141592f;
-    ModelMatrix* temp = (ModelMatrix*)malloc(sizeof(ModelMatrix));
-    float rz = 2.0f * pi * anglez / 360.0f;
-    float rx = 2.0f * pi * anglex / 360.0f;
-    float ry = 2.0f * pi * angley / 360.0f;
-    float sy = SDL_sinf(ry);
-    float cy = SDL_cosf(ry);
-    float sx = SDL_sinf(rx);
-    float cx = SDL_cosf(rx);
-    float sz = SDL_sinf(rz);
-    float cz = SDL_cosf(rz);
-
-    ModelMatrixLoadIdentity(temp);
-
-    temp->m[0][0] = cy * cz - sx * sy * sz;
-    temp->m[0][1] = cz * sx * sy + cy * sz;
-    temp->m[0][2] = -cx * sy;
-    temp->m[1][0] = -cx * sz;
-    temp->m[1][1] = cx * cz;
-    temp->m[1][2] = sx;
-
-    temp->m[2][0] = cz * sy + cy * sx * sz;
-    temp->m[2][1] = -cy * cz * sx + sy * sz;
-    temp->m[2][2] = cx * cy;
-
-    multiply_matrix(matrix, temp, matrix);
-    free(temp);
-}
-
-void Tizen_remote_indicator(int res_id)
-{
-    if(!shared_info.tizen_rs) {
-        //create tizen_remote_surface
-        shared_info.tizen_rs = tizen_remote_surface_manager_create_surface(shared_info.tizen_rsm, res_id, shared_info.wl_tbm);
-        if(!shared_info.tizen_rs)
-        {
-            SDL_Log("tizen_rs is NULL");
-            return;
-        }
-        tizen_remote_surface_add_listener(shared_info.tizen_rs, &_extn_gl_plug_listener, NULL);
-        tizen_remote_surface_redirect(shared_info.tizen_rs);
-    }
-}
-
-void Tizen_glTexImage2D(int idx)
-{
-    GLES2_Context Mainctx;
-    LoadContext(&Mainctx);
-
-    Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
-    Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shared_info.fileInfo[idx].ImageWidth, shared_info.fileInfo[idx].ImageHeight,
-                      0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)(shared_info.fileInfo[idx].sharedFile->address));
-}
-
-void Tizen_DrawIndicator(SDL_Window *window)
-{
-    SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata;
-    if (wdata->received_rotation == 1) {
-        ecore_wl_window_rotation_change_done_send(wdata->window);
-        wdata->received_rotation = 0;
-    }
-    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && wdata->indicator_show)
-    {
-        if(wdata->last_indicator_showtime + 3000< SDL_GetTicks())
-        {
-            ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f);
-        }
-        if(wdata->last_indicator_showtime + 3500 <SDL_GetTicks()) {
-            wdata->indicator_show = SDL_FALSE;
-            _tizen_indicator_event_filter();
-        }
-        GLES2_Context Mainctx;
-        LoadContext(&Mainctx);
-        Mainctx.glViewport(0, 0, window->w, window->h);
-        Mainctx.glUseProgram(programObject);
-
-        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
-        Mainctx.glVertexAttribPointer(vIndex, 3, GL_FLOAT, GL_FALSE, 0, vVertices);
-        Mainctx.glVertexAttribPointer(cIndex, 2, GL_FLOAT, GL_FALSE, 0, vCoord);
-        Mainctx.glUniformMatrix4fv(Mainctx.glGetUniformLocation(programObject,  "modelMatrix"), 1, GL_FALSE, mMatrix.m);
-
-        Mainctx.glEnableVertexAttribArray(vIndex);
-        Mainctx.glEnableVertexAttribArray(cIndex);
-
-        GLboolean isDepthTest = Mainctx.glIsEnabled(GL_DEPTH_TEST);
-        if(isDepthTest) Mainctx.glDisable(GL_DEPTH_TEST);
-        Mainctx.glDrawArrays(GL_TRIANGLES, 0, 6);
-
-        if(isDepthTest) Mainctx.glEnable(GL_DEPTH_TEST);
-        Mainctx.glDisableVertexAttribArray(vIndex);
-        Mainctx.glDisableVertexAttribArray(cIndex);
-    }
-}
-
-SDL_bool Tizen_remote_surface_init(void)
-{
-    Eina_Inlist *globals;
-    Ecore_Wl_Global *global;
-    struct wl_registry *registry;
-    if (!shared_info.tizen_rsm)
-    {
-        registry = ecore_wl_registry_get();
-        globals = ecore_wl_globals_get();
-
-        if (!registry || !globals)
-          {
-             SDL_Log( "Could not get registry(%p) or global list(%p)\n", registry, globals);
-             return SDL_FALSE;
-          }
-
-        EINA_INLIST_FOREACH(globals, global)
-          {
-             if (!strcmp(global->interface, "tizen_remote_surface_manager"))
-               {
-                  shared_info.tizen_rsm = wl_registry_bind(registry, global->id,
-                                      &tizen_remote_surface_manager_interface, 1);
-                   SDL_Log("[SDL] Create tizen_rsm : %p",shared_info.tizen_rsm);
-               }
-          }
-        shared_info.tizen_rs = NULL;
-    }
-    if (!shared_info.tizen_rsm)
-    {
-        SDL_Log("Could not bind tizen_remote_surface_manager");
-        return SDL_FALSE;
-    }
-
-    if(!shared_info.tbm_client)
-    {
-        shared_info.tbm_client = (struct wayland_tbm_client *)wayland_tbm_client_init(ecore_wl_display_get());
-        shared_info.wl_tbm = (struct wl_tbm *)wayland_tbm_client_get_wl_tbm(shared_info.tbm_client);
-        if (!shared_info.wl_tbm)
-        {
-            SDL_Log("[SDL]wl_tbm is NULL");
-            return SDL_FALSE;
-        }
-    }
-
-    eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("eglCreateImageKHR");
-    eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("eglDestroyImageKHR");
-    glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)SDL_GetVideoDevice()->egl_data->eglGetProcAddress("glEGLImageTargetTexture2DOES");
-
-    return SDL_TRUE;
-}
-
-int Tizen_FiniIndicator()
-{
-    int n;
-    for (n=0; n < SHARED_FILE_NUMBER; n++)
-        Tizen_Indicator_SharedFile_Free(&shared_info, n);
-
-    if(shared_info.eglImage_Indicator != NULL)
-        eglDestroyImageKHR(SDL_GetVideoDevice()->egl_data->egl_display, shared_info.eglImage_Indicator);
-
-    if (shared_info.tizen_rs)
-        tizen_remote_surface_destroy(shared_info.tizen_rs);
-    if (shared_info.tbm_client)
-        wayland_tbm_client_deinit(shared_info.tbm_client);
-    if (shared_info.tizen_rsm)
-        tizen_remote_surface_manager_destroy(shared_info.tizen_rsm);
-
-    GLES2_Context Mainctx;
-    LoadContext(&Mainctx);
-    Mainctx.glDeleteProgram(programObject);
-    return SDL_TRUE;
-}
-
-int Indicator_GLES_Init(SDL_Window* window)
-{
-    SDL_WindowData *wind = window->driverdata;
-    ecore_wl_indicator_visible_type_set(wind->window, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
-    ecore_wl_window_indicator_opacity_set(wind->window, ECORE_WL_INDICATOR_OPAQUE);
-    ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_ON);
-
-    Ecore_Ipc_Server* IpcServer = serverConnection("elm_indicator", &shared_info);
-    if(!IpcServer)
-    {
-        SDL_Log("Fail to connect elm_indicator!\n");
-        return 0;
-    }
-
-    GLchar vShaderStr[] =
-        "attribute vec4 vVertices;\n"
-        "attribute vec2 vCoord;\n"
-        "uniform mat4 modelMatrix;\n"
-        "varying vec2 Coord;\n"
-        "void main()\n"
-        "{\n"
-        "    gl_Position = modelMatrix * vVertices;\n"
-        "    Coord = vCoord;\n"
-        "}\n";
-
-    GLchar fShaderStr[] =
-        "precision mediump float;\n"
-        "varying vec2 Coord;\n"
-        "uniform sampler2D s_texture;\n"
-        "void main()\n"
-        "{\n"
-        " gl_FragColor = texture2D(s_texture,Coord);\n"
-        "}\n";
-
-    GLuint vertexShader;
-    GLuint fragmentShader;
-
-    GLint linked;
-
-    GLES2_Context Mainctx;
-    LoadContext(&Mainctx);
-
-    vertexShader = LoadShader(&Mainctx, vShaderStr, GL_VERTEX_SHADER);
-    fragmentShader = LoadShader(&Mainctx, fShaderStr, GL_FRAGMENT_SHADER);
-    SDL_Log("The vertex shader is %d", vertexShader);
-    SDL_Log("The fragment shader is %d", fragmentShader);
-
-    programObject = Mainctx.glCreateProgram();
-    if(programObject == 0)
-        return 0;
-
-    Mainctx.glAttachShader(programObject, vertexShader);
-    Mainctx.glAttachShader(programObject, fragmentShader);
-
-    Mainctx.glLinkProgram(programObject);
-    Mainctx.glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
-
-    if(!linked)
-    {
-        GLint infoLen = 0;
-        Mainctx.glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);
-        if(infoLen > 1)
-        {
-            char* infoLog = (char*)(malloc(sizeof(char) * infoLen));
-            Mainctx.glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
-            SDL_Log("Error linking program: %s", infoLog);
-            free(infoLog);
-        }
-        Mainctx.glDeleteProgram(programObject);
-        return 0;
-    }
-
-    Mainctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    Mainctx.glEnable(GL_DEPTH_TEST);
-
-    vIndex = Mainctx.glGetAttribLocation(programObject, "vVertices");
-    cIndex = Mainctx.glGetAttribLocation(programObject, "vCoord");
-
-    Mainctx.glBindAttribLocation(programObject, vIndex, "vVertices");
-    Mainctx.glBindAttribLocation(programObject, cIndex, "vCoord");
-
-    ModelMatrixLoadIdentity(&mMatrix);
-
-
-    Mainctx.glGenTextures(1, &textureID);
-    Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
-
-    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-    wind->indicator_show = SDL_TRUE;
-    wind->last_indicator_showtime = SDL_GetTicks();
-
-    ecore_main_loop_iterate();
-    SDL_IndicatorProcessEvent(window, wind->rotation);
-    _tizen_indicator_event_filter();
-
-    return 1;
-}
-
 SDL_GLContext
 Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
 {
@@ -573,7 +63,7 @@ Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
         SDL_VideoData *data = (SDL_VideoData *) (SDL_GetVideoDevice()->driverdata);
         if(data->current_thread != SDL_GetThreadID(0))
             return context;
-        if(!Indicator_GLES_Init(window))
+        if(!Tizen_Indicator_GLES_Init(window))
         {
             SDL_Log("Indicator GLES init error!");
         }
@@ -611,38 +101,6 @@ Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context)
     SDL_EGL_DeleteContext(_this, context);
 }
 
-void
-SDL_IndicatorProcessEvent(SDL_Window *window, int rot)
-{
-    SDL_WindowData *wind = window->driverdata;
-    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && wind->indicator_show)
-    {
-        GLES2_Context Mainctx;
-        LoadContext(&Mainctx);
-
-        double ratio = 0.92f;
-        if( rot == 90 || rot ==270)
-            ratio = 0.86f;
-
-        vVertices[4] = vVertices[7] = vVertices[16] = ratio;
-
-        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo);
-        Mainctx.glBufferData(GL_ARRAY_BUFFER, 18 * 4, vVertices, GL_STATIC_DRAW);
-        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo);
-        Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW);
-
-        ModelMatrixLoadIdentity(&mMatrix);
-
-        if (!wind->support_pre_rotation)
-            rotate_indicator(&mMatrix, 0, 0, rot);
-
-        wind->indicator_show = SDL_TRUE;
-        wind->last_indicator_showtime = SDL_GetTicks();
-
-        _tizen_indicator_event_filter();
-    }
-}
-
 #endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
 
 /* vi: set ts=4 sw=4 expandtab: */
index 1025662..c9610f7 100755 (executable)
@@ -26,7 +26,6 @@
 
 #include "../SDL_sysvideo.h"
 #include "../SDL_egl_c.h"
-#include "SDL_events.h"
 
 #if SDL_VIDEO_OPENGL_EGL
 
@@ -40,26 +39,11 @@ typedef struct SDL_PrivateGLESData {
 #define Tizen_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
 #define Tizen_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
 
-extern void Tizen_glTexImage2D(int idx);
-extern void SDL_IndicatorProcessEvent(SDL_Window* window, int rot);
-
 extern int Tizen_GLES_LoadLibrary(_THIS, const char *path);
 extern SDL_GLContext Tizen_GLES_CreateContext(_THIS, SDL_Window *window);
 extern void Tizen_GLES_SwapWindow(_THIS, SDL_Window *window);
 extern int Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
 extern void Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context);
-extern int Tizen_FiniIndicator();
-
-extern SDL_bool Tizen_remote_surface_init(void);
-extern void Tizen_remote_indicator(int res_id);
-
-typedef struct
-{
-    float   m[4][4];
-}ModelMatrix;
-
-extern void ModelMatrixLoadIdentity(ModelMatrix* matrix);
-extern void ModelMatrixTranslateInit(ModelMatrix* matrix);
 #endif
 
 #endif /* _SDL_tizenopengles_h */
index c4cecb6..9e397b9 100755 (executable)
 
 #if SDL_VIDEO_DRIVER_TIZEN
 
-#include "../SDL_sysvideo.h"
 #include "SDL_video.h"
 #include "SDL_mouse.h"
 #include "SDL_stdinc.h"
 #include "SDL_hints.h"
 #include "SDL_log.h"
+
+#include "../SDL_sysvideo.h"
 #include "../../events/SDL_events_c.h"
 #include "../../core/tizen/SDL_tizen.h"
 
index 78553b0..65709da 100755 (executable)
@@ -1,4 +1,4 @@
- /*
+/*
   Simple DirectMedia Layer
   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
 #include "SDL_video.h"
 #include "SDL_mouse.h"
 #include "SDL_stdinc.h"
+
 #include "../../events/SDL_events_c.h"
 #include "../../core/tizen/SDL_tizen.h"
 
 #include "SDL_tizenvideo.h"
-#include "SDL_tizenevents_c.h"
 #include "SDL_tizenwindow.h"
-#include "SDL_tizenopengles.h"
-#include "SDL_tizenmouse.h"
-#include "SDL_tizentouch.h"
 #include "SDL_tizenkeyboard.h"
 #include "SDL_tizenvulkan.h"
+#include "SDL_tizenopengles.h"
+#include "SDL_tizenindicator.h"
 
+#include "SDL_tizenevents_c.h"
+#include "SDL_tizenmouse.h"
 
-#define TIZENVID_DRIVER_NAME "tizen"
-
-/* Initialization/Query functions */
-static int
-Tizen_VideoInit(_THIS);
-
-static void
-Tizen_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display);
-static int
-Tizen_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
 
-static void
-Tizen_VideoQuit(_THIS);
+#define TIZENVID_DRIVER_NAME "tizen"
 
 static void
 _tizen_add_display(SDL_VideoData *d, uint32_t id)
@@ -177,13 +167,13 @@ Tizen_VideoInit(_THIS)
     return 0;
 }
 
-static void
+void
 Tizen_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
 {
     SDL_Unsupported();
 }
 
-static int
+int
 Tizen_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
 {
     return SDL_Unsupported();
@@ -200,7 +190,6 @@ Tizen_VideoQuit(_THIS)
     Tizen_FiniKeyboard();
     Tizen_FiniMouse();
 
-
     SDL_tizen_app_exit();
     ecore_wl_shutdown();
     free(data);
index de5068c..a58382a 100755 (executable)
@@ -25,6 +25,8 @@
 #ifndef _SDL_tizenvideo_h
 #define _SDL_tizenvideo_h
 
+#include "../SDL_sysvideo.h"
+
 #include <EGL/egl.h>
 #include <Ecore_Wayland.h>
 
@@ -39,6 +41,12 @@ typedef struct {
     unsigned int current_thread;
 } SDL_VideoData;
 
+/* Initialization/Query functions */
+int Tizen_VideoInit(_THIS);
+void Tizen_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display);
+int Tizen_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
+void Tizen_VideoQuit(_THIS);
+
 #endif /* _SDL_tizenvideo_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
index 77dfeaa..440811f 100755 (executable)
 */
 #include "../../SDL_internal.h"
 
-/*
-  Simple DirectMedia Layer
-  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
 #if SDL_VIDEO_VULKAN
-#include <SDL_syswm.h>
+
 #include "../SDL_sysvideo.h"
+
+#include "SDL_syswm.h"
 #include "SDL_video.h"
 #include "SDL_loadso.h"
+
 #include "SDL_tizenwindow.h"
 #include "SDL_tizenvideo.h"
-#include "SDL_tizenvideo.h"
 #include "SDL_tizenvulkan.h"
 
 #define DEFAULT_VULKAN "libvulkan.so"
index 4710f58..c552774 100755 (executable)
@@ -26,6 +26,7 @@
 
 #if SDL_VIDEO_VULKAN
 #define VK_USE_PLATFORM_WAYLAND_KHR
+
 #include <vulkan/vulkan.h>
 #include "../SDL_sysvideo.h"
 
index 80f85d1..45f4efa 100755 (executable)
 
 #if SDL_VIDEO_DRIVER_TIZEN
 
-#include "../SDL_sysvideo.h"
-#include "../../events/SDL_windowevents_c.h"
-#include "../SDL_egl_c.h"
-#include "SDL_tizenwindow.h"
+#include "SDL_log.h"
+#include "SDL_hints.h"
+#include "SDL_loadso.h"
+
+#include "SDL_tizenindicator.h"
+
 #include "SDL_tizenvideo.h"
 #include "SDL_tizentouch.h"
 #include "SDL_tizenkeyboard.h"
-
 #include "SDL_tizenmouse.h"
 #include "SDL_tizenevents_c.h"
-#include "SDL_log.h"
-#include "SDL_hints.h"
+
+#include "SDL_tizenwindow.h"
+
 #include "../../events/SDL_mouse_c.h"
 #include "../../joystick/tizen/SDL_sysjoystick_c.h"
-#include <wayland-egl.h>
+
+#include "../SDL_egl_c.h"
+#include "../SDL_sysvideo.h"
+#include "../../events/SDL_windowevents_c.h"
+
+#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) \
+{ \
+    SDL_SetError("Could not retrieve pre-rotation function " #NAME); \
+    return SDL_FALSE; \
+}
 
 int
 _tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path)
@@ -49,7 +62,7 @@ _tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path)
     if (_this->isLoaded_pre_rotation)
         return SDL_TRUE;
 
-    _this->tizen_pre_rotation_data = (struct Tizen_Prerotation_Data *) SDL_calloc(1, sizeof(Tizen_Prerotation_Data));
+    _this->tizen_pre_rotation_data = (Tizen_Prerotation_Data *) SDL_calloc(1, sizeof(Tizen_Prerotation_Data));
     if (!_this->tizen_pre_rotation_data) {
         return SDL_OutOfMemory();
     }
@@ -67,14 +80,8 @@ _tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path)
     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;
-
+    LOAD_FUNC(wl_egl_window_set_rotation);
+    LOAD_FUNC(wl_egl_window_get_capabilities);
     _this->isLoaded_pre_rotation = 1;
 
     return SDL_TRUE;
@@ -281,7 +288,6 @@ Tizen_CreateWindow(_THIS, SDL_Window *window)
         //Support PreRotation
         wind->support_pre_rotation = 0;
         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");
@@ -442,7 +448,6 @@ _tizen_cb_window_configure(void *data, int type EINA_UNUSED, void *event)
    SDL_Window *window;
    SDL_WindowData *wind;
    Ecore_Wl_Event_Window_Configure *ev;
-   int nx = 0, ny = 0, nw = 0, nh = 0;
    ev = event;
    ew = ecore_wl_window_find(ev->win);
    window = Tizen_FindWindow(_this, ew);
@@ -452,6 +457,7 @@ _tizen_cb_window_configure(void *data, int type EINA_UNUSED, void *event)
       return ECORE_CALLBACK_PASS_ON;
    }
 /*
+   int nx = 0, ny = 0, nw = 0, nh = 0;
   SDL_Log( "configure notify window: %p, ecore_wl_window: %p\n", window, ew);
 
    ecore_wl_window_geometry_get(ew, &nx, &ny, &nw, &nh);
@@ -542,7 +548,7 @@ _tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event)
     wind->received_rotation = 1;
     const char* hint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
     if(hint && *hint != '\0')
-        SDL_IndicatorProcessEvent(_this->current_glwin, wind->rotation);
+        Tizen_IndicatorProcessEvent(_this->current_glwin, wind->rotation);
 
     return ECORE_CALLBACK_PASS_ON;
 }
index 8e051f4..565fe68 100755 (executable)
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
 */
-#include <Ecore_Input.h>
-
 #include "../../SDL_internal.h"
 
 #ifndef _SDL_tizenwindow_h
 #define _SDL_tizenwindow_h
 
 #include "../SDL_sysvideo.h"
+
 #include "SDL_syswm.h"
 
 #include "SDL_tizenvideo.h"
+#include <Ecore_Input.h>
+#include <wayland-egl.h>
 
 typedef struct Tizen_PreRotation_Data{
     void *prerotation_dll_handle;
@@ -58,7 +59,6 @@ typedef struct {
 
 } SDL_WindowData;
 
-
 extern SDL_Window* Tizen_FindWindow(_THIS, Ecore_Wl_Window *ewin);
 extern void Tizen_ShowWindow(_THIS, SDL_Window *window);
 extern void Tizen_SetWindowFullscreen(_THIS, SDL_Window *window,