| 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); |
| 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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); | 3111 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); |
| 3091 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; | 3112 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; |
| 3092 scroll_result.unused_scroll_delta = unused_root_delta; | 3113 scroll_result.unused_scroll_delta = unused_root_delta; |
| 3093 | 3114 |
| 3094 if (scroll_result.did_scroll) { | 3115 if (scroll_result.did_scroll) { |
| 3095 // Scrolling can change the root scroll offset, so inform the synchronous | 3116 // Scrolling can change the root scroll offset, so inform the synchronous |
| 3096 // input handler. | 3117 // input handler. |
| 3097 UpdateRootLayerStateForSynchronousInputHandler(); | 3118 UpdateRootLayerStateForSynchronousInputHandler(); |
| 3098 } | 3119 } |
| 3099 | 3120 |
| 3121 // Update compositor worker mutations which may respond to scrolling. |
| 3122 Mutate(CurrentBeginFrameArgs().frame_time); |
| 3123 |
| 3100 return scroll_result; | 3124 return scroll_result; |
| 3101 } | 3125 } |
| 3102 | 3126 |
| 3103 // This implements scrolling by page as described here: | 3127 // This implements scrolling by page as described here: |
| 3104 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | 3128 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel |
| 3105 // for events with WHEEL_PAGESCROLL set. | 3129 // for events with WHEEL_PAGESCROLL set. |
| 3106 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 3130 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
| 3107 ScrollDirection direction) { | 3131 ScrollDirection direction) { |
| 3108 DCHECK(wheel_scrolling_); | 3132 DCHECK(wheel_scrolling_); |
| 3109 | 3133 |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3837 } | 3861 } |
| 3838 | 3862 |
| 3839 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( | 3863 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( |
| 3840 int layer_id, | 3864 int layer_id, |
| 3841 LayerTreeImpl* tree, | 3865 LayerTreeImpl* tree, |
| 3842 const gfx::ScrollOffset& scroll_offset) { | 3866 const gfx::ScrollOffset& scroll_offset) { |
| 3843 if (!tree) | 3867 if (!tree) |
| 3844 return; | 3868 return; |
| 3845 | 3869 |
| 3846 LayerImpl* layer = tree->LayerById(layer_id); | 3870 LayerImpl* layer = tree->LayerById(layer_id); |
| 3847 if (layer) | 3871 if (layer) { |
| 3848 layer->OnScrollOffsetAnimated(scroll_offset); | 3872 layer->OnScrollOffsetAnimated(scroll_offset); |
| 3873 // Run mutation callbacks to respond to updated scroll offset. |
| 3874 Mutate(CurrentBeginFrameArgs().frame_time); |
| 3875 } |
| 3849 } | 3876 } |
| 3850 | 3877 |
| 3851 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( | 3878 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( |
| 3852 int layer_id, | 3879 int layer_id, |
| 3853 LayerTreeImpl* tree, | 3880 LayerTreeImpl* tree, |
| 3854 bool is_animating) { | 3881 bool is_animating) { |
| 3855 if (!tree) | 3882 if (!tree) |
| 3856 return; | 3883 return; |
| 3857 | 3884 |
| 3858 LayerImpl* layer = tree->LayerById(layer_id); | 3885 LayerImpl* layer = tree->LayerById(layer_id); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3948 return task_runner_provider_->HasImplThread(); | 3975 return task_runner_provider_->HasImplThread(); |
| 3949 } | 3976 } |
| 3950 | 3977 |
| 3951 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3978 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3952 // In single threaded mode we skip the pending tree and commit directly to the | 3979 // In single threaded mode we skip the pending tree and commit directly to the |
| 3953 // active tree. | 3980 // active tree. |
| 3954 return !task_runner_provider_->HasImplThread(); | 3981 return !task_runner_provider_->HasImplThread(); |
| 3955 } | 3982 } |
| 3956 | 3983 |
| 3957 } // namespace cc | 3984 } // namespace cc |
| OLD | NEW |