Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java

Issue 2058543002: Updating initial zoom level for remote connections in Android Client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing CR Feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..874697800986af858b459db23e285607a52b3cd1 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,18 @@ public class DesktopCanvas {
return;
}
- float screenToImageScale = 1.0f;
- float[] imageSize = {mRenderData.imageWidth, mRenderData.imageHeight};
- mRenderData.transform.mapVectors(imageSize);
+ 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 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);
+ // If the image is smaller than the screen in either dimension, then we want to scale it
+ // 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);
}
/**
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698