move indicator flags to SDL_WindowData 92/99192/2
authorMaJunqing <junqing.ma@samsung.com>
Tue, 22 Nov 2016 06:48:25 +0000 (14:48 +0800)
committerMaJunqing <junqing.ma@samsung.com>
Tue, 22 Nov 2016 08:03:55 +0000 (16:03 +0800)
Change-Id: Ia212c075200ef72fa5d6adb24524dd84d42f137d

src/events/SDL_events.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/tizen/SDL_tizenmouse.c
src/video/tizen/SDL_tizenopengles.c
src/video/tizen/SDL_tizenwindow.c
src/video/tizen/SDL_tizenwindow.h

index 9e49cf0..93a4d41 100755 (executable)
@@ -472,11 +472,15 @@ SDL_PushEvent(SDL_Event * event)
 
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
     SDL_GestureProcessEvent(event);
-    if(event->type == SDL_ROTATEEVENT && SDL_GetHint(SDL_HINT_ORIENTATIONS))
+    const char* hint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
+    if(event->type == SDL_ROTATEEVENT )
     {
-        if(*(SDL_GetHint(SDL_HINT_ORIENTATIONS)) != '\0')
+        if(hint)
         {
-            SDL_IndicatorProcessEvent(event, _this->current_glwin);
+            if(*hint != '\0')
+            {
+               SDL_IndicatorProcessEvent(event, _this->current_glwin);
+            }
         }
     }
     return 1;
index 0326bec..1f99689 100755 (executable)
@@ -108,9 +108,6 @@ struct SDL_Window
     SDL_Window *prev;
     SDL_Window *next;
 
-    SDL_bool indicator_show;
-    Uint32 last_indicator_showtime;
-    int indicator_type;
 };
 #define FULLSCREEN_VISIBLE(W) \
     (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
index e5fc528..afc1905 100755 (executable)
@@ -1427,7 +1427,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
     window->next = _this->windows;
     window->is_destroying = SDL_FALSE;
 
-    window->indicator_type = 0;
 
     if (_this->windows) {
         _this->windows->prev = window;
index 947068d..e365853 100755 (executable)
@@ -259,52 +259,54 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event)
     Ecore_Event_Mouse_Button *e = event;
     Ecore_Wl_Window *ew;
     SDL_Window *window;
+    SDL_WindowData *wind;
 
     ew = ecore_wl_window_find(e->window);
     window = Tizen_FindWindow(_this, ew);
+    wind = window->driverdata;
 
     SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)",e->x,e->y);
-    if(window->indicator_type == 0)
+    if(wind->indicator_type == 0)
     {
         if(e->x > window->x && e->x <  window->x + window->w &&
             e->y > window->y && e->y < window->y + 52)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            window->indicator_show = SDL_TRUE;
-            window->last_indicator_showtime = SDL_GetTicks();
+            wind->indicator_show = SDL_TRUE;
+            wind->last_indicator_showtime = SDL_GetTicks();
             _tizen_indicator_event_filter();
         }
     }
-    else if(window->indicator_type == 1)
+    else if(wind->indicator_type == 1)
     {
         if(e->x > window->x && e->x <  window->x + 52 &&
             e->y > window->y && e->y < window->y + window->h)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            window->indicator_show = SDL_TRUE;
-            window->last_indicator_showtime = SDL_GetTicks();
+            wind->indicator_show = SDL_TRUE;
+            wind->last_indicator_showtime = SDL_GetTicks();
             _tizen_indicator_event_filter();
         }
     }
-    else if(window->indicator_type == 2)
+    else if(wind->indicator_type == 2)
     {
         if(e->x > window->x && e->x <  window->x + window->w  &&
             e->y > window->y + window->h -52 && e->y < window->y + window->h)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            window->indicator_show = SDL_TRUE;
-            window->last_indicator_showtime = SDL_GetTicks();
+            wind->indicator_show = SDL_TRUE;
+            wind->last_indicator_showtime = SDL_GetTicks();
             _tizen_indicator_event_filter();
         }
     }
-    else if(window->indicator_type == 3)
+    else if(wind->indicator_type == 3)
     {
         if(e->x > window->x + window->w -52 && e->x <  window->x + window->w  &&
             e->y > window->y && e->y < window->y + window->h)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            window->indicator_show = SDL_TRUE;
-            window->last_indicator_showtime = SDL_GetTicks();
+            wind->indicator_show = SDL_TRUE;
+            wind->last_indicator_showtime = SDL_GetTicks();
             _tizen_indicator_event_filter();
         }
     }
index 86df032..34f8d26 100755 (executable)
@@ -93,11 +93,11 @@ _tizen_indicator_event_filter()
     SDL_Window *window = SDL_GetVideoDevice()->windows;
     SDL_WindowData *wind = window->driverdata;
 
-    if(window->indicator_show && wind->indicator_timer == NULL)
+    if(wind->indicator_show && wind->indicator_timer == NULL)
     {
         wind->indicator_timer = ecore_timer_add(0.02, _tizen_timer_callback_indicator, NULL);
     }
-    else if(!window->indicator_show && wind->indicator_timer != NULL)
+    else if(!wind->indicator_show && wind->indicator_timer != NULL)
     {
         ecore_timer_del(wind ->indicator_timer);
         wind->indicator_timer = NULL;
@@ -218,9 +218,9 @@ void drawIndicator(SDL_Window *window)
         wdata->received_rotation = 0;
     }
 
-    if(window->last_indicator_showtime + 3000< SDL_GetTicks())
+    if(wdata->last_indicator_showtime + 3000< SDL_GetTicks())
     {
-        switch(window->indicator_type)
+        switch(wdata->indicator_type)
         {
         case 0://0
             ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f);
@@ -237,12 +237,12 @@ void drawIndicator(SDL_Window *window)
         }
     }
 
-    if(window->last_indicator_showtime + 3500 <SDL_GetTicks()) {
-        window->indicator_show = SDL_FALSE;
+    if(wdata->last_indicator_showtime + 3500 <SDL_GetTicks()) {
+        wdata->indicator_show = SDL_FALSE;
         _tizen_indicator_event_filter();
     }
 
-    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && window->indicator_show)
+    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && wdata->indicator_show)
     {
         GLES2_Context Mainctx;
         LoadContext(&Mainctx);
@@ -368,8 +368,8 @@ static int Indicator_GLES_Init(SDL_Window* window)
     if(fileInfo.ImageWidth != 0 && fileInfo.ImageHeight != 0)
         Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
 
-    window->indicator_show = SDL_TRUE;
-    window->last_indicator_showtime = SDL_GetTicks();
+    wind->indicator_show = SDL_TRUE;
+    wind->last_indicator_showtime = SDL_GetTicks();
 
     _tizen_indicator_event_filter();
 
@@ -397,7 +397,7 @@ Tizen_GLES_CreateContext(_THIS, SDL_Window *window)
 void
 Tizen_GLES_SwapWindow(_THIS, SDL_Window *window)
 {
-    if(!window->indicator_show) {
+    if(!((SDL_WindowData*)window->driverdata)->indicator_show) {
         drawIndicator(window);
         SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
     }
@@ -429,10 +429,12 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window)
     GLES2_Context Mainctx;
     LoadContext(&Mainctx);
 
+   SDL_WindowData *wind = window->driverdata;
+
     if(event->type == SDL_ROTATEEVENT)
     {
-        window->indicator_type = ((int)event->user.data1) / 90;
-        if( window->indicator_type == 0)
+        wind->indicator_type = ((int)event->user.data1) / 90;
+        if( wind->indicator_type == 0)
         {
             SDL_Log("===rotate 0 degree!\n");
             vVertices[0] = 1.0f;
@@ -462,7 +464,7 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window)
             vCoord[11] = 1.0f;
 
         }
-        else if(window->indicator_type == 1)
+        else if(wind->indicator_type == 1)
         {
             SDL_Log("===rotate 90 degree!\n");
             vVertices[0] = -0.86f;
@@ -491,7 +493,7 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window)
             vCoord[10] = 1.0f;
             vCoord[11] = 0.0f;
         }
-        else if(window->indicator_type == 2)
+        else if(wind->indicator_type == 2)
         {
             SDL_Log("===rotate 180 degree!\n");
             vVertices[0] = -1.0f;
@@ -520,7 +522,7 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window)
             vCoord[10] = 0.0f;
             vCoord[11] = 0.0f;
         }
-        else if(window->indicator_type == 3)
+        else if(wind->indicator_type == 3)
         {
             SDL_Log("===rotate 270 degree!\n");
             vVertices[0] = 1.0f;
@@ -550,9 +552,9 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window)
             vCoord[11] = 0.0f;
         }
 
-        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo[window->indicator_type]);
+        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_vbo[wind->indicator_type]);
         Mainctx.glBufferData(GL_ARRAY_BUFFER, 18 * 4, vVertices, GL_STATIC_DRAW);
-        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[window->indicator_type]);
+        Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[wind->indicator_type]);
         Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW);
 
         Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
@@ -561,8 +563,8 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window)
             Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
 
         ModelMatrixLoadIdentity(&mMatrix);
-        window->indicator_show = SDL_TRUE;
-        window->last_indicator_showtime = SDL_GetTicks();
+        wind->indicator_show = SDL_TRUE;
+        wind->last_indicator_showtime = SDL_GetTicks();
 
         _tizen_indicator_event_filter();
 
index 39f66a9..b329cdc 100755 (executable)
@@ -191,6 +191,7 @@ Tizen_CreateWindow(_THIS, SDL_Window *window)
     wind->rotation = 0;
     wind->rotation_supported = 0;
     wind->received_rotation = 0;
+    wind->indicator_type = 0;
     ecore_wl_window_opaque_region_set(wind->window, window->x, window->y, window->w, window->h);
 
 #if SDL_VIDEO_OPENGL_EGL
index 39b4d0f..1ee4e91 100755 (executable)
@@ -43,6 +43,10 @@ typedef struct {
     int received_rotation;
     void *indicator_timer;
 
+    SDL_bool indicator_show;
+    Uint32 last_indicator_showtime;
+    int indicator_type;
+
 } SDL_WindowData;