| 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" |
| 11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
| 12 #include "cc/quads/draw_quad.h" | 12 #include "cc/quads/draw_quad.h" |
| 13 #include "cc/resources/prioritized_resource_manager.h" | 13 #include "cc/resources/prioritized_resource_manager.h" |
| 14 #include "cc/resources/resource_update_controller.h" | 14 #include "cc/resources/resource_update_controller.h" |
| 15 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
| 16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 17 #include "cc/trees/layer_tree_impl.h" | 17 #include "cc/trees/layer_tree_impl.h" |
| 18 #include "cc/trees/scoped_abort_remaining_swap_promises.h" | 18 #include "cc/trees/scoped_abort_remaining_swap_promises.h" |
| 19 #include "ui/gfx/frame_time.h" | 19 #include "ui/gfx/frame_time.h" |
| 20 | 20 |
| 21 namespace cc { | 21 namespace cc { |
| 22 | 22 |
| 23 scoped_ptr<Proxy> SingleThreadProxy::Create( | 23 scoped_ptr<Proxy> SingleThreadProxy::Create( |
| 24 LayerTreeHost* layer_tree_host, | 24 LayerTreeHost* layer_tree_host, |
| 25 LayerTreeHostSingleThreadClient* client, | 25 LayerTreeHostSingleThreadClient* client, |
| 26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 26 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 27 return make_scoped_ptr( | 27 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| 28 new SingleThreadProxy(layer_tree_host, client, main_task_runner)); | 28 return make_scoped_ptr(new SingleThreadProxy( |
| 29 layer_tree_host, |
| 30 client, |
| 31 main_task_runner, |
| 32 external_begin_frame_source.Pass())); |
| 29 } | 33 } |
| 30 | 34 |
| 31 SingleThreadProxy::SingleThreadProxy( | 35 SingleThreadProxy::SingleThreadProxy( |
| 32 LayerTreeHost* layer_tree_host, | 36 LayerTreeHost* layer_tree_host, |
| 33 LayerTreeHostSingleThreadClient* client, | 37 LayerTreeHostSingleThreadClient* client, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 38 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 39 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
| 35 : Proxy(main_task_runner, NULL), | 40 : Proxy(main_task_runner, NULL), |
| 36 layer_tree_host_(layer_tree_host), | 41 layer_tree_host_(layer_tree_host), |
| 37 client_(client), | 42 client_(client), |
| 38 timing_history_(layer_tree_host->rendering_stats_instrumentation()), | 43 timing_history_(layer_tree_host->rendering_stats_instrumentation()), |
| 39 next_frame_is_newly_committed_frame_(false), | 44 next_frame_is_newly_committed_frame_(false), |
| 40 inside_draw_(false), | 45 inside_draw_(false), |
| 41 defer_commits_(false), | 46 defer_commits_(false), |
| 42 commit_was_deferred_(false), | 47 commit_was_deferred_(false), |
| 43 commit_requested_(false), | 48 commit_requested_(false), |
| 44 output_surface_creation_requested_(false), | 49 output_surface_creation_requested_(false), |
| 50 external_begin_frame_source_(external_begin_frame_source.Pass()), |
| 45 weak_factory_(this) { | 51 weak_factory_(this) { |
| 46 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 52 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 47 DCHECK(Proxy::IsMainThread()); | 53 DCHECK(Proxy::IsMainThread()); |
| 48 DCHECK(layer_tree_host); | 54 DCHECK(layer_tree_host); |
| 49 } | 55 } |
| 50 | 56 |
| 51 void SingleThreadProxy::Start() { | 57 void SingleThreadProxy::Start() { |
| 52 DebugScopedSetImplThread impl(this); | 58 DebugScopedSetImplThread impl(this); |
| 53 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 59 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 54 } | 60 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 76 | 82 |
| 77 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 83 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
| 78 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 84 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); |
| 79 // Scheduling is controlled by the embedder in the single thread case, so | 85 // Scheduling is controlled by the embedder in the single thread case, so |
| 80 // nothing to do. | 86 // nothing to do. |
| 81 DCHECK(Proxy::IsMainThread()); | 87 DCHECK(Proxy::IsMainThread()); |
| 82 DebugScopedSetImplThread impl(this); | 88 DebugScopedSetImplThread impl(this); |
| 83 if (layer_tree_host_->settings().single_thread_proxy_scheduler && | 89 if (layer_tree_host_->settings().single_thread_proxy_scheduler && |
| 84 !scheduler_on_impl_thread_) { | 90 !scheduler_on_impl_thread_) { |
| 85 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | 91 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |
| 86 scheduler_on_impl_thread_ = Scheduler::Create(this, | 92 scheduler_on_impl_thread_ = |
| 87 scheduler_settings, | 93 Scheduler::Create(this, |
| 88 layer_tree_host_->id(), | 94 scheduler_settings, |
| 89 MainThreadTaskRunner(), | 95 layer_tree_host_->id(), |
| 90 base::PowerMonitor::Get()); | 96 MainThreadTaskRunner(), |
| 97 base::PowerMonitor::Get(), |
| 98 external_begin_frame_source_.Pass()); |
| 91 scheduler_on_impl_thread_->SetCanStart(); | 99 scheduler_on_impl_thread_->SetCanStart(); |
| 92 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 100 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
| 93 } | 101 } |
| 94 } | 102 } |
| 95 | 103 |
| 96 void SingleThreadProxy::SetVisible(bool visible) { | 104 void SingleThreadProxy::SetVisible(bool visible) { |
| 97 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 105 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
| 98 DebugScopedSetImplThread impl(this); | 106 DebugScopedSetImplThread impl(this); |
| 99 layer_tree_host_impl_->SetVisible(visible); | 107 layer_tree_host_impl_->SetVisible(visible); |
| 100 if (scheduler_on_impl_thread_) | 108 if (scheduler_on_impl_thread_) |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 DebugScopedSetMainThread main(this); | 614 DebugScopedSetMainThread main(this); |
| 607 next_frame_is_newly_committed_frame_ = false; | 615 next_frame_is_newly_committed_frame_ = false; |
| 608 layer_tree_host_->DidCommitAndDrawFrame(); | 616 layer_tree_host_->DidCommitAndDrawFrame(); |
| 609 } | 617 } |
| 610 } | 618 } |
| 611 | 619 |
| 612 bool SingleThreadProxy::MainFrameWillHappenForTesting() { | 620 bool SingleThreadProxy::MainFrameWillHappenForTesting() { |
| 613 return false; | 621 return false; |
| 614 } | 622 } |
| 615 | 623 |
| 616 BeginFrameSource* SingleThreadProxy::ExternalBeginFrameSource() { | |
| 617 return layer_tree_host_impl_.get(); | |
| 618 } | |
| 619 | |
| 620 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 624 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 621 layer_tree_host_impl_->WillBeginImplFrame(args); | 625 layer_tree_host_impl_->WillBeginImplFrame(args); |
| 622 } | 626 } |
| 623 | 627 |
| 624 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { | 628 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 625 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); | 629 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); |
| 626 // Although this proxy is single-threaded, it's problematic to synchronously | 630 // Although this proxy is single-threaded, it's problematic to synchronously |
| 627 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This | 631 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This |
| 628 // could cause a commit to occur in between a series of SetNeedsCommit calls | 632 // could cause a commit to occur in between a series of SetNeedsCommit calls |
| 629 // (i.e. property modifications) causing some to fall on one frame and some to | 633 // (i.e. property modifications) causing some to fall on one frame and some to |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 778 |
| 775 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 779 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
| 776 return timing_history_.CommitToActivateDurationEstimate(); | 780 return timing_history_.CommitToActivateDurationEstimate(); |
| 777 } | 781 } |
| 778 | 782 |
| 779 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 783 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
| 780 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 784 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
| 781 } | 785 } |
| 782 | 786 |
| 783 } // namespace cc | 787 } // namespace cc |
| OLD | NEW |