OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/lazy_instance.h" |
11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
12 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
13 | 14 |
14 namespace android_webview { | 15 namespace android_webview { |
15 | 16 |
16 class BrowserViewRenderer; | 17 class HardwareRenderer; |
17 | 18 |
18 class GLViewRendererManager { | 19 class GLViewRendererManager { |
19 typedef std::list<BrowserViewRenderer*> ListType; | 20 typedef std::list<HardwareRenderer*> ListType; |
| 21 |
20 public: | 22 public: |
21 typedef ListType::iterator Key; | 23 typedef ListType::iterator Key; |
22 | 24 |
23 GLViewRendererManager(); | 25 static GLViewRendererManager* GetInstance(); |
24 ~GLViewRendererManager(); | |
25 | 26 |
26 bool OnRenderThread() const; | 27 bool OnRenderThread() const; |
27 | 28 |
28 // If |key| is NullKey(), then |view| is inserted at the front and a new key | 29 // If |key| is NullKey(), then |view| is inserted at the front and a new key |
29 // is returned. Otherwise |key| must point to |view| which is moved to the | 30 // is returned. Otherwise |key| must point to |view| which is moved to the |
30 // front. | 31 // front. |
31 Key DidDrawGL(Key key, BrowserViewRenderer* view); | 32 Key DidDrawGL(Key key, HardwareRenderer* view); |
32 | 33 |
33 void NoLongerExpectsDrawGL(Key key); | 34 void NoLongerExpectsDrawGL(Key key); |
34 | 35 |
35 BrowserViewRenderer* GetMostRecentlyDrawn() const; | 36 HardwareRenderer* GetMostRecentlyDrawn() const; |
36 | 37 |
37 Key NullKey(); | 38 Key NullKey(); |
38 | 39 |
39 private: | 40 private: |
| 41 friend struct base::DefaultLazyInstanceTraits<GLViewRendererManager>; |
| 42 |
| 43 GLViewRendererManager(); |
| 44 ~GLViewRendererManager(); |
| 45 |
40 void MarkRenderThread(); | 46 void MarkRenderThread(); |
41 | 47 |
42 mutable base::Lock lock_; | 48 mutable base::Lock lock_; |
43 base::PlatformThreadHandle render_thread_; | 49 base::PlatformThreadHandle render_thread_; |
44 ListType mru_list_; | 50 ListType mru_list_; |
45 | 51 |
46 DISALLOW_COPY_AND_ASSIGN(GLViewRendererManager); | 52 DISALLOW_COPY_AND_ASSIGN(GLViewRendererManager); |
47 }; | 53 }; |
48 | 54 |
49 } // namespace android_webview | 55 } // namespace android_webview |
50 | 56 |
51 #endif // ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ | 57 #endif // ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ |
OLD | NEW |