1 // Copyright 2013 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.
5 #include "android_webview/browser/gl_view_renderer_manager.h"
7 #include "base/logging.h"
8 #include "base/threading/platform_thread.h"
10 namespace android_webview
{
15 base::LazyInstance
<GLViewRendererManager
>::Leaky g_view_renderer_manager
=
16 LAZY_INSTANCE_INITIALIZER
;
20 GLViewRendererManager
* GLViewRendererManager::GetInstance() {
21 return g_view_renderer_manager
.Pointer();
24 GLViewRendererManager::GLViewRendererManager() {}
26 GLViewRendererManager::~GLViewRendererManager() {}
28 GLViewRendererManager::Key
GLViewRendererManager::NullKey() {
29 AutoLock
auto_lock(lock_
);
30 return mru_list_
.end();
33 GLViewRendererManager::Key
GLViewRendererManager::PushBack(RendererType view
) {
34 AutoLock
auto_lock(lock_
);
35 DCHECK(mru_list_
.end() ==
36 std::find(mru_list_
.begin(), mru_list_
.end(), view
));
37 mru_list_
.push_back(view
);
38 Key back
= mru_list_
.end();
43 void GLViewRendererManager::DidDrawGL(Key key
) {
44 AutoLock
auto_lock(lock_
);
45 DCHECK(mru_list_
.end() != key
);
46 mru_list_
.splice(mru_list_
.begin(), mru_list_
, key
);
49 void GLViewRendererManager::Remove(Key key
) {
50 AutoLock
auto_lock(lock_
);
51 DCHECK(mru_list_
.end() != key
);
55 GLViewRendererManager::RendererType
56 GLViewRendererManager::GetMostRecentlyDrawn() const {
57 AutoLock
auto_lock(lock_
);
58 if (mru_list_
.begin() == mru_list_
.end())
60 return *mru_list_
.begin();
63 } // namespace android_webview