From 93513e1afe37cbd71da2b846bae2e32486a2c0c0 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Fri, 22 Nov 2013 14:13:41 +0900 Subject: [PATCH] display: modified Blank Guide image resizing Emulator should resize the Blank Guide image to fit the display, base on its resolution and scale. Change-Id: If8a89f2e46068ad15fc8d5163b85108f22773093 Signed-off-by: GiWoong Kim --- tizen/src/maru_sdl.c | 21 ++++++---- .../org/tizen/emulator/skin/EmulatorShmSkin.java | 46 ++++++++++++---------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 571ed36..e791008 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -496,20 +496,27 @@ static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl) int dst_x = 0; int dst_y = 0; int dst_w = 0; int dst_h = 0; - if (current_scale_factor != 1.0) { + unsigned int screen_width = + get_emul_resolution_width() * current_scale_factor; + unsigned int screen_height = + get_emul_resolution_height() * current_scale_factor; + + int margin_w = screen_width - guide->w; + int margin_h = screen_height - guide->h; + + if (margin_w < 0 || margin_h < 0) { /* guide image scaling */ + int margin = (margin_w < margin_h)? margin_w : margin_h; + dst_w = guide->w + margin; + dst_h = guide->h + margin; + SDL_Surface *scaled_guide = SDL_CreateRGBSurface( - SDL_SWSURFACE, - guide->w * current_scale_factor, - guide->h * current_scale_factor, - get_emul_sdl_bpp(), + SDL_SWSURFACE, dst_w, dst_h, get_emul_sdl_bpp(), guide->format->Rmask, guide->format->Gmask, guide->format->Bmask, guide->format->Amask); scaled_guide = maru_do_pixman_scale(guide, scaled_guide); - dst_w = scaled_guide->w; - dst_h = scaled_guide->h; dst_x = (surface_screen->w - dst_w) / 2; dst_y = (surface_screen->h - dst_h) / 2; SDL_Rect dst_rect = { dst_x, dst_y, dst_w, dst_h }; 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 41a4f6c..d5b9582 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 @@ -284,8 +284,8 @@ public class EmulatorShmSkin extends EmulatorSkin { logger.info("Advanced graphics not supported"); } */ - int ww = lcdCanvas.getSize().x; - int hh = lcdCanvas.getSize().y; + final int screen_width = lcdCanvas.getSize().x; + final int screen_height = lcdCanvas.getSize().y; /* if (pollThread.getWaitIntervalTime() == 0) { logger.info("draw black screen"); @@ -297,24 +297,25 @@ public class EmulatorShmSkin extends EmulatorSkin { if (currentState.getCurrentAngle() == 0) { /* portrait */ e.gc.drawImage(pollThread.imageFramebuffer, 0, 0, pollThread.widthFB, pollThread.heightFB, - 0, 0, ww, hh); + 0, 0, screen_width, screen_height); } else { /* non-portrait */ Transform newTransform = new Transform(lcdCanvas.getDisplay()); Transform oldTransform = new Transform(lcdCanvas.getDisplay()); newTransform.rotate(currentState.getCurrentAngle()); + int frame_width = 0, frame_height = 0; if (currentState.getCurrentAngle() == 90) { /* reverse landscape */ - int temp = ww; - ww = hh; - hh = temp; - newTransform.translate(0, hh * -1); + frame_width = screen_height; + frame_height = screen_width; + newTransform.translate(0, frame_height * -1); } else if (currentState.getCurrentAngle() == 180) { /* reverse portrait */ - newTransform.translate(ww * -1, hh * -1); + frame_width = screen_width; + frame_height = screen_height; + newTransform.translate(frame_width * -1, frame_height * -1); } else if (currentState.getCurrentAngle() == -90) { /* landscape */ - int temp = ww; - ww = hh; - hh = temp; - newTransform.translate(ww * -1, 0); + frame_width = screen_height; + frame_height = screen_width; + newTransform.translate(frame_width * -1, 0); } /* save current transform as oldTransform */ @@ -323,7 +324,7 @@ public class EmulatorShmSkin extends EmulatorSkin { e.gc.setTransform(newTransform); e.gc.drawImage(pollThread.imageFramebuffer, 0, 0, pollThread.widthFB, pollThread.heightFB, - 0, 0, ww, hh); + 0, 0, frame_width, frame_height); /* back to old transform */ e.gc.setTransform(oldTransform); @@ -335,18 +336,23 @@ public class EmulatorShmSkin extends EmulatorSkin { if (imageGuide != null) { logger.info("draw blank guide"); - float convertedScale = SkinUtil.convertScale( - currentState.getCurrentScale()); - int widthImage = imageGuide.getImageData().width; int heightImage = imageGuide.getImageData().height; - int scaledWidthImage = (int)(widthImage * convertedScale); - int scaledHeightImage = (int)(heightImage * convertedScale); + int margin_w = screen_width - widthImage; + int margin_h = screen_height - heightImage; + int margin = Math.min(margin_w, margin_h); + + int scaledWidthImage = widthImage; + int scaledHeightImage = heightImage; + if (margin < 0) { + scaledWidthImage += margin; + scaledHeightImage += margin; + } e.gc.drawImage(imageGuide, 0, 0, widthImage, heightImage, - (lcdCanvas.getSize().x - scaledWidthImage) / 2, - (lcdCanvas.getSize().y - scaledHeightImage) / 2, + (screen_width - scaledWidthImage) / 2, + (screen_height - scaledHeightImage) / 2, scaledWidthImage, scaledHeightImage); imageGuide = null; -- 2.7.4