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

Side by Side 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: Cleaning up some logic in the handler class. 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.graphics.PointF; 7 import android.graphics.PointF;
8 import android.graphics.RectF; 8 import android.graphics.RectF;
9 9
10 /** 10 /**
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 public PointF getViewportSize() { 84 public PointF getViewportSize() {
85 float adjustedScreenWidth, adjustedScreenHeight; 85 float adjustedScreenWidth, adjustedScreenHeight;
86 synchronized (mRenderData) { 86 synchronized (mRenderData) {
87 adjustedScreenWidth = mRenderData.screenWidth - mInputMethodOffsetX; 87 adjustedScreenWidth = mRenderData.screenWidth - mInputMethodOffsetX;
88 adjustedScreenHeight = mRenderData.screenHeight - mInputMethodOffset Y; 88 adjustedScreenHeight = mRenderData.screenHeight - mInputMethodOffset Y;
89 } 89 }
90 90
91 return new PointF(adjustedScreenWidth, adjustedScreenHeight); 91 return new PointF(adjustedScreenWidth, adjustedScreenHeight);
92 } 92 }
93 93
94 /** Repositions the image by zooming it such that the complete image fits on the screen. */ 94 /** Repositions the image by zooming it such that the image is displayed wit hout borders. */
95 public void resizeImageToFitScreen() { 95 public void resizeImageToFitScreen() {
96 synchronized (mRenderData) { 96 synchronized (mRenderData) {
97 // Protect against being called before the image has been initialize d. 97 // Protect against being called before the image has been initialize d.
98 if (mRenderData.imageWidth == 0 || mRenderData.imageHeight == 0) { 98 if (mRenderData.imageWidth == 0 || mRenderData.imageHeight == 0) {
99 return; 99 return;
100 } 100 }
101 101
102 float screenToImageScale = 1.0f; 102 float widthRatio = (float) mRenderData.screenWidth / mRenderData.ima geWidth;
103 float[] imageSize = {mRenderData.imageWidth, mRenderData.imageHeight }; 103 float heightRatio = (float) mRenderData.screenHeight / mRenderData.i mageHeight;
104 mRenderData.transform.mapVectors(imageSize); 104 float screenToImageScale = Math.max(widthRatio, heightRatio);
105 105 // 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.
106 // If the image is smaller than the screen in both dimensions, then we want 106 // up to fit both and fill the screen with the image of the remote d esktop.
107 // to scale it up to fit. 107 if (screenToImageScale > 1.0f) {
108 boolean scaleImageUp = imageSize[0] < mRenderData.screenWidth
109 && imageSize[1] < mRenderData.screenHeight;
110
111 // If the image is larger than the screen in any dimension, we want to
112 // shrink it to fit.
113 boolean scaleImageDown = imageSize[0] > mRenderData.screenWidth
114 || imageSize[1] > mRenderData.screenHeight;
115
116 if (scaleImageUp || scaleImageDown) {
117 // Displayed image is too small or too large to fit the screen d imensions.
118 // Apply the minimum scale needed to fit both the width and heig ht.
119 screenToImageScale =
120 Math.min((float) mRenderData.screenWidth / mRenderData.i mageWidth,
121 (float) mRenderData.screenHeight / mRenderData. imageHeight);
122 mRenderData.transform.setScale(screenToImageScale, screenToImage Scale); 108 mRenderData.transform.setScale(screenToImageScale, screenToImage Scale);
123 } 109 }
124 } 110 }
125 111
126 repositionImage(true); 112 repositionImage(false);
127 } 113 }
128 114
129 /** 115 /**
130 * Repositions the image by translating it (without affecting the zoom level ). 116 * Repositions the image by translating it (without affecting the zoom level ).
131 * 117 *
132 * @param centerViewport Determines whether the viewport will be translated to the desired 118 * @param centerViewport Determines whether the viewport will be translated to the desired
133 * center position before being adjusted to fit the sc reen boundaries. 119 * center position before being adjusted to fit the sc reen boundaries.
134 */ 120 */
135 public void repositionImage(boolean centerViewport) { 121 public void repositionImage(boolean centerViewport) {
136 PointF adjustedViewportSize = getViewportSize(); 122 PointF adjustedViewportSize = getViewportSize();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // level needed to fit either the width or height. 205 // level needed to fit either the width or height.
220 float scale = Math.min((float) mRenderData.screenWidth / mRender Data.imageWidth, 206 float scale = Math.min((float) mRenderData.screenWidth / mRender Data.imageWidth,
221 (float) mRenderData.screenHeight / mRende rData.imageHeight); 207 (float) mRenderData.screenHeight / mRende rData.imageHeight);
222 mRenderData.transform.setScale(scale, scale); 208 mRenderData.transform.setScale(scale, scale);
223 } 209 }
224 } 210 }
225 211
226 repositionImage(centerViewport); 212 repositionImage(centerViewport);
227 } 213 }
228 } 214 }
OLDNEW
« 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