| 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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
| 10 #include "cc/debug/devtools_instrumentation.h" | 10 #include "cc/debug/devtools_instrumentation.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 DebugScopedSetImplThread impl(this); | 75 DebugScopedSetImplThread impl(this); |
| 76 layer_tree_host_impl_->FinishAllRendering(); | 76 layer_tree_host_impl_->FinishAllRendering(); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool SingleThreadProxy::IsStarted() const { | 80 bool SingleThreadProxy::IsStarted() const { |
| 81 DCHECK(Proxy::IsMainThread()); | 81 DCHECK(Proxy::IsMainThread()); |
| 82 return layer_tree_host_impl_; | 82 return layer_tree_host_impl_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool SingleThreadProxy::CommitToActiveTree() const { |
| 86 // With SingleThreadProxy we skip the pending tree and commit directly to the |
| 87 // active tree. |
| 88 return true; |
| 89 } |
| 90 |
| 85 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 91 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
| 86 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 92 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); |
| 87 // Scheduling is controlled by the embedder in the single thread case, so | 93 // Scheduling is controlled by the embedder in the single thread case, so |
| 88 // nothing to do. | 94 // nothing to do. |
| 89 DCHECK(Proxy::IsMainThread()); | 95 DCHECK(Proxy::IsMainThread()); |
| 90 DebugScopedSetImplThread impl(this); | 96 DebugScopedSetImplThread impl(this); |
| 91 if (layer_tree_host_->settings().single_thread_proxy_scheduler && | 97 if (layer_tree_host_->settings().single_thread_proxy_scheduler && |
| 92 !scheduler_on_impl_thread_) { | 98 !scheduler_on_impl_thread_) { |
| 93 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | 99 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |
| 94 // SingleThreadProxy should run in main thread low latency mode. | 100 // SingleThreadProxy should run in main thread low latency mode. |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 MainThreadTaskRunner(), | 239 MainThreadTaskRunner(), |
| 234 queue_for_commit_.Pass(), | 240 queue_for_commit_.Pass(), |
| 235 layer_tree_host_impl_->resource_provider()); | 241 layer_tree_host_impl_->resource_provider()); |
| 236 update_controller->Finalize(); | 242 update_controller->Finalize(); |
| 237 | 243 |
| 238 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 244 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
| 239 layer_tree_host_->RecreateUIResources(); | 245 layer_tree_host_->RecreateUIResources(); |
| 240 | 246 |
| 241 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 247 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
| 242 | 248 |
| 243 layer_tree_host_impl_->CommitComplete(); | |
| 244 | |
| 245 #if DCHECK_IS_ON() | 249 #if DCHECK_IS_ON() |
| 246 // In the single-threaded case, the scale and scroll deltas should never be | 250 // In the single-threaded case, the scale and scroll deltas should never be |
| 247 // touched on the impl layer tree. | 251 // touched on the impl layer tree. |
| 248 scoped_ptr<ScrollAndScaleSet> scroll_info = | 252 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 249 layer_tree_host_impl_->ProcessScrollDeltas(); | 253 layer_tree_host_impl_->ProcessScrollDeltas(); |
| 250 DCHECK(!scroll_info->scrolls.size()); | 254 DCHECK(!scroll_info->scrolls.size()); |
| 251 DCHECK_EQ(1.f, scroll_info->page_scale_delta); | 255 DCHECK_EQ(1.f, scroll_info->page_scale_delta); |
| 252 #endif | 256 #endif |
| 253 } | |
| 254 | 257 |
| 255 if (layer_tree_host_->settings().impl_side_painting) { | 258 if (layer_tree_host_->settings().impl_side_painting) { |
| 256 // TODO(enne): just commit directly to the active tree. | 259 // Commit goes directly to the active tree, but we need to synchronously |
| 257 // | 260 // "activate" the tree still during commit to satisfy any potential |
| 258 // Synchronously activate during commit to satisfy any potential | 261 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree |
| 259 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree | 262 // might not be ready to draw, so DidActivateSyncTree must set |
| 260 // might not be ready to draw, so DidActivateSyncTree must set | 263 // the flag to force the tree to not draw until textures are ready. |
| 261 // the flag to force the tree to not draw until textures are ready. | 264 NotifyReadyToActivate(); |
| 262 NotifyReadyToActivate(); | 265 } else { |
| 263 } else { | 266 CommitComplete(); |
| 264 CommitComplete(); | 267 } |
| 265 } | 268 } |
| 266 } | 269 } |
| 267 | 270 |
| 268 void SingleThreadProxy::CommitComplete() { | 271 void SingleThreadProxy::CommitComplete() { |
| 269 DCHECK(!layer_tree_host_impl_->pending_tree()) | 272 DCHECK(!layer_tree_host_impl_->pending_tree()) |
| 270 << "Activation is expected to have synchronously occurred by now."; | 273 << "Activation is expected to have synchronously occurred by now."; |
| 271 DCHECK(commit_blocking_task_runner_); | 274 DCHECK(commit_blocking_task_runner_); |
| 272 | 275 |
| 276 // Notify commit complete on the impl side after activate to satisfy any |
| 277 // SetNextCommitWaitsForActivation calls. |
| 278 layer_tree_host_impl_->CommitComplete(); |
| 279 |
| 273 DebugScopedSetMainThread main(this); | 280 DebugScopedSetMainThread main(this); |
| 274 commit_blocking_task_runner_.reset(); | 281 commit_blocking_task_runner_.reset(); |
| 275 layer_tree_host_->CommitComplete(); | 282 layer_tree_host_->CommitComplete(); |
| 276 layer_tree_host_->DidBeginMainFrame(); | 283 layer_tree_host_->DidBeginMainFrame(); |
| 277 timing_history_.DidCommit(); | 284 timing_history_.DidCommit(); |
| 278 | 285 |
| 279 next_frame_is_newly_committed_frame_ = true; | 286 next_frame_is_newly_committed_frame_ = true; |
| 280 } | 287 } |
| 281 | 288 |
| 282 void SingleThreadProxy::SetNeedsCommit() { | 289 void SingleThreadProxy::SetNeedsCommit() { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return contents_texture_manager->ReduceMemoryOnImplThread( | 433 return contents_texture_manager->ReduceMemoryOnImplThread( |
| 427 limit_bytes, priority_cutoff, resource_provider); | 434 limit_bytes, priority_cutoff, resource_provider); |
| 428 } | 435 } |
| 429 | 436 |
| 430 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 437 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
| 431 | 438 |
| 432 void SingleThreadProxy::DidActivateSyncTree() { | 439 void SingleThreadProxy::DidActivateSyncTree() { |
| 433 // Non-impl-side painting finishes commit in DoCommit. Impl-side painting | 440 // Non-impl-side painting finishes commit in DoCommit. Impl-side painting |
| 434 // defers until here to simulate SetNextCommitWaitsForActivation. | 441 // defers until here to simulate SetNextCommitWaitsForActivation. |
| 435 if (layer_tree_host_impl_->settings().impl_side_painting) { | 442 if (layer_tree_host_impl_->settings().impl_side_painting) { |
| 436 // This is required because NotifyReadyToActivate gets called when | 443 // This is required because NotifyReadyToActivate gets called immediately |
| 437 // the pending tree is not actually ready in the SingleThreadProxy. | 444 // after commit since single thread commits directly to the active tree. |
| 438 layer_tree_host_impl_->SetRequiresHighResToDraw(); | 445 layer_tree_host_impl_->SetRequiresHighResToDraw(); |
| 439 | 446 |
| 440 // Synchronously call to CommitComplete. Resetting | 447 // Synchronously call to CommitComplete. Resetting |
| 441 // |commit_blocking_task_runner| would make sure all tasks posted during | 448 // |commit_blocking_task_runner| would make sure all tasks posted during |
| 442 // commit/activation before CommitComplete. | 449 // commit/activation before CommitComplete. |
| 443 CommitComplete(); | 450 CommitComplete(); |
| 444 } | 451 } |
| 445 | 452 |
| 446 timing_history_.DidActivateSyncTree(); | 453 timing_history_.DidActivateSyncTree(); |
| 447 } | 454 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 LayerTreeHostImpl::FrameData frame; | 542 LayerTreeHostImpl::FrameData frame; |
| 536 DoComposite(frame_begin_time, &frame); | 543 DoComposite(frame_begin_time, &frame); |
| 537 | 544 |
| 538 // DoComposite could abort, but because this is a synchronous composite | 545 // DoComposite could abort, but because this is a synchronous composite |
| 539 // another draw will never be scheduled, so break remaining promises. | 546 // another draw will never be scheduled, so break remaining promises. |
| 540 layer_tree_host_impl_->active_tree()->BreakSwapPromises( | 547 layer_tree_host_impl_->active_tree()->BreakSwapPromises( |
| 541 SwapPromise::SWAP_FAILS); | 548 SwapPromise::SWAP_FAILS); |
| 542 } | 549 } |
| 543 } | 550 } |
| 544 | 551 |
| 545 void SingleThreadProxy::AsValueInto(base::debug::TracedValue* state) const { | 552 void SingleThreadProxy::AsValueInto( |
| 553 base::trace_event::TracedValue* state) const { |
| 546 // The following line casts away const modifiers because it is just | 554 // The following line casts away const modifiers because it is just |
| 547 // setting debug state. We still want the AsValue() function and its | 555 // setting debug state. We still want the AsValue() function and its |
| 548 // call chain to be const throughout. | 556 // call chain to be const throughout. |
| 549 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); | 557 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); |
| 550 | 558 |
| 551 state->BeginDictionary("layer_tree_host_impl"); | 559 state->BeginDictionary("layer_tree_host_impl"); |
| 552 layer_tree_host_impl_->AsValueInto(state); | 560 layer_tree_host_impl_->AsValueInto(state); |
| 553 state->EndDictionary(); | 561 state->EndDictionary(); |
| 554 } | 562 } |
| 555 | 563 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 826 |
| 819 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 827 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
| 820 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 828 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
| 821 } | 829 } |
| 822 | 830 |
| 823 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 831 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
| 824 layer_tree_host_->SendBeginFramesToChildren(args); | 832 layer_tree_host_->SendBeginFramesToChildren(args); |
| 825 } | 833 } |
| 826 | 834 |
| 827 } // namespace cc | 835 } // namespace cc |
| OLD | NEW |