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

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

Issue 2367423002: Change Viewport calculations to use screen size without System UI (Closed)
Patch Set: Created 4 years, 3 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 | no next file » | 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 a524417d727f84217e73c0a7bed2cac469fd639e..f47a651e2723faf7b74c97e9b93b379bb2b19b48 100644
--- a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java
+++ b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java
@@ -87,28 +87,14 @@ public class DesktopCanvas {
}
/**
- * Returns the current size of the viewport. This size includes the offset calculations for
- * any visible system UI.
- *
- * @return A point representing the current size of the viewport.
- */
- private PointF getViewportSize() {
- float adjustedScreenWidth = mRenderData.screenWidth - mSystemUiOffsetPixels.right;
- float adjustedScreenHeight = mRenderData.screenHeight - mSystemUiOffsetPixels.bottom;
-
- return new PointF(adjustedScreenWidth, adjustedScreenHeight);
- }
-
- /**
* Returns the true center position of the viewport (in image coordinates).
*
* @return A point representing the true center position of the viewport.
*/
private PointF getTrueViewportCenter() {
- PointF viewportSize = getViewportSize();
-
// Find the center point of the viewport on the screen.
- float[] viewportPosition = {((float) viewportSize.x / 2), ((float) viewportSize.y / 2)};
+ float[] viewportPosition = {
+ ((float) mRenderData.screenWidth / 2), ((float) mRenderData.screenHeight / 2)};
// Convert the screen position to an image position.
Matrix screenToImage = new Matrix();
@@ -156,7 +142,6 @@ public class DesktopCanvas {
* center position before being adjusted to fit the screen boundaries.
*/
public void repositionImage(boolean centerViewport) {
- PointF viewportSize = getViewportSize();
// The goal of the code below is to position the viewport as close to the desired center
// position as possible whilst keeping as much of the desktop in view as possible.
// To achieve these goals, we first position the desktop image at the desired center
@@ -166,10 +151,11 @@ public class DesktopCanvas {
float[] viewportPosition = {mViewportPosition.x, mViewportPosition.y};
mRenderData.transform.mapPoints(viewportPosition);
+ float viewportTransX = ((float) mRenderData.screenWidth / 2) - viewportPosition[0];
+ float viewportTransY = ((float) mRenderData.screenHeight / 2) - viewportPosition[1];
+
// Translate so the viewport is displayed in the middle of the screen.
- mRenderData.transform.postTranslate(
- ((float) viewportSize.x / 2) - viewportPosition[0],
- ((float) viewportSize.y / 2) - viewportPosition[1]);
+ mRenderData.transform.postTranslate(viewportTransX, viewportTransY);
}
// Get the coordinates of the desktop rectangle (top-left/bottom-right corners) in
@@ -186,7 +172,7 @@ public class DesktopCanvas {
float xAdjust = 0;
float yAdjust = 0;
- if (rectScreen.right - rectScreen.left < viewportSize.x) {
+ if (rectScreen.right - rectScreen.left < mRenderData.screenWidth) {
// Image is narrower than the screen, so center it.
xAdjust = -(rightDelta + leftDelta) / 2;
} else if (leftDelta > 0 && rightDelta > 0) {
@@ -198,7 +184,7 @@ public class DesktopCanvas {
}
// Apply similar logic for yAdjust.
- if (rectScreen.bottom - rectScreen.top < viewportSize.y) {
+ if (rectScreen.bottom - rectScreen.top < mRenderData.screenHeight) {
yAdjust = -(bottomDelta + topDelta) / 2;
} else if (topDelta > 0 && bottomDelta > 0) {
yAdjust = -Math.min(topDelta, bottomDelta);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698