| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/viz/frame_sinks/frame_evictor.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace viz { |
| 10 |
| 11 FrameEvictor::FrameEvictor(FrameEvictorClient* client) |
| 12 : client_(client), has_frame_(false), visible_(false) {} |
| 13 |
| 14 FrameEvictor::~FrameEvictor() { |
| 15 DiscardedFrame(); |
| 16 } |
| 17 |
| 18 void FrameEvictor::SwappedFrame(bool visible) { |
| 19 visible_ = visible; |
| 20 has_frame_ = true; |
| 21 FrameEvictionManager::GetInstance()->AddFrame(this, visible); |
| 22 } |
| 23 |
| 24 void FrameEvictor::DiscardedFrame() { |
| 25 FrameEvictionManager::GetInstance()->RemoveFrame(this); |
| 26 has_frame_ = false; |
| 27 } |
| 28 |
| 29 void FrameEvictor::SetVisible(bool visible) { |
| 30 if (visible_ == visible) |
| 31 return; |
| 32 visible_ = visible; |
| 33 if (has_frame_) { |
| 34 if (visible) { |
| 35 LockFrame(); |
| 36 } else { |
| 37 UnlockFrame(); |
| 38 } |
| 39 } |
| 40 } |
| 41 |
| 42 void FrameEvictor::LockFrame() { |
| 43 DCHECK(has_frame_); |
| 44 FrameEvictionManager::GetInstance()->LockFrame(this); |
| 45 } |
| 46 |
| 47 void FrameEvictor::UnlockFrame() { |
| 48 DCHECK(has_frame_); |
| 49 FrameEvictionManager::GetInstance()->UnlockFrame(this); |
| 50 } |
| 51 |
| 52 void FrameEvictor::EvictCurrentFrame() { |
| 53 client_->EvictDelegatedFrame(); |
| 54 } |
| 55 |
| 56 } // namespace viz |
| OLD | NEW |