| 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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 110 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
| 111 TRACE_EVENT0( | 111 TRACE_EVENT0( |
| 112 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 112 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
| 113 DCHECK(Proxy::IsMainThread()); | 113 DCHECK(Proxy::IsMainThread()); |
| 114 DCHECK(layer_tree_host_->output_surface_lost()); | 114 DCHECK(layer_tree_host_->output_surface_lost()); |
| 115 | 115 |
| 116 scoped_ptr<OutputSurface> output_surface = | 116 scoped_ptr<OutputSurface> output_surface = |
| 117 layer_tree_host_->CreateOutputSurface(); | 117 layer_tree_host_->CreateOutputSurface(); |
| 118 OutputSurface* output_surface_ptr = output_surface.get(); |
| 118 | 119 |
| 119 renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 120 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
| 120 | 121 |
| 121 bool success = !!output_surface; | 122 bool success = !!output_surface; |
| 122 if (success) { | 123 if (success) { |
| 123 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 124 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 124 DebugScopedSetImplThread impl(this); | 125 DebugScopedSetImplThread impl(this); |
| 125 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 126 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
| 126 layer_tree_host_impl_->resource_provider()); | 127 layer_tree_host_impl_->resource_provider()); |
| 127 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 128 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
| 128 } | 129 } |
| 129 | 130 |
| 130 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 131 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
| 131 | 132 |
| 132 if (success) { | 133 if (success) { |
| 133 if (scheduler_on_impl_thread_) | 134 if (scheduler_on_impl_thread_) |
| 134 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 135 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface( |
| 136 output_surface_ptr); |
| 135 } else if (Proxy::MainThreadTaskRunner()) { | 137 } else if (Proxy::MainThreadTaskRunner()) { |
| 136 MainThreadTaskRunner()->PostTask( | 138 MainThreadTaskRunner()->PostTask( |
| 137 FROM_HERE, | 139 FROM_HERE, |
| 138 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, | 140 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, |
| 139 weak_factory_.GetWeakPtr())); | 141 weak_factory_.GetWeakPtr())); |
| 140 } | 142 } |
| 141 } | 143 } |
| 142 | 144 |
| 143 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 145 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 144 DCHECK(Proxy::IsMainThread()); | 146 DCHECK(Proxy::IsMainThread()); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 DebugScopedSetMainThread main(this); | 546 DebugScopedSetMainThread main(this); |
| 545 next_frame_is_newly_committed_frame_ = false; | 547 next_frame_is_newly_committed_frame_ = false; |
| 546 layer_tree_host_->DidCommitAndDrawFrame(); | 548 layer_tree_host_->DidCommitAndDrawFrame(); |
| 547 } | 549 } |
| 548 } | 550 } |
| 549 | 551 |
| 550 bool SingleThreadProxy::MainFrameWillHappenForTesting() { | 552 bool SingleThreadProxy::MainFrameWillHappenForTesting() { |
| 551 return false; | 553 return false; |
| 552 } | 554 } |
| 553 | 555 |
| 554 BeginFrameSource* SingleThreadProxy::GetExternalBeginFrameSource() { | |
| 555 return layer_tree_host_impl_.get(); | |
| 556 } | |
| 557 | |
| 558 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 556 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 559 layer_tree_host_impl_->WillBeginImplFrame(args); | 557 layer_tree_host_impl_->WillBeginImplFrame(args); |
| 560 } | 558 } |
| 561 | 559 |
| 562 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { | 560 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 563 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); | 561 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); |
| 564 // Although this proxy is single-threaded, it's problematic to synchronously | 562 // Although this proxy is single-threaded, it's problematic to synchronously |
| 565 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This | 563 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This |
| 566 // could cause a commit to occur in between a series of SetNeedsCommit calls | 564 // could cause a commit to occur in between a series of SetNeedsCommit calls |
| 567 // (i.e. property modifications) causing some to fall on one frame and some to | 565 // (i.e. property modifications) causing some to fall on one frame and some to |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 681 |
| 684 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 682 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
| 685 return timing_history_.CommitToActivateDurationEstimate(); | 683 return timing_history_.CommitToActivateDurationEstimate(); |
| 686 } | 684 } |
| 687 | 685 |
| 688 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 686 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
| 689 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 687 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
| 690 } | 688 } |
| 691 | 689 |
| 692 } // namespace cc | 690 } // namespace cc |
| OLD | NEW |