[Title] prepare sdl video resize
authorgiwoong.kim <giwoong.kim@samsung.com>
Sat, 17 Mar 2012 11:39:09 +0000 (20:39 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Sat, 17 Mar 2012 11:39:09 +0000 (20:39 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/emul_state.c
tizen/src/emul_state.h [changed mode: 0755->0644]
tizen/src/emulator.c
tizen/src/emulator.h [changed mode: 0755->0644]
tizen/src/maru_sdl.c
tizen/src/maru_sdl.h
tizen/src/sdl_zoom.c [changed mode: 0755->0644]
tizen/src/sdl_zoom.h [changed mode: 0755->0644]
tizen/src/skin/maruskin_operation.c [changed mode: 0755->0644]
tizen/src/skin/maruskin_operation.h
tizen/src/skin/maruskin_server.c

index a6e6c094459a1e0bf20695c92fb826aada810594..b8d9fa8ce2cb6bb8d1faea71f13db5f23551eeb3 100644 (file)
@@ -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;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 346f8cb..5d5e5b9
@@ -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);
 
 
index 1c50b7dcd1cddb8e7c902e4cfa7dc2f6a38c6bcd..6d4dffd5bf61db3451e6755b064662fa30357912 100644 (file)
@@ -43,7 +43,7 @@
 #include "process.h"
 #include "option.h"
 #include "emul_state.h"
-#include "sdl_rotate.h"
+
 #ifdef _WIN32
 #include <winsock2.h>
 #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);
 
 
old mode 100755 (executable)
new mode 100644 (file)
index af32767d09758478fcaca4c62a5ac1f489a38db8..69bc0e80ca401b7e0d55e270ed00573342035c16 100644 (file)
@@ -31,6 +31,7 @@
 #include <pthread.h>
 #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);
+}
index 3ea67cd8817cc71efdc3dcb39a3873573f2bc6d4..a3394492aa23c88da36e314b08f13fd0fee7c914 100644 (file)
@@ -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_ */
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index b816e36..c1a9bdf
@@ -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 );
index a3c43a25a0e981bbe55d1daf5011213d40a40362..e04386d4283730fff62d2498892ee53d42bab613 100644 (file)
@@ -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);
 
index 76871b44008dd5c71f9980b6cc265b469d16ca48..3290aa8e91d655b4aec9f9bcf769518e726bca26 100644 (file)
@@ -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;
                 }