OLD | NEW |
---|---|
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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 set_impl_thread.reset( | 160 set_impl_thread.reset( |
161 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); | 161 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); |
162 } | 162 } |
163 | 163 |
164 // TODO(enne): This should probably happen post-animate. | 164 // TODO(enne): This should probably happen post-animate. |
165 if (layer_tree_host_impl_->pending_tree()) { | 165 if (layer_tree_host_impl_->pending_tree()) { |
166 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); | 166 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); |
167 layer_tree_host_impl_->ManageTiles(); | 167 layer_tree_host_impl_->ManageTiles(); |
168 } | 168 } |
169 | 169 |
170 // TODO(mithro): Change to using something like | |
171 // OnBackgroundFrame(BeginFrameArgs xxx) | |
172 layer_tree_host_impl_->OverrideCurrentFrameTime( | |
danakj
2014/03/11 18:32:36
This should be above UpdateDrawProps/ManageTiles.
| |
173 time_source_->LastTickTime()); | |
170 layer_tree_host_impl_->Animate( | 174 layer_tree_host_impl_->Animate( |
171 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 175 layer_tree_host_impl_->CurrentFrameTimeTicks()); |
172 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); | 176 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); |
173 bool start_ready_animations = true; | 177 bool start_ready_animations = true; |
174 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 178 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
175 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | |
176 } | 179 } |
177 | 180 |
178 void SetActive(bool active) { | 181 void SetActive(bool active) { |
179 if (active != time_source_->Active()) | 182 if (active != time_source_->Active()) |
180 time_source_->SetActive(active); | 183 time_source_->SetActive(active); |
181 } | 184 } |
182 | 185 |
183 bool Active() const { return time_source_->Active(); } | 186 bool Active() const { return time_source_->Active(); } |
184 | 187 |
185 private: | 188 private: |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1283 } | 1286 } |
1284 | 1287 |
1285 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1288 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
1286 if (damage_rect.IsEmpty()) | 1289 if (damage_rect.IsEmpty()) |
1287 return; | 1290 return; |
1288 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1291 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
1289 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1292 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
1290 } | 1293 } |
1291 | 1294 |
1292 void LayerTreeHostImpl::BeginImplFrame(const BeginFrameArgs& args) { | 1295 void LayerTreeHostImpl::BeginImplFrame(const BeginFrameArgs& args) { |
1296 last_frame_args_ = current_frame_args_; | |
1297 current_frame_args_ = args; | |
1298 | |
1293 client_->BeginImplFrame(args); | 1299 client_->BeginImplFrame(args); |
1294 } | 1300 } |
1295 | 1301 |
1296 void LayerTreeHostImpl::DidSwapBuffers() { | 1302 void LayerTreeHostImpl::DidSwapBuffers() { |
1297 client_->DidSwapBuffersOnImplThread(); | 1303 client_->DidSwapBuffersOnImplThread(); |
1298 } | 1304 } |
1299 | 1305 |
1300 void LayerTreeHostImpl::OnSwapBuffersComplete() { | 1306 void LayerTreeHostImpl::OnSwapBuffersComplete() { |
1301 client_->OnSwapBuffersCompleteOnImplThread(); | 1307 client_->OnSwapBuffersCompleteOnImplThread(); |
1302 } | 1308 } |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2463 LayerImpl* scroll_layer_impl = active_tree_->LayerById( | 2469 LayerImpl* scroll_layer_impl = active_tree_->LayerById( |
2464 scroll_layer_id_when_mouse_over_scrollbar_); | 2470 scroll_layer_id_when_mouse_over_scrollbar_); |
2465 | 2471 |
2466 // The check for a null scroll_layer_impl below was added to see if it will | 2472 // The check for a null scroll_layer_impl below was added to see if it will |
2467 // eliminate the crashes described in http://crbug.com/326635. | 2473 // eliminate the crashes described in http://crbug.com/326635. |
2468 // TODO(wjmaclean) Add a unit test if this fixes the crashes. | 2474 // TODO(wjmaclean) Add a unit test if this fixes the crashes. |
2469 ScrollbarAnimationController* animation_controller = | 2475 ScrollbarAnimationController* animation_controller = |
2470 scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() | 2476 scroll_layer_impl ? scroll_layer_impl->scrollbar_animation_controller() |
2471 : NULL; | 2477 : NULL; |
2472 if (animation_controller) { | 2478 if (animation_controller) { |
2473 animation_controller->DidMouseMoveOffScrollbar( | 2479 animation_controller->DidMouseMoveOffScrollbar(CurrentFrameTimeTicks()); |
aelias_OOO_until_Jul13
2014/03/21 01:37:44
physical time
| |
2474 CurrentPhysicalTimeTicks()); | |
2475 StartScrollbarAnimation(); | 2480 StartScrollbarAnimation(); |
2476 } | 2481 } |
2477 scroll_layer_id_when_mouse_over_scrollbar_ = 0; | 2482 scroll_layer_id_when_mouse_over_scrollbar_ = 0; |
2478 } | 2483 } |
2479 | 2484 |
2480 bool scroll_on_main_thread = false; | 2485 bool scroll_on_main_thread = false; |
2481 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 2486 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
2482 device_viewport_point, InputHandler::Gesture, layer_impl, | 2487 device_viewport_point, InputHandler::Gesture, layer_impl, |
2483 &scroll_on_main_thread); | 2488 &scroll_on_main_thread); |
2484 if (scroll_on_main_thread || !scroll_layer_impl) | 2489 if (scroll_on_main_thread || !scroll_layer_impl) |
2485 return; | 2490 return; |
2486 | 2491 |
2487 ScrollbarAnimationController* animation_controller = | 2492 ScrollbarAnimationController* animation_controller = |
2488 scroll_layer_impl->scrollbar_animation_controller(); | 2493 scroll_layer_impl->scrollbar_animation_controller(); |
2489 if (!animation_controller) | 2494 if (!animation_controller) |
2490 return; | 2495 return; |
2491 | 2496 |
2492 // TODO(wjmaclean) Is it ok to choose distance from more than two scrollbars? | 2497 // TODO(wjmaclean) Is it ok to choose distance from more than two scrollbars? |
2493 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 2498 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
2494 for (LayerImpl::ScrollbarSet::iterator it = | 2499 for (LayerImpl::ScrollbarSet::iterator it = |
2495 scroll_layer_impl->scrollbars()->begin(); | 2500 scroll_layer_impl->scrollbars()->begin(); |
2496 it != scroll_layer_impl->scrollbars()->end(); | 2501 it != scroll_layer_impl->scrollbars()->end(); |
2497 ++it) | 2502 ++it) |
2498 distance_to_scrollbar = | 2503 distance_to_scrollbar = |
2499 std::min(distance_to_scrollbar, | 2504 std::min(distance_to_scrollbar, |
2500 DeviceSpaceDistanceToLayer(device_viewport_point, *it)); | 2505 DeviceSpaceDistanceToLayer(device_viewport_point, *it)); |
2501 | 2506 |
2507 // TODO(mithro): Show this be something other then frame time? | |
2502 bool should_animate = animation_controller->DidMouseMoveNear( | 2508 bool should_animate = animation_controller->DidMouseMoveNear( |
2503 CurrentPhysicalTimeTicks(), distance_to_scrollbar / device_scale_factor_); | 2509 CurrentFrameTimeTicks(), distance_to_scrollbar / device_scale_factor_); |
danakj
2014/03/11 18:32:36
What happens if you get input here and you're not
| |
2504 if (should_animate) | 2510 if (should_animate) |
2505 StartScrollbarAnimation(); | 2511 StartScrollbarAnimation(); |
2506 } | 2512 } |
2507 | 2513 |
2508 bool LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl, | 2514 bool LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl, |
2509 const gfx::PointF& device_viewport_point) { | 2515 const gfx::PointF& device_viewport_point) { |
2510 if (layer_impl && layer_impl->ToScrollbarLayer()) { | 2516 if (layer_impl && layer_impl->ToScrollbarLayer()) { |
2511 int scroll_layer_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 2517 int scroll_layer_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
2512 layer_impl = active_tree_->LayerById(scroll_layer_id); | 2518 layer_impl = active_tree_->LayerById(scroll_layer_id); |
2513 if (layer_impl && layer_impl->scrollbar_animation_controller()) { | 2519 if (layer_impl && layer_impl->scrollbar_animation_controller()) { |
2514 scroll_layer_id_when_mouse_over_scrollbar_ = scroll_layer_id; | 2520 scroll_layer_id_when_mouse_over_scrollbar_ = scroll_layer_id; |
2515 bool should_animate = | 2521 bool should_animate = |
2516 layer_impl->scrollbar_animation_controller()->DidMouseMoveNear( | 2522 layer_impl->scrollbar_animation_controller()->DidMouseMoveNear( |
2517 CurrentPhysicalTimeTicks(), 0); | 2523 CurrentFrameTimeTicks(), 0); |
aelias_OOO_until_Jul13
2014/03/21 01:37:44
physical time
| |
2518 if (should_animate) | 2524 if (should_animate) |
2519 StartScrollbarAnimation(); | 2525 StartScrollbarAnimation(); |
2520 } else { | 2526 } else { |
2521 scroll_layer_id_when_mouse_over_scrollbar_ = 0; | 2527 scroll_layer_id_when_mouse_over_scrollbar_ = 0; |
2522 } | 2528 } |
2523 | 2529 |
2524 return true; | 2530 return true; |
2525 } | 2531 } |
2526 | 2532 |
2527 return false; | 2533 return false; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2823 TRACE_EVENT_SCOPE_THREAD); | 2829 TRACE_EVENT_SCOPE_THREAD); |
2824 SetNeedsRedraw(); | 2830 SetNeedsRedraw(); |
2825 } | 2831 } |
2826 | 2832 |
2827 for (size_t i = 0; i < layer->children().size(); ++i) | 2833 for (size_t i = 0; i < layer->children().size(); ++i) |
2828 AnimateScrollbarsRecursive(layer->children()[i], time); | 2834 AnimateScrollbarsRecursive(layer->children()[i], time); |
2829 } | 2835 } |
2830 | 2836 |
2831 void LayerTreeHostImpl::StartScrollbarAnimation() { | 2837 void LayerTreeHostImpl::StartScrollbarAnimation() { |
2832 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); | 2838 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); |
2833 StartScrollbarAnimationRecursive(RootLayer(), CurrentPhysicalTimeTicks()); | 2839 StartScrollbarAnimationRecursive(RootLayer(), CurrentFrameTimeTicks()); |
aelias_OOO_until_Jul13
2014/03/21 01:37:44
This is another thing I specifically changed to ph
| |
2834 } | 2840 } |
2835 | 2841 |
2836 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, | 2842 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, |
2837 base::TimeTicks time) { | 2843 base::TimeTicks time) { |
2838 if (!layer) | 2844 if (!layer) |
2839 return; | 2845 return; |
2840 | 2846 |
2841 ScrollbarAnimationController* scrollbar_controller = | 2847 ScrollbarAnimationController* scrollbar_controller = |
2842 layer->scrollbar_animation_controller(); | 2848 layer->scrollbar_animation_controller(); |
2843 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { | 2849 if (scrollbar_controller && scrollbar_controller->IsAnimating()) { |
(...skipping 11 matching lines...) Expand all Loading... | |
2855 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 2861 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
2856 if (!tile_manager_) | 2862 if (!tile_manager_) |
2857 return; | 2863 return; |
2858 | 2864 |
2859 if (global_tile_state_.tree_priority == priority) | 2865 if (global_tile_state_.tree_priority == priority) |
2860 return; | 2866 return; |
2861 global_tile_state_.tree_priority = priority; | 2867 global_tile_state_.tree_priority = priority; |
2862 DidModifyTilePriorities(); | 2868 DidModifyTilePriorities(); |
2863 } | 2869 } |
2864 | 2870 |
2865 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { | 2871 void LayerTreeHostImpl::OverrideCurrentFrameTime(base::TimeTicks frame_time) { |
2866 current_frame_timeticks_ = base::TimeTicks(); | 2872 TRACE_EVENT1("cc", |
2873 "LayerTreeHostImpl::OverrideCurrentFrameTime", | |
2874 "frame_time", | |
2875 frame_time.ToInternalValue()); | |
2876 current_frame_args_.frame_time = frame_time; | |
2867 } | 2877 } |
2868 | 2878 |
2869 void LayerTreeHostImpl::UpdateCurrentFrameTime(base::TimeTicks* ticks) const { | 2879 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() const { |
2870 if (ticks->is_null()) { | 2880 return current_frame_args_.frame_time; |
2871 *ticks = CurrentPhysicalTimeTicks(); | |
2872 } | |
2873 } | |
2874 | |
2875 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { | |
2876 UpdateCurrentFrameTime(¤t_frame_timeticks_); | |
2877 return current_frame_timeticks_; | |
2878 } | |
2879 | |
2880 base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const { | |
2881 return gfx::FrameTime::Now(); | |
2882 } | 2881 } |
2883 | 2882 |
2884 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( | 2883 scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( |
2885 FrameData* frame) const { | 2884 FrameData* frame) const { |
2886 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 2885 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
2887 if (this->pending_tree_) | 2886 if (this->pending_tree_) |
2888 state->Set("activation_state", ActivationStateAsValue().release()); | 2887 state->Set("activation_state", ActivationStateAsValue().release()); |
2889 state->Set("device_viewport_size", | 2888 state->Set("device_viewport_size", |
2890 MathUtil::AsValue(device_viewport_size_).release()); | 2889 MathUtil::AsValue(device_viewport_size_).release()); |
2891 if (tile_manager_) | 2890 if (tile_manager_) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3030 swap_promise_monitor_.erase(monitor); | 3029 swap_promise_monitor_.erase(monitor); |
3031 } | 3030 } |
3032 | 3031 |
3033 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3032 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3034 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3033 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3035 for (; it != swap_promise_monitor_.end(); it++) | 3034 for (; it != swap_promise_monitor_.end(); it++) |
3036 (*it)->OnSetNeedsRedrawOnImpl(); | 3035 (*it)->OnSetNeedsRedrawOnImpl(); |
3037 } | 3036 } |
3038 | 3037 |
3039 } // namespace cc | 3038 } // namespace cc |
OLD | NEW |