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

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

Issue 2485143004: Always consider SystemUI for panning boundaries in split-screen mode (Closed)
Patch Set: Created 4 years, 1 month 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
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.Matrix; 7 import android.graphics.Matrix;
8 import android.graphics.PointF; 8 import android.graphics.PointF;
9 import android.graphics.Rect; 9 import android.graphics.Rect;
10 import android.graphics.RectF; 10 import android.graphics.RectF;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 updateCursorPosition( 105 updateCursorPosition(
106 mDesiredCenter.x + deltaX, mDesiredCenter.y + deltaY, getViewpor tBounds()); 106 mDesiredCenter.x + deltaX, mDesiredCenter.y + deltaY, getViewpor tBounds());
107 } 107 }
108 108
109 /** 109 /**
110 * Handles System UI size and visibility changes. 110 * Handles System UI size and visibility changes.
111 * 111 *
112 * @param parameter The set of values defining the current System UI state. 112 * @param parameter The set of values defining the current System UI state.
113 */ 113 */
114 public void onSystemUiVisibilityChanged(SystemUiVisibilityChangedEventParame ter parameter) { 114 public void onSystemUiVisibilityChanged(SystemUiVisibilityChangedEventParame ter parameter) {
115 if (parameter.softInputMethodVisible) { 115 mSystemUiScreenRect.set(parameter.left, parameter.top, parameter.right, parameter.bottom);
116 mSystemUiScreenRect.set( 116 stopOffsetReductionAnimation();
117 parameter.left, parameter.top, parameter.right, parameter.bo ttom);
118 117
119 stopOffsetReductionAnimation(); 118 PointF targetOffset;
119 if (mSystemUiScreenRect.isEmpty()) {
120 targetOffset = new PointF(0.0f, 0.0f);
120 } else { 121 } else {
121 mSystemUiScreenRect.setEmpty(); 122 // If the System UI size has changed such viewport offset is affecte d, then start an
122 startOffsetReductionAnimation(); 123 // animation to adjust the amount of offset used. This functionalit y ensures that we
124 // don't leave content-less areas on the screen when the System UI r esizes.
125 RectF systemUiOverlap = getSystemUiOverlap();
126 RectF newBounds = new RectF(-systemUiOverlap.left, -systemUiOverlap. top,
127 systemUiOverlap.right, systemUiOverlap.bottom);
128 targetOffset = new PointF(mViewportOffset.x, mViewportOffset.y);
129 constrainPointToBounds(targetOffset, newBounds);
130 }
131
132 if (!targetOffset.equals(mViewportOffset.x, mViewportOffset.y)) {
Lambros 2016/11/08 21:55:03 Is this a float equality comparison? Maybe better
joedow 2016/11/08 23:04:17 I wanted to use the Android class functions for th
133 startOffsetReductionAnimation(targetOffset);
123 } 134 }
124 135
125 if (mRenderData.initialized()) { 136 if (mRenderData.initialized()) {
126 // The viewport center may have changed so update the position to re flect the new value. 137 // The viewport center may have changed so update the position to re flect the new value.
127 repositionImage(); 138 repositionImage();
128 } 139 }
129 } 140 }
130 141
131 public void adjustViewportForSystemUi(boolean adjustViewportForSystemUi) { 142 public void adjustViewportForSystemUi(boolean adjustViewportForSystemUi) {
132 mAdjustViewportSizeForSystemUi = adjustViewportForSystemUi; 143 mAdjustViewportSizeForSystemUi = adjustViewportForSystemUi;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // viewport offset as a maximum boundary. If we add the offset first, t he result ends up 403 // viewport offset as a maximum boundary. If we add the offset first, t he result ends up
393 // being unbounded. Thus we use a temporary object for the boundary cal culation. 404 // being unbounded. Thus we use a temporary object for the boundary cal culation.
394 PointF requestedOffset = 405 PointF requestedOffset =
395 new PointF(mViewportOffset.x + offsets[0], mViewportOffset.y + o ffsets[1]); 406 new PointF(mViewportOffset.x + offsets[0], mViewportOffset.y + o ffsets[1]);
396 constrainPointToBounds(requestedOffset, getViewportOffsetBounds()); 407 constrainPointToBounds(requestedOffset, getViewportOffsetBounds());
397 mViewportOffset.set(requestedOffset); 408 mViewportOffset.set(requestedOffset);
398 } 409 }
399 410
400 /** 411 /**
401 * Starts an animation to smoothly reduce the viewport offset. Does nothing if an animation is 412 * Starts an animation to smoothly reduce the viewport offset. Does nothing if an animation is
402 * already running or the offset is already 0. 413 * already running or the offset is already 0.
Lambros 2016/11/08 21:55:03 "already 0" still correct?
joedow 2016/11/08 23:04:16 Yeah this is correct. There is no work to do if t
403 */ 414 */
404 private void startOffsetReductionAnimation() { 415 private void startOffsetReductionAnimation(final PointF targetOffset) {
405 if (mFrameRenderedCallback != null || mViewportOffset.length() < EPSILON ) { 416 if (mFrameRenderedCallback != null || mViewportOffset.length() < EPSILON ) {
Lambros 2016/11/08 21:55:02 Is this still the right test if targetOffset is no
joedow 2016/11/08 23:04:16 Yeah I think so. The point of this method is to r
406 return; 417 return;
407 } 418 }
408 419
409 mFrameRenderedCallback = new Event.ParameterCallback<Boolean, Void>() { 420 mFrameRenderedCallback = new Event.ParameterCallback<Boolean, Void>() {
410 private static final float DURATION_MS = 250.0f; 421 private static final float DURATION_MS = 250.0f;
411 422
412 private final Interpolator mInterpolator = new DecelerateInterpolato r(); 423 private final Interpolator mInterpolator = new DecelerateInterpolato r();
413 424
414 private long mStartTime = 0; 425 private long mStartTime = 0;
415 private float mOriginalX = 0.0f; 426 private final float mOriginalX = mViewportOffset.x - targetOffset.x;
416 private float mOriginalY = 0.0f; 427 private final float mOriginalY = mViewportOffset.y - targetOffset.y;
417 428
418 @Override 429 @Override
419 public Boolean run(Void p) { 430 public Boolean run(Void p) {
420 if (mFrameRenderedCallback == null) { 431 if (mFrameRenderedCallback == null) {
421 return false; 432 return false;
422 } 433 }
423 434
424 if (mStartTime == 0) { 435 if (mStartTime == 0) {
425 mStartTime = SystemClock.elapsedRealtime(); 436 mStartTime = SystemClock.elapsedRealtime();
426 mOriginalX = mViewportOffset.x;
427 mOriginalY = mViewportOffset.y;
428 } 437 }
429 438
430 float progress = (SystemClock.elapsedRealtime() - mStartTime) / DURATION_MS; 439 float progress = (SystemClock.elapsedRealtime() - mStartTime) / DURATION_MS;
431 if (progress < 1.0f) { 440 if (progress < 1.0f) {
432 float reductionFactor = 1.0f - mInterpolator.getInterpolatio n(progress); 441 float reductionFactor = 1.0f - mInterpolator.getInterpolatio n(progress);
433 mViewportOffset.set(mOriginalX * reductionFactor, mOriginalY * reductionFactor); 442 mViewportOffset.set(mOriginalX * reductionFactor + targetOff set.x,
443 mOriginalY * reductionFactor + targetOffset.y);
434 } else { 444 } else {
435 mViewportOffset.set(0.0f, 0.0f); 445 mViewportOffset.set(targetOffset.x, targetOffset.y);
436 mFrameRenderedCallback = null; 446 mFrameRenderedCallback = null;
437 } 447 }
438 448
439 repositionImage(); 449 repositionImage();
440 450
441 return mFrameRenderedCallback != null; 451 return mFrameRenderedCallback != null;
442 } 452 }
443 }; 453 };
444 454
445 mRenderStub.onCanvasRendered().addSelfRemovable(mFrameRenderedCallback); 455 mRenderStub.onCanvasRendered().addSelfRemovable(mFrameRenderedCallback);
446 } 456 }
447 457
448 /** 458 /**
449 * Stops an existing offset reduction animation. 459 * Stops an existing offset reduction animation.
450 */ 460 */
451 private void stopOffsetReductionAnimation() { 461 private void stopOffsetReductionAnimation() {
452 // Setting this value this null will prevent it from continuing to execu te. 462 // Setting this value this null will prevent it from continuing to execu te.
453 mFrameRenderedCallback = null; 463 mFrameRenderedCallback = null;
454 } 464 }
455 } 465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698