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

Unified Diff: cc/surfaces/primary_begin_frame_source.cc

Issue 2880023002: cc::SurfaceDependencyTracker should not crash when a Display goes away (Closed)
Patch Set: Fix LayerTreeHostImpl unit tests Created 3 years, 7 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/surfaces/primary_begin_frame_source.h ('k') | cc/surfaces/surface.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/primary_begin_frame_source.cc
diff --git a/cc/surfaces/primary_begin_frame_source.cc b/cc/surfaces/primary_begin_frame_source.cc
new file mode 100644
index 0000000000000000000000000000000000000000..588dbfae67e07ba6d65c40d3376d75e14e2d37ac
--- /dev/null
+++ b/cc/surfaces/primary_begin_frame_source.cc
@@ -0,0 +1,87 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/surfaces/primary_begin_frame_source.h"
+
+namespace cc {
+
+PrimaryBeginFrameSource::PrimaryBeginFrameSource()
+ : begin_frame_source_(this) {}
+
+PrimaryBeginFrameSource::~PrimaryBeginFrameSource() = default;
+
+void PrimaryBeginFrameSource::OnBeginFrameSourceAdded(
+ BeginFrameSource* begin_frame_source) {
+ sources_.insert(begin_frame_source);
+
+ if (current_begin_frame_source_)
+ return;
+
+ current_begin_frame_source_ = begin_frame_source;
+ if (needs_begin_frames_ && current_begin_frame_source_)
+ current_begin_frame_source_->AddObserver(this);
+}
+
+void PrimaryBeginFrameSource::OnBeginFrameSourceRemoved(
+ BeginFrameSource* begin_frame_source) {
+ sources_.erase(begin_frame_source);
+ if (current_begin_frame_source_ != begin_frame_source)
+ return;
+
+ if (needs_begin_frames_)
+ current_begin_frame_source_->RemoveObserver(this);
+
+ if (!sources_.empty())
+ current_begin_frame_source_ = *sources_.begin();
+ else
+ current_begin_frame_source_ = nullptr;
+
+ if (needs_begin_frames_ && current_begin_frame_source_)
+ current_begin_frame_source_->AddObserver(this);
+}
+
+void PrimaryBeginFrameSource::OnBeginFrame(const BeginFrameArgs& args) {
+ begin_frame_source_.OnBeginFrame(args);
+ last_begin_frame_args_ = args;
+}
+
+const BeginFrameArgs& PrimaryBeginFrameSource::LastUsedBeginFrameArgs() const {
+ return last_begin_frame_args_;
+}
+
+void PrimaryBeginFrameSource::OnBeginFrameSourcePausedChanged(bool paused) {}
+
+void PrimaryBeginFrameSource::DidFinishFrame(BeginFrameObserver* obs,
+ const BeginFrameAck& ack) {
+ begin_frame_source_.DidFinishFrame(obs, ack);
+}
+
+void PrimaryBeginFrameSource::AddObserver(BeginFrameObserver* obs) {
+ begin_frame_source_.AddObserver(obs);
+}
+
+void PrimaryBeginFrameSource::RemoveObserver(BeginFrameObserver* obs) {
+ begin_frame_source_.RemoveObserver(obs);
+}
+
+bool PrimaryBeginFrameSource::IsThrottled() const {
+ return begin_frame_source_.IsThrottled();
+}
+
+void PrimaryBeginFrameSource::OnNeedsBeginFrames(bool needs_begin_frames) {
+ if (needs_begin_frames_ == needs_begin_frames)
+ return;
+
+ needs_begin_frames_ = needs_begin_frames;
+
+ if (!current_begin_frame_source_)
+ return;
+
+ if (needs_begin_frames_)
+ current_begin_frame_source_->AddObserver(this);
+ else
+ current_begin_frame_source_->RemoveObserver(this);
+}
+
+} // namespace cc
« no previous file with comments | « cc/surfaces/primary_begin_frame_source.h ('k') | cc/surfaces/surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698