display: modified Blank Guide image resizing 52/12852/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 22 Nov 2013 05:13:41 +0000 (14:13 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Fri, 22 Nov 2013 06:20:40 +0000 (15:20 +0900)
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 <giwoong.kim@samsung.com>
tizen/src/maru_sdl.c
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java

index 571ed36c6a4f0396c5597e7cdb5227752c82936f..e7910088192567b58f4b0b5a9ed39b48d1b329ba 100644 (file)
@@ -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 };
index 41a4f6c1d3b6d929f34a60c5835f8992e7650942..d5b9582cdddf4c8865fc1965fd2854967473f9cd 100644 (file)
@@ -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;