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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 16925007: Fix scrollbar fade animation scheduling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mock out physical time Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 active_tree_->ClearCurrentlyScrollingLayer(); 1920 active_tree_->ClearCurrentlyScrollingLayer();
1921 did_lock_scrolling_layer_ = false; 1921 did_lock_scrolling_layer_ = false;
1922 accumulated_root_overscroll_ = gfx::Vector2dF(); 1922 accumulated_root_overscroll_ = gfx::Vector2dF();
1923 current_fling_velocity_ = gfx::Vector2dF(); 1923 current_fling_velocity_ = gfx::Vector2dF();
1924 } 1924 }
1925 1925
1926 void LayerTreeHostImpl::ScrollEnd() { 1926 void LayerTreeHostImpl::ScrollEnd() {
1927 if (top_controls_manager_) 1927 if (top_controls_manager_)
1928 top_controls_manager_->ScrollEnd(); 1928 top_controls_manager_->ScrollEnd();
1929 ClearCurrentlyScrollingLayer(); 1929 ClearCurrentlyScrollingLayer();
1930 StartScrollbarAnimation(CurrentFrameTimeTicks()); 1930 StartScrollbarAnimation();
1931 } 1931 }
1932 1932
1933 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { 1933 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
1934 if (active_tree_->CurrentlyScrollingLayer()) 1934 if (active_tree_->CurrentlyScrollingLayer())
1935 return ScrollStarted; 1935 return ScrollStarted;
1936 1936
1937 return ScrollIgnored; 1937 return ScrollIgnored;
1938 } 1938 }
1939 1939
1940 void LayerTreeHostImpl::NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) { 1940 void LayerTreeHostImpl::NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 TRACE_EVENT_INSTANT0( 2192 TRACE_EVENT_INSTANT0(
2193 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars", 2193 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars",
2194 TRACE_EVENT_SCOPE_THREAD); 2194 TRACE_EVENT_SCOPE_THREAD);
2195 client_->SetNeedsRedrawOnImplThread(); 2195 client_->SetNeedsRedrawOnImplThread();
2196 } 2196 }
2197 2197
2198 for (size_t i = 0; i < layer->children().size(); ++i) 2198 for (size_t i = 0; i < layer->children().size(); ++i)
2199 AnimateScrollbarsRecursive(layer->children()[i], time); 2199 AnimateScrollbarsRecursive(layer->children()[i], time);
2200 } 2200 }
2201 2201
2202 void LayerTreeHostImpl::StartScrollbarAnimation(base::TimeTicks time) { 2202 void LayerTreeHostImpl::StartScrollbarAnimation() {
2203 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); 2203 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation");
2204 StartScrollbarAnimationRecursive(RootLayer(), time); 2204 StartScrollbarAnimationRecursive(RootLayer(), CurrentPhysicalTimeTicks());
2205 } 2205 }
2206 2206
2207 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, 2207 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer,
2208 base::TimeTicks time) { 2208 base::TimeTicks time) {
2209 if (!layer) 2209 if (!layer)
2210 return; 2210 return;
2211 2211
2212 ScrollbarAnimationController* scrollbar_controller = 2212 ScrollbarAnimationController* scrollbar_controller =
2213 layer->scrollbar_animation_controller(); 2213 layer->scrollbar_animation_controller();
2214 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { 2214 if (scrollbar_controller && scrollbar_controller->IsAnimating()) {
(...skipping 19 matching lines...) Expand all
2234 new_state.tree_priority = priority; 2234 new_state.tree_priority = priority;
2235 tile_manager_->SetGlobalState(new_state); 2235 tile_manager_->SetGlobalState(new_state);
2236 manage_tiles_needed_ = true; 2236 manage_tiles_needed_ = true;
2237 } 2237 }
2238 2238
2239 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { 2239 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() {
2240 current_frame_timeticks_ = base::TimeTicks(); 2240 current_frame_timeticks_ = base::TimeTicks();
2241 current_frame_time_ = base::Time(); 2241 current_frame_time_ = base::Time();
2242 } 2242 }
2243 2243
2244 static void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) { 2244 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks,
2245 base::Time* now) const {
2245 if (ticks->is_null()) { 2246 if (ticks->is_null()) {
2246 DCHECK(now->is_null()); 2247 DCHECK(now->is_null());
2247 *ticks = base::TimeTicks::Now(); 2248 *ticks = CurrentPhysicalTimeTicks();
2248 *now = base::Time::Now(); 2249 *now = base::Time::Now();
2249 } 2250 }
2250 } 2251 }
2251 2252
2252 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { 2253 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() {
2253 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_); 2254 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_);
2254 return current_frame_timeticks_; 2255 return current_frame_timeticks_;
2255 } 2256 }
2256 2257
2257 base::Time LayerTreeHostImpl::CurrentFrameTime() { 2258 base::Time LayerTreeHostImpl::CurrentFrameTime() {
2258 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_); 2259 UpdateCurrentFrameTime(&current_frame_timeticks_, &current_frame_time_);
2259 return current_frame_time_; 2260 return current_frame_time_;
2260 } 2261 }
2261 2262
2263 base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const {
danakj 2013/06/14 18:35:10 Think I'd prefer this is virtual instead of adding
2264 if (!fake_current_physical_time_for_test_.is_null())
2265 return fake_current_physical_time_for_test_;
2266 else
2267 return base::TimeTicks::Now();
2268 }
2269
2270 void LayerTreeHostImpl::SetCurrentPhysicalTimeTicksForTest(
2271 base::TimeTicks fake_time) {
2272 fake_current_physical_time_for_test_ = fake_time;
2273 }
2274
2262 scoped_ptr<base::Value> LayerTreeHostImpl::AsValue() const { 2275 scoped_ptr<base::Value> LayerTreeHostImpl::AsValue() const {
2263 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 2276 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
2264 if (this->pending_tree_) 2277 if (this->pending_tree_)
2265 state->Set("activation_state", ActivationStateAsValue().release()); 2278 state->Set("activation_state", ActivationStateAsValue().release());
2266 state->Set("device_viewport_size", 2279 state->Set("device_viewport_size",
2267 MathUtil::AsValue(device_viewport_size_).release()); 2280 MathUtil::AsValue(device_viewport_size_).release());
2268 if (tile_manager_) 2281 if (tile_manager_)
2269 state->Set("tiles", tile_manager_->AllTilesAsValue().release()); 2282 state->Set("tiles", tile_manager_->AllTilesAsValue().release());
2270 state->Set("active_tree", active_tree_->AsValue().release()); 2283 state->Set("active_tree", active_tree_->AsValue().release());
2271 if (pending_tree_) 2284 if (pending_tree_)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 } 2321 }
2309 2322
2310 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2323 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2311 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2324 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2312 paint_time_counter_->ClearHistory(); 2325 paint_time_counter_->ClearHistory();
2313 2326
2314 debug_state_ = debug_state; 2327 debug_state_ = debug_state;
2315 } 2328 }
2316 2329
2317 } // namespace cc 2330 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698