Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| index 986745ec1f821fe917ff2b74731dd619fafbfb87..19bc6c589da564fc2de0374e865513377a8a71dc 100644 |
| --- a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| +++ b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java |
| @@ -91,7 +91,7 @@ public class DesktopCanvas { |
| return new PointF(adjustedScreenWidth, adjustedScreenHeight); |
| } |
| - /** Repositions the image by zooming it such that the complete image fits on the screen. */ |
| + /** Repositions the image by zooming it such that the image is displayed without borders. */ |
| public void resizeImageToFitScreen() { |
| synchronized (mRenderData) { |
| // Protect against being called before the image has been initialized. |
| @@ -99,31 +99,17 @@ public class DesktopCanvas { |
| return; |
| } |
| - float screenToImageScale = 1.0f; |
| - float[] imageSize = {mRenderData.imageWidth, mRenderData.imageHeight}; |
| - mRenderData.transform.mapVectors(imageSize); |
| - |
| - // If the image is smaller than the screen in both dimensions, then we want |
| - // to scale it up to fit. |
| - boolean scaleImageUp = imageSize[0] < mRenderData.screenWidth |
| - && imageSize[1] < mRenderData.screenHeight; |
| - |
| - // If the image is larger than the screen in any dimension, we want to |
| - // shrink it to fit. |
| - boolean scaleImageDown = imageSize[0] > mRenderData.screenWidth |
| - || imageSize[1] > mRenderData.screenHeight; |
| - |
| - if (scaleImageUp || scaleImageDown) { |
| - // Displayed image is too small or too large to fit the screen dimensions. |
| - // Apply the minimum scale needed to fit both the width and height. |
| - screenToImageScale = |
| - Math.min((float) mRenderData.screenWidth / mRenderData.imageWidth, |
| - (float) mRenderData.screenHeight / mRenderData.imageHeight); |
| + float widthRatio = (float) mRenderData.screenWidth / mRenderData.imageWidth; |
| + float heightRatio = (float) mRenderData.screenHeight / mRenderData.imageHeight; |
| + float screenToImageScale = Math.max(widthRatio, heightRatio); |
| + // If the image is smaller than the screen in either dimension, then we want to scale it |
|
Lambros
2016/06/10 01:01:51
Blank line before comment please.
joedow
2016/06/10 03:46:16
Done.
|
| + // up to fit both and fill the screen with the image of the remote desktop. |
| + if (screenToImageScale > 1.0f) { |
| mRenderData.transform.setScale(screenToImageScale, screenToImageScale); |
| } |
| } |
| - repositionImage(true); |
| + repositionImage(false); |
| } |
| /** |