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

Side by Side Diff: content/browser/renderer_host/input/synthetic_smooth_move_gesture.cc

Issue 2742473002: gpu benchmarking swipe for touchpad
Patch Set: Update direction in tests that use swipeElement/Page to maintain the same behavior. Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/renderer_host/input/synthetic_smooth_move_gesture.h" 5 #include "content/browser/renderer_host/input/synthetic_smooth_move_gesture.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gfx/geometry/point_f.h" 10 #include "ui/gfx/geometry/point_f.h"
(...skipping 20 matching lines...) Expand all
31 31
32 double ConvertTimestampToSeconds(const base::TimeTicks& timestamp) { 32 double ConvertTimestampToSeconds(const base::TimeTicks& timestamp) {
33 return (timestamp - base::TimeTicks()).InSecondsF(); 33 return (timestamp - base::TimeTicks()).InSecondsF();
34 } 34 }
35 35
36 const int kDefaultSpeedInPixelsPerSec = 800; 36 const int kDefaultSpeedInPixelsPerSec = 800;
37 37
38 } // namespace 38 } // namespace
39 39
40 SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams() 40 SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams()
41 : speed_in_pixels_s(kDefaultSpeedInPixelsPerSec), 41 : velocity(gfx::Vector2dF(0, 0)),
42 speed_in_pixels_s(kDefaultSpeedInPixelsPerSec),
42 prevent_fling(true), 43 prevent_fling(true),
43 add_slop(true) {} 44 add_slop(true) {}
44 45
45 SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams( 46 SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams(
46 const SyntheticSmoothMoveGestureParams& other) = default; 47 const SyntheticSmoothMoveGestureParams& other) = default;
47 48
48 SyntheticSmoothMoveGestureParams::~SyntheticSmoothMoveGestureParams() {} 49 SyntheticSmoothMoveGestureParams::~SyntheticSmoothMoveGestureParams() {}
49 50
50 SyntheticSmoothMoveGesture::SyntheticSmoothMoveGesture( 51 SyntheticSmoothMoveGesture::SyntheticSmoothMoveGesture(
51 SyntheticSmoothMoveGestureParams params) 52 SyntheticSmoothMoveGestureParams params)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 gfx::Vector2d delta_discrete = 171 gfx::Vector2d delta_discrete =
171 FloorTowardZero(current_move_segment_total_delta - 172 FloorTowardZero(current_move_segment_total_delta -
172 current_move_segment_total_delta_discrete_); 173 current_move_segment_total_delta_discrete_);
173 ForwardMouseWheelEvent(target, delta_discrete, event_timestamp); 174 ForwardMouseWheelEvent(target, delta_discrete, event_timestamp);
174 current_move_segment_total_delta_discrete_ += delta_discrete; 175 current_move_segment_total_delta_discrete_ += delta_discrete;
175 176
176 if (FinishedCurrentMoveSegment(event_timestamp)) { 177 if (FinishedCurrentMoveSegment(event_timestamp)) {
177 if (!IsLastMoveSegment()) { 178 if (!IsLastMoveSegment()) {
178 current_move_segment_total_delta_discrete_ = gfx::Vector2d(); 179 current_move_segment_total_delta_discrete_ = gfx::Vector2d();
179 ComputeNextMoveSegment(); 180 ComputeNextMoveSegment();
180 ForwardMouseWheelInputEvents(timestamp, target); 181 } else if (params_.prevent_fling) {
182 state_ = DONE;
181 } else { 183 } else {
182 state_ = DONE; 184 state_ = STOPPING;
183 } 185 }
184 } 186 }
185 } break; 187 } break;
188 case STOPPING: {
189 gfx::Vector2d velocity_discrete = FloorTowardZero(params_.velocity);
190 ForwardTouchpadFlingEvent(target, velocity_discrete, timestamp);
191 state_ = DONE;
192 } break;
186 case SETUP: 193 case SETUP:
187 NOTREACHED() << "State SETUP invalid for synthetic scroll using mouse " 194 NOTREACHED() << "State SETUP invalid for synthetic scroll using mouse "
188 "wheel input."; 195 "wheel input.";
189 case STOPPING:
190 NOTREACHED() << "State STOPPING invalid for synthetic scroll using mouse "
191 "wheel input.";
192 case DONE: 196 case DONE:
193 NOTREACHED() 197 NOTREACHED()
194 << "State DONE invalid for synthetic scroll using mouse wheel input."; 198 << "State DONE invalid for synthetic scroll using mouse wheel input.";
195 } 199 }
196 } 200 }
197 201
198 void SyntheticSmoothMoveGesture::ForwardMouseClickInputEvents( 202 void SyntheticSmoothMoveGesture::ForwardMouseClickInputEvents(
199 const base::TimeTicks& timestamp, 203 const base::TimeTicks& timestamp,
200 SyntheticGestureTarget* target) { 204 SyntheticGestureTarget* target) {
201 base::TimeTicks event_timestamp = timestamp; 205 base::TimeTicks event_timestamp = timestamp;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 251
248 mouse_wheel_event.SetPositionInWidget( 252 mouse_wheel_event.SetPositionInWidget(
249 current_move_segment_start_position_.x(), 253 current_move_segment_start_position_.x(),
250 current_move_segment_start_position_.y()); 254 current_move_segment_start_position_.y());
251 255
252 mouse_wheel_event.SetTimeStampSeconds(ConvertTimestampToSeconds(timestamp)); 256 mouse_wheel_event.SetTimeStampSeconds(ConvertTimestampToSeconds(timestamp));
253 257
254 target->DispatchInputEventToPlatform(mouse_wheel_event); 258 target->DispatchInputEventToPlatform(mouse_wheel_event);
255 } 259 }
256 260
261 void SyntheticSmoothMoveGesture::ForwardTouchpadFlingEvent(
262 SyntheticGestureTarget* target,
263 const gfx::Vector2dF& velocity,
264 const base::TimeTicks& timestamp) const {
265 blink::WebGestureEvent fling_event =
266 SyntheticWebGestureEventBuilder::BuildFling(
267 velocity.x(), velocity.y(),
268 blink::WebGestureDevice::kWebGestureDeviceTouchpad);
269
270 fling_event.x = current_move_segment_start_position_.x();
271 fling_event.y = current_move_segment_start_position_.y();
272
273 fling_event.SetTimeStampSeconds(ConvertTimestampToSeconds(timestamp));
274
275 target->DispatchInputEventToPlatform(fling_event);
276 }
277
257 void SyntheticSmoothMoveGesture::PressPoint(SyntheticGestureTarget* target, 278 void SyntheticSmoothMoveGesture::PressPoint(SyntheticGestureTarget* target,
258 const base::TimeTicks& timestamp) { 279 const base::TimeTicks& timestamp) {
259 DCHECK_EQ(current_move_segment_, 0); 280 DCHECK_EQ(current_move_segment_, 0);
260 synthetic_pointer_driver_->Press(current_move_segment_start_position_.x(), 281 synthetic_pointer_driver_->Press(current_move_segment_start_position_.x(),
261 current_move_segment_start_position_.y()); 282 current_move_segment_start_position_.y());
262 synthetic_pointer_driver_->DispatchEvent(target, timestamp); 283 synthetic_pointer_driver_->DispatchEvent(target, timestamp);
263 } 284 }
264 285
265 void SyntheticSmoothMoveGesture::MovePoint(SyntheticGestureTarget* target, 286 void SyntheticSmoothMoveGesture::MovePoint(SyntheticGestureTarget* target,
266 const gfx::Vector2dF& delta, 287 const gfx::Vector2dF& delta,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 DCHECK_LT(current_move_segment_, static_cast<int>(params_.distances.size())); 358 DCHECK_LT(current_move_segment_, static_cast<int>(params_.distances.size()));
338 return current_move_segment_ == 359 return current_move_segment_ ==
339 static_cast<int>(params_.distances.size()) - 1; 360 static_cast<int>(params_.distances.size()) - 1;
340 } 361 }
341 362
342 bool SyntheticSmoothMoveGesture::MoveIsNoOp() const { 363 bool SyntheticSmoothMoveGesture::MoveIsNoOp() const {
343 return params_.distances.size() == 0 || params_.distances[0].IsZero(); 364 return params_.distances.size() == 0 || params_.distances[0].IsZero();
344 } 365 }
345 366
346 } // namespace content 367 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698