We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / android_webview / browser / gl_view_renderer_manager.cc
blob204239c8af4bd796303bc896afea33c4305d48df
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 {
12 using base::AutoLock;
14 namespace {
15 base::LazyInstance<GLViewRendererManager>::Leaky g_view_renderer_manager =
16 LAZY_INSTANCE_INITIALIZER;
17 } // namespace
19 // static
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();
39 back--;
40 return back;
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);
52 mru_list_.erase(key);
55 GLViewRendererManager::RendererType
56 GLViewRendererManager::GetMostRecentlyDrawn() const {
57 AutoLock auto_lock(lock_);
58 if (mru_list_.begin() == mru_list_.end())
59 return NULL;
60 return *mru_list_.begin();
63 } // namespace android_webview