From a1adc7b2693aad6e4935f9b13a82f7a918fba9a2 Mon Sep 17 00:00:00 2001 From: SeokYeon Hwang Date: Sun, 9 Aug 2015 14:26:15 +0900 Subject: [PATCH] emul_state: cleaned-up display resolution state management Change-Id: Ic8a8169e8e7e8f328488d2a67d149f0ded2d338a Signed-off-by: SeokYeon Hwang --- tizen/src/display/maru_sdl.c | 14 +++--- tizen/src/display/maru_shm.c | 11 +++-- tizen/src/display/qt5_supplement.cpp | 4 +- tizen/src/emul_state.c | 73 ++++++++++++++++++++-------- tizen/src/emul_state.h | 14 +++--- tizen/src/emulator.c | 22 +-------- tizen/src/emulator_legacy.c | 2 +- tizen/src/eventcast/encode_fb.c | 8 +-- tizen/src/eventcast/touch.c | 4 +- tizen/src/skin/maruskin_operation.c | 3 +- tizen/src/ui/displayswapper.cpp | 1 - vl.c | 21 ++++++-- 12 files changed, 100 insertions(+), 77 deletions(-) diff --git a/tizen/src/display/maru_sdl.c b/tizen/src/display/maru_sdl.c index 766ca088f4..a3c30874b6 100644 --- a/tizen/src/display/maru_sdl.c +++ b/tizen/src/display/maru_sdl.c @@ -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(); diff --git a/tizen/src/display/maru_shm.c b/tizen/src/display/maru_shm.c index f7dc615d1e..41f30e87d2 100644 --- a/tizen/src/display/maru_shm.c +++ b/tizen/src/display/maru_shm.c @@ -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 */ diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index 9cdefcd0b0..3cd245084e 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -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(); diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index eae6bc9cb7..a31de28b48 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -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; diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 9fb1a8e726..2661018947 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -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__ */ diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 0254fa734b..f6cc9724dd 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -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, diff --git a/tizen/src/emulator_legacy.c b/tizen/src/emulator_legacy.c index b11cd55aaf..42e220a74c 100644 --- a/tizen/src/emulator_legacy.c +++ b/tizen/src/emulator_legacy.c @@ -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); } } } diff --git a/tizen/src/eventcast/encode_fb.c b/tizen/src/eventcast/encode_fb.c index a141dbbbe7..10d607c1d0 100644 --- a/tizen/src/eventcast/encode_fb.c +++ b/tizen/src/eventcast/encode_fb.c @@ -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", diff --git a/tizen/src/eventcast/touch.c b/tizen/src/eventcast/touch.c index bc0c648482..94c6137b9f 100644 --- a/tizen/src/eventcast/touch.c +++ b/tizen/src/eventcast/touch.c @@ -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; diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index fd9927e629..f212b7f2ab 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -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) { diff --git a/tizen/src/ui/displayswapper.cpp b/tizen/src/ui/displayswapper.cpp index 34f56a1e3b..95b30db5c1 100644 --- a/tizen/src/ui/displayswapper.cpp +++ b/tizen/src/ui/displayswapper.cpp @@ -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 1576323de9..190886c592 100644 --- 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"); -- 2.34.1