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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 debug_rect_history_(DebugRectHistory::Create()), | 219 debug_rect_history_(DebugRectHistory::Create()), |
220 texture_mailbox_deleter_(new TextureMailboxDeleter(GetTaskRunner())), | 220 texture_mailbox_deleter_(new TextureMailboxDeleter(GetTaskRunner())), |
221 max_memory_needed_bytes_(0), | 221 max_memory_needed_bytes_(0), |
222 resourceless_software_draw_(false), | 222 resourceless_software_draw_(false), |
223 animation_registrar_(), | 223 animation_registrar_(), |
224 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 224 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
225 micro_benchmark_controller_(this), | 225 micro_benchmark_controller_(this), |
226 shared_bitmap_manager_(shared_bitmap_manager), | 226 shared_bitmap_manager_(shared_bitmap_manager), |
227 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 227 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
228 task_graph_runner_(task_graph_runner), | 228 task_graph_runner_(task_graph_runner), |
| 229 mutator_(nullptr), |
229 id_(id), | 230 id_(id), |
230 requires_high_res_to_draw_(false), | 231 requires_high_res_to_draw_(false), |
231 is_likely_to_require_a_draw_(false), | 232 is_likely_to_require_a_draw_(false), |
232 frame_timing_tracker_(FrameTimingTracker::Create(this)) { | 233 frame_timing_tracker_(FrameTimingTracker::Create(this)) { |
233 if (settings.use_compositor_animation_timelines) { | 234 if (settings.use_compositor_animation_timelines) { |
234 if (settings.accelerated_animation_enabled) { | 235 if (settings.accelerated_animation_enabled) { |
235 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); | 236 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); |
236 animation_host_->SetMutatorHostClient(this); | 237 animation_host_->SetMutatorHostClient(this); |
237 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); | 238 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); |
238 } | 239 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 input_handler_client_->Animate(monotonic_time); | 453 input_handler_client_->Animate(monotonic_time); |
453 } | 454 } |
454 } | 455 } |
455 | 456 |
456 did_animate |= AnimatePageScale(monotonic_time); | 457 did_animate |= AnimatePageScale(monotonic_time); |
457 did_animate |= AnimateLayers(monotonic_time); | 458 did_animate |= AnimateLayers(monotonic_time); |
458 did_animate |= AnimateScrollbars(monotonic_time); | 459 did_animate |= AnimateScrollbars(monotonic_time); |
459 did_animate |= AnimateTopControls(monotonic_time); | 460 did_animate |= AnimateTopControls(monotonic_time); |
460 | 461 |
461 if (active_tree) { | 462 if (active_tree) { |
| 463 did_animate |= Mutate(monotonic_time); |
| 464 |
462 // Animating stuff can change the root scroll offset, so inform the | 465 // Animating stuff can change the root scroll offset, so inform the |
463 // synchronous input handler. | 466 // synchronous input handler. |
464 UpdateRootLayerStateForSynchronousInputHandler(); | 467 UpdateRootLayerStateForSynchronousInputHandler(); |
465 if (did_animate) { | 468 if (did_animate) { |
466 // If the tree changed, then we want to draw at the end of the current | 469 // If the tree changed, then we want to draw at the end of the current |
467 // frame. | 470 // frame. |
468 SetNeedsRedraw(); | 471 SetNeedsRedraw(); |
469 } | 472 } |
470 } | 473 } |
471 } | 474 } |
472 | 475 |
| 476 bool LayerTreeHostImpl::Mutate(base::TimeTicks monotonic_time) { |
| 477 if (!mutator_) |
| 478 return false; |
| 479 TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::Mutate"); |
| 480 if (mutator_->Mutate(monotonic_time, active_tree_.get())) |
| 481 client_->SetNeedsOneBeginImplFrameOnImplThread(); |
| 482 return true; |
| 483 } |
| 484 |
| 485 void LayerTreeHostImpl::SetNeedsMutate() { |
| 486 TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::SetNeedsMutate"); |
| 487 client_->SetNeedsOneBeginImplFrameOnImplThread(); |
| 488 } |
| 489 |
473 bool LayerTreeHostImpl::PrepareTiles() { | 490 bool LayerTreeHostImpl::PrepareTiles() { |
474 if (!tile_priorities_dirty_) | 491 if (!tile_priorities_dirty_) |
475 return false; | 492 return false; |
476 | 493 |
477 client_->WillPrepareTiles(); | 494 client_->WillPrepareTiles(); |
478 bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_); | 495 bool did_prepare_tiles = tile_manager_->PrepareTiles(global_tile_state_); |
479 if (did_prepare_tiles) | 496 if (did_prepare_tiles) |
480 tile_priorities_dirty_ = false; | 497 tile_priorities_dirty_ = false; |
481 client_->DidPrepareTiles(); | 498 client_->DidPrepareTiles(); |
482 return did_prepare_tiles; | 499 return did_prepare_tiles; |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 // tree, rename the pending tree the recycle tree so we can reuse it on the | 2070 // tree, rename the pending tree the recycle tree so we can reuse it on the |
2054 // next sync. | 2071 // next sync. |
2055 DCHECK(!recycle_tree_); | 2072 DCHECK(!recycle_tree_); |
2056 pending_tree_.swap(recycle_tree_); | 2073 pending_tree_.swap(recycle_tree_); |
2057 | 2074 |
2058 UpdateViewportContainerSizes(); | 2075 UpdateViewportContainerSizes(); |
2059 | 2076 |
2060 // If we commit to the active tree directly, this is already done during | 2077 // If we commit to the active tree directly, this is already done during |
2061 // commit. | 2078 // commit. |
2062 ActivateAnimations(); | 2079 ActivateAnimations(); |
| 2080 Mutate(CurrentBeginFrameArgs().frame_time); |
2063 } else { | 2081 } else { |
2064 active_tree_->ProcessUIResourceRequestQueue(); | 2082 active_tree_->ProcessUIResourceRequestQueue(); |
2065 } | 2083 } |
2066 | 2084 |
2067 // bounds_delta isn't a pushed property, so the newly-pushed property tree | 2085 // bounds_delta isn't a pushed property, so the newly-pushed property tree |
2068 // won't already account for current bounds_delta values. | 2086 // won't already account for current bounds_delta values. |
2069 active_tree_->UpdatePropertyTreesForBoundsDelta(); | 2087 active_tree_->UpdatePropertyTreesForBoundsDelta(); |
2070 active_tree_->DidBecomeActive(); | 2088 active_tree_->DidBecomeActive(); |
2071 client_->RenewTreePriority(); | 2089 client_->RenewTreePriority(); |
2072 // If we have any picture layers, then by activating we also modified tile | 2090 // If we have any picture layers, then by activating we also modified tile |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 request_ids, start_time, end_time, active_tree_->source_frame_number()); | 2321 request_ids, start_time, end_time, active_tree_->source_frame_number()); |
2304 } | 2322 } |
2305 | 2323 |
2306 void LayerTreeHostImpl::PostFrameTimingEvents( | 2324 void LayerTreeHostImpl::PostFrameTimingEvents( |
2307 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 2325 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
2308 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 2326 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
2309 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), | 2327 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), |
2310 std::move(main_frame_events)); | 2328 std::move(main_frame_events)); |
2311 } | 2329 } |
2312 | 2330 |
| 2331 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
| 2332 if (mutator == mutator_) |
| 2333 return; |
| 2334 TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::SetLayerTreeMutator"); |
| 2335 mutator_ = mutator; |
| 2336 mutator_->SetClient(this); |
| 2337 } |
| 2338 |
2313 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2339 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2314 ClearUIResources(); | 2340 ClearUIResources(); |
2315 tile_manager_->FinishTasksAndCleanUp(); | 2341 tile_manager_->FinishTasksAndCleanUp(); |
2316 resource_pool_ = nullptr; | 2342 resource_pool_ = nullptr; |
2317 tile_task_worker_pool_ = nullptr; | 2343 tile_task_worker_pool_ = nullptr; |
2318 single_thread_synchronous_task_graph_runner_ = nullptr; | 2344 single_thread_synchronous_task_graph_runner_ = nullptr; |
2319 } | 2345 } |
2320 | 2346 |
2321 void LayerTreeHostImpl::ReleaseOutputSurface() { | 2347 void LayerTreeHostImpl::ReleaseOutputSurface() { |
2322 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseOutputSurface"); | 2348 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseOutputSurface"); |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); | 3000 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); |
2975 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; | 3001 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; |
2976 scroll_result.unused_scroll_delta = unused_root_delta; | 3002 scroll_result.unused_scroll_delta = unused_root_delta; |
2977 | 3003 |
2978 if (scroll_result.did_scroll) { | 3004 if (scroll_result.did_scroll) { |
2979 // Scrolling can change the root scroll offset, so inform the synchronous | 3005 // Scrolling can change the root scroll offset, so inform the synchronous |
2980 // input handler. | 3006 // input handler. |
2981 UpdateRootLayerStateForSynchronousInputHandler(); | 3007 UpdateRootLayerStateForSynchronousInputHandler(); |
2982 } | 3008 } |
2983 | 3009 |
| 3010 // Update compositor worker mutations which may respond to scrolling. |
| 3011 Mutate(CurrentBeginFrameArgs().frame_time); |
| 3012 |
2984 return scroll_result; | 3013 return scroll_result; |
2985 } | 3014 } |
2986 | 3015 |
2987 // This implements scrolling by page as described here: | 3016 // This implements scrolling by page as described here: |
2988 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | 3017 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel |
2989 // for events with WHEEL_PAGESCROLL set. | 3018 // for events with WHEEL_PAGESCROLL set. |
2990 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, | 3019 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, |
2991 ScrollDirection direction) { | 3020 ScrollDirection direction) { |
2992 DCHECK(wheel_scrolling_); | 3021 DCHECK(wheel_scrolling_); |
2993 | 3022 |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3902 return task_runner_provider_->HasImplThread(); | 3931 return task_runner_provider_->HasImplThread(); |
3903 } | 3932 } |
3904 | 3933 |
3905 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3934 bool LayerTreeHostImpl::CommitToActiveTree() const { |
3906 // In single threaded mode we skip the pending tree and commit directly to the | 3935 // In single threaded mode we skip the pending tree and commit directly to the |
3907 // active tree. | 3936 // active tree. |
3908 return !task_runner_provider_->HasImplThread(); | 3937 return !task_runner_provider_->HasImplThread(); |
3909 } | 3938 } |
3910 | 3939 |
3911 } // namespace cc | 3940 } // namespace cc |
OLD | NEW |