From: GiWoong Kim Date: Wed, 27 Nov 2013 06:21:35 +0000 (+0900) Subject: menu: added interpolation menu X-Git-Tag: TizenStudio_2.0_p2.3~439^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c549aa2322d20a21b17d68a963f59b6aee9d259;p=sdk%2Femulator%2Fqemu.git menu: added interpolation menu 1. Now, user can choose the interpolation filter type for emulator window scaling by popup menu. (Scale>Interpolation) 2. delete unused resource image file (usb_keyboard.png) Change-Id: I32010ea2577cabf58abd4c289fe8fd22c400cfb7 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/maru_display.c b/tizen/src/maru_display.c index 582f842..f387388 100644 --- a/tizen/src/maru_display.c +++ b/tizen/src/maru_display.c @@ -74,6 +74,15 @@ void maru_display_fini(void) #endif } +void maru_display_interpolation(bool on) +{ +#ifndef CONFIG_USE_SHM + maruskin_sdl_interpolation(on); +#else + /* do nothing */ +#endif +} + void maruskin_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide) diff --git a/tizen/src/maru_display.h b/tizen/src/maru_display.h index 3c1f756..326c676 100644 --- a/tizen/src/maru_display.h +++ b/tizen/src/maru_display.h @@ -41,6 +41,7 @@ typedef struct MaruScreenshot { void maru_display_init(DisplayState *ds); void maru_display_fini(void); +void maru_display_interpolation(bool on); void maruskin_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index e791008..a6ce7e1 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -57,6 +57,7 @@ static SDL_Surface *surface_guide; /* blank guide image */ static double current_scale_factor = 1.0; static double current_screen_degree; +static pixman_filter_t sdl_pixman_filter; static int sdl_alteration; @@ -109,7 +110,8 @@ static void maru_do_pixman_dpy_surface(pixman_image_t *dst_image) } static SDL_Surface *maru_do_pixman_scale(SDL_Surface *rz_src, - SDL_Surface *rz_dst) + SDL_Surface *rz_dst, + pixman_filter_t filter) { pixman_image_t *src = NULL; pixman_image_t *dst = NULL; @@ -132,7 +134,7 @@ static SDL_Surface *maru_do_pixman_scale(SDL_Surface *rz_src, pixman_f_transform_scale(&matrix_f, NULL, sx, sy); pixman_transform_from_pixman_f_transform(&matrix, &matrix_f); pixman_image_set_transform(src, &matrix); - pixman_image_set_filter(src, PIXMAN_FILTER_BILINEAR, NULL, 0); + pixman_image_set_filter(src, filter, NULL, 0); pixman_image_composite(PIXMAN_OP_SRC, src, NULL, dst, 0, 0, 0, 0, 0, 0, rz_dst->w, rz_dst->h); @@ -190,7 +192,7 @@ static SDL_Surface *maru_do_pixman_rotate(SDL_Surface *rz_src, } pixman_transform_from_pixman_f_transform(&matrix, &matrix_f); pixman_image_set_transform(src, &matrix); - pixman_image_set_filter(src, PIXMAN_FILTER_BILINEAR, NULL, 0); + //pixman_image_set_filter(src, PIXMAN_FILTER_BILINEAR, NULL, 0); pixman_image_composite(PIXMAN_OP_SRC, src, NULL, dst, 0, 0, 0, 0, 0, 0, rz_dst->w, rz_dst->h); @@ -515,7 +517,8 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) guide->format->Rmask, guide->format->Gmask, guide->format->Bmask, guide->format->Amask); - scaled_guide = maru_do_pixman_scale(guide, scaled_guide); + scaled_guide = maru_do_pixman_scale( + guide, scaled_guide, PIXMAN_FILTER_BEST); dst_x = (surface_screen->w - dst_w) / 2; dst_y = (surface_screen->h - dst_h) / 2; @@ -594,6 +597,21 @@ DisplayChangeListenerOps maru_dcl_ops = { .dpy_refresh = qemu_ds_sdl_refresh, }; +void maruskin_sdl_interpolation(bool on) +{ + if (on == true) { + INFO("set PIXMAN_FILTER_BEST filter for image processing\n"); + + /* PIXMAN_FILTER_BILINEAR */ + sdl_pixman_filter = PIXMAN_FILTER_BEST; + } else { + INFO("set PIXMAN_FILTER_FAST filter for image processing\n"); + + /* PIXMAN_FILTER_NEAREST */ + sdl_pixman_filter = PIXMAN_FILTER_FAST; + } +} + static void qemu_update(void) { if (sdl_alteration == -1) { @@ -616,7 +634,7 @@ static void qemu_update(void) surface_qemu, rotated_screen, (int)current_screen_degree); scaled_screen = maru_do_pixman_scale( - rotated_screen, scaled_screen); + rotated_screen, scaled_screen, sdl_pixman_filter); SDL_BlitSurface(scaled_screen, NULL, surface_screen, NULL); } @@ -821,6 +839,7 @@ void maruskin_sdl_init(uint64 swt_handle, set_emul_resolution(display_width, display_height); set_emul_sdl_bpp(SDL_BPP); + maruskin_sdl_interpolation(true); init_multi_touch_state(); if (blank_guide_enable == true) { diff --git a/tizen/src/maru_sdl.h b/tizen/src/maru_sdl.h index 79fed28..a5ac72b 100644 --- a/tizen/src/maru_sdl.h +++ b/tizen/src/maru_sdl.h @@ -43,6 +43,7 @@ void maruskin_sdl_init(uint64 swt_handle, unsigned int display_width, unsigned int display_height, bool blank_guide); void maruskin_sdl_resize(void); +void maruskin_sdl_interpolation(bool on); void maruskin_sdl_quit(void); #endif /* MARU_SDL_H_ */ diff --git a/tizen/src/skin/client/resource/icons/usb_keyboard.png b/tizen/src/skin/client/resource/icons/usb_keyboard.png deleted file mode 100644 index 69a87f3..0000000 Binary files a/tizen/src/skin/client/resource/icons/usb_keyboard.png and /dev/null differ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java index be5e1e9..1168206 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java @@ -323,6 +323,14 @@ public class EmulatorShmSkin extends EmulatorSkin { return; }*/ + if (isOnInterpolation == false) { + /* Mac - NSImageInterpolationNone */ + e.gc.setInterpolation(SWT.NONE); + } else { + /* Mac - NSImageInterpolationHigh */ + e.gc.setInterpolation(SWT.HIGH); + } + if (currentState.getCurrentAngle() == 0) { /* portrait */ e.gc.drawImage(pollThread.imageFramebuffer, 0, 0, pollThread.widthFB, pollThread.heightFB, diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 6079201..edce0fb 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -151,6 +151,7 @@ public class EmulatorSkin { protected Point shellGrabPosition; protected boolean isShutdownRequested; public boolean isOnTop; + public boolean isOnInterpolation; public boolean isKeyWindow; public boolean isOnKbd; private PopupMenu popupMenu; @@ -189,6 +190,7 @@ public class EmulatorSkin { this.pressedKeyEventList = new LinkedList(); this.isOnTop = isOnTop; + this.isOnInterpolation = true; this.isOnKbd = false; this.isKeyWindow = false; @@ -1257,8 +1259,8 @@ public class EmulatorSkin { getShell().getDisplay().asyncExec(new Runnable() { @Override public void run() { - getPopupMenu().kbdOnItem.setSelection(isOnKbd); - getPopupMenu().kbdOffItem.setSelection(!isOnKbd); + getPopupMenu().hostKbdOnItem.setSelection(isOnKbd); + getPopupMenu().hostKbdOffItem.setSelection(!isOnKbd); } }); } @@ -1484,6 +1486,26 @@ public class EmulatorSkin { return listener; } + public SelectionAdapter createInterpolationMenuListener() { + SelectionAdapter listener = new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + MenuItem item = (MenuItem) e.getSource(); + if (item.getSelection()) { + boolean on = item.equals(popupMenu.interpolationHighItem); + isOnInterpolation = on; + logger.info("Scale interpolation : " + isOnInterpolation); + + communicator.sendToQEMU(SendCommand.SEND_INTERPOLATION_STATE, + new BooleanData(on, SendCommand.SEND_INTERPOLATION_STATE.toString()), + false); + } + } + }; + + return listener; + } + public SelectionAdapter createKeyWindowMenuListener() { SelectionAdapter listener = new SelectionAdapter() { @Override @@ -1583,7 +1605,7 @@ public class EmulatorSkin { return listener; } - public SelectionAdapter createHostKeyboardMenuListener() { + public SelectionAdapter createHostKbdMenuListener() { SelectionAdapter listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -1592,17 +1614,17 @@ public class EmulatorSkin { "Host Keyboard is not ready.\n" + "Please wait until the emulator is completely boot up.", SWT.ICON_WARNING, config); - popupMenu.kbdOnItem.setSelection(isOnKbd); - popupMenu.kbdOffItem.setSelection(!isOnKbd); + popupMenu.hostKbdOnItem.setSelection(isOnKbd); + popupMenu.hostKbdOffItem.setSelection(!isOnKbd); return; } MenuItem item = (MenuItem) e.getSource(); if (item.getSelection()) { - boolean on = item.equals(popupMenu.kbdOnItem); + boolean on = item.equals(popupMenu.hostKbdOnItem); isOnKbd = on; - logger.info("Host Keyboard " + isOnKbd); + logger.info("Host Keyboard : " + isOnKbd); communicator.sendToQEMU(SendCommand.SEND_HOST_KBD_STATE, new BooleanData(on, SendCommand.SEND_HOST_KBD_STATE.toString()), false); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java index db75567..e17fc4a 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java @@ -203,6 +203,7 @@ public interface ICommunicator extends Runnable { SEND_RAM_DUMP((short) 18), SEND_GUEST_DUMP((short) 19), SEND_ECP_PORT_REQ((short) 20), + SEND_INTERPOLATION_STATE((short) 21), RESPONSE_HEART_BEAT((short) 900), RESPONSE_DRAW_FRAME((short) 901), diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java index d61f9f0..30cc6b7 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java @@ -78,8 +78,7 @@ public class ImageRegistry { ADVANCED("advanced.png"), CLOSE("close.png"), SCREENSHOT("screenshot.png"), - USB_KEYBOARD("usb_keyboard.png"), - HOST_KEYBOARD("host_keyboard.png"), + HOST_KBD("host_keyboard.png"), DIAGNOSIS("diagnosis.png"), FORCE_CLOSE("force_close.png"), ABOUT("about.png"), diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java index 57335a4..70bbbe7 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java @@ -55,10 +55,11 @@ public class PopupMenu { public static final String TOPMOST_MENUITEM_NAME = "&Always On Top"; public static final String ROTATE_MENUITEM_NAME = "&Rotate"; public static final String SCALE_MENUITEM_NAME = "&Scale"; + public static final String INTERPOLATION_MENUITEM_NAME = "&Interpolation"; public static final String KEYWINDOW_MENUITEM_NAME = "&Key Window"; public static final String ADVANCED_MENUITEM_NAME = "Ad&vanced"; public static final String SCREENSHOT_MENUITEM_NAME = "&Screen Shot"; - public static final String HOSTKEYBOARD_MENUITEM_NAME = "&Host Keyboard"; + public static final String HOSTKBD_MENUITEM_NAME = "&Host Keyboard"; public static final String DIAGNOSIS_MENUITEM_NAME = "&Diagnosis"; public static final String RAMDUMP_MENUITEM_NAME = "&Ram Dump"; public static final String ABOUT_MENUITEM_NAME = "&About"; @@ -81,12 +82,15 @@ public class PopupMenu { public MenuItem onTopItem; public MenuItem rotateItem; public MenuItem scaleItem; + public MenuItem interpolationItem; + public MenuItem interpolationHighItem; + public MenuItem interpolationLowItem; public MenuItem keyWindowItem; /* key window menu */ public MenuItem advancedItem; /* advanced menu */ public MenuItem screenshotItem; - public MenuItem hostKeyboardItem; - public MenuItem kbdOnItem; - public MenuItem kbdOffItem; + public MenuItem hostKbdItem; + public MenuItem hostKbdOnItem; + public MenuItem hostKbdOffItem; public MenuItem diagnosisItem; public MenuItem ramdumpItem; public MenuItem aboutItem; @@ -197,13 +201,13 @@ public class PopupMenu { /* VirtIO Keyboard menu */ if (itemProperties == null || itemProperties.getHostKeyboardItem() == null) { - createHostKeyboardItem(advancedSubMenu, HOSTKEYBOARD_MENUITEM_NAME); + createHostKbdItem(advancedSubMenu, HOSTKBD_MENUITEM_NAME); } else { - MenuItemType hostKeyboardMenuType = itemProperties.getHostKeyboardItem(); - if (hostKeyboardMenuType.isVisible() == true) { - createHostKeyboardItem(advancedSubMenu, - (hostKeyboardMenuType.getItemName().isEmpty()) ? - HOSTKEYBOARD_MENUITEM_NAME : hostKeyboardMenuType.getItemName()); + MenuItemType hostKbdMenuType = itemProperties.getHostKeyboardItem(); + if (hostKbdMenuType.isVisible() == true) { + createHostKbdItem(advancedSubMenu, + (hostKbdMenuType.getItemName().isEmpty()) ? + HOSTKBD_MENUITEM_NAME : hostKbdMenuType.getItemName()); } } @@ -335,11 +339,39 @@ public class PopupMenu { } matchedItem.setSelection(true); + + /* interpolation menu */ + createInterpolationItem(scaleSubMenu, INTERPOLATION_MENUITEM_NAME); } scaleItem.setMenu(scaleSubMenu); } + private void createInterpolationItem(Menu menu, String name) { + interpolationItem = new MenuItem(menu, SWT.CASCADE); + interpolationItem.setText(name); + + Menu interpolationSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); + { + createInterpolationHighLowItem(interpolationSubMenu); + } + interpolationItem.setMenu(interpolationSubMenu); + } + + private void createInterpolationHighLowItem(Menu menu) { + interpolationHighItem = new MenuItem(menu, SWT.RADIO); + interpolationHighItem.setText("High"); + interpolationHighItem.setSelection(skin.isOnInterpolation); + + interpolationLowItem = new MenuItem(menu, SWT.RADIO); + interpolationLowItem.setText("Low"); + interpolationLowItem.setSelection(!skin.isOnInterpolation); + + SelectionAdapter interpolationListener = skin.createInterpolationMenuListener(); + interpolationHighItem.addSelectionListener(interpolationListener); + interpolationLowItem.addSelectionListener(interpolationListener); + } + private void createKeyWindowItem(Menu menu, String name) { /* load Key Window layout */ SelectionAdapter keyWindowListener = skin.createKeyWindowMenuListener(); @@ -388,30 +420,30 @@ public class PopupMenu { screenshotItem.addSelectionListener(screenshotListener); } - private void createHostKeyboardItem(Menu menu, String name) { - hostKeyboardItem = new MenuItem(menu, SWT.CASCADE); - hostKeyboardItem.setText(name); - hostKeyboardItem.setImage(imageRegistry.getIcon(IconName.HOST_KEYBOARD)); + private void createHostKbdItem(Menu menu, String name) { + hostKbdItem = new MenuItem(menu, SWT.CASCADE); + hostKbdItem.setText(name); + hostKbdItem.setImage(imageRegistry.getIcon(IconName.HOST_KBD)); - Menu hostKeyboardSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); + Menu hostKbdSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); { - createKeyboardOnOffItem(hostKeyboardSubMenu); + createKbdOnOffItem(hostKbdSubMenu); } - hostKeyboardItem.setMenu(hostKeyboardSubMenu); + hostKbdItem.setMenu(hostKbdSubMenu); } - private void createKeyboardOnOffItem(Menu menu) { - kbdOnItem = new MenuItem(menu, SWT.RADIO); - kbdOnItem.setText("On"); - kbdOnItem.setSelection(skin.isOnKbd); + private void createKbdOnOffItem(Menu menu) { + hostKbdOnItem = new MenuItem(menu, SWT.RADIO); + hostKbdOnItem.setText("On"); + hostKbdOnItem.setSelection(skin.isOnKbd); - kbdOffItem = new MenuItem(menu, SWT.RADIO); - kbdOffItem.setText("Off"); - kbdOffItem.setSelection(!skin.isOnKbd); + hostKbdOffItem = new MenuItem(menu, SWT.RADIO); + hostKbdOffItem.setText("Off"); + hostKbdOffItem.setSelection(!skin.isOnKbd); - SelectionAdapter hostKeyboardListener = skin.createHostKeyboardMenuListener(); - kbdOnItem.addSelectionListener(hostKeyboardListener); - kbdOffItem.addSelectionListener(hostKeyboardListener); + SelectionAdapter hostKbdListener = skin.createHostKbdMenuListener(); + hostKbdOnItem.addSelectionListener(hostKbdListener); + hostKbdOffItem.addSelectionListener(hostKbdListener); } private void createRamDumpItem(Menu menu, String name) { diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index a1d2e32..4f01c43 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -566,6 +566,13 @@ void do_host_kbd_enable(bool on) #endif } +void do_interpolation_enable(bool on) +{ + INFO("interpolation enable : %d\n", on); + + maru_display_interpolation(on); +} + void do_ram_dump(void) { INFO("dump ram!\n"); diff --git a/tizen/src/skin/maruskin_operation.h b/tizen/src/skin/maruskin_operation.h index 76d0011..e7234c0 100644 --- a/tizen/src/skin/maruskin_operation.h +++ b/tizen/src/skin/maruskin_operation.h @@ -66,6 +66,7 @@ void free_screenshot_info(QemuSurfaceInfo *); void do_open_shell(void); void do_host_kbd_enable(bool on); +void do_interpolation_enable(bool on); void do_ram_dump(void); void do_guestmemory_dump(void); diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 8025f5d..ebcb90f 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -112,6 +112,7 @@ enum { RECV_RAM_DUMP = 18, RECV_GUESTMEMORY_DUMP = 19, RECV_ECP_PORT_REQ = 20, + RECV_INTERPOLATION_STATE = 21, RECV_RESPONSE_HEART_BEAT = 900, RECV_RESPONSE_DRAW_FRAME = 901, @@ -1092,6 +1093,27 @@ static void* run_skin_server(void* args) } break; } + case RECV_INTERPOLATION_STATE: { + char on = 0; + + log_cnt += sprintf(log_buf + log_cnt, "RECV_INTERPOLATION_STATE ==\n"); + TRACE(log_buf); + + if (length <= 0) { + INFO("there is no data looking at 0 length.\n"); + continue; + } + + memcpy(&on, recvbuf, sizeof(on)); + + if (on == 0) { + do_interpolation_enable(false); + } else { + do_interpolation_enable(true); + } + + break; + } case RECV_RESPONSE_DRAW_FRAME: { pthread_mutex_lock(&mutex_draw_display); draw_display_state = 0; /* framebuffer has been drawn */