emul_state: cleaned-up display resolution state management
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Sun, 9 Aug 2015 05:26:15 +0000 (14:26 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 10 Aug 2015 07:43:14 +0000 (16:43 +0900)
Change-Id: Ic8a8169e8e7e8f328488d2a67d149f0ded2d338a
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
12 files changed:
tizen/src/display/maru_sdl.c
tizen/src/display/maru_shm.c
tizen/src/display/qt5_supplement.cpp
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/emulator.c
tizen/src/emulator_legacy.c
tizen/src/eventcast/encode_fb.c
tizen/src/eventcast/touch.c
tizen/src/skin/maruskin_operation.c
tizen/src/ui/displayswapper.cpp
vl.c

index 766ca088f4c9164b44c36b068eabb333f64d3b1f..a3c30874b657372a2a53e9b77d59d375e42279ad 100644 (file)
@@ -137,8 +137,8 @@ static void qemu_ds_sdl_switch(DisplayChangeListener *dcl,
     PixelFormat pf = qemu_pixelformat_from_pixman(dpy_surface->format);
 
     /* create surface_qemu */
-    if (console_width == get_emul_resolution_width() &&
-        console_height == get_emul_resolution_height()) {
+    if (console_width == get_display_resolution_width() &&
+        console_height == get_display_resolution_height()) {
         INFO("create SDL screen : (%d, %d)\n",
              console_width, console_height);
 
@@ -153,7 +153,8 @@ static void qemu_ds_sdl_switch(DisplayChangeListener *dcl,
             pf.amask);
     } else {
         INFO("create blank screen : (%d, %d)\n",
-             get_emul_resolution_width(), get_emul_resolution_height());
+            get_display_resolution_width(),
+            get_display_resolution_height());
 
         surface_qemu = SDL_CreateRGBSurface(
             SDL_SWSURFACE,
@@ -401,8 +402,8 @@ static void maru_sdl_resize_bh(void *opaque)
 #endif
 
     /* get current setting information and calculate screen size */
-    display_width = get_emul_resolution_width();
-    display_height = get_emul_resolution_height();
+    display_width = get_display_resolution_width();
+    display_height = get_display_resolution_height();
     current_scale_factor = get_emul_win_scale();
 
     short rotaton_type = get_emul_rotation();
@@ -467,7 +468,7 @@ static void maru_sdl_resize_bh(void *opaque)
     /* rearrange multi-touch finger points */
     if (get_emul_multi_touch_state()->multitouch_enable != 0) {
         rearrange_finger_points(
-            get_emul_resolution_width(), get_emul_resolution_height(),
+            get_display_resolution_width(), get_display_resolution_height(),
             current_scale_factor, rotaton_type);
     }
 
@@ -606,7 +607,6 @@ static void maru_sdl_init(uint64 swt_handle,
     INFO("register SDL environment variable. "
         "(SDL_WINDOWID = %s)\n", SDL_windowhack);
 
-    set_emul_resolution(display_width, display_height);
     set_emul_sdl_bpp(SDL_BPP);
     maru_sdl_set_interpolation(false);
     init_multi_touch_state();
index f7dc615d1e7d782bc532b67300e3916d44b2fb03..41f30e87d2afc17b88b9c3e24e00e157c38ccb17 100644 (file)
@@ -92,7 +92,8 @@ static void qemu_ds_shm_update(DisplayChangeListener *dcl,
                     surface_height(dpy_surface));
             } else {
                 int shm_size =
-                   get_emul_resolution_width() * get_emul_resolution_height() * 4;
+                    get_display_resolution_width() *
+                    get_display_resolution_height() * 4;
                 memset(shared_memory, 0x00, (size_t)shm_size);
             }
 
@@ -136,8 +137,8 @@ static void qemu_ds_shm_switch(DisplayChangeListener *dcl,
     INFO("qemu_ds_shm_switch : (%d, %d)\n",
         console_width, console_height);
 
-    if (console_width == get_emul_resolution_width() &&
-        console_height == get_emul_resolution_height()) {
+    if (console_width == get_display_resolution_width() &&
+        console_height == get_display_resolution_height()) {
         is_fit_console_size = true;
     }
 }
@@ -245,7 +246,6 @@ static void maru_shm_init(uint64 swt_handle,
 
     INFO("maru shm init\n");
 
-    set_emul_resolution(display_width, display_height);
     set_emul_sdl_bpp(32);
 
     if (blank_guide_enable == true) {
@@ -254,7 +254,8 @@ static void maru_shm_init(uint64 swt_handle,
 
     /* byte */
     int shm_size =
-        get_emul_resolution_width() * get_emul_resolution_height() * 4;
+        get_display_resolution_width() *
+        get_display_resolution_height() * 4;
 
     /* base + 1 = sdb port */
     /* base + 2 = shared memory key */
index 9cdefcd0b0e3f249817e8bd47e7366fc2782f9ae..3cd245084e998cee18e3d197b7331cd59c6713bb 100644 (file)
@@ -114,8 +114,8 @@ void qt5_gui_init(void)
     uiInfo->vmName = QString(get_vm_name()).trimmed();
     qDebug() << "VM name :" <<  uiInfo->vmName;
 
-    uiInfo->resolution.setWidth(get_emul_resolution_width());
-    uiInfo->resolution.setHeight(get_emul_resolution_height());
+    uiInfo->resolution.setWidth(get_display_resolution_width());
+    uiInfo->resolution.setHeight(get_display_resolution_height());
     uiInfo->basePort = get_emul_vm_base_port();
 
     uiInfo->vmDataPath = QDir(get_vm_data_path()).canonicalPath();
index eae6bc9cb71b96c58067d6858b7bdc05db520ba7..a31de28b48d76bd6aa033fbda8e5b047c15e3e1a 100644 (file)
@@ -44,6 +44,7 @@ extern bool hax_allowed;
 extern bool hax_allowed;
 #endif
 
+#include "ui/console.h"
 #include "sysemu/sysemu.h"
 #include "block/block_int.h"
 #include "sysemu/block-backend.h"
@@ -105,26 +106,6 @@ const char *get_log_path(void)
     return log_path;
 }
 
-/* display screen resolution */
-void set_emul_resolution(int width, int height)
-{
-    _emul_info.resolution_w = width;
-    _emul_info.resolution_h = height;
-
-    LOG_INFO("emulator graphic resolution : %dx%d\n",
-        _emul_info.resolution_w, _emul_info.resolution_h);
-}
-
-int get_emul_resolution_width(void)
-{
-    return _emul_info.resolution_w;
-}
-
-int get_emul_resolution_height(void)
-{
-    return _emul_info.resolution_h;
-}
-
 /* sdl bits per pixel */
 void set_emul_sdl_bpp(int bpp)
 {
@@ -670,6 +651,58 @@ const char *get_vm_data_path(void)
     return vm_data_path;
 }
 
+// display resolution
+static int initial_resolution_width = -1;
+static int initial_resolution_height = -1;
+
+#ifdef CONFIG_JAVA_UI
+static void set_resolution_legacy(void)
+{
+    char *resolution = get_variable("resolution");
+    if (!resolution) {
+        error_report("variable [resolution] is required.");
+        exit(1);
+    }
+    char **splitted = g_strsplit(resolution, "x", 2);
+    if (!splitted[0] || !splitted[1]) {
+        error_report("resolution value [%s] is weird. Please use format \"WIDTHxHEIGHT\"", resolution);
+        g_strfreev(splitted);
+        exit(1);
+    }
+    else {
+        set_initial_display_resolution(g_ascii_strtoull(splitted[0], NULL, 0),
+                g_ascii_strtoull(splitted[1], NULL, 0));
+    }
+    g_strfreev(splitted);
+        }
+#endif
+
+void set_initial_display_resolution(int width, int height)
+{
+    initial_resolution_width = width;
+    initial_resolution_height = height;
+}
+
+int get_display_resolution_width(void)
+{
+#ifdef CONFIG_JAVA_UI
+    if (initial_resolution_width == -1) {
+        set_resolution_legacy();
+    }
+#endif
+    return initial_resolution_width;
+}
+
+int get_display_resolution_height(void)
+{
+#ifdef CONFIG_JAVA_UI
+    if (initial_resolution_width == -1) {
+        set_resolution_legacy();
+    }
+#endif
+    return initial_resolution_height;
+}
+
 #ifdef CONFIG_JAVA_UI
 /* skin enabled */
 static bool skin_enabled = true;
index 9fb1a8e726d592f8f1c7232244ea84d99fc7ceb2..266101894751409db7aaa640bc5fafba543b2ec0 100644 (file)
@@ -90,8 +90,6 @@ enum {
 
 typedef  struct EmulatorConfigInfo {
     bool skin_enable;
-    int resolution_w;
-    int resolution_h;
     int sdl_bpp;
     bool input_mouse_enable;
     bool input_touch_enable;
@@ -133,7 +131,6 @@ char const *get_bin_path(void);
 char const *get_log_path(void);
 
 /* setter */
-void set_emul_resolution(int width, int height);
 void set_emul_win_scale(double scale);
 void set_emul_sdl_bpp(int bpp);
 void set_emul_input_mouse_enable(bool on);
@@ -154,8 +151,6 @@ void set_emuld_connection(bool connected);
 void set_sdb_connection(bool connected);
 
 /* getter */
-int get_emul_resolution_width(void);
-int get_emul_resolution_height(void);
 double get_emul_win_scale(void);
 int get_emul_sdl_bpp(void);
 bool is_emul_input_mouse_enable(void);
@@ -198,12 +193,15 @@ const char *get_vm_name(void);
 const char *get_profile_name(void);
 bool is_gpu_accel_enabled(void);
 const char *get_vm_data_path(void);
-#ifdef SUPPORT_LEGACY_ARGS
-void set_vm_data_path(const char *path);
-#endif
+void set_initial_display_resolution(int width, int height);
+int get_display_resolution_width(void);
+int get_display_resolution_height(void);
 #ifdef CONFIG_JAVA_UI
 void set_skin_enabled(bool enabled);
 bool is_skin_enabled(void);
 #endif
+#ifdef SUPPORT_LEGACY_ARGS
+void set_vm_data_path(const char *path);
+#endif
 
 #endif /* __EMUL_STATE_H__ */
index 0254fa734b7ad192cb06780ca7b10349043165f6..f6cc9724dd7f427bf87951ce6d2144c23261f754 100644 (file)
@@ -260,7 +260,7 @@ const char *prepare_maru(const char * const kernel_cmdline)
     // Assemble new kernel cmdline
     maru_kernel_cmdline = g_strdup_printf("%s sdb_port=%d, "
             "vm_resolution=%dx%d", kernel_cmdline, get_emul_vm_base_port(),
-            get_emul_resolution_width(), get_emul_resolution_height());
+            get_display_resolution_width(), get_display_resolution_height());
     set_emul_host_ip(maru_kernel_cmdline);
     LOG_INFO("kernel commandline : %s\n", maru_kernel_cmdline);
 
@@ -360,26 +360,6 @@ static int emulator_main(int argc, char *argv[], char **envp)
             return -1;
         }
 
-        // set emulator resolution
-        {
-            char *resolution = get_variable("resolution");
-            if (!resolution) {
-                fprintf(stderr, "[resolution] is required.\n");
-                return -1;
-            }
-            char **splitted = g_strsplit(resolution, "x", 2);
-            if (!splitted[0] || !splitted[1]) {
-                fprintf(stderr, "resolution value [%s] is weird. Please use format \"WIDTHxHEIGHT\"\n", resolution);
-                g_strfreev(splitted);
-                return -1;
-            }
-            else {
-                set_emul_resolution(g_ascii_strtoull(splitted[0], NULL, 0),
-                        g_ascii_strtoull(splitted[1], NULL, 0));
-            }
-            g_strfreev(splitted);
-        }
-
         // assemble arguments for qemu and skin
 #ifdef SUPPORT_SKIN_OPTIONS
         if (!assemble_emulator_args(&_qemu_argc, _qemu_argv,
index b11cd55aaf6baabb4a2ee5529a98aeeb503de80d..42e220a74cb1f057b7760bd261b81223a302c650 100644 (file)
@@ -242,7 +242,7 @@ static void extract_skin_info(int skin_argc, char **skin_argv)
         }
 
         if (w != 0 && h != 0) {
-            set_emul_resolution(w, h);
+            set_initial_display_resolution(w, h);
         }
     }
 }
index a141dbbbe713dd325eb48e78a000329599f60bba..10d607c1d0d7b434e63dcad2cf0a452c3f2f9340 100644 (file)
@@ -77,8 +77,8 @@ static void *encode_webp(void)
     container->buffer = NULL;
     container->length = 0;
 
-    width = get_emul_resolution_width();
-    height = get_emul_resolution_height();
+    width = get_display_resolution_width();
+    height = get_display_resolution_height();
 
     image_stride = width * 4;
     LOG_TRACE("width %d, height %d, stride %d, raw image %d\n",
@@ -164,8 +164,8 @@ static void *encode_png(void)
     png_infop info_ptr = NULL;
     png_bytepp row_pointers = NULL;
 
-    width = get_emul_resolution_width();
-    height = get_emul_resolution_height();
+    width = get_display_resolution_width();
+    height = get_display_resolution_height();
 
     image_stride = width * 4;
     LOG_TRACE("width %d, height %d, stride %d, raw image %d\n",
index bc0c6484824678b8df367a85b2ab8688be8c3fe3..94c6137b9f18f8a5dcd377949de9b6c4d13e09f5 100644 (file)
@@ -145,8 +145,8 @@ static bool send_set_touch_resolution(void)
 
     LOG_TRACE("enter: %s\n", __func__);
 
-    resolution.width = get_emul_resolution_width();
-    resolution.height = get_emul_resolution_height();
+    resolution.width = get_display_resolution_width();
+    resolution.height = get_display_resolution_height();
 
     mt.type = EVENTCAST__TOUCH_MSG__TYPE__RESOLUTION;
     mt.resolution = &resolution;
index fd9927e629cce885f64b0d768f95d8e150d2c6e1..f212b7f2ab7eee06b8f7284cab9efe24a6cd2eb7 100644 (file)
@@ -418,7 +418,8 @@ void save_screenshot(DisplaySurface *surface)
 
 Framebuffer *request_screenshot(void)
 {
-    const int length = get_emul_resolution_width() * get_emul_resolution_height() * 4;
+    const int length = get_display_resolution_width() *
+        get_display_resolution_height() * 4;
     INFO("screenshot data length : %d\n", length);
 
     if (0 >= length) {
index 34f56a1e3bfc4d84e365fe8e3312e197f4c74934..95b30db5c12fda174ebd8f04e32475675dc5888c 100644 (file)
@@ -31,7 +31,6 @@
 #include "displayswapper.h"
 
 extern "C" {
-void qt5_graphic_hw_update(void);
 int qt5_graphic_hw_display(void);
 }
 
diff --git a/vl.c b/vl.c
index 1576323de995d026758ceada86b4932233f829e3..190886c592d8e9feadd633cf3118d6561a3972ed 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2166,14 +2166,14 @@ static DisplayType select_display(const char *p)
 #endif
 #ifdef CONFIG_MARU
     } else if (strstart(p, "maru_sdl", &opts)) {
-# ifdef CONFIG_SDL
+# if defined(CONFIG_SDL) && defined(CONFIG_JAVA_UI)
         display = DT_MARU_SDL;
 # else
         fprintf(stderr, "maru_sdl support is disabled\n");
         exit(1);
 # endif
     } else if (strstart(p, "maru_shm", &opts)) {
-# ifdef CONFIG_USE_SHM
+# if defined(CONFIG_USE_SHM) && defined(CONFIG_JAVA_UI)
         display = DT_MARU_SHM;
 # else
         fprintf(stderr, "maru_shm is disabled\n");
@@ -2181,7 +2181,8 @@ static DisplayType select_display(const char *p)
 # endif
     } else if (strstart(p, "maru_qt", &opts)) {
 # ifdef CONFIG_QT
-        if (*opts) {
+        display = DT_MARU_QT_ONSCREEN;
+        while (*opts) {
             const char *nextopt;
             if (strstart(opts, ",rendering=", &nextopt)) {
                 opts = nextopt;
@@ -2192,13 +2193,23 @@ static DisplayType select_display(const char *p)
                 } else {
                     goto invalid_maru_qt_args;
                 }
+            } else if (strstart(opts, ",resolution=", &nextopt)) {
+                opts = nextopt;
+                char *endptr = NULL;
+                // Resolution should be formed "640x480" or "640*480".
+                int width = (int)g_ascii_strtoll(opts, &endptr, 10);
+                int height = (int)g_ascii_strtoll(++endptr, &endptr, 10);
+                if (width == 0 || height == 0) {
+                    goto invalid_maru_qt_args;
+                }
+                set_initial_display_resolution(width, height);
+                nextopt = endptr;
             } else {
             invalid_maru_qt_args:
                 fprintf(stderr, "Invalid maru_qt option string: %s\n", p);
                 exit(1);
             }
-        } else {
-            display = DT_MARU_QT_ONSCREEN;
+            opts = nextopt;
         }
 # else
         error_report("maru_qt is disabled.\n");