Chromium Code Reviews| Index: components/display_compositor/frame_evictor.cc |
| diff --git a/components/display_compositor/frame_evictor.cc b/components/display_compositor/frame_evictor.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..752252e44571a8cd4dc480d614b26d5aef8b4ba7 |
| --- /dev/null |
| +++ b/components/display_compositor/frame_evictor.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
|
Fady Samuel
2017/04/12 03:17:02
nit: 2017
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/display_compositor/frame_evictor.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace display_compositor { |
| + |
| +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 display_compositor |