Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: cc/trees/single_thread_proxy.cc

Issue 845393002: cc: Create ProxyBeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/trace_event/trace_event.h" 8 #include "base/trace_event/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/scheduler/commit_earlyout_reason.h" 15 #include "cc/scheduler/commit_earlyout_reason.h"
16 #include "cc/trees/layer_tree_host.h" 16 #include "cc/trees/layer_tree_host.h"
17 #include "cc/trees/layer_tree_host_single_thread_client.h" 17 #include "cc/trees/layer_tree_host_single_thread_client.h"
18 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
19 #include "cc/trees/scoped_abort_remaining_swap_promises.h" 19 #include "cc/trees/scoped_abort_remaining_swap_promises.h"
20 #include "ui/gfx/frame_time.h" 20 #include "ui/gfx/frame_time.h"
21 21
22 namespace cc { 22 namespace cc {
23 23
24 scoped_ptr<Proxy> SingleThreadProxy::Create( 24 scoped_ptr<Proxy> SingleThreadProxy::Create(
25 LayerTreeHost* layer_tree_host, 25 LayerTreeHost* layer_tree_host,
26 LayerTreeHostSingleThreadClient* client, 26 LayerTreeHostSingleThreadClient* client,
27 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 27 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
28 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 28 scoped_ptr<BeginFrameSource> external_begin_frame_source,
29 ProxyBeginFrameSource* proxy_begin_frame_source) {
29 return make_scoped_ptr(new SingleThreadProxy( 30 return make_scoped_ptr(new SingleThreadProxy(
30 layer_tree_host, 31 layer_tree_host,
31 client, 32 client,
32 main_task_runner, 33 main_task_runner,
33 external_begin_frame_source.Pass())); 34 external_begin_frame_source.Pass(),
35 proxy_begin_frame_source));
34 } 36 }
35 37
36 SingleThreadProxy::SingleThreadProxy( 38 SingleThreadProxy::SingleThreadProxy(
37 LayerTreeHost* layer_tree_host, 39 LayerTreeHost* layer_tree_host,
38 LayerTreeHostSingleThreadClient* client, 40 LayerTreeHostSingleThreadClient* client,
39 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
40 scoped_ptr<BeginFrameSource> external_begin_frame_source) 42 scoped_ptr<BeginFrameSource> external_begin_frame_source,
43 ProxyBeginFrameSource* proxy_begin_frame_source)
41 : Proxy(main_task_runner, NULL), 44 : Proxy(main_task_runner, NULL),
42 layer_tree_host_(layer_tree_host), 45 layer_tree_host_(layer_tree_host),
43 client_(client), 46 client_(client),
44 timing_history_(layer_tree_host->rendering_stats_instrumentation()), 47 timing_history_(layer_tree_host->rendering_stats_instrumentation()),
45 next_frame_is_newly_committed_frame_(false), 48 next_frame_is_newly_committed_frame_(false),
46 inside_draw_(false), 49 inside_draw_(false),
47 defer_commits_(false), 50 defer_commits_(false),
48 commit_was_deferred_(false), 51 commit_was_deferred_(false),
49 commit_requested_(false), 52 commit_requested_(false),
50 inside_synchronous_composite_(false), 53 inside_synchronous_composite_(false),
51 output_surface_creation_requested_(false), 54 output_surface_creation_requested_(false),
52 external_begin_frame_source_(external_begin_frame_source.Pass()), 55 external_begin_frame_source_(external_begin_frame_source.Pass()),
56 proxy_begin_frame_source_(proxy_begin_frame_source),
53 weak_factory_(this) { 57 weak_factory_(this) {
54 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 58 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
55 DCHECK(Proxy::IsMainThread()); 59 DCHECK(Proxy::IsMainThread());
56 DCHECK(layer_tree_host); 60 DCHECK(layer_tree_host);
57 } 61 }
58 62
59 void SingleThreadProxy::Start() { 63 void SingleThreadProxy::Start() {
60 DebugScopedSetImplThread impl(this); 64 DebugScopedSetImplThread impl(this);
61 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 65 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
62 } 66 }
(...skipping 28 matching lines...) Expand all
91 if (layer_tree_host_->settings().single_thread_proxy_scheduler && 95 if (layer_tree_host_->settings().single_thread_proxy_scheduler &&
92 !scheduler_on_impl_thread_) { 96 !scheduler_on_impl_thread_) {
93 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); 97 SchedulerSettings scheduler_settings(layer_tree_host_->settings());
94 scheduler_settings.main_thread_should_always_be_low_latency = true; 98 scheduler_settings.main_thread_should_always_be_low_latency = true;
95 scheduler_on_impl_thread_ = 99 scheduler_on_impl_thread_ =
96 Scheduler::Create(this, 100 Scheduler::Create(this,
97 scheduler_settings, 101 scheduler_settings,
98 layer_tree_host_->id(), 102 layer_tree_host_->id(),
99 MainThreadTaskRunner(), 103 MainThreadTaskRunner(),
100 base::PowerMonitor::Get(), 104 base::PowerMonitor::Get(),
101 external_begin_frame_source_.Pass()); 105 external_begin_frame_source_.Pass(),
106 proxy_begin_frame_source_);
102 scheduler_on_impl_thread_->SetCanStart(); 107 scheduler_on_impl_thread_->SetCanStart();
103 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 108 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
104 } 109 }
105 } 110 }
106 111
107 void SingleThreadProxy::SetVisible(bool visible) { 112 void SingleThreadProxy::SetVisible(bool visible) {
108 TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); 113 TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible);
109 DebugScopedSetImplThread impl(this); 114 DebugScopedSetImplThread impl(this);
110 layer_tree_host_impl_->SetVisible(visible); 115 layer_tree_host_impl_->SetVisible(visible);
111 if (scheduler_on_impl_thread_) 116 if (scheduler_on_impl_thread_)
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 DebugScopedSetMainThread main(this); 647 DebugScopedSetMainThread main(this);
643 next_frame_is_newly_committed_frame_ = false; 648 next_frame_is_newly_committed_frame_ = false;
644 layer_tree_host_->DidCommitAndDrawFrame(); 649 layer_tree_host_->DidCommitAndDrawFrame();
645 } 650 }
646 } 651 }
647 652
648 bool SingleThreadProxy::MainFrameWillHappenForTesting() { 653 bool SingleThreadProxy::MainFrameWillHappenForTesting() {
649 return false; 654 return false;
650 } 655 }
651 656
652 void SingleThreadProxy::SetChildrenNeedBeginFrames(
653 bool children_need_begin_frames) {
654 scheduler_on_impl_thread_->SetChildrenNeedBeginFrames(
655 children_need_begin_frames);
656 }
657
658 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 657 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
659 layer_tree_host_impl_->WillBeginImplFrame(args); 658 layer_tree_host_impl_->WillBeginImplFrame(args);
660 } 659 }
661 660
662 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { 661 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() {
663 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); 662 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
664 // Although this proxy is single-threaded, it's problematic to synchronously 663 // Although this proxy is single-threaded, it's problematic to synchronously
665 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This 664 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This
666 // could cause a commit to occur in between a series of SetNeedsCommit calls 665 // could cause a commit to occur in between a series of SetNeedsCommit calls
667 // (i.e. property modifications) causing some to fall on one frame and some to 666 // (i.e. property modifications) causing some to fall on one frame and some to
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 } 808 }
810 809
811 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { 810 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
812 return timing_history_.CommitToActivateDurationEstimate(); 811 return timing_history_.CommitToActivateDurationEstimate();
813 } 812 }
814 813
815 void SingleThreadProxy::DidBeginImplFrameDeadline() { 814 void SingleThreadProxy::DidBeginImplFrameDeadline() {
816 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); 815 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
817 } 816 }
818 817
819 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) {
820 layer_tree_host_->SendBeginFramesToChildren(args);
821 }
822
823 } // namespace cc 818 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698