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

Side by Side Diff: content/renderer/input/input_handler_proxy.cc

Issue 206793003: cc: Split animating and drawing into separate actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix input handler proxy test build. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/thread_proxy.cc ('k') | content/renderer/input/input_handler_proxy_unittest.cc » ('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 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/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 "input", 323 "input",
324 "InputHandlerProxy::HandleGestureFling::started", 324 "InputHandlerProxy::HandleGestureFling::started",
325 this, 325 this,
326 "vx", 326 "vx",
327 gesture_event.data.flingStart.velocityX, 327 gesture_event.data.flingStart.velocityX,
328 "vy", 328 "vy",
329 gesture_event.data.flingStart.velocityY); 329 gesture_event.data.flingStart.velocityY);
330 // Note that the timestamp will only be used to kickstart the animation if 330 // Note that the timestamp will only be used to kickstart the animation if
331 // its sufficiently close to the timestamp of the first call |Animate()|. 331 // its sufficiently close to the timestamp of the first call |Animate()|.
332 has_fling_animation_started_ = false; 332 has_fling_animation_started_ = false;
333 fling_parameters_.startTime = gesture_event.timeStampSeconds; 333 fling_parameters_.startTime = gesture_event.timeStampSeconds;
334 fling_parameters_.delta = 334 fling_parameters_.delta =
335 WebFloatPoint(gesture_event.data.flingStart.velocityX, 335 WebFloatPoint(gesture_event.data.flingStart.velocityX,
336 gesture_event.data.flingStart.velocityY); 336 gesture_event.data.flingStart.velocityY);
337 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); 337 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y);
338 fling_parameters_.globalPoint = 338 fling_parameters_.globalPoint =
339 WebPoint(gesture_event.globalX, gesture_event.globalY); 339 WebPoint(gesture_event.globalX, gesture_event.globalY);
340 fling_parameters_.modifiers = gesture_event.modifiers; 340 fling_parameters_.modifiers = gesture_event.modifiers;
341 fling_parameters_.sourceDevice = gesture_event.sourceDevice; 341 fling_parameters_.sourceDevice = gesture_event.sourceDevice;
342 input_handler_->ScheduleAnimation(); 342 input_handler_->SetNeedsAnimate();
343 return DID_HANDLE; 343 return DID_HANDLE;
344 } 344 }
345 case cc::InputHandler::ScrollUnknown: 345 case cc::InputHandler::ScrollUnknown:
346 case cc::InputHandler::ScrollOnMainThread: { 346 case cc::InputHandler::ScrollOnMainThread: {
347 TRACE_EVENT_INSTANT0("input", 347 TRACE_EVENT_INSTANT0("input",
348 "InputHandlerProxy::HandleGestureFling::" 348 "InputHandlerProxy::HandleGestureFling::"
349 "scroll_on_main_thread", 349 "scroll_on_main_thread",
350 TRACE_EVENT_SCOPE_THREAD); 350 TRACE_EVENT_SCOPE_THREAD);
351 fling_may_be_active_on_main_thread_ = true; 351 fling_may_be_active_on_main_thread_ = true;
352 return DID_NOT_HANDLE; 352 return DID_NOT_HANDLE;
(...skipping 20 matching lines...) Expand all
373 373
374 void InputHandlerProxy::Animate(base::TimeTicks time) { 374 void InputHandlerProxy::Animate(base::TimeTicks time) {
375 if (!fling_curve_) 375 if (!fling_curve_)
376 return; 376 return;
377 377
378 double monotonic_time_sec = InSecondsF(time); 378 double monotonic_time_sec = InSecondsF(time);
379 if (!has_fling_animation_started_) { 379 if (!has_fling_animation_started_) {
380 has_fling_animation_started_ = true; 380 has_fling_animation_started_ = true;
381 // Guard against invalid, future or sufficiently stale start times, as there 381 // Guard against invalid, future or sufficiently stale start times, as there
382 // are no guarantees fling event and animation timestamps are compatible. 382 // are no guarantees fling event and animation timestamps are compatible.
383 if (!fling_parameters_.startTime || 383 if (!fling_parameters_.startTime ||
384 monotonic_time_sec <= fling_parameters_.startTime || 384 monotonic_time_sec <= fling_parameters_.startTime ||
385 monotonic_time_sec >= fling_parameters_.startTime + 385 monotonic_time_sec >= fling_parameters_.startTime +
386 kMaxSecondsFromFlingTimestampToFirstAnimate) { 386 kMaxSecondsFromFlingTimestampToFirstAnimate) {
387 fling_parameters_.startTime = monotonic_time_sec; 387 fling_parameters_.startTime = monotonic_time_sec;
388 input_handler_->ScheduleAnimation(); 388 input_handler_->SetNeedsAnimate();
389 return; 389 return;
390 } 390 }
391 } 391 }
392 392
393 bool fling_is_active = 393 bool fling_is_active =
394 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, 394 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime,
395 this); 395 this);
396 396
397 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_) 397 if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_)
398 fling_is_active = false; 398 fling_is_active = false;
399 399
400 if (fling_is_active) { 400 if (fling_is_active) {
401 input_handler_->ScheduleAnimation(); 401 input_handler_->SetNeedsAnimate();
402 } else { 402 } else {
403 TRACE_EVENT_INSTANT0("input", 403 TRACE_EVENT_INSTANT0("input",
404 "InputHandlerProxy::animate::flingOver", 404 "InputHandlerProxy::animate::flingOver",
405 TRACE_EVENT_SCOPE_THREAD); 405 TRACE_EVENT_SCOPE_THREAD);
406 CancelCurrentFling(true); 406 CancelCurrentFling(true);
407 } 407 }
408 } 408 }
409 409
410 void InputHandlerProxy::MainThreadHasStoppedFlinging() { 410 void InputHandlerProxy::MainThreadHasStoppedFlinging() {
411 fling_may_be_active_on_main_thread_ = false; 411 fling_may_be_active_on_main_thread_ = false;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // trigger a scroll, e.g., with a trivial time delta between fling updates. 561 // trigger a scroll, e.g., with a trivial time delta between fling updates.
562 // Return true in this case to prevent early fling termination. 562 // Return true in this case to prevent early fling termination.
563 if (std::abs(clipped_increment.width) < kScrollEpsilon && 563 if (std::abs(clipped_increment.width) < kScrollEpsilon &&
564 std::abs(clipped_increment.height) < kScrollEpsilon) 564 std::abs(clipped_increment.height) < kScrollEpsilon)
565 return true; 565 return true;
566 566
567 return did_scroll; 567 return did_scroll;
568 } 568 }
569 569
570 } // namespace content 570 } // namespace content
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.cc ('k') | content/renderer/input/input_handler_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698