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

Unified Diff: components/viz/frame_sinks/frame_evictor.cc

Issue 2811083002: Move frame eviction into components (Closed)
Patch Set: Rebase Created 3 years, 8 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 | « components/viz/frame_sinks/frame_evictor.h ('k') | components/viz/frame_sinks/mojo_frame_sink_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/viz/frame_sinks/frame_evictor.cc
diff --git a/components/viz/frame_sinks/frame_evictor.cc b/components/viz/frame_sinks/frame_evictor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0207423adce69af8d7497204c89b57789286b79c
--- /dev/null
+++ b/components/viz/frame_sinks/frame_evictor.cc
@@ -0,0 +1,56 @@
+// 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 "components/viz/frame_sinks/frame_evictor.h"
+
+#include "base/logging.h"
+
+namespace viz {
+
+FrameEvictor::FrameEvictor(FrameEvictorClient* client)
+ : client_(client), has_frame_(false), visible_(false) {}
+
+FrameEvictor::~FrameEvictor() {
+ DiscardedFrame();
+}
+
+void FrameEvictor::SwappedFrame(bool visible) {
+ visible_ = visible;
+ has_frame_ = true;
+ FrameEvictionManager::GetInstance()->AddFrame(this, visible);
+}
+
+void FrameEvictor::DiscardedFrame() {
+ FrameEvictionManager::GetInstance()->RemoveFrame(this);
+ has_frame_ = false;
+}
+
+void FrameEvictor::SetVisible(bool visible) {
+ if (visible_ == visible)
+ return;
+ visible_ = visible;
+ if (has_frame_) {
+ if (visible) {
+ LockFrame();
+ } else {
+ UnlockFrame();
+ }
+ }
+}
+
+void FrameEvictor::LockFrame() {
+ DCHECK(has_frame_);
+ FrameEvictionManager::GetInstance()->LockFrame(this);
+}
+
+void FrameEvictor::UnlockFrame() {
+ DCHECK(has_frame_);
+ FrameEvictionManager::GetInstance()->UnlockFrame(this);
+}
+
+void FrameEvictor::EvictCurrentFrame() {
+ client_->EvictDelegatedFrame();
+}
+
+} // namespace viz
« no previous file with comments | « components/viz/frame_sinks/frame_evictor.h ('k') | components/viz/frame_sinks/mojo_frame_sink_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698