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

Side by Side Diff: cc/scheduler/scheduler.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8
8 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
9 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
10 #include "base/debug/trace_event_argument.h" 11 #include "base/debug/trace_event_argument.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "cc/debug/devtools_instrumentation.h" 14 #include "cc/debug/devtools_instrumentation.h"
14 #include "cc/debug/traced_value.h" 15 #include "cc/debug/traced_value.h"
15 #include "cc/scheduler/delay_based_time_source.h" 16 #include "cc/scheduler/delay_based_time_source.h"
16 #include "ui/gfx/frame_time.h" 17 #include "ui/gfx/frame_time.h"
17 18
18 namespace cc { 19 namespace cc {
19 20
20 BeginFrameSource* SchedulerFrameSourcesConstructor::ConstructPrimaryFrameSource( 21 BeginFrameSource* SchedulerFrameSourcesConstructor::ConstructPrimaryFrameSource(
21 Scheduler* scheduler) { 22 Scheduler* scheduler) {
22 if (!scheduler->settings_.throttle_frame_production) { 23 if (!scheduler->settings_.throttle_frame_production) {
23 TRACE_EVENT1("cc", 24 TRACE_EVENT1("cc",
24 "Scheduler::Scheduler()", 25 "Scheduler::Scheduler()",
25 "PrimaryFrameSource", 26 "PrimaryFrameSource",
26 "BackToBackBeginFrameSource"); 27 "BackToBackBeginFrameSource");
27 DCHECK(!scheduler->primary_frame_source_internal_); 28 DCHECK(!scheduler->primary_frame_source_internal_);
28 scheduler->primary_frame_source_internal_ = 29 scheduler->primary_frame_source_internal_ =
29 BackToBackBeginFrameSource::Create(scheduler->task_runner_.get()); 30 BackToBackBeginFrameSource::Create(scheduler->task_runner_.get());
30 return scheduler->primary_frame_source_internal_.get(); 31 return scheduler->primary_frame_source_internal_.get();
31 } else if (scheduler->settings_.begin_frame_scheduling_enabled) { 32 } else if (scheduler->settings_.begin_frame_scheduling_enabled) {
32 TRACE_EVENT1("cc", 33 TRACE_EVENT1("cc",
33 "Scheduler::Scheduler()", 34 "Scheduler::Scheduler()",
34 "PrimaryFrameSource", 35 "PrimaryFrameSource",
35 "SchedulerClient"); 36 "ExternalBeginFrameSource");
36 return scheduler->client_->ExternalBeginFrameSource(); 37 DCHECK(scheduler->primary_frame_source_internal_)
38 << "Need external BeginFrameSource";
39 return scheduler->primary_frame_source_internal_.get();
37 } else { 40 } else {
38 TRACE_EVENT1("cc", 41 TRACE_EVENT1("cc",
39 "Scheduler::Scheduler()", 42 "Scheduler::Scheduler()",
40 "PrimaryFrameSource", 43 "PrimaryFrameSource",
41 "SyntheticBeginFrameSource"); 44 "SyntheticBeginFrameSource");
42 scoped_ptr<SyntheticBeginFrameSource> synthetic_source = 45 scoped_ptr<SyntheticBeginFrameSource> synthetic_source =
43 SyntheticBeginFrameSource::Create(scheduler->task_runner_.get(), 46 SyntheticBeginFrameSource::Create(scheduler->task_runner_.get(),
44 scheduler->Now(), 47 scheduler->Now(),
45 BeginFrameArgs::DefaultInterval()); 48 BeginFrameArgs::DefaultInterval());
46 49
(...skipping 20 matching lines...) Expand all
67 scheduler->settings_.background_frame_interval); 70 scheduler->settings_.background_frame_interval);
68 return scheduler->background_frame_source_internal_.get(); 71 return scheduler->background_frame_source_internal_.get();
69 } 72 }
70 73
71 Scheduler::Scheduler( 74 Scheduler::Scheduler(
72 SchedulerClient* client, 75 SchedulerClient* client,
73 const SchedulerSettings& scheduler_settings, 76 const SchedulerSettings& scheduler_settings,
74 int layer_tree_host_id, 77 int layer_tree_host_id,
75 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 78 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
76 base::PowerMonitor* power_monitor, 79 base::PowerMonitor* power_monitor,
80 scoped_ptr<BeginFrameSource> external_begin_frame_source,
77 SchedulerFrameSourcesConstructor* frame_sources_constructor) 81 SchedulerFrameSourcesConstructor* frame_sources_constructor)
78 : frame_source_(), 82 : frame_source_(),
79 primary_frame_source_(NULL), 83 primary_frame_source_(NULL),
80 background_frame_source_(NULL), 84 background_frame_source_(NULL),
81 primary_frame_source_internal_(), 85 primary_frame_source_internal_(external_begin_frame_source.Pass()),
82 background_frame_source_internal_(), 86 background_frame_source_internal_(),
83 vsync_observer_(NULL), 87 vsync_observer_(NULL),
84 settings_(scheduler_settings), 88 settings_(scheduler_settings),
85 client_(client), 89 client_(client),
86 layer_tree_host_id_(layer_tree_host_id), 90 layer_tree_host_id_(layer_tree_host_id),
87 task_runner_(task_runner), 91 task_runner_(task_runner),
88 power_monitor_(power_monitor), 92 power_monitor_(power_monitor),
89 begin_retro_frame_posted_(false), 93 begin_retro_frame_posted_(false),
90 state_machine_(scheduler_settings), 94 state_machine_(scheduler_settings),
91 inside_process_scheduled_actions_(false), 95 inside_process_scheduled_actions_(false),
(...skipping 15 matching lines...) Expand all
107 advance_commit_state_closure_ = base::Bind( 111 advance_commit_state_closure_ = base::Bind(
108 &Scheduler::PollToAdvanceCommitState, weak_factory_.GetWeakPtr()); 112 &Scheduler::PollToAdvanceCommitState, weak_factory_.GetWeakPtr());
109 113
110 frame_source_ = BeginFrameSourceMultiplexer::Create(); 114 frame_source_ = BeginFrameSourceMultiplexer::Create();
111 frame_source_->AddObserver(this); 115 frame_source_->AddObserver(this);
112 116
113 // Primary frame source 117 // Primary frame source
114 primary_frame_source_ = 118 primary_frame_source_ =
115 frame_sources_constructor->ConstructPrimaryFrameSource(this); 119 frame_sources_constructor->ConstructPrimaryFrameSource(this);
116 frame_source_->AddSource(primary_frame_source_); 120 frame_source_->AddSource(primary_frame_source_);
121 primary_frame_source_->SetClientReady();
117 122
118 // Background ticking frame source 123 // Background ticking frame source
119 background_frame_source_ = 124 background_frame_source_ =
120 frame_sources_constructor->ConstructBackgroundFrameSource(this); 125 frame_sources_constructor->ConstructBackgroundFrameSource(this);
121 frame_source_->AddSource(background_frame_source_); 126 frame_source_->AddSource(background_frame_source_);
122 127
123 SetupPowerMonitoring(); 128 SetupPowerMonitoring();
124 } 129 }
125 130
126 Scheduler::~Scheduler() { 131 Scheduler::~Scheduler() {
127 TeardownPowerMonitoring(); 132 TeardownPowerMonitoring();
133 if (frame_source_->NeedsBeginFrames())
134 frame_source_->SetNeedsBeginFrames(false);
128 } 135 }
129 136
130 base::TimeTicks Scheduler::Now() const { 137 base::TimeTicks Scheduler::Now() const {
131 base::TimeTicks now = gfx::FrameTime::Now(); 138 base::TimeTicks now = gfx::FrameTime::Now();
132 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), 139 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"),
133 "Scheduler::Now", 140 "Scheduler::Now",
134 "now", 141 "now",
135 now); 142 now);
136 return now; 143 return now;
137 } 144 }
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 } 779 }
773 780
774 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 781 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
775 return (state_machine_.commit_state() == 782 return (state_machine_.commit_state() ==
776 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 783 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
777 state_machine_.commit_state() == 784 state_machine_.commit_state() ==
778 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 785 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
779 } 786 }
780 787
781 } // namespace cc 788 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698