[Title] sdl init refactoring
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 12 Jul 2012 01:49:38 +0000 (10:49 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 12 Jul 2012 01:49:38 +0000 (10:49 +0900)
[Type] enhancement
[Module] Emulator / sdl
[Priority] minor
[Jira#]
[Redmine#]
[Problem]
[Cause] prepare to OpenGL conditions
[Solution]
[TestCase]

tizen/src/maru_sdl.c
tizen/src/maru_sdl.h
tizen/src/skin/maruskin_operation.c

index 731e31890e1a7dcd525de1baef5d5940f317fb62..8a357df9a6747ea87fa84d1dcf5299c4c52ff1fd 100644 (file)
@@ -36,6 +36,7 @@
 #include "maru_finger.h"
 #include "hw/maru_pm.h"
 #include "debug_ch.h"
+//#include "SDL_opengl.h"
 
 MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
 
@@ -234,40 +235,12 @@ static void qemu_ds_refresh(DisplayState *ds)
         switch (ev->type) {
             case SDL_VIDEORESIZE:
             {
-                int w, h, temp;
-
-                //get current setting information and calculate screen size
-                scale_factor = get_emul_win_scale();
-                w = get_emul_lcd_width() * scale_factor;
-                h = get_emul_lcd_height() * scale_factor;
-
-                short rotaton_type = get_emul_rotation();
-                if (rotaton_type == ROTATION_PORTRAIT) {
-                    screen_degree = 0.0;
-                } else if (rotaton_type == ROTATION_LANDSCAPE) {
-                    screen_degree = 90.0;
-                    temp = w;
-                    w = h;
-                    h = temp;
-                } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
-                    screen_degree = 180.0;
-                } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
-                    screen_degree = 270.0;
-                    temp = w;
-                    w = h;
-                    h = temp;
-                }
-
                 pthread_mutex_lock(&sdl_mutex);
 
                 SDL_Quit(); //The returned surface is freed by SDL_Quit and must not be freed by the caller
-                surface_screen = SDL_SetVideoMode(w, h, SDL_BPP, SDL_FLAGS);
-                if (surface_screen == NULL) {
-                    ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, SDL_BPP, SDL_GetError());
-                }
+                maruskin_sdl_init(0, get_emul_lcd_width(), get_emul_lcd_height(), true);
 
                 pthread_mutex_unlock(&sdl_mutex);
-
                 break;
             }
             case SDL_USEREVENT: {
@@ -294,44 +267,50 @@ void maruskin_display_init(DisplayState *ds)
     dcl->dpy_refresh = qemu_ds_refresh;
 
     register_displaychangelistener(ds, dcl);
-
-#ifdef SDL_THREAD
-    if (sdl_thread_initialized == 0) {
-        sdl_thread_initialized = 1;
-        pthread_t thread_id;
-        INFO( "sdl update thread create\n");
-        if (pthread_create(&thread_id, NULL, run_qemu_update, NULL) != 0) {
-            ERR( "pthread_create fail\n");
-            return;
-        }
-    }
-#endif
 }
 
-void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height)
+void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize)
 {
-    int w, h;
+    int w, h, temp;
     gchar SDL_windowhack[32];
     SDL_SysWMinfo info;
     long window_id = swt_handle;
 
-    sprintf(SDL_windowhack, "%ld", window_id);
-    g_setenv("SDL_WINDOWID", SDL_windowhack, 1);
-    INFO("register SDL environment variable. (SDL_WINDOWID = %s)\n", SDL_windowhack);
+    if (is_resize == FALSE) {
+        sprintf(SDL_windowhack, "%ld", window_id);
+        g_setenv("SDL_WINDOWID", SDL_windowhack, 1);
+        INFO("register SDL environment variable. (SDL_WINDOWID = %s)\n", SDL_windowhack);
 
-    if (SDL_Init(SDL_INIT_VIDEO) < 0 ) {
-        ERR( "unable to init SDL: %s", SDL_GetError() );
-        exit(1);
-    }
+        if (SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+            ERR( "unable to init SDL: %s", SDL_GetError() );
+            exit(1);
+        }
 
-    set_emul_lcd_size(lcd_size_width, lcd_size_height);
+        set_emul_lcd_size(lcd_size_width, lcd_size_height);
+        set_emul_sdl_bpp(SDL_BPP);
+    }
 
     //get current setting information and calculate screen size
     scale_factor = get_emul_win_scale();
     w = lcd_size_width * scale_factor;
     h = lcd_size_height * scale_factor;
 
-    set_emul_sdl_bpp(SDL_BPP);
+    short rotaton_type = get_emul_rotation();
+    if (rotaton_type == ROTATION_PORTRAIT) {
+        screen_degree = 0.0;
+    } else if (rotaton_type == ROTATION_LANDSCAPE) {
+        screen_degree = 90.0;
+        temp = w;
+        w = h;
+        h = temp;
+    } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
+        screen_degree = 180.0;
+    } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
+        screen_degree = 270.0;
+        temp = w;
+        w = h;
+        h = temp;
+    }
 
     INFO( "maru sdl initialization\n");
     surface_screen = SDL_SetVideoMode(w, h, get_emul_sdl_bpp(), SDL_FLAGS);
@@ -339,13 +318,27 @@ void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_heigh
         ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, get_emul_sdl_bpp(), SDL_GetError());
     }
 
+#ifdef SDL_THREAD
+    if (sdl_thread_initialized == 0) {
+        sdl_thread_initialized = 1;
+        pthread_t thread_id;
+        INFO( "sdl update thread create\n");
+        if (pthread_create(&thread_id, NULL, run_qemu_update, NULL) != 0) {
+            ERR( "pthread_create fail\n");
+            return;
+        }
+    }
+#endif
+
 #ifndef _WIN32
     SDL_VERSION(&info.version);
     SDL_GetWMInfo(&info);
 #endif
 
-    sdl_initialized = 1;
-    init_multi_touch_state();
+    if (sdl_initialized == 0) {
+        sdl_initialized = 1;
+        init_multi_touch_state();
+    }
 }
 
 void maruskin_sdl_resize(void)
index 9b6ef1580748aa8ffc6343161969eb9807ec7182..3b56bf4e98bd4ecc713a2bee319debf8b15ca67e 100644 (file)
@@ -47,7 +47,7 @@
 #define SDL_USER_EVENT_CODE_HARDKEY 1
 
 void maruskin_display_init(DisplayState *ds);
-void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height);
+void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
 void maruskin_sdl_resize(void);
 
 DisplaySurface* get_qemu_display_surface( void );
index e7c7566963c3d7e73747e16787beb21e2d95e227..a7d204bbebdb2b2e53c201fa5d0aaabbbbd1072e 100644 (file)
@@ -67,7 +67,7 @@ void start_display(uint64 handle_id, int lcd_size_width, int lcd_size_height, do
         handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation_type );
 
     set_emul_win_scale(scale_factor);
-    maruskin_sdl_init(handle_id, lcd_size_width, lcd_size_height);
+    maruskin_sdl_init(handle_id, lcd_size_width, lcd_size_height, false);
 }
 
 void do_mouse_event( int event_type, int origin_x, int origin_y, int x, int y, int z )