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

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: Bring up oilpan support during compositor worker creation and oilpan the compositor mutator and pro… Created 4 years, 7 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 request_ids, start_time, end_time, active_tree_->source_frame_number()); 2281 request_ids, start_time, end_time, active_tree_->source_frame_number());
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(
2292 std::unique_ptr<LayerTreeMutator> mutator) {
2293 if (mutator == mutator_)
2294 return;
2275 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 2295 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
2276 "LayerTreeHostImpl::SetLayerTreeMutator"); 2296 "LayerTreeHostImpl::SetLayerTreeMutator");
2277 mutator_ = mutator; 2297 mutator_ = std::move(mutator);
2298 mutator_->SetClient(this);
2278 } 2299 }
2279 2300
2280 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { 2301 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() {
2281 ClearUIResources(); 2302 ClearUIResources();
2282 tile_manager_->FinishTasksAndCleanUp(); 2303 tile_manager_->FinishTasksAndCleanUp();
2283 resource_pool_ = nullptr; 2304 resource_pool_ = nullptr;
2284 tile_task_worker_pool_ = nullptr; 2305 tile_task_worker_pool_ = nullptr;
2285 single_thread_synchronous_task_graph_runner_ = nullptr; 2306 single_thread_synchronous_task_graph_runner_ = nullptr;
2286 image_decode_controller_ = nullptr; 2307 image_decode_controller_ = nullptr;
2287 } 2308 }
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); 3144 scroll_result.did_overscroll_root = !unused_root_delta.IsZero();
3124 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; 3145 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_;
3125 scroll_result.unused_scroll_delta = unused_root_delta; 3146 scroll_result.unused_scroll_delta = unused_root_delta;
3126 3147
3127 if (scroll_result.did_scroll) { 3148 if (scroll_result.did_scroll) {
3128 // Scrolling can change the root scroll offset, so inform the synchronous 3149 // Scrolling can change the root scroll offset, so inform the synchronous
3129 // input handler. 3150 // input handler.
3130 UpdateRootLayerStateForSynchronousInputHandler(); 3151 UpdateRootLayerStateForSynchronousInputHandler();
3131 } 3152 }
3132 3153
3154 // Update compositor worker mutations which may respond to scrolling.
3155 Mutate(CurrentBeginFrameArgs().frame_time);
3156
3133 return scroll_result; 3157 return scroll_result;
3134 } 3158 }
3135 3159
3136 // This implements scrolling by page as described here: 3160 // 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 3161 // 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. 3162 // for events with WHEEL_PAGESCROLL set.
3139 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, 3163 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point,
3140 ScrollDirection direction) { 3164 ScrollDirection direction) {
3141 DCHECK(wheel_scrolling_); 3165 DCHECK(wheel_scrolling_);
3142 3166
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 } 3894 }
3871 3895
3872 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( 3896 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated(
3873 int layer_id, 3897 int layer_id,
3874 LayerTreeImpl* tree, 3898 LayerTreeImpl* tree,
3875 const gfx::ScrollOffset& scroll_offset) { 3899 const gfx::ScrollOffset& scroll_offset) {
3876 if (!tree) 3900 if (!tree)
3877 return; 3901 return;
3878 3902
3879 LayerImpl* layer = tree->LayerById(layer_id); 3903 LayerImpl* layer = tree->LayerById(layer_id);
3880 if (layer) 3904 if (layer) {
3881 layer->OnScrollOffsetAnimated(scroll_offset); 3905 layer->OnScrollOffsetAnimated(scroll_offset);
3906 // Run mutation callbacks to respond to updated scroll offset.
3907 Mutate(CurrentBeginFrameArgs().frame_time);
3908 }
3882 } 3909 }
3883 3910
3884 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( 3911 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged(
3885 int layer_id, 3912 int layer_id,
3886 LayerTreeImpl* tree, 3913 LayerTreeImpl* tree,
3887 bool is_animating) { 3914 bool is_animating) {
3888 if (!tree) 3915 if (!tree)
3889 return; 3916 return;
3890 3917
3891 LayerImpl* layer = tree->LayerById(layer_id); 3918 LayerImpl* layer = tree->LayerById(layer_id);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 return task_runner_provider_->HasImplThread(); 4007 return task_runner_provider_->HasImplThread();
3981 } 4008 }
3982 4009
3983 bool LayerTreeHostImpl::CommitToActiveTree() const { 4010 bool LayerTreeHostImpl::CommitToActiveTree() const {
3984 // In single threaded mode we skip the pending tree and commit directly to the 4011 // In single threaded mode we skip the pending tree and commit directly to the
3985 // active tree. 4012 // active tree.
3986 return !task_runner_provider_->HasImplThread(); 4013 return !task_runner_provider_->HasImplThread();
3987 } 4014 }
3988 4015
3989 } // namespace cc 4016 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698