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

Unified Diff: cc/scheduler/begin_frame_source.cc

Issue 1765723002: Hoist begin frame sources out of scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler_remove_throttle_flag
Patch Set: Rebase Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/begin_frame_source.h ('k') | cc/scheduler/begin_frame_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/begin_frame_source.cc
diff --git a/cc/scheduler/begin_frame_source.cc b/cc/scheduler/begin_frame_source.cc
index 54470862b43f63d05d98e4cc0972ee9feb011522..99bc9c6aa06c51915efb02f8aeaf3af2a5361c1f 100644
--- a/cc/scheduler/begin_frame_source.cc
+++ b/cc/scheduler/begin_frame_source.cc
@@ -270,195 +270,4 @@ void SyntheticBeginFrameSource::AsValueInto(
dict->EndDictionary();
}
-// BeginFrameSourceMultiplexer -------------------------------------------
-scoped_ptr<BeginFrameSourceMultiplexer> BeginFrameSourceMultiplexer::Create() {
- return make_scoped_ptr(new BeginFrameSourceMultiplexer());
-}
-
-BeginFrameSourceMultiplexer::BeginFrameSourceMultiplexer()
- : BeginFrameSourceBase(),
- active_source_(nullptr),
- inside_add_observer_(false) {}
-
-BeginFrameSourceMultiplexer::BeginFrameSourceMultiplexer(
- base::TimeDelta minimum_interval)
- : BeginFrameSourceBase(),
- active_source_(nullptr),
- inside_add_observer_(false) {}
-
-BeginFrameSourceMultiplexer::~BeginFrameSourceMultiplexer() {
- if (active_source_ && needs_begin_frames())
- active_source_->RemoveObserver(this);
-}
-
-void BeginFrameSourceMultiplexer::SetMinimumInterval(
- base::TimeDelta new_minimum_interval) {
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::SetMinimumInterval",
- "current minimum (us)",
- minimum_interval_.InMicroseconds(),
- "new minimum (us)",
- new_minimum_interval.InMicroseconds());
- DCHECK_GE(new_minimum_interval.ToInternalValue(), 0);
- minimum_interval_ = new_minimum_interval;
-}
-
-void BeginFrameSourceMultiplexer::AddSource(BeginFrameSource* new_source) {
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::AddSource", "current active",
- active_source_, "source to be added", new_source);
- DCHECK(new_source);
- DCHECK(!HasSource(new_source));
-
- source_list_.insert(new_source);
-
- // If there is no active source, set the new one as the active one.
- if (!active_source_)
- SetActiveSource(new_source);
-}
-
-void BeginFrameSourceMultiplexer::RemoveSource(
- BeginFrameSource* existing_source) {
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::RemoveSource", "current active",
- active_source_, "source to be removed", existing_source);
- DCHECK(existing_source);
- DCHECK(HasSource(existing_source));
- DCHECK_NE(existing_source, active_source_);
- source_list_.erase(existing_source);
-}
-
-void BeginFrameSourceMultiplexer::SetActiveSource(
- BeginFrameSource* new_source) {
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::SetActiveSource",
- "current active",
- active_source_,
- "to become active",
- new_source);
-
- DCHECK(HasSource(new_source) || new_source == nullptr);
-
- if (active_source_ == new_source)
- return;
-
- if (active_source_ && needs_begin_frames())
- active_source_->RemoveObserver(this);
-
- active_source_ = new_source;
-
- if (active_source_ && needs_begin_frames())
- active_source_->AddObserver(this);
-}
-
-const BeginFrameSource* BeginFrameSourceMultiplexer::ActiveSource() {
- return active_source_;
-}
-
-// BeginFrameObserver support
-void BeginFrameSourceMultiplexer::OnBeginFrame(const BeginFrameArgs& args) {
- if (!IsIncreasing(args)) {
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::OnBeginFrame",
- "action",
- "discarding",
- "new args",
- args.AsValue());
- return;
- }
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::OnBeginFrame",
- "action",
- "using",
- "new args",
- args.AsValue());
- last_begin_frame_args_ = args;
- CallOnBeginFrame(args);
-}
-
-const BeginFrameArgs& BeginFrameSourceMultiplexer::LastUsedBeginFrameArgs()
- const {
- return last_begin_frame_args_;
-}
-
-void BeginFrameSourceMultiplexer::OnBeginFrameSourcePausedChanged(bool paused) {
- if (paused_ == paused)
- return;
- paused_ = paused;
- if (!inside_add_observer_) {
- std::set<BeginFrameObserver*> observers(observers_);
- for (auto& it : observers)
- it->OnBeginFrameSourcePausedChanged(paused);
- }
-}
-
-// BeginFrameSource support
-void BeginFrameSourceMultiplexer::DidFinishFrame(size_t remaining_frames) {
- DEBUG_FRAMES("BeginFrameSourceMultiplexer::DidFinishFrame",
- "active_source",
- active_source_,
- "remaining_frames",
- remaining_frames);
- if (active_source_)
- active_source_->DidFinishFrame(remaining_frames);
-}
-
-void BeginFrameSourceMultiplexer::AddObserver(BeginFrameObserver* obs) {
- base::AutoReset<bool> reset(&inside_add_observer_, true);
- BeginFrameSourceBase::AddObserver(obs);
-}
-
-void BeginFrameSourceMultiplexer::OnNeedsBeginFramesChanged(
- bool needs_begin_frames) {
- if (!active_source_)
- return;
- if (needs_begin_frames) {
- active_source_->AddObserver(this);
- } else {
- active_source_->RemoveObserver(this);
- }
-}
-
-// Tracing support
-void BeginFrameSourceMultiplexer::AsValueInto(
- base::trace_event::TracedValue* dict) const {
- dict->SetString("type", "BeginFrameSourceMultiplexer");
-
- dict->SetInteger("minimum_interval_us", minimum_interval_.InMicroseconds());
-
- dict->BeginDictionary("last_begin_frame_args");
- last_begin_frame_args_.AsValueInto(dict);
- dict->EndDictionary();
-
- if (active_source_) {
- dict->BeginDictionary("active_source");
- active_source_->AsValueInto(dict);
- dict->EndDictionary();
- } else {
- dict->SetString("active_source", "NULL");
- }
-
- dict->BeginArray("sources");
- for (std::set<BeginFrameSource*>::const_iterator it = source_list_.begin();
- it != source_list_.end();
- ++it) {
- dict->BeginDictionary();
- (*it)->AsValueInto(dict);
- dict->EndDictionary();
- }
- dict->EndArray();
-}
-
-// protected methods
-bool BeginFrameSourceMultiplexer::HasSource(BeginFrameSource* source) {
- return (source_list_.find(source) != source_list_.end());
-}
-
-bool BeginFrameSourceMultiplexer::IsIncreasing(const BeginFrameArgs& args) {
- DCHECK(args.IsValid());
-
- // If the last begin frame is invalid, then any new begin frame is valid.
- if (!last_begin_frame_args_.IsValid())
- return true;
-
- // Only allow new args have a *strictly bigger* frame_time value and statisfy
- // minimum interval requirement.
- return (args.frame_time >=
- last_begin_frame_args_.frame_time + minimum_interval_);
-}
-
} // namespace cc
« no previous file with comments | « cc/scheduler/begin_frame_source.h ('k') | cc/scheduler/begin_frame_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698