From: giwoong.kim Date: Sat, 17 Mar 2012 11:39:09 +0000 (+0900) Subject: [Title] prepare sdl video resize X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1791 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8dade2b9736c3314d5ff7d198f2a9401450d1025;p=sdk%2Femulator%2Fqemu.git [Title] prepare sdl video resize [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index a6e6c09445..b8d9fa8ce2 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -59,25 +59,25 @@ int get_emul_lcd_height(void) } /* emulator window scale */ -void set_emul_win_scale(int scale) +void set_emul_win_scale(double scale_factor) { - _emul_state.scale = scale; - INFO("emulator window scale = %d\n", _emul_state.scale); + _emul_state.scale_factor = scale_factor; + INFO("emulator window scale_factor = %d\n", _emul_state.scale_factor); } -int get_emul_win_scale(void) +double get_emul_win_scale(void) { - return _emul_state.scale; + return _emul_state.scale_factor; } /* emulator rotation */ -void set_emul_rotation(short rotation) +void set_emul_rotation(short rotation_type) { - _emul_state.rotation = rotation; - INFO("emulator rotation = %d\n", _emul_state.rotation); + _emul_state.rotation_type = rotation_type; + INFO("emulator rotation type = %d\n", _emul_state.rotation_type); } short get_emul_rotation(void) { - return _emul_state.rotation; + return _emul_state.rotation_type; } diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h old mode 100755 new mode 100644 index 346f8cb1f4..5d5e5b95e0 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -48,21 +48,21 @@ typedef struct emulator_config_info { } emulator_config_info; typedef struct emulator_config_state { - int scale; - short rotation; + double scale_factor; + short rotation_type; //TODO: } emulator_config_state; /* setter */ void set_emul_lcd_size(int width, int height); -void set_emul_win_scale(int scale); -void set_emul_rotation(short scale); +void set_emul_win_scale(double scale); +void set_emul_rotation(short rotation_type); /* getter */ int get_emul_lcd_width(void); int get_emul_lcd_height(void); -int get_emul_win_scale(void); +double get_emul_win_scale(void); short get_emul_rotation(void); diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 1c50b7dcd1..6d4dffd5bf 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -43,7 +43,7 @@ #include "process.h" #include "option.h" #include "emul_state.h" -#include "sdl_rotate.h" + #ifdef _WIN32 #include #endif @@ -85,7 +85,7 @@ static void construct_main_window(int skin_argc, char* skin_argv[]) INFO("construct main window\n"); //TODO: init - set_emul_win_scale(50); + set_emul_win_scale(0.5); set_emul_rotation(0); diff --git a/tizen/src/emulator.h b/tizen/src/emulator.h old mode 100755 new mode 100644 diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index af32767d09..69bc0e80ca 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -31,6 +31,7 @@ #include #include "maru_sdl.h" #include "emul_state.h" +#include "sdl_rotate.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL(tizen, maru_sdl); @@ -48,25 +49,27 @@ static pthread_cond_t sdl_cond = PTHREAD_COND_INITIALIZER; static int sdl_thread_initialized = 0; #endif +#define SDL_FLAGS (SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME) + static void qemu_update(void) { #ifndef SDL_THREAD pthread_mutex_lock(&sdl_mutex); #endif SDL_Surface *processing_screen; - double angle = 0.0; + double angle = 0.0; //ROTATION_PORTRAIT //TODO: convert type define to angle value short rotaton_type = get_emul_rotation(); - if (rotaton_type == 1) { + if (rotaton_type == ROTATION_LANDSCAPE) { angle = 90.0; - } else if (rotaton_type == 2) { + } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) { angle = 180.0; - } else if (rotaton_type == 3) { + } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) { angle = 270.0; } - processing_screen = rotozoomSurface(surface_qemu, angle, ((double)get_emul_win_scale()) / 100, 1); + processing_screen = rotozoomSurface(surface_qemu, angle, get_emul_win_scale(), 1); SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL); SDL_UpdateRect(surface_screen, 0, 0, 0, 0); @@ -148,9 +151,18 @@ static void qemu_ds_refresh(DisplayState *ds) while (SDL_PollEvent(ev)) { switch (ev->type) { - case SDL_KEYDOWN: - case SDL_KEYUP: + case SDL_VIDEORESIZE: + { + SDL_ResizeEvent *rev = &ev->resize; + SDL_Quit(); + + surface_screen = SDL_SetVideoMode(rev->w, rev->h, 0, SDL_FLAGS); + if (surface_screen == NULL) { + //TODO : SDL_GetError + } break; + } + default: break; } @@ -200,8 +212,10 @@ void maruskin_sdl_init(int swt_handle, int lcd_size_width, int lcd_size_height) } INFO( "qemu_sdl_initialize\n"); - surface_screen = SDL_SetVideoMode(lcd_size_width, lcd_size_height, - 0, SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME); + surface_screen = SDL_SetVideoMode(lcd_size_width, lcd_size_height, 0, SDL_FLAGS); + if (surface_screen == NULL) { + //TODO : SDL_GetError + } set_emul_lcd_size(lcd_size_width, lcd_size_height); #ifndef _WIN32 @@ -209,3 +223,15 @@ void maruskin_sdl_init(int swt_handle, int lcd_size_width, int lcd_size_height) SDL_GetWMInfo(&info); #endif } + +void maruskin_sdl_resize(int w, int h) +{ + SDL_Event ev; + + /* this fails if SDL is not initialized */ + memset(&ev, 0, sizeof(ev)); + ev.resize.type = SDL_VIDEORESIZE; + ev.resize.w = w; + ev.resize.h = h; + SDL_PushEvent(&ev); +} diff --git a/tizen/src/maru_sdl.h b/tizen/src/maru_sdl.h index 3ea67cd881..a3394492aa 100644 --- a/tizen/src/maru_sdl.h +++ b/tizen/src/maru_sdl.h @@ -45,5 +45,6 @@ void maruskin_display_init(DisplayState *ds); void maruskin_sdl_init(int swt_handle, int lcd_size_width, int lcd_size_height); +void maruskin_sdl_resize(int w, int h); #endif /* MARU_SDL_H_ */ diff --git a/tizen/src/sdl_zoom.c b/tizen/src/sdl_zoom.c old mode 100755 new mode 100644 diff --git a/tizen/src/sdl_zoom.h b/tizen/src/sdl_zoom.h old mode 100755 new mode 100644 diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c old mode 100755 new mode 100644 index b816e36395..c1a9bdf52b --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -39,7 +39,6 @@ #include "nbd.h" #include "../mloop_event.h" #include "emul_state.h" -#include "sdl_rotate.h" #ifndef _WIN32 #include "maruskin_keymap.h" @@ -63,9 +62,9 @@ enum { KEY_RELEASED = 2, }; -void start_display( int handle_id, int lcd_size_width, int lcd_size_height, int scale, short rotation ) { - INFO( "start_display handle_id:%d, lcd size:%dx%d, scale:%d, rotation:%d\n", - handle_id, lcd_size_width, lcd_size_height, scale, rotation ); +void start_display( int handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short rotation ) { + INFO( "start_display handle_id:%d, lcd size:%dx%d, scale_factor:%lf, rotation:%d\n", + handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation ); maruskin_sdl_init(handle_id, lcd_size_width, lcd_size_height); } @@ -127,36 +126,46 @@ void do_hardkey_event( int event_type, int keycode ) { } -void do_scale_event( int event_type) { - INFO( "do_scale_event event_type:%d", event_type); +void do_scale_event( double scale_factor ) { + INFO( "do_scale_event scale_factor:%lf", scale_factor); + + /*int rotation_type = get_emul_rotation(); + if (rotation_type == ROTATION_PORTRAIT || rotation_type == ROTATION_REVERSE_PORTRAIT) { + maruskin_sdl_resize(get_emul_lcd_width() * scale_factor, get_emul_lcd_height() * scale_factor); + } else if (rotation_type == ROTATION_LANDSCAPE || rotation_type == ROTATION_REVERSE_LANDSCAPE) { + maruskin_sdl_resize(get_emul_lcd_height() * scale_factor, get_emul_lcd_width() * scale_factor); + }*/ //qemu refresh vga_hw_invalidate(); vga_hw_update(); - set_emul_win_scale(event_type); + set_emul_win_scale(scale_factor); } -void do_rotation_event( int event_type) { +void do_rotation_event( int rotation_type) { - INFO( "do_rotation_event event_type:%d", event_type); + INFO( "do_rotation_event rotation_type:%d", rotation_type); int buf_size = 32; char send_buf[32] = { 0 }; - switch ( event_type ) { - case ROTATION_PORTRAIT: - sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" ); - break; - case ROTATION_LANDSCAPE: - sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" ); - break; - case ROTATION_REVERSE_PORTRAIT: - sprintf( send_buf, "1\n3\n-9.80665\n0\n0\n" ); - break; - case ROTATION_REVERSE_LANDSCAPE: - sprintf(send_buf, "1\n3\n9.80665\n0\n0\n"); - break; + switch ( rotation_type ) { + case ROTATION_PORTRAIT: + sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" ); + break; + case ROTATION_LANDSCAPE: + sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" ); + break; + case ROTATION_REVERSE_PORTRAIT: + sprintf( send_buf, "1\n3\n-9.80665\n0\n0\n" ); + break; + case ROTATION_REVERSE_LANDSCAPE: + sprintf(send_buf, "1\n3\n9.80665\n0\n0\n"); + break; + + default: + break; } // send_to_sensor_daemon @@ -175,7 +184,12 @@ void do_rotation_event( int event_type) { INFO( "send to sendord(size: %d) 127.0.0.1:%d/tcp \n", buf_size, tizen_base_port + SDB_TCP_EMULD_INDEX); - set_emul_rotation(event_type); + /*if (rotation_type == ROTATION_PORTRAIT || rotation_type == ROTATION_REVERSE_PORTRAIT) { + maruskin_sdl_resize(get_emul_lcd_width(), get_emul_lcd_height()); + } else if (rotation_type == ROTATION_LANDSCAPE || rotation_type == ROTATION_REVERSE_LANDSCAPE) { + maruskin_sdl_resize(get_emul_lcd_height(), get_emul_lcd_width()); + }*/ + set_emul_rotation(rotation_type); #ifdef _WIN32 closesocket( s ); diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index a3c43a25a0..e04386d428 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -30,7 +30,7 @@ #ifndef MARUSKIN_OPERATION_H_ #define MARUSKIN_OPERATION_H_ -void start_display( int handle_id, int lcd_size_width, int lcd_size_height, int scale, short direction ); +void start_display( int handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short direction ); void do_mouse_event( int event_type, int x, int y, int z ); @@ -38,9 +38,9 @@ void do_key_event( int event_type, int keycode ); void do_hardkey_event( int event_type, int keycode ); -void do_scale_event( int event_type); +void do_scale_event( double scale_factor); -void do_rotation_event( int event_type ); +void do_rotation_event( int rotation_type ); void open_shell(void); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 76871b4400..3290aa8e91 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -331,6 +331,7 @@ static void* run_skin_server( void* args ) { int lcd_size_width = 0; int lcd_size_height = 0; int scale = 0; + double scale_ratio = 0.0; short rotation = 0; char* p = readbuf; @@ -348,12 +349,13 @@ static void* run_skin_server( void* args ) { lcd_size_width = ntohl( lcd_size_width ); lcd_size_height = ntohl( lcd_size_height ); scale = ntohl( scale ); + scale_ratio = ((double)scale) / 100; rotation = ntohs( rotation ); - set_emul_win_scale(scale); + set_emul_win_scale(scale_ratio); if ( start_heart_beat( client_sock ) ) { - start_display( handle_id, lcd_size_width, lcd_size_height, scale, rotation ); + start_display( handle_id, lcd_size_width, lcd_size_height, scale_ratio, rotation ); } else { stop_server = 1; } @@ -438,22 +440,24 @@ static void* run_skin_server( void* args ) { } int scale = 0; - short rotation = 0; + double scale_ratio = 0.0; + short rotation_type = 0; char* p = readbuf; memcpy( &scale, p, sizeof( scale ) ); p += sizeof( scale ); - memcpy( &rotation, p, sizeof( rotation ) ); + memcpy( &rotation_type, p, sizeof( rotation_type ) ); scale = ntohl( scale ); - rotation = ntohs( rotation ); + scale_ratio = ((double)scale) / 100; + rotation_type = ntohs( rotation_type ); - if ( get_emul_win_scale() != scale ) { - do_scale_event( scale ); + if ( get_emul_win_scale() != scale_ratio ) { + do_scale_event( scale_ratio ); } - if ( is_sensord_initialized == 1 && get_emul_rotation() != rotation ) { - do_rotation_event( rotation ); + if ( is_sensord_initialized == 1 && get_emul_rotation() != rotation_type ) { + do_rotation_event( rotation_type ); } break; }