blob: 204239c8af4bd796303bc896afea33c4305d48df (
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
57
58
59
60
61
62
63
|
// 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 "android_webview/browser/gl_view_renderer_manager.h"
#include "base/logging.h"
#include "base/threading/platform_thread.h"
namespace android_webview {
using base::AutoLock;
namespace {
base::LazyInstance<GLViewRendererManager>::Leaky g_view_renderer_manager =
LAZY_INSTANCE_INITIALIZER;
} // namespace
// static
GLViewRendererManager* GLViewRendererManager::GetInstance() {
return g_view_renderer_manager.Pointer();
}
GLViewRendererManager::GLViewRendererManager() {}
GLViewRendererManager::~GLViewRendererManager() {}
GLViewRendererManager::Key GLViewRendererManager::NullKey() {
AutoLock auto_lock(lock_);
return mru_list_.end();
}
GLViewRendererManager::Key GLViewRendererManager::PushBack(RendererType view) {
AutoLock auto_lock(lock_);
DCHECK(mru_list_.end() ==
std::find(mru_list_.begin(), mru_list_.end(), view));
mru_list_.push_back(view);
Key back = mru_list_.end();
back--;
return back;
}
void GLViewRendererManager::DidDrawGL(Key key) {
AutoLock auto_lock(lock_);
DCHECK(mru_list_.end() != key);
mru_list_.splice(mru_list_.begin(), mru_list_, key);
}
void GLViewRendererManager::Remove(Key key) {
AutoLock auto_lock(lock_);
DCHECK(mru_list_.end() != key);
mru_list_.erase(key);
}
GLViewRendererManager::RendererType
GLViewRendererManager::GetMostRecentlyDrawn() const {
AutoLock auto_lock(lock_);
if (mru_list_.begin() == mru_list_.end())
return NULL;
return *mru_list_.begin();
}
} // namespace android_webview
|