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 23 matching lines...) Expand all Loading... |
34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) |
35 : Proxy(main_task_runner, NULL), | 35 : Proxy(main_task_runner, NULL), |
36 layer_tree_host_(layer_tree_host), | 36 layer_tree_host_(layer_tree_host), |
37 client_(client), | 37 client_(client), |
38 timing_history_(layer_tree_host->rendering_stats_instrumentation()), | 38 timing_history_(layer_tree_host->rendering_stats_instrumentation()), |
39 next_frame_is_newly_committed_frame_(false), | 39 next_frame_is_newly_committed_frame_(false), |
40 inside_draw_(false), | 40 inside_draw_(false), |
41 defer_commits_(false), | 41 defer_commits_(false), |
42 commit_was_deferred_(false), | 42 commit_was_deferred_(false), |
43 commit_requested_(false), | 43 commit_requested_(false), |
| 44 inside_synchronous_composite_(false), |
44 output_surface_creation_requested_(false), | 45 output_surface_creation_requested_(false), |
45 weak_factory_(this) { | 46 weak_factory_(this) { |
46 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 47 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
47 DCHECK(Proxy::IsMainThread()); | 48 DCHECK(Proxy::IsMainThread()); |
48 DCHECK(layer_tree_host); | 49 DCHECK(layer_tree_host); |
49 } | 50 } |
50 | 51 |
51 void SingleThreadProxy::Start() { | 52 void SingleThreadProxy::Start() { |
52 DebugScopedSetImplThread impl(this); | 53 DebugScopedSetImplThread impl(this); |
53 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 54 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 128 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
128 layer_tree_host_impl_->resource_provider()); | 129 layer_tree_host_impl_->resource_provider()); |
129 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 130 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
130 } | 131 } |
131 | 132 |
132 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 133 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
133 | 134 |
134 if (success) { | 135 if (success) { |
135 if (scheduler_on_impl_thread_) | 136 if (scheduler_on_impl_thread_) |
136 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 137 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
| 138 else if (!inside_synchronous_composite_) |
| 139 SetNeedsCommit(); |
137 } else if (Proxy::MainThreadTaskRunner()) { | 140 } else if (Proxy::MainThreadTaskRunner()) { |
138 ScheduleRequestNewOutputSurface(); | 141 ScheduleRequestNewOutputSurface(); |
139 } | 142 } |
140 } | 143 } |
141 | 144 |
142 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 145 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
143 DCHECK(Proxy::IsMainThread()); | 146 DCHECK(Proxy::IsMainThread()); |
144 DCHECK(!layer_tree_host_->output_surface_lost()); | 147 DCHECK(!layer_tree_host_->output_surface_lost()); |
145 return renderer_capabilities_for_main_thread_; | 148 return renderer_capabilities_for_main_thread_; |
146 } | 149 } |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 460 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
458 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 461 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
459 if (scheduler_on_impl_thread_) | 462 if (scheduler_on_impl_thread_) |
460 scheduler_on_impl_thread_->DidSwapBuffersComplete(); | 463 scheduler_on_impl_thread_->DidSwapBuffersComplete(); |
461 layer_tree_host_->DidCompleteSwapBuffers(); | 464 layer_tree_host_->DidCompleteSwapBuffers(); |
462 } | 465 } |
463 | 466 |
464 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 467 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
465 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); | 468 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); |
466 DCHECK(Proxy::IsMainThread()); | 469 DCHECK(Proxy::IsMainThread()); |
467 DCHECK(!layer_tree_host_->output_surface_lost()); | |
468 DCHECK(!layer_tree_host_impl_->settings().impl_side_painting) | 470 DCHECK(!layer_tree_host_impl_->settings().impl_side_painting) |
469 << "Impl-side painting and synchronous compositing are not supported."; | 471 << "Impl-side painting and synchronous compositing are not supported."; |
| 472 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
| 473 |
| 474 if (layer_tree_host_->output_surface_lost()) { |
| 475 RequestNewOutputSurface(); |
| 476 // RequestNewOutputSurface could have synchronously created an output |
| 477 // surface, so check again before returning. |
| 478 if (layer_tree_host_->output_surface_lost()) |
| 479 return; |
| 480 } |
470 | 481 |
471 { | 482 { |
472 BeginFrameArgs begin_frame_args( | 483 BeginFrameArgs begin_frame_args( |
473 BeginFrameArgs::Create(frame_begin_time, | 484 BeginFrameArgs::Create(frame_begin_time, |
474 base::TimeTicks(), | 485 base::TimeTicks(), |
475 BeginFrameArgs::DefaultInterval())); | 486 BeginFrameArgs::DefaultInterval())); |
476 DoBeginMainFrame(begin_frame_args); | 487 DoBeginMainFrame(begin_frame_args); |
477 DoCommit(); | 488 DoCommit(); |
478 | 489 |
479 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) | 490 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 | 785 |
775 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 786 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
776 return timing_history_.CommitToActivateDurationEstimate(); | 787 return timing_history_.CommitToActivateDurationEstimate(); |
777 } | 788 } |
778 | 789 |
779 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 790 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
780 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 791 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
781 } | 792 } |
782 | 793 |
783 } // namespace cc | 794 } // namespace cc |
OLD | NEW |