From: GiWoong Kim Date: Thu, 25 Jul 2013 07:03:43 +0000 (+0900) Subject: display: define 'display.shm' option for skin args X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~877 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca478df6285f63476971308777dff91fefd55621;p=sdk%2Femulator%2Fqemu.git display: define 'display.shm' option for skin args define 'display.shm' option for skin args & code indenting Change-Id: Id36aaac1ec9062865170fcbebca6cab8bae527d7 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java index c3375594f9..11f8d74809 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java @@ -75,20 +75,11 @@ public class EmulatorSkinMain { private static Logger logger; - private static int useSharedMemory = 0; - - static { - if (SwtUtil.isMacPlatform() == true) { - useSharedMemory = 1; - } - } - /** * @param args */ public static void main(String[] args) { - - if(SwtUtil.isMacPlatform()) { + if (SwtUtil.isMacPlatform()) { //TODO: event handling of about dialog System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Emulator"); @@ -110,7 +101,6 @@ public class EmulatorSkinMain { SocketCommunicator communicator = null; try { - /* get vm path from startup argument */ String vmPath = getVmPath(args); if (StringUtil.isEmpty(vmPath)) { @@ -137,8 +127,8 @@ public class EmulatorSkinMain { /* get skin path from startup argument */ String argSkinPath = (String) argsMap.get(ArgsConstants.SKIN_PATH); - String skinPath = ".." + - File.separator + SKINS_FOLDER + File.separator + DEFAULT_SKIN_FOLDER; + String skinPath = ".." + File.separator + + SKINS_FOLDER + File.separator + DEFAULT_SKIN_FOLDER; File f = new File(argSkinPath); if (f.isDirectory() == false) { @@ -151,7 +141,8 @@ public class EmulatorSkinMain { } /* set skin information */ - String skinInfoFilePath = skinPath + File.separator + SKIN_INFO_FILE_NAME; + String skinInfoFilePath = + skinPath + File.separator + SKIN_INFO_FILE_NAME; Properties skinInfoProperties = loadProperties(skinInfoFilePath, false); if (null == skinInfoProperties) { logger.severe("Fail to load skin information file."); @@ -166,34 +157,33 @@ public class EmulatorSkinMain { temp.dispose(); System.exit(-1); - } else { - logger.info("skin info:" + skinInfoProperties); //TODO: } - /* determine the layout */ String skinInfoResolutionW = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH); String skinInfoResolutionH = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT); - boolean isGeneralSkin = false; - if (skinInfoResolutionW.equalsIgnoreCase("all") || - skinInfoResolutionH.equalsIgnoreCase("all")) { - isGeneralSkin = true; - } - SkinInformation skinInfo = new SkinInformation( - skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME), - skinPath, isGeneralSkin); + logger.info("skin ini : " + SkinInfoConstants.SKIN_NAME + "=" + + skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME)); + logger.info("skin ini : " + SkinInfoConstants.RESOLUTION_WIDTH + + "=" + skinInfoResolutionW); + logger.info("skin ini : " + SkinInfoConstants.RESOLUTION_HEIGHT + + "=" + skinInfoResolutionH); + logger.info("skin ini : " + SkinInfoConstants.MANAGER_PRIORITY + "=" + + skinInfoProperties.getProperty(SkinInfoConstants.MANAGER_PRIORITY)); /* set emulator window skin property */ - String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME; + String skinPropFilePath = + vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME; Properties skinProperties = loadProperties(skinPropFilePath, true); if (null == skinProperties) { logger.severe("Fail to load skin properties file."); } /* set emulator window config property */ - String configPropFilePath = vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME; + String configPropFilePath = + vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME; Properties configProperties = loadProperties(configPropFilePath, false); /* able to use log file after loading properties */ @@ -204,6 +194,16 @@ public class EmulatorSkinMain { EmulatorConfig.validateSkinProperties(skinProperties); EmulatorConfig.validateSkinConfigProperties(configProperties); + /* determine the layout */ + boolean isGeneralSkin = false; + if (skinInfoResolutionW.equalsIgnoreCase("all") || + skinInfoResolutionH.equalsIgnoreCase("all")) { + isGeneralSkin = true; + } + SkinInformation skinInfo = new SkinInformation( + skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME), + skinPath, isGeneralSkin); + /* load dbi file */ EmulatorUI dbiContents = loadXMLForSkin(skinPath); if (null == dbiContents) { @@ -236,9 +236,13 @@ public class EmulatorSkinMain { /* create a skin */ EmulatorSkin skin = null; - if (useSharedMemory == 1) { + if (config.getArgBoolean(ArgsConstants.DISPLAY_SHM) == true) { + logger.info("maru_shm"); /* shared framebuffer */ + skin = new EmulatorShmSkin(config, skinInfo, isOnTop); } else { /* linux & windows */ + logger.info("maru_sdl"); /* WINDOWID_hack */ + skin = new EmulatorSdlSkin(config, skinInfo, isOnTop); } @@ -254,7 +258,6 @@ public class EmulatorSkinMain { Socket commSocket = communicator.getSocket(); if (null != commSocket) { - Runtime.getRuntime().addShutdownHook( new EmulatorShutdownhook(communicator)); @@ -291,7 +294,6 @@ public class EmulatorSkinMain { } } catch (Throwable e) { - if (null != logger) { logger.log(Level.SEVERE, e.getMessage(), e); logger.warning("Shutdown skin process !!!"); @@ -303,17 +305,15 @@ public class EmulatorSkinMain { if (null != communicator) { communicator.terminate(); } - } finally { ImageRegistry.getInstance().dispose(); Display.getDefault().close(); SkinLogger.end(); } - } - private static void initLog(Map argsMap, Properties properties) { - + private static void initLog( + Map argsMap, Properties properties) { String argLogLevel = argsMap.get(ArgsConstants.LOG_LEVEL); String configPropertyLogLevel = null; @@ -346,40 +346,38 @@ public class EmulatorSkinMain { } SkinLogger.setLevel(skinLogLevel.level()); - } private static String getSimpleMsg(String[] args) { - - for ( int i = 0; i < args.length; i++ ) { - final String simple = "simple.msg"; + for (int i = 0; i < args.length; i++) { String arg = args[i]; - String[] split = arg.split( "=" ); - if ( 1 < split.length ) { - if ( simple.equals( split[0].trim() ) ) { + String[] split = arg.split("="); + + if (1 < split.length) { + if (ArgsConstants.SIMPLE_MESSAGE.equals( + split[0].trim())) { return split[1].trim(); } } } return null; - } - private static String getVmPath( String[] args ) { - - for ( int i = 0; i < args.length; i++ ) { + private static String getVmPath(String[] args) { + for (int i = 0; i < args.length; i++) { String arg = args[i]; - String[] split = arg.split( "=" ); - if ( 1 < split.length ) { - if ( ArgsConstants.VM_PATH.equals( split[0].trim() ) ) { + String[] split = arg.split("="); + + if (1 < split.length) { + if (ArgsConstants.VM_PATH.equals( + split[0].trim())) { return split[1].trim(); } } } return null; - } private static Map parseArgs(String[] args) { @@ -433,48 +431,41 @@ public class EmulatorSkinMain { return emulatorUI; } - private static Properties loadProperties( String filePath, boolean create ) { - + private static Properties loadProperties( + String filePath, boolean create) { FileInputStream fis = null; Properties properties = null; try { - - File file = new File( filePath ); + File file = new File(filePath); - if (create) { - if ( !file.exists() ) { - if ( !file.createNewFile() ) { - logger.severe( "Fail to create new " + filePath + " property file." ); + if (create == true) { + if (file.exists() == false) { + if (file.createNewFile() == false) { + logger.severe( + "Fail to create new " + filePath + " property file."); return null; } } - - fis = new FileInputStream( filePath ); + + fis = new FileInputStream(filePath); properties = new Properties(); - properties.load( fis ); - + properties.load(fis); } else { - - if ( file.exists() ) { - - fis = new FileInputStream( filePath ); + if (file.exists() == true) { + fis = new FileInputStream(filePath); properties = new Properties(); - properties.load( fis ); + properties.load(fis); } - } - logger.info( "load properties file : " + filePath ); - - } catch ( IOException e ) { - logger.log( Level.SEVERE, "Fail to load skin properties file.", e ); + logger.info("load properties file : " + filePath); + } catch (IOException e) { + logger.log(Level.SEVERE, "failed to load skin properties file", e); } finally { - IOUtil.close( fis ); + IOUtil.close(fis); } return properties; - } - } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java index dd902b90a5..1e9918af4d 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java @@ -69,6 +69,7 @@ public class EmulatorConfig { public static final SkinLogLevel DEFAULT_LOG_LEVEL = SkinLogLevel.DEBUG; public interface ArgsConstants { + public static final String SIMPLE_MESSAGE = "simple.msg"; public static final String UID = "uid"; public static final String SERVER_PORT = "svr.port"; public static final String RESOLUTION_WIDTH = "width"; @@ -78,14 +79,16 @@ public class EmulatorConfig { public static final String LOG_LEVEL = "log.level"; public static final String NET_BASE_PORT = "net.baseport"; public static final String SKIN_PATH = "skin.path"; + public static final String DISPLAY_SHM = "display.shm"; public static final String MAX_TOUCHPOINT = "max.touchpoint"; } public interface SkinInfoConstants { - public static final String SDK_VERSION_NAME = "sdk.version-name"; + public static final String SDK_VERSION_NAME = "sdk.version-name"; /* from version file */ public static final String SKIN_NAME = "skin.name"; public static final String RESOLUTION_WIDTH = "resolution.width"; public static final String RESOLUTION_HEIGHT = "resolution.height"; + public static final String MANAGER_PRIORITY = "manager.priority"; } public interface SkinPropertiesConstants { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/info/SkinInformation.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/info/SkinInformation.java index 7f2d932668..c31f5f67bf 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/info/SkinInformation.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/info/SkinInformation.java @@ -37,6 +37,9 @@ public class SkinInformation { private boolean isGeneralSkin; private int skinOption; + /** + * Constructor + */ public SkinInformation(String skinName, String skinPath, boolean isGeneralSkin) { this.skinName = skinName; this.skinPath = skinPath; diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index b4c700157c..3643e6066a 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -1,7 +1,7 @@ /* * communicate with java skin process * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * GiWoong Kim @@ -51,13 +51,15 @@ MULTI_DEBUG_CHANNEL(qemu, skin_client); -#define SKIN_SERVER_READY_TIME 3 // second -#define SKIN_SERVER_SLEEP_TIME 10 // milli second + +#define SKIN_SERVER_READY_TIME 3 /* second */ +#define SKIN_SERVER_SLEEP_TIME 10 /* milli second */ #define OPT_SVR_PORT "svr.port" #define OPT_UID "uid" #define OPT_VM_PATH "vm.path" #define OPT_NET_BASE_PORT "net.baseport" +#define OPT_DISPLAY_SHM "display.shm" #define OPT_MAX_TOUCHPOINT "max.touchpoint" extern char tizen_target_path[]; @@ -97,8 +99,15 @@ static void* run_skin_client(void* arg) sprintf(buf_uid, "%d", uid); sprintf(buf_tizen_base_port, "%d", get_emul_vm_base_port()); + char buf_display_shm[8] = { 0, }; +#ifdef CONFIG_USE_SHM + strcpy(buf_display_shm, "true"); +#else + strcpy(buf_display_shm, "false"); +#endif + #ifdef CONFIG_WIN32 - // find java path in 64bit windows + /* find java path in 64bit windows */ JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH); memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); if (is_wow64()) { @@ -130,19 +139,24 @@ static void* run_skin_client(void* arg) int len = strlen(JAVA_EXEFILE_PATH) + strlen(JAVA_EXEOPTION) + #ifdef CONFIG_WIN32 - strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) + + strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) + #else - strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) + + strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) + #endif - strlen(OPT_SVR_PORT) + strlen(buf_skin_server_port) + strlen(OPT_UID) + strlen(buf_uid) + - strlen(OPT_VM_PATH) + strlen(vm_path) + strlen(OPT_NET_BASE_PORT) + strlen(buf_tizen_base_port) + - strlen(OPT_MAX_TOUCHPOINT) + len_maxtouchpoint + strlen(argv) + 46; + strlen(OPT_SVR_PORT) + strlen(buf_skin_server_port) + + strlen(OPT_UID) + strlen(buf_uid) + + strlen(OPT_VM_PATH) + strlen(vm_path) + + strlen(OPT_NET_BASE_PORT) + strlen(buf_tizen_base_port) + + strlen(OPT_MAX_TOUCHPOINT) + len_maxtouchpoint + + strlen(OPT_DISPLAY_SHM) + strlen(buf_display_shm) + + strlen(argv) + 48; + if (len > JAVA_MAX_COMMAND_LENGTH) { INFO("swt command length is too long! (%d)\n", len); len = JAVA_MAX_COMMAND_LENGTH; } - snprintf(cmd, len, "%s %s %s=\"%s\" \"%s%s\" %s=\"%d\" %s=\"%d\" %s=\"%s\" %s=\"%d\" %s=%d %s", + snprintf(cmd, len, "%s %s %s=\"%s\" \"%s%s\" %s=\"%d\" %s=\"%d\" %s=\"%s\" %s=\"%d\" %s=%s %s=%d %s", JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, #ifdef CONFIG_WIN32 bin_dir_win, bin_dir, JAR_SKINFILE, @@ -153,13 +167,14 @@ static void* run_skin_client(void* arg) OPT_UID, uid, OPT_VM_PATH, vm_path, OPT_NET_BASE_PORT, get_emul_vm_base_port(), + OPT_DISPLAY_SHM, buf_display_shm, OPT_MAX_TOUCHPOINT, maxtouchpoint, argv); INFO("command for swt : %s\n", cmd); #ifdef CONFIG_WIN32 - // for 64bit windows + /* for 64bit windows */ free(JAVA_EXEFILE_PATH); JAVA_EXEFILE_PATH = NULL; @@ -202,7 +217,7 @@ static void* run_skin_client(void* arg) break; } - //retrieves the termination status of the specified process + /* retrieves the termination status of the specified process */ if (GetExitCodeProcess(pi.hProcess, &dwRet) != 0) { ERR("failed to GetExitCodeProcess, error %u\n", GetLastError()); } @@ -221,7 +236,7 @@ static void* run_skin_client(void* arg) } } -#else //ifndef CONFIG_WIN32 +#else /* ifndef CONFIG_WIN32 */ int ret = system(cmd); if (ret == 127) { @@ -230,8 +245,8 @@ static void* run_skin_client(void* arg) INFO("fork error!\n"); } else { ret = WEXITSTATUS(ret); - //The high-order 8 bits are the exit code from exit(). - //The low-order 8 bits are zero if the process exited normally. + /* The high-order 8 bits are the exit code from exit() */ + /* The low-order 8 bits are zero if the process exited normally */ INFO("child return value : %d\n", ret); if (ret != 0) { @@ -252,7 +267,6 @@ int start_skin_client(int argc, char* argv[]) int skin_server_ready = 0; while(1) { - if (100 * SKIN_SERVER_READY_TIME < count) { break; } @@ -284,7 +298,7 @@ int start_skin_client(int argc, char* argv[]) pthread_t thread_id; if (0 != pthread_create(&thread_id, NULL, run_skin_client, NULL)) { - ERR( "fail to create skin_client pthread.\n" ); + ERR("fail to create skin_client pthread\n"); return -1; } @@ -299,7 +313,7 @@ int start_simple_client(char* msg) INFO("run simple client\n"); #ifdef CONFIG_WIN32 - // find java path in 64bit windows + /* find java path in 64bit windows */ JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH); memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH); if (is_wow64()) { @@ -310,6 +324,7 @@ int start_simple_client(char* msg) } else { strcpy(JAVA_EXEFILE_PATH, "java"); } + char* bin_dir = get_bin_path(); int bin_dir_len = strlen(bin_dir); char bin_dir_win[bin_dir_len]; @@ -323,25 +338,28 @@ int start_simple_client(char* msg) int len = strlen(JAVA_EXEFILE_PATH) + strlen(JAVA_EXEOPTION) + strlen(JAVA_LIBRARY_PATH) + #ifdef CONFIG_WIN32 - strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) + + strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) + #else - strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) + + strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) + #endif - strlen(bin_dir) + strlen(JAVA_SIMPLEMODE_OPTION) + strlen(msg) + 11; + strlen(bin_dir) + strlen(JAVA_SIMPLEMODE_OPTION) + strlen(msg) + 11; + if (len > JAVA_MAX_COMMAND_LENGTH) { len = JAVA_MAX_COMMAND_LENGTH; } + snprintf(cmd, len, "%s %s %s=\"%s\" %s%s %s=\"%s\"", #ifdef CONFIG_WIN32 - JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir_win, + JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir_win, #else - JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir, + JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir, #endif - bin_dir, JAR_SKINFILE, JAVA_SIMPLEMODE_OPTION, msg); + bin_dir, JAR_SKINFILE, JAVA_SIMPLEMODE_OPTION, msg); + INFO("command for swt : %s\n", cmd); #ifdef CONFIG_WIN32 - // for 64bit windows + /* for 64bit windows */ free(JAVA_EXEFILE_PATH); JAVA_EXEFILE_PATH=0;