Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 input_handler_client_->Animate(monotonic_time); | 455 input_handler_client_->Animate(monotonic_time); |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 | 458 |
| 459 did_animate |= AnimatePageScale(monotonic_time); | 459 did_animate |= AnimatePageScale(monotonic_time); |
| 460 did_animate |= AnimateLayers(monotonic_time); | 460 did_animate |= AnimateLayers(monotonic_time); |
| 461 did_animate |= AnimateScrollbars(monotonic_time); | 461 did_animate |= AnimateScrollbars(monotonic_time); |
| 462 did_animate |= AnimateTopControls(monotonic_time); | 462 did_animate |= AnimateTopControls(monotonic_time); |
| 463 | 463 |
| 464 if (active_tree) { | 464 if (active_tree) { |
| 465 did_animate |= Mutate(monotonic_time); | |
| 466 | |
| 465 // Animating stuff can change the root scroll offset, so inform the | 467 // Animating stuff can change the root scroll offset, so inform the |
| 466 // synchronous input handler. | 468 // synchronous input handler. |
| 467 UpdateRootLayerStateForSynchronousInputHandler(); | 469 UpdateRootLayerStateForSynchronousInputHandler(); |
| 468 if (did_animate) { | 470 if (did_animate) { |
| 469 // If the tree changed, then we want to draw at the end of the current | 471 // If the tree changed, then we want to draw at the end of the current |
| 470 // frame. | 472 // frame. |
| 471 SetNeedsRedraw(); | 473 SetNeedsRedraw(); |
| 472 } | 474 } |
| 473 } | 475 } |
| 474 } | 476 } |
| 475 | 477 |
| 478 bool LayerTreeHostImpl::Mutate(base::TimeTicks monotonic_time) { | |
| 479 if (!mutator_) | |
| 480 return false; | |
| 481 TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::Mutate"); | |
| 482 if (mutator_->Mutate(monotonic_time)) | |
| 483 client_->SetNeedsOneBeginImplFrameOnImplThread(); | |
| 484 return true; | |
| 485 } | |
| 486 | |
| 487 void LayerTreeHostImpl::SetNeedsMutate() { | |
| 488 TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::SetNeedsMutate"); | |
| 489 client_->SetNeedsOneBeginImplFrameOnImplThread(); | |
| 490 } | |
| 491 | |
| 476 bool LayerTreeHostImpl::PrepareTiles() { | 492 bool LayerTreeHostImpl::PrepareTiles() { |
| 477 if (!tile_priorities_dirty_) | 493 if (!tile_priorities_dirty_) |
| 478 return false; | 494 return false; |
| 479 | 495 |
| 480 client_->WillPrepareTiles(); | 496 client_->WillPrepareTiles(); |
| 481 bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_); | 497 bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_); |
| 482 if (did_prepare_tiles) | 498 if (did_prepare_tiles) |
| 483 tile_priorities_dirty_ = false; | 499 tile_priorities_dirty_ = false; |
| 484 client_->DidPrepareTiles(); | 500 client_->DidPrepareTiles(); |
| 485 return did_prepare_tiles; | 501 return did_prepare_tiles; |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1983 | 1999 |
| 1984 // Now that we've synced everything from the pending tree to the active | 2000 // Now that we've synced everything from the pending tree to the active |
| 1985 // tree, rename the pending tree the recycle tree so we can reuse it on the | 2001 // tree, rename the pending tree the recycle tree so we can reuse it on the |
| 1986 // next sync. | 2002 // next sync. |
| 1987 DCHECK(!recycle_tree_); | 2003 DCHECK(!recycle_tree_); |
| 1988 pending_tree_.swap(recycle_tree_); | 2004 pending_tree_.swap(recycle_tree_); |
| 1989 | 2005 |
| 1990 // If we commit to the active tree directly, this is already done during | 2006 // If we commit to the active tree directly, this is already done during |
| 1991 // commit. | 2007 // commit. |
| 1992 ActivateAnimations(); | 2008 ActivateAnimations(); |
| 2009 Mutate(CurrentBeginFrameArgs().frame_time); | |
|
ajuma
2016/05/05 14:35:45
Is this done here (rather than in the call to Anim
flackr
2016/05/05 15:13:14
Yes, comment added. However, afaik this will be th
| |
| 1993 } else { | 2010 } else { |
| 1994 active_tree_->ProcessUIResourceRequestQueue(); | 2011 active_tree_->ProcessUIResourceRequestQueue(); |
| 1995 } | 2012 } |
| 1996 | 2013 |
| 1997 // bounds_delta isn't a pushed property, so the newly-pushed property tree | 2014 // bounds_delta isn't a pushed property, so the newly-pushed property tree |
| 1998 // won't already account for current bounds_delta values. This needs to | 2015 // won't already account for current bounds_delta values. This needs to |
| 1999 // happen before calling UpdateViewportContainerSizes(). | 2016 // happen before calling UpdateViewportContainerSizes(). |
| 2000 active_tree_->UpdatePropertyTreesForBoundsDelta(); | 2017 active_tree_->UpdatePropertyTreesForBoundsDelta(); |
| 2001 UpdateViewportContainerSizes(); | 2018 UpdateViewportContainerSizes(); |
| 2002 | 2019 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2231 const int max_copy_texture_chromium_size = | 2248 const int max_copy_texture_chromium_size = |
| 2232 context_provider->ContextCapabilities().max_copy_texture_chromium_size; | 2249 context_provider->ContextCapabilities().max_copy_texture_chromium_size; |
| 2233 | 2250 |
| 2234 *raster_buffer_provider = OneCopyRasterBufferProvider::Create( | 2251 *raster_buffer_provider = OneCopyRasterBufferProvider::Create( |
| 2235 GetTaskRunner(), context_provider, resource_provider_.get(), | 2252 GetTaskRunner(), context_provider, resource_provider_.get(), |
| 2236 max_copy_texture_chromium_size, settings_.use_partial_raster, | 2253 max_copy_texture_chromium_size, settings_.use_partial_raster, |
| 2237 settings_.max_staging_buffer_usage_in_bytes, | 2254 settings_.max_staging_buffer_usage_in_bytes, |
| 2238 settings_.renderer_settings.preferred_tile_format); | 2255 settings_.renderer_settings.preferred_tile_format); |
| 2239 } | 2256 } |
| 2240 | 2257 |
| 2241 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { | 2258 void LayerTreeHostImpl::SetLayerTreeMutator( |
| 2259 std::unique_ptr<LayerTreeMutator> mutator) { | |
| 2260 if (mutator == mutator_) | |
| 2261 return; | |
| 2242 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 2262 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 2243 "LayerTreeHostImpl::SetLayerTreeMutator"); | 2263 "LayerTreeHostImpl::SetLayerTreeMutator"); |
| 2244 mutator_ = mutator; | 2264 mutator_ = std::move(mutator); |
| 2265 mutator_->SetClient(this); | |
| 2245 } | 2266 } |
| 2246 | 2267 |
| 2247 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2268 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
| 2248 ClearUIResources(); | 2269 ClearUIResources(); |
| 2249 tile_manager_->FinishTasksAndCleanUp(); | 2270 tile_manager_->FinishTasksAndCleanUp(); |
| 2250 resource_pool_ = nullptr; | 2271 resource_pool_ = nullptr; |
| 2251 tile_task_manager_ = nullptr; | 2272 tile_task_manager_ = nullptr; |
| 2252 single_thread_synchronous_task_graph_runner_ = nullptr; | 2273 single_thread_synchronous_task_graph_runner_ = nullptr; |
| 2253 image_decode_controller_ = nullptr; | 2274 image_decode_controller_ = nullptr; |
| 2254 } | 2275 } |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3094 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); | 3115 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); |
| 3095 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; | 3116 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; |
| 3096 scroll_result.unused_scroll_delta = unused_root_delta; | 3117 scroll_result.unused_scroll_delta = unused_root_delta; |
| 3097 | 3118 |
| 3098 if (scroll_result.did_scroll) { | 3119 if (scroll_result.did_scroll) { |
| 3099 // Scrolling can change the root scroll offset, so inform the synchronous | 3120 // Scrolling can change the root scroll offset, so inform the synchronous |
| 3100 // input handler. | 3121 // input handler. |
| 3101 UpdateRootLayerStateForSynchronousInputHandler(); | 3122 UpdateRootLayerStateForSynchronousInputHandler(); |
| 3102 } | 3123 } |
| 3103 | 3124 |
| 3125 // Update compositor worker mutations which may respond to scrolling. | |
| 3126 Mutate(CurrentBeginFrameArgs().frame_time); | |
| 3127 | |
| 3104 return scroll_result; | 3128 return scroll_result; |
| 3105 } | 3129 } |
| 3106 | 3130 |
| 3107 // This implements scrolling by page as described here: | 3131 // This implements scrolling by page as described here: |
| 3108 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel | 3132 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel |
| 3109 // for events with WHEEL_PAGESCROLL set. | 3133 // for events with WHEEL_PAGESCROLL set. |
| 3110 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 3134 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
| 3111 ScrollDirection direction) { | 3135 ScrollDirection direction) { |
| 3112 DCHECK(wheel_scrolling_); | 3136 DCHECK(wheel_scrolling_); |
| 3113 | 3137 |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3841 } | 3865 } |
| 3842 | 3866 |
| 3843 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( | 3867 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( |
| 3844 int layer_id, | 3868 int layer_id, |
| 3845 LayerTreeImpl* tree, | 3869 LayerTreeImpl* tree, |
| 3846 const gfx::ScrollOffset& scroll_offset) { | 3870 const gfx::ScrollOffset& scroll_offset) { |
| 3847 if (!tree) | 3871 if (!tree) |
| 3848 return; | 3872 return; |
| 3849 | 3873 |
| 3850 LayerImpl* layer = tree->LayerById(layer_id); | 3874 LayerImpl* layer = tree->LayerById(layer_id); |
| 3851 if (layer) | 3875 if (layer) { |
| 3852 layer->OnScrollOffsetAnimated(scroll_offset); | 3876 layer->OnScrollOffsetAnimated(scroll_offset); |
| 3877 // Run mutation callbacks to respond to updated scroll offset. | |
| 3878 Mutate(CurrentBeginFrameArgs().frame_time); | |
| 3879 } | |
| 3853 } | 3880 } |
| 3854 | 3881 |
| 3855 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( | 3882 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( |
| 3856 int layer_id, | 3883 int layer_id, |
| 3857 LayerTreeImpl* tree, | 3884 LayerTreeImpl* tree, |
| 3858 bool is_animating) { | 3885 bool is_animating) { |
| 3859 if (!tree) | 3886 if (!tree) |
| 3860 return; | 3887 return; |
| 3861 | 3888 |
| 3862 LayerImpl* layer = tree->LayerById(layer_id); | 3889 LayerImpl* layer = tree->LayerById(layer_id); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3952 return task_runner_provider_->HasImplThread(); | 3979 return task_runner_provider_->HasImplThread(); |
| 3953 } | 3980 } |
| 3954 | 3981 |
| 3955 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3982 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3956 // In single threaded mode we skip the pending tree and commit directly to the | 3983 // In single threaded mode we skip the pending tree and commit directly to the |
| 3957 // active tree. | 3984 // active tree. |
| 3958 return !task_runner_provider_->HasImplThread(); | 3985 return !task_runner_provider_->HasImplThread(); |
| 3959 } | 3986 } |
| 3960 | 3987 |
| 3961 } // namespace cc | 3988 } // namespace cc |
| OLD | NEW |