OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/begin_frame_source.h" | 5 #include "cc/scheduler/begin_frame_source.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 for (const auto& it : observers_) { | 120 for (const auto& it : observers_) { |
121 dict->BeginDictionary(); | 121 dict->BeginDictionary(); |
122 it->AsValueInto(dict); | 122 it->AsValueInto(dict); |
123 dict->EndDictionary(); | 123 dict->EndDictionary(); |
124 } | 124 } |
125 dict->EndArray(); | 125 dict->EndArray(); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 // BackToBackBeginFrameSource -------------------------------------------- | 129 // BackToBackBeginFrameSource -------------------------------------------- |
130 scoped_ptr<BackToBackBeginFrameSource> BackToBackBeginFrameSource::Create( | |
131 base::SingleThreadTaskRunner* task_runner) { | |
132 return make_scoped_ptr(new BackToBackBeginFrameSource(task_runner)); | |
133 } | |
134 | |
135 BackToBackBeginFrameSource::BackToBackBeginFrameSource( | 130 BackToBackBeginFrameSource::BackToBackBeginFrameSource( |
136 base::SingleThreadTaskRunner* task_runner) | 131 base::SingleThreadTaskRunner* task_runner) |
137 : BeginFrameSourceBase(), | 132 : BeginFrameSourceBase(), task_runner_(task_runner), weak_factory_(this) { |
138 task_runner_(task_runner), | |
139 weak_factory_(this) { | |
140 DCHECK(task_runner); | 133 DCHECK(task_runner); |
141 } | 134 } |
142 | 135 |
143 BackToBackBeginFrameSource::~BackToBackBeginFrameSource() { | 136 BackToBackBeginFrameSource::~BackToBackBeginFrameSource() { |
144 } | 137 } |
145 | 138 |
146 base::TimeTicks BackToBackBeginFrameSource::Now() { | 139 base::TimeTicks BackToBackBeginFrameSource::Now() { |
147 return base::TimeTicks::Now(); | 140 return base::TimeTicks::Now(); |
148 } | 141 } |
149 | 142 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 181 } |
189 | 182 |
190 // Tracing support | 183 // Tracing support |
191 void BackToBackBeginFrameSource::AsValueInto( | 184 void BackToBackBeginFrameSource::AsValueInto( |
192 base::trace_event::TracedValue* dict) const { | 185 base::trace_event::TracedValue* dict) const { |
193 dict->SetString("type", "BackToBackBeginFrameSource"); | 186 dict->SetString("type", "BackToBackBeginFrameSource"); |
194 BeginFrameSourceBase::AsValueInto(dict); | 187 BeginFrameSourceBase::AsValueInto(dict); |
195 } | 188 } |
196 | 189 |
197 // SyntheticBeginFrameSource --------------------------------------------- | 190 // SyntheticBeginFrameSource --------------------------------------------- |
198 scoped_ptr<SyntheticBeginFrameSource> SyntheticBeginFrameSource::Create( | 191 SyntheticBeginFrameSource::SyntheticBeginFrameSource( |
199 base::SingleThreadTaskRunner* task_runner, | 192 base::SingleThreadTaskRunner* task_runner, |
200 base::TimeDelta initial_vsync_interval) { | 193 base::TimeDelta initial_vsync_interval) |
201 scoped_ptr<DelayBasedTimeSource> time_source = | 194 : time_source_( |
202 DelayBasedTimeSource::Create(initial_vsync_interval, task_runner); | 195 DelayBasedTimeSource::Create(initial_vsync_interval, task_runner)) { |
203 return make_scoped_ptr(new SyntheticBeginFrameSource(std::move(time_source))); | 196 time_source_->SetClient(this); |
204 } | 197 } |
205 | 198 |
206 SyntheticBeginFrameSource::SyntheticBeginFrameSource( | 199 SyntheticBeginFrameSource::SyntheticBeginFrameSource( |
207 scoped_ptr<DelayBasedTimeSource> time_source) | 200 scoped_ptr<DelayBasedTimeSource> time_source) |
208 : BeginFrameSourceBase(), time_source_(std::move(time_source)) { | 201 : time_source_(std::move(time_source)) { |
209 time_source_->SetClient(this); | 202 time_source_->SetClient(this); |
210 } | 203 } |
211 | 204 |
212 SyntheticBeginFrameSource::~SyntheticBeginFrameSource() {} | 205 SyntheticBeginFrameSource::~SyntheticBeginFrameSource() {} |
213 | 206 |
214 void SyntheticBeginFrameSource::OnUpdateVSyncParameters( | 207 void SyntheticBeginFrameSource::OnUpdateVSyncParameters( |
215 base::TimeTicks new_vsync_timebase, | 208 base::TimeTicks new_vsync_timebase, |
216 base::TimeDelta new_vsync_interval) { | 209 base::TimeDelta new_vsync_interval) { |
217 time_source_->SetTimebaseAndInterval(new_vsync_timebase, new_vsync_interval); | 210 time_source_->SetTimebaseAndInterval(new_vsync_timebase, new_vsync_interval); |
218 } | 211 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 base::trace_event::TracedValue* dict) const { | 257 base::trace_event::TracedValue* dict) const { |
265 dict->SetString("type", "SyntheticBeginFrameSource"); | 258 dict->SetString("type", "SyntheticBeginFrameSource"); |
266 BeginFrameSourceBase::AsValueInto(dict); | 259 BeginFrameSourceBase::AsValueInto(dict); |
267 | 260 |
268 dict->BeginDictionary("time_source"); | 261 dict->BeginDictionary("time_source"); |
269 time_source_->AsValueInto(dict); | 262 time_source_->AsValueInto(dict); |
270 dict->EndDictionary(); | 263 dict->EndDictionary(); |
271 } | 264 } |
272 | 265 |
273 } // namespace cc | 266 } // namespace cc |
OLD | NEW |