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

Side by Side Diff: cc/layers/viewport.cc

Issue 2040543002: Take MT jank into account when animating the scroll offset on CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix constant Created 4 years, 6 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 #include "cc/layers/viewport.h" 5 #include "cc/layers/viewport.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/input/top_controls_manager.h" 9 #include "cc/input/top_controls_manager.h"
10 #include "cc/trees/layer_tree_host_impl.h" 10 #include "cc/trees/layer_tree_host_impl.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 bool Viewport::ShouldAnimateViewport(const gfx::Vector2dF& viewport_delta, 67 bool Viewport::ShouldAnimateViewport(const gfx::Vector2dF& viewport_delta,
68 const gfx::Vector2dF& pending_delta) { 68 const gfx::Vector2dF& pending_delta) {
69 float max_dim_viewport_delta = 69 float max_dim_viewport_delta =
70 std::max(std::abs(viewport_delta.x()), std::abs(viewport_delta.y())); 70 std::max(std::abs(viewport_delta.x()), std::abs(viewport_delta.y()));
71 float max_dim_pending_delta = 71 float max_dim_pending_delta =
72 std::max(std::abs(pending_delta.x()), std::abs(pending_delta.y())); 72 std::max(std::abs(pending_delta.x()), std::abs(pending_delta.y()));
73 return max_dim_viewport_delta > max_dim_pending_delta; 73 return max_dim_viewport_delta > max_dim_pending_delta;
74 } 74 }
75 75
76 gfx::Vector2dF Viewport::ScrollAnimated(const gfx::Vector2dF& delta) { 76 gfx::Vector2dF Viewport::ScrollAnimated(const gfx::Vector2dF& delta,
77 base::TimeTicks original_event_time) {
77 ScrollTree& scroll_tree = 78 ScrollTree& scroll_tree =
78 host_impl_->active_tree()->property_trees()->scroll_tree; 79 host_impl_->active_tree()->property_trees()->scroll_tree;
79 80
80 float scale_factor = host_impl_->active_tree()->current_page_scale_factor(); 81 float scale_factor = host_impl_->active_tree()->current_page_scale_factor();
81 gfx::Vector2dF scaled_delta = delta; 82 gfx::Vector2dF scaled_delta = delta;
82 scaled_delta.Scale(1.f / scale_factor); 83 scaled_delta.Scale(1.f / scale_factor);
83 84
84 ScrollNode* inner_node = 85 ScrollNode* inner_node =
85 scroll_tree.Node(InnerScrollLayer()->scroll_tree_index()); 86 scroll_tree.Node(InnerScrollLayer()->scroll_tree_index());
86 gfx::Vector2dF inner_delta = 87 gfx::Vector2dF inner_delta =
(...skipping 10 matching lines...) Expand all
97 if (inner_delta.IsZero() && outer_delta.IsZero()) 98 if (inner_delta.IsZero() && outer_delta.IsZero())
98 return gfx::Vector2dF(0, 0); 99 return gfx::Vector2dF(0, 0);
99 100
100 // Animate the viewport to which the majority of scroll delta will be applied. 101 // Animate the viewport to which the majority of scroll delta will be applied.
101 // The animation system only supports running one scroll offset animation. 102 // The animation system only supports running one scroll offset animation.
102 // TODO(ymalik): Fix the visible jump seen by instant scrolling one of the 103 // TODO(ymalik): Fix the visible jump seen by instant scrolling one of the
103 // viewports. 104 // viewports.
104 bool will_animate = false; 105 bool will_animate = false;
105 if (ShouldAnimateViewport(inner_delta, outer_delta)) { 106 if (ShouldAnimateViewport(inner_delta, outer_delta)) {
106 scroll_tree.ScrollBy(outer_node, outer_delta, host_impl_->active_tree()); 107 scroll_tree.ScrollBy(outer_node, outer_delta, host_impl_->active_tree());
107 will_animate = host_impl_->ScrollAnimationCreate(inner_node, inner_delta); 108 will_animate = host_impl_->ScrollAnimationCreate(inner_node, inner_delta,
109 original_event_time);
108 } else { 110 } else {
109 scroll_tree.ScrollBy(inner_node, inner_delta, host_impl_->active_tree()); 111 scroll_tree.ScrollBy(inner_node, inner_delta, host_impl_->active_tree());
110 will_animate = host_impl_->ScrollAnimationCreate(outer_node, outer_delta); 112 will_animate = host_impl_->ScrollAnimationCreate(outer_node, outer_delta,
113 original_event_time);
111 } 114 }
112 115
113 if (will_animate) { 116 if (will_animate) {
114 // Consume entire scroll delta as long as we are starting an animation. 117 // Consume entire scroll delta as long as we are starting an animation.
115 return delta; 118 return delta;
116 } 119 }
117 120
118 pending_delta = scaled_delta - inner_delta - outer_delta; 121 pending_delta = scaled_delta - inner_delta - outer_delta;
119 pending_delta.Scale(scale_factor); 122 pending_delta.Scale(scale_factor);
120 return pending_delta; 123 return pending_delta;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 236
234 LayerImpl* Viewport::InnerScrollLayer() const { 237 LayerImpl* Viewport::InnerScrollLayer() const {
235 return host_impl_->InnerViewportScrollLayer(); 238 return host_impl_->InnerViewportScrollLayer();
236 } 239 }
237 240
238 LayerImpl* Viewport::OuterScrollLayer() const { 241 LayerImpl* Viewport::OuterScrollLayer() const {
239 return host_impl_->OuterViewportScrollLayer(); 242 return host_impl_->OuterViewportScrollLayer();
240 } 243 }
241 244
242 } // namespace cc 245 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698