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

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

Issue 2272483002: [Remoting Android] Remove Synchronizations on RenderData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback / Merge ToT Created 4 years, 4 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
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.content.Context; 7 import android.content.Context;
8 import android.graphics.PointF; 8 import android.graphics.PointF;
9 import android.os.SystemClock; 9 import android.os.SystemClock;
10 import android.view.MotionEvent; 10 import android.view.MotionEvent;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // on their muscle memory when interacting with our UI. With respect to the original 70 // on their muscle memory when interacting with our UI. With respect to the original
71 // problem, getScaledDoubleTapSlop() gives a value which is optimized fo r an Android based 71 // problem, getScaledDoubleTapSlop() gives a value which is optimized fo r an Android based
72 // UI however this value is too large for interacting with remote elemen ts in our app. 72 // UI however this value is too large for interacting with remote elemen ts in our app.
73 // Our solution is to use the original value from getScaledDoubleTapSlop () (which includes 73 // Our solution is to use the original value from getScaledDoubleTapSlop () (which includes
74 // scaling to account for display differences between devices) and apply a fudge/scale 74 // scaling to account for display differences between devices) and apply a fudge/scale
75 // factor to make the interaction more intuitive and useful for our scen ario. 75 // factor to make the interaction more intuitive and useful for our scen ario.
76 int scaledDoubleTapSlopInPx = config.getScaledDoubleTapSlop(); 76 int scaledDoubleTapSlopInPx = config.getScaledDoubleTapSlop();
77 scaledDoubleTapSlopInPx *= DOUBLE_TAP_SLOP_SCALE_FACTOR; 77 scaledDoubleTapSlopInPx *= DOUBLE_TAP_SLOP_SCALE_FACTOR;
78 mDoubleTapSlopSquareInPx = scaledDoubleTapSlopInPx * scaledDoubleTapSlop InPx; 78 mDoubleTapSlopSquareInPx = scaledDoubleTapSlopInPx * scaledDoubleTapSlop InPx;
79 79
80 synchronized (mRenderData) { 80 mRenderData.drawCursor = false;
81 mRenderData.drawCursor = false;
82 }
83 } 81 }
84 82
85 @Override 83 @Override
86 public boolean onTap(int button) { 84 public boolean onTap(int button) {
87 PointF currentTapPoint = getCursorPosition(); 85 PointF currentTapPoint = getCursorPosition();
88 if (button == InputStub.BUTTON_LEFT) { 86 if (button == InputStub.BUTTON_LEFT) {
89 // Left clicks are handled a little differently than the events for other buttons. 87 // Left clicks are handled a little differently than the events for other buttons.
90 // This is needed because translating touch events to mouse events h as a problem with 88 // This is needed because translating touch events to mouse events h as a problem with
91 // location consistency for double clicks. If you take the center l ocation of each tap 89 // location consistency for double clicks. If you take the center l ocation of each tap
92 // and inject them as mouse clicks, the distance between those two p oints will often 90 // and inject them as mouse clicks, the distance between those two p oints will often
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 public DesktopView.InputFeedbackType getLongPressFeedbackType() { 145 public DesktopView.InputFeedbackType getLongPressFeedbackType() {
148 return DesktopView.InputFeedbackType.LARGE_ANIMATION; 146 return DesktopView.InputFeedbackType.LARGE_ANIMATION;
149 } 147 }
150 148
151 @Override 149 @Override
152 public boolean isIndirectInputMode() { 150 public boolean isIndirectInputMode() {
153 return false; 151 return false;
154 } 152 }
155 153
156 private PointF getCursorPosition() { 154 private PointF getCursorPosition() {
157 synchronized (mRenderData) { 155 return mRenderData.getCursorPosition();
158 return mRenderData.getCursorPosition();
159 }
160 } 156 }
161 157
162 private boolean isDoubleTap(float currentX, float currentY, long tapInterval ) { 158 private boolean isDoubleTap(float currentX, float currentY, long tapInterval ) {
163 if (tapInterval > mDoubleTapDurationInMs || mLastTapPoint == null) { 159 if (tapInterval > mDoubleTapDurationInMs || mLastTapPoint == null) {
164 return false; 160 return false;
165 } 161 }
166 162
167 // Convert the image based coordinates back to screen coordinates so the user experiences 163 // Convert the image based coordinates back to screen coordinates so the user experiences
168 // consistent double tap behavior regardless of zoom level. 164 // consistent double tap behavior regardless of zoom level.
169 // 165 //
170 float[] currentValues = {currentX, currentY}; 166 float[] currentValues = {currentX, currentY};
171 float[] previousValues = {mLastTapPoint.x, mLastTapPoint.y}; 167 float[] previousValues = {mLastTapPoint.x, mLastTapPoint.y};
172 synchronized (mRenderData) { 168
173 mRenderData.transform.mapPoints(currentValues); 169 mRenderData.transform.mapPoints(currentValues);
174 mRenderData.transform.mapPoints(previousValues); 170 mRenderData.transform.mapPoints(previousValues);
175 }
176 171
177 int deltaX = (int) (currentValues[0] - previousValues[0]); 172 int deltaX = (int) (currentValues[0] - previousValues[0]);
178 int deltaY = (int) (currentValues[1] - previousValues[1]); 173 int deltaY = (int) (currentValues[1] - previousValues[1]);
179 return ((deltaX * deltaX + deltaY * deltaY) <= mDoubleTapSlopSquareInPx) ; 174 return ((deltaX * deltaX + deltaY * deltaY) <= mDoubleTapSlopSquareInPx) ;
180 } 175 }
181 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698