| 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<ExternalBeginFrameSource> 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<ExternalBeginFrameSource> 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), |
| 49 external_begin_frame_source_(external_begin_frame_source.Pass()), |
| 44 weak_factory_(this) { | 50 weak_factory_(this) { |
| 45 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 51 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 46 DCHECK(Proxy::IsMainThread()); | 52 DCHECK(Proxy::IsMainThread()); |
| 47 DCHECK(layer_tree_host); | 53 DCHECK(layer_tree_host); |
| 48 } | 54 } |
| 49 | 55 |
| 50 void SingleThreadProxy::Start() { | 56 void SingleThreadProxy::Start() { |
| 51 DebugScopedSetImplThread impl(this); | 57 DebugScopedSetImplThread impl(this); |
| 52 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 58 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 53 } | 59 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 75 | 81 |
| 76 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 82 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
| 77 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 83 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); |
| 78 // Scheduling is controlled by the embedder in the single thread case, so | 84 // Scheduling is controlled by the embedder in the single thread case, so |
| 79 // nothing to do. | 85 // nothing to do. |
| 80 DCHECK(Proxy::IsMainThread()); | 86 DCHECK(Proxy::IsMainThread()); |
| 81 DebugScopedSetImplThread impl(this); | 87 DebugScopedSetImplThread impl(this); |
| 82 if (layer_tree_host_->settings().single_thread_proxy_scheduler && | 88 if (layer_tree_host_->settings().single_thread_proxy_scheduler && |
| 83 !scheduler_on_impl_thread_) { | 89 !scheduler_on_impl_thread_) { |
| 84 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | 90 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |
| 85 scheduler_on_impl_thread_ = Scheduler::Create(this, | 91 scheduler_on_impl_thread_ = |
| 86 scheduler_settings, | 92 Scheduler::Create(this, |
| 87 layer_tree_host_->id(), | 93 scheduler_settings, |
| 88 MainThreadTaskRunner()); | 94 layer_tree_host_->id(), |
| 95 MainThreadTaskRunner(), |
| 96 external_begin_frame_source_.Pass()); |
| 89 scheduler_on_impl_thread_->SetCanStart(); | 97 scheduler_on_impl_thread_->SetCanStart(); |
| 90 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 98 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
| 91 } | 99 } |
| 92 } | 100 } |
| 93 | 101 |
| 94 void SingleThreadProxy::SetVisible(bool visible) { | 102 void SingleThreadProxy::SetVisible(bool visible) { |
| 95 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 103 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
| 96 DebugScopedSetImplThread impl(this); | 104 DebugScopedSetImplThread impl(this); |
| 97 layer_tree_host_impl_->SetVisible(visible); | 105 layer_tree_host_impl_->SetVisible(visible); |
| 98 if (scheduler_on_impl_thread_) | 106 if (scheduler_on_impl_thread_) |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 DebugScopedSetMainThread main(this); | 599 DebugScopedSetMainThread main(this); |
| 592 next_frame_is_newly_committed_frame_ = false; | 600 next_frame_is_newly_committed_frame_ = false; |
| 593 layer_tree_host_->DidCommitAndDrawFrame(); | 601 layer_tree_host_->DidCommitAndDrawFrame(); |
| 594 } | 602 } |
| 595 } | 603 } |
| 596 | 604 |
| 597 bool SingleThreadProxy::MainFrameWillHappenForTesting() { | 605 bool SingleThreadProxy::MainFrameWillHappenForTesting() { |
| 598 return false; | 606 return false; |
| 599 } | 607 } |
| 600 | 608 |
| 601 BeginFrameSource* SingleThreadProxy::ExternalBeginFrameSource() { | |
| 602 return layer_tree_host_impl_.get(); | |
| 603 } | |
| 604 | |
| 605 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 609 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 606 layer_tree_host_impl_->WillBeginImplFrame(args); | 610 layer_tree_host_impl_->WillBeginImplFrame(args); |
| 607 } | 611 } |
| 608 | 612 |
| 609 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { | 613 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { |
| 610 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); | 614 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); |
| 611 // Although this proxy is single-threaded, it's problematic to synchronously | 615 // Although this proxy is single-threaded, it's problematic to synchronously |
| 612 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This | 616 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This |
| 613 // could cause a commit to occur in between a series of SetNeedsCommit calls | 617 // could cause a commit to occur in between a series of SetNeedsCommit calls |
| 614 // (i.e. property modifications) causing some to fall on one frame and some to | 618 // (i.e. property modifications) causing some to fall on one frame and some to |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 766 |
| 763 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 767 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
| 764 return timing_history_.CommitToActivateDurationEstimate(); | 768 return timing_history_.CommitToActivateDurationEstimate(); |
| 765 } | 769 } |
| 766 | 770 |
| 767 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 771 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
| 768 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 772 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
| 769 } | 773 } |
| 770 | 774 |
| 771 } // namespace cc | 775 } // namespace cc |
| OLD | NEW |