| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void SingleThreadProxy::SetVisible(bool visible) { | 100 void SingleThreadProxy::SetVisible(bool visible) { |
| 101 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 101 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
| 102 DebugScopedSetImplThread impl(this); | 102 DebugScopedSetImplThread impl(this); |
| 103 layer_tree_host_impl_->SetVisible(visible); | 103 layer_tree_host_impl_->SetVisible(visible); |
| 104 if (scheduler_on_impl_thread_) | 104 if (scheduler_on_impl_thread_) |
| 105 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 105 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
| 106 // Changing visibility could change ShouldComposite(). | 106 // Changing visibility could change ShouldComposite(). |
| 107 UpdateBackgroundAnimateTicking(); | 107 UpdateBackgroundAnimateTicking(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 110 void SingleThreadProxy::RequestNewOutputSurface() { |
| 111 TRACE_EVENT0( | |
| 112 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | |
| 113 DCHECK(Proxy::IsMainThread()); | 111 DCHECK(Proxy::IsMainThread()); |
| 114 DCHECK(layer_tree_host_->output_surface_lost()); | 112 DCHECK(layer_tree_host_->output_surface_lost()); |
| 113 layer_tree_host_->RequestNewOutputSurface(); |
| 114 } |
| 115 | 115 |
| 116 scoped_ptr<OutputSurface> output_surface = | 116 void SingleThreadProxy::SetOutputSurface( |
| 117 layer_tree_host_->CreateOutputSurface(); | 117 scoped_ptr<OutputSurface> output_surface) { |
| 118 | 118 DCHECK(Proxy::IsMainThread()); |
| 119 DCHECK(layer_tree_host_->output_surface_lost()); |
| 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(); |
| 135 } else if (Proxy::MainThreadTaskRunner()) { | 136 } else if (Proxy::MainThreadTaskRunner()) { |
| 136 MainThreadTaskRunner()->PostTask( | 137 MainThreadTaskRunner()->PostTask( |
| 137 FROM_HERE, | 138 FROM_HERE, |
| 138 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, | 139 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, |
| 139 weak_factory_.GetWeakPtr())); | 140 weak_factory_.GetWeakPtr())); |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 | 143 |
| 143 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 144 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
| 144 DCHECK(Proxy::IsMainThread()); | 145 DCHECK(Proxy::IsMainThread()); |
| 145 DCHECK(!layer_tree_host_->output_surface_lost()); | 146 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 146 return renderer_capabilities_for_main_thread_; | 147 return renderer_capabilities_for_main_thread_; |
| 147 } | 148 } |
| 148 | 149 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 658 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
| 658 DebugScopedSetMainThread main(this); | 659 DebugScopedSetMainThread main(this); |
| 659 DCHECK(scheduler_on_impl_thread_); | 660 DCHECK(scheduler_on_impl_thread_); |
| 660 // If possible, create the output surface in a post task. Synchronously | 661 // If possible, create the output surface in a post task. Synchronously |
| 661 // creating the output surface makes tests more awkward since this differs | 662 // creating the output surface makes tests more awkward since this differs |
| 662 // from the ThreadProxy behavior. However, sometimes there is no | 663 // from the ThreadProxy behavior. However, sometimes there is no |
| 663 // task runner. | 664 // task runner. |
| 664 if (Proxy::MainThreadTaskRunner()) { | 665 if (Proxy::MainThreadTaskRunner()) { |
| 665 MainThreadTaskRunner()->PostTask( | 666 MainThreadTaskRunner()->PostTask( |
| 666 FROM_HERE, | 667 FROM_HERE, |
| 667 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, | 668 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, |
| 668 weak_factory_.GetWeakPtr())); | 669 weak_factory_.GetWeakPtr())); |
| 669 } else { | 670 } else { |
| 670 CreateAndInitializeOutputSurface(); | 671 RequestNewOutputSurface(); |
| 671 } | 672 } |
| 672 } | 673 } |
| 673 | 674 |
| 674 void SingleThreadProxy::ScheduledActionManageTiles() { | 675 void SingleThreadProxy::ScheduledActionManageTiles() { |
| 675 // Impl-side painting only. | 676 // Impl-side painting only. |
| 676 NOTREACHED(); | 677 NOTREACHED(); |
| 677 } | 678 } |
| 678 | 679 |
| 679 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { | 680 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
| 680 } | 681 } |
| 681 | 682 |
| 682 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { | 683 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { |
| 683 return timing_history_.DrawDurationEstimate(); | 684 return timing_history_.DrawDurationEstimate(); |
| 684 } | 685 } |
| 685 | 686 |
| 686 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { | 687 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { |
| 687 return timing_history_.BeginMainFrameToCommitDurationEstimate(); | 688 return timing_history_.BeginMainFrameToCommitDurationEstimate(); |
| 688 } | 689 } |
| 689 | 690 |
| 690 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 691 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
| 691 return timing_history_.CommitToActivateDurationEstimate(); | 692 return timing_history_.CommitToActivateDurationEstimate(); |
| 692 } | 693 } |
| 693 | 694 |
| 694 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 695 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
| 695 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 696 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
| 696 } | 697 } |
| 697 | 698 |
| 698 } // namespace cc | 699 } // namespace cc |
| OLD | NEW |