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. 4 5 #include "android_webview/browser/gl_view_renderer_manager.h" 6 7 #include "base/logging.h" 8 9 namespace android_webview { 10 11 GLViewRendererManager::GLViewRendererManager() {} 12 13 GLViewRendererManager::~GLViewRendererManager() {} 14 15 GLViewRendererManager::Key GLViewRendererManager::DidDrawGL( 16 Key key, 17 BrowserViewRenderer* view) { 18 if (key == mru_list_.end()) { 19 DCHECK(mru_list_.end() == 20 std::find(mru_list_.begin(), mru_list_.end(), view)); 21 mru_list_.push_front(view); 22 return mru_list_.begin(); 23 } else { 24 DCHECK(*key == view); 25 mru_list_.splice(mru_list_.begin(), mru_list_, key); 26 return key; 27 } 28 } 29 30 void GLViewRendererManager::NoLongerExpectsDrawGL(Key key) { 31 DCHECK(mru_list_.end() != key); 32 mru_list_.erase(key); 33 } 34 35 BrowserViewRenderer* GLViewRendererManager::GetMostRecentlyDrawn() const { 36 if (mru_list_.begin() == mru_list_.end()) 37 return NULL; 38 return *mru_list_.begin(); 39 } 40 41 GLViewRendererManager::Key GLViewRendererManager::NullKey() { 42 return mru_list_.end(); 43 } 44 45 } // namespace android_webview 46