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

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

Issue 1895873006: compositor-worker: Initialize CW machinery plumbing to compositor and fire CW rAF callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary scope Created 4 years, 8 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
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 <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
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 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 2015
2000 // Now that we've synced everything from the pending tree to the active 2016 // Now that we've synced everything from the pending tree to the active
2001 // tree, rename the pending tree the recycle tree so we can reuse it on the 2017 // tree, rename the pending tree the recycle tree so we can reuse it on the
2002 // next sync. 2018 // next sync.
2003 DCHECK(!recycle_tree_); 2019 DCHECK(!recycle_tree_);
2004 pending_tree_.swap(recycle_tree_); 2020 pending_tree_.swap(recycle_tree_);
2005 2021
2006 // If we commit to the active tree directly, this is already done during 2022 // If we commit to the active tree directly, this is already done during
2007 // commit. 2023 // commit.
2008 ActivateAnimations(); 2024 ActivateAnimations();
2025 Mutate(CurrentBeginFrameArgs().frame_time);
2009 } else { 2026 } else {
2010 active_tree_->ProcessUIResourceRequestQueue(); 2027 active_tree_->ProcessUIResourceRequestQueue();
2011 } 2028 }
2012 2029
2013 // bounds_delta isn't a pushed property, so the newly-pushed property tree 2030 // bounds_delta isn't a pushed property, so the newly-pushed property tree
2014 // won't already account for current bounds_delta values. This needs to 2031 // won't already account for current bounds_delta values. This needs to
2015 // happen before calling UpdateViewportContainerSizes(). 2032 // happen before calling UpdateViewportContainerSizes().
2016 active_tree_->UpdatePropertyTreesForBoundsDelta(); 2033 active_tree_->UpdatePropertyTreesForBoundsDelta();
2017 UpdateViewportContainerSizes(); 2034 UpdateViewportContainerSizes();
2018 2035
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 } 2282 }
2266 2283
2267 void LayerTreeHostImpl::PostFrameTimingEvents( 2284 void LayerTreeHostImpl::PostFrameTimingEvents(
2268 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 2285 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
2269 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 2286 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
2270 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), 2287 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events),
2271 std::move(main_frame_events)); 2288 std::move(main_frame_events));
2272 } 2289 }
2273 2290
2274 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { 2291 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) {
2292 if (mutator == mutator_)
2293 return;
2275 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 2294 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
2276 "LayerTreeHostImpl::SetLayerTreeMutator"); 2295 "LayerTreeHostImpl::SetLayerTreeMutator");
2277 mutator_ = mutator; 2296 mutator_ = mutator;
2297 mutator_->SetClient(this);
2278 } 2298 }
2279 2299
2280 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { 2300 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() {
2281 ClearUIResources(); 2301 ClearUIResources();
2282 tile_manager_->FinishTasksAndCleanUp(); 2302 tile_manager_->FinishTasksAndCleanUp();
2283 resource_pool_ = nullptr; 2303 resource_pool_ = nullptr;
2284 tile_task_worker_pool_ = nullptr; 2304 tile_task_worker_pool_ = nullptr;
2285 single_thread_synchronous_task_graph_runner_ = nullptr; 2305 single_thread_synchronous_task_graph_runner_ = nullptr;
2286 image_decode_controller_ = nullptr; 2306 image_decode_controller_ = nullptr;
2287 } 2307 }
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); 3143 scroll_result.did_overscroll_root = !unused_root_delta.IsZero();
3124 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; 3144 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_;
3125 scroll_result.unused_scroll_delta = unused_root_delta; 3145 scroll_result.unused_scroll_delta = unused_root_delta;
3126 3146
3127 if (scroll_result.did_scroll) { 3147 if (scroll_result.did_scroll) {
3128 // Scrolling can change the root scroll offset, so inform the synchronous 3148 // Scrolling can change the root scroll offset, so inform the synchronous
3129 // input handler. 3149 // input handler.
3130 UpdateRootLayerStateForSynchronousInputHandler(); 3150 UpdateRootLayerStateForSynchronousInputHandler();
3131 } 3151 }
3132 3152
3153 // Update compositor worker mutations which may respond to scrolling.
3154 Mutate(CurrentBeginFrameArgs().frame_time);
3155
3133 return scroll_result; 3156 return scroll_result;
3134 } 3157 }
3135 3158
3136 // This implements scrolling by page as described here: 3159 // This implements scrolling by page as described here:
3137 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel 3160 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel
3138 // for events with WHEEL_PAGESCROLL set. 3161 // for events with WHEEL_PAGESCROLL set.
3139 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, 3162 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point,
3140 ScrollDirection direction) { 3163 ScrollDirection direction) {
3141 DCHECK(wheel_scrolling_); 3164 DCHECK(wheel_scrolling_);
3142 3165
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 } 3893 }
3871 3894
3872 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( 3895 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated(
3873 int layer_id, 3896 int layer_id,
3874 LayerTreeImpl* tree, 3897 LayerTreeImpl* tree,
3875 const gfx::ScrollOffset& scroll_offset) { 3898 const gfx::ScrollOffset& scroll_offset) {
3876 if (!tree) 3899 if (!tree)
3877 return; 3900 return;
3878 3901
3879 LayerImpl* layer = tree->LayerById(layer_id); 3902 LayerImpl* layer = tree->LayerById(layer_id);
3880 if (layer) 3903 if (layer) {
3881 layer->OnScrollOffsetAnimated(scroll_offset); 3904 layer->OnScrollOffsetAnimated(scroll_offset);
3905 // Run mutation callbacks to respond to updated scroll offset.
3906 Mutate(CurrentBeginFrameArgs().frame_time);
3907 }
3882 } 3908 }
3883 3909
3884 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( 3910 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged(
3885 int layer_id, 3911 int layer_id,
3886 LayerTreeImpl* tree, 3912 LayerTreeImpl* tree,
3887 bool is_animating) { 3913 bool is_animating) {
3888 if (!tree) 3914 if (!tree)
3889 return; 3915 return;
3890 3916
3891 LayerImpl* layer = tree->LayerById(layer_id); 3917 LayerImpl* layer = tree->LayerById(layer_id);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 return task_runner_provider_->HasImplThread(); 4006 return task_runner_provider_->HasImplThread();
3981 } 4007 }
3982 4008
3983 bool LayerTreeHostImpl::CommitToActiveTree() const { 4009 bool LayerTreeHostImpl::CommitToActiveTree() const {
3984 // In single threaded mode we skip the pending tree and commit directly to the 4010 // In single threaded mode we skip the pending tree and commit directly to the
3985 // active tree. 4011 // active tree.
3986 return !task_runner_provider_->HasImplThread(); 4012 return !task_runner_provider_->HasImplThread();
3987 } 4013 }
3988 4014
3989 } // namespace cc 4015 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698