blob: 65ae48329323b638eac52fc7723e5beeced2c948 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright 2013 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 "content/browser/renderer_host/delegated_frame_evictor.h"
#include "base/logging.h"
namespace content {
DelegatedFrameEvictor::DelegatedFrameEvictor(
DelegatedFrameEvictorClient* client)
: client_(client), has_frame_(false), visible_(false) {
}
DelegatedFrameEvictor::~DelegatedFrameEvictor() { DiscardedFrame(); }
void DelegatedFrameEvictor::SwappedFrame(bool visible) {
visible_ = visible;
has_frame_ = true;
RendererFrameManager::GetInstance()->AddFrame(this, visible);
}
void DelegatedFrameEvictor::DiscardedFrame() {
RendererFrameManager::GetInstance()->RemoveFrame(this);
has_frame_ = false;
}
void DelegatedFrameEvictor::SetVisible(bool visible) {
if (visible_ == visible)
return;
visible_ = visible;
if (has_frame_) {
if (visible) {
LockFrame();
} else {
UnlockFrame();
}
}
}
void DelegatedFrameEvictor::LockFrame() {
DCHECK(has_frame_);
RendererFrameManager::GetInstance()->LockFrame(this);
}
void DelegatedFrameEvictor::UnlockFrame() {
DCHECK(has_frame_);
RendererFrameManager::GetInstance()->UnlockFrame(this);
}
void DelegatedFrameEvictor::EvictCurrentFrame() {
client_->EvictDelegatedFrame();
}
} // namespace content
|