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 "android_webview/browser/shared_renderer_state.h" |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
13 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "content/public/browser/android/synchronous_compositor.h" |
14 | 16 |
15 namespace android_webview { | 17 namespace android_webview { |
16 | 18 |
| 19 namespace { |
| 20 typedef content::SynchronousCompositorMemoryPolicy MemoryPolicy; |
| 21 } // namespace |
| 22 |
17 class SharedRendererState; | 23 class SharedRendererState; |
18 | 24 |
19 class GLViewRendererManager { | 25 class GLViewRendererManager { |
20 public: | 26 public: |
21 typedef SharedRendererState* RendererType; | 27 typedef SharedRendererState* RendererType; |
22 | 28 |
23 private: | 29 private: |
24 typedef std::list<RendererType> ListType; | 30 typedef std::list<RendererType> ListType; |
25 | 31 |
26 public: | 32 public: |
27 typedef ListType::iterator Key; | 33 typedef ListType::iterator Key; |
28 | 34 |
29 static GLViewRendererManager* GetInstance(); | 35 static GLViewRendererManager* GetInstance(); |
30 | 36 |
31 // TODO(boliu): Move RenderThread checking out of this class. | 37 // TODO(boliu): Move RenderThread checking out of this class. |
32 bool OnRenderThread() const; | 38 bool OnRenderThread() const; |
33 | 39 |
34 Key PushBack(RendererType view); | 40 Key PushBack(RendererType view); |
35 | 41 |
36 // |key| must be already in manager. Move renderer corresponding to |key| to | 42 // |key| must be already in manager. Move renderer corresponding to |key| to |
37 // most recent. | 43 // most recent. |
38 void DidDrawGL(Key key); | 44 void DidDrawGL(Key key); |
39 | 45 |
40 void Remove(Key key); | 46 void Remove(Key key); |
41 | 47 |
42 RendererType GetMostRecentlyDrawn() const; | 48 RendererType GetMostRecentlyDrawn() const; |
43 | 49 |
| 50 // See GpuMemoryManager::EvictUntilSatisfied. |
| 51 MemoryPolicy EvictUntilSatisfied(MemoryPolicy desired_policy, Key key); |
| 52 |
44 private: | 53 private: |
45 friend struct base::DefaultLazyInstanceTraits<GLViewRendererManager>; | 54 friend struct base::DefaultLazyInstanceTraits<GLViewRendererManager>; |
46 | 55 |
47 GLViewRendererManager(); | 56 GLViewRendererManager(); |
48 ~GLViewRendererManager(); | 57 ~GLViewRendererManager(); |
49 | 58 |
50 void MarkRenderThread(); | 59 void MarkRenderThread(); |
51 | 60 |
52 mutable base::Lock lock_; | 61 mutable base::Lock lock_; |
53 base::PlatformThreadHandle render_thread_; | 62 base::PlatformThreadHandle render_thread_; |
54 ListType mru_list_; | 63 ListType mru_list_; |
55 | 64 |
56 DISALLOW_COPY_AND_ASSIGN(GLViewRendererManager); | 65 DISALLOW_COPY_AND_ASSIGN(GLViewRendererManager); |
57 }; | 66 }; |
58 | 67 |
59 } // namespace android_webview | 68 } // namespace android_webview |
60 | 69 |
61 #endif // ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ | 70 #endif // ANDROID_WEBVIEW_BROWSER_GL_VIEW_RENDERER_MANAGER_H_ |
OLD | NEW |