From 047a8c5ac86f7d847d2e03692ac3060deb5b884a Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Thu, 12 Jul 2012 10:49:38 +0900 Subject: [PATCH] [Title] sdl init refactoring [Type] enhancement [Module] Emulator / sdl [Priority] minor [Jira#] [Redmine#] [Problem] [Cause] prepare to OpenGL conditions [Solution] [TestCase] --- tizen/src/maru_sdl.c | 101 +++++++++++++++++------------------- tizen/src/maru_sdl.h | 2 +- tizen/src/skin/maruskin_operation.c | 2 +- 3 files changed, 49 insertions(+), 56 deletions(-) diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 731e318..8a357df 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -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) diff --git a/tizen/src/maru_sdl.h b/tizen/src/maru_sdl.h index 9b6ef15..3b56bf4 100644 --- a/tizen/src/maru_sdl.h +++ b/tizen/src/maru_sdl.h @@ -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 ); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index e7c7566..a7d204b 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -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 ) -- 2.7.4