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 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 | 2009 |
1994 // Now that we've synced everything from the pending tree to the active | 2010 // Now that we've synced everything from the pending tree to the active |
1995 // tree, rename the pending tree the recycle tree so we can reuse it on the | 2011 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1996 // next sync. | 2012 // next sync. |
1997 DCHECK(!recycle_tree_); | 2013 DCHECK(!recycle_tree_); |
1998 pending_tree_.swap(recycle_tree_); | 2014 pending_tree_.swap(recycle_tree_); |
1999 | 2015 |
2000 // If we commit to the active tree directly, this is already done during | 2016 // If we commit to the active tree directly, this is already done during |
2001 // commit. | 2017 // commit. |
2002 ActivateAnimations(); | 2018 ActivateAnimations(); |
| 2019 |
| 2020 // Compositor worker operates on the active tree so we have to run again |
| 2021 // after activation. |
| 2022 Mutate(CurrentBeginFrameArgs().frame_time); |
2003 } else { | 2023 } else { |
2004 active_tree_->ProcessUIResourceRequestQueue(); | 2024 active_tree_->ProcessUIResourceRequestQueue(); |
2005 } | 2025 } |
2006 | 2026 |
2007 // bounds_delta isn't a pushed property, so the newly-pushed property tree | 2027 // bounds_delta isn't a pushed property, so the newly-pushed property tree |
2008 // won't already account for current bounds_delta values. This needs to | 2028 // won't already account for current bounds_delta values. This needs to |
2009 // happen before calling UpdateViewportContainerSizes(). | 2029 // happen before calling UpdateViewportContainerSizes(). |
2010 active_tree_->UpdatePropertyTreesForBoundsDelta(); | 2030 active_tree_->UpdatePropertyTreesForBoundsDelta(); |
2011 UpdateViewportContainerSizes(); | 2031 UpdateViewportContainerSizes(); |
2012 | 2032 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 const int max_copy_texture_chromium_size = | 2261 const int max_copy_texture_chromium_size = |
2242 context_provider->ContextCapabilities().max_copy_texture_chromium_size; | 2262 context_provider->ContextCapabilities().max_copy_texture_chromium_size; |
2243 | 2263 |
2244 *raster_buffer_provider = OneCopyRasterBufferProvider::Create( | 2264 *raster_buffer_provider = OneCopyRasterBufferProvider::Create( |
2245 GetTaskRunner(), context_provider, resource_provider_.get(), | 2265 GetTaskRunner(), context_provider, resource_provider_.get(), |
2246 max_copy_texture_chromium_size, settings_.use_partial_raster, | 2266 max_copy_texture_chromium_size, settings_.use_partial_raster, |
2247 settings_.max_staging_buffer_usage_in_bytes, | 2267 settings_.max_staging_buffer_usage_in_bytes, |
2248 settings_.renderer_settings.preferred_tile_format); | 2268 settings_.renderer_settings.preferred_tile_format); |
2249 } | 2269 } |
2250 | 2270 |
2251 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { | 2271 void LayerTreeHostImpl::SetLayerTreeMutator( |
| 2272 std::unique_ptr<LayerTreeMutator> mutator) { |
| 2273 if (mutator == mutator_) |
| 2274 return; |
2252 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 2275 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
2253 "LayerTreeHostImpl::SetLayerTreeMutator"); | 2276 "LayerTreeHostImpl::SetLayerTreeMutator"); |
2254 mutator_ = mutator; | 2277 mutator_ = std::move(mutator); |
| 2278 mutator_->SetClient(this); |
2255 } | 2279 } |
2256 | 2280 |
2257 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2281 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2258 ClearUIResources(); | 2282 ClearUIResources(); |
2259 tile_manager_->FinishTasksAndCleanUp(); | 2283 tile_manager_->FinishTasksAndCleanUp(); |
2260 resource_pool_ = nullptr; | 2284 resource_pool_ = nullptr; |
2261 tile_task_manager_ = nullptr; | 2285 tile_task_manager_ = nullptr; |
2262 single_thread_synchronous_task_graph_runner_ = nullptr; | 2286 single_thread_synchronous_task_graph_runner_ = nullptr; |
2263 image_decode_controller_ = nullptr; | 2287 image_decode_controller_ = nullptr; |
2264 } | 2288 } |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); | 3128 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); |
3105 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; | 3129 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; |
3106 scroll_result.unused_scroll_delta = unused_root_delta; | 3130 scroll_result.unused_scroll_delta = unused_root_delta; |
3107 | 3131 |
3108 if (scroll_result.did_scroll) { | 3132 if (scroll_result.did_scroll) { |
3109 // Scrolling can change the root scroll offset, so inform the synchronous | 3133 // Scrolling can change the root scroll offset, so inform the synchronous |
3110 // input handler. | 3134 // input handler. |
3111 UpdateRootLayerStateForSynchronousInputHandler(); | 3135 UpdateRootLayerStateForSynchronousInputHandler(); |
3112 } | 3136 } |
3113 | 3137 |
| 3138 // Update compositor worker mutations which may respond to scrolling. |
| 3139 Mutate(CurrentBeginFrameArgs().frame_time); |
| 3140 |
3114 return scroll_result; | 3141 return scroll_result; |
3115 } | 3142 } |
3116 | 3143 |
3117 // This implements scrolling by page as described here: | 3144 // This implements scrolling by page as described here: |
3118 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | 3145 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel |
3119 // for events with WHEEL_PAGESCROLL set. | 3146 // for events with WHEEL_PAGESCROLL set. |
3120 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 3147 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
3121 ScrollDirection direction) { | 3148 ScrollDirection direction) { |
3122 DCHECK(wheel_scrolling_); | 3149 DCHECK(wheel_scrolling_); |
3123 | 3150 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3851 } | 3878 } |
3852 | 3879 |
3853 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( | 3880 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( |
3854 int layer_id, | 3881 int layer_id, |
3855 LayerTreeImpl* tree, | 3882 LayerTreeImpl* tree, |
3856 const gfx::ScrollOffset& scroll_offset) { | 3883 const gfx::ScrollOffset& scroll_offset) { |
3857 if (!tree) | 3884 if (!tree) |
3858 return; | 3885 return; |
3859 | 3886 |
3860 LayerImpl* layer = tree->LayerById(layer_id); | 3887 LayerImpl* layer = tree->LayerById(layer_id); |
3861 if (layer) | 3888 if (layer) { |
3862 layer->OnScrollOffsetAnimated(scroll_offset); | 3889 layer->OnScrollOffsetAnimated(scroll_offset); |
| 3890 // Run mutation callbacks to respond to updated scroll offset. |
| 3891 Mutate(CurrentBeginFrameArgs().frame_time); |
| 3892 } |
3863 } | 3893 } |
3864 | 3894 |
3865 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( | 3895 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( |
3866 int layer_id, | 3896 int layer_id, |
3867 LayerTreeImpl* tree, | 3897 LayerTreeImpl* tree, |
3868 bool is_animating) { | 3898 bool is_animating) { |
3869 if (!tree) | 3899 if (!tree) |
3870 return; | 3900 return; |
3871 | 3901 |
3872 LayerImpl* layer = tree->LayerById(layer_id); | 3902 LayerImpl* layer = tree->LayerById(layer_id); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3962 return task_runner_provider_->HasImplThread(); | 3992 return task_runner_provider_->HasImplThread(); |
3963 } | 3993 } |
3964 | 3994 |
3965 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3995 bool LayerTreeHostImpl::CommitToActiveTree() const { |
3966 // In single threaded mode we skip the pending tree and commit directly to the | 3996 // In single threaded mode we skip the pending tree and commit directly to the |
3967 // active tree. | 3997 // active tree. |
3968 return !task_runner_provider_->HasImplThread(); | 3998 return !task_runner_provider_->HasImplThread(); |
3969 } | 3999 } |
3970 | 4000 |
3971 } // namespace cc | 4001 } // namespace cc |
OLD | NEW |