OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SHARED_RENDERER_STATE_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
7 | 7 |
8 #include <queue> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
13 #include "content/public/browser/android/synchronous_compositor.h" | 10 #include "content/public/browser/android/synchronous_compositor.h" |
14 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/gfx/geometry/vector2d.h" | 12 #include "ui/gfx/geometry/vector2d.h" |
16 | 13 |
17 namespace android_webview { | 14 namespace android_webview { |
18 | 15 |
19 class BrowserViewRendererClient; | 16 class BrowserViewRendererClient; |
20 | 17 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 content::SynchronousCompositor* GetCompositor(); | 54 content::SynchronousCompositor* GetCompositor(); |
58 | 55 |
59 void SetMemoryPolicy(const content::SynchronousCompositorMemoryPolicy policy); | 56 void SetMemoryPolicy(const content::SynchronousCompositorMemoryPolicy policy); |
60 content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() const; | 57 content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() const; |
61 | 58 |
62 void SetMemoryPolicyDirty(bool is_dirty); | 59 void SetMemoryPolicyDirty(bool is_dirty); |
63 bool IsMemoryPolicyDirty() const; | 60 bool IsMemoryPolicyDirty() const; |
64 void SetDrawGLInput(const DrawGLInput& input); | 61 void SetDrawGLInput(const DrawGLInput& input); |
65 DrawGLInput GetDrawGLInput() const; | 62 DrawGLInput GetDrawGLInput() const; |
66 | 63 |
67 void ClearClosureQueue(); | 64 // Set by UI and read by RT. |
68 void AppendClosure(const base::Closure& closure); | 65 void SetHardwareAllowed(bool allowed); |
69 // Will return empty closure if queue empty. | 66 bool IsHardwareAllowed() const; |
70 base::Closure PopFrontClosure(); | |
71 | 67 |
| 68 // Set by RT and read by UI. |
72 void SetHardwareInitialized(bool initialized); | 69 void SetHardwareInitialized(bool initialized); |
73 bool IsHardwareInitialized() const; | 70 bool IsHardwareInitialized() const; |
74 | 71 |
75 private: | 72 private: |
76 void ClientRequestDrawGLOnUIThread(); | 73 void ClientRequestDrawGLOnUIThread(); |
77 | 74 |
78 scoped_refptr<base::MessageLoopProxy> ui_loop_; | 75 scoped_refptr<base::MessageLoopProxy> ui_loop_; |
79 // TODO(boliu): Remove |client_on_ui_| from shared state. | 76 // TODO(boliu): Remove |client_on_ui_| from shared state. |
80 BrowserViewRendererClient* client_on_ui_; | 77 BrowserViewRendererClient* client_on_ui_; |
81 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; | 78 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; |
82 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; | 79 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; |
83 | 80 |
84 // Accessed by both UI and RT thread. | 81 // Accessed by both UI and RT thread. |
85 mutable base::Lock lock_; | 82 mutable base::Lock lock_; |
86 content::SynchronousCompositor* compositor_; | 83 content::SynchronousCompositor* compositor_; |
87 content::SynchronousCompositorMemoryPolicy memory_policy_; | 84 content::SynchronousCompositorMemoryPolicy memory_policy_; |
88 // Set to true when SetMemoryPolicy called with a different memory policy. | 85 // Set to true when SetMemoryPolicy called with a different memory policy. |
89 // Set to false when memory policy is read and enforced to compositor. | 86 // Set to false when memory policy is read and enforced to compositor. |
90 bool memory_policy_dirty_; | 87 bool memory_policy_dirty_; |
91 DrawGLInput draw_gl_input_; | 88 DrawGLInput draw_gl_input_; |
92 std::queue<base::Closure> closure_queue_; | 89 bool hardware_allowed_; |
93 bool hardware_initialized_; | 90 bool hardware_initialized_; |
94 }; | 91 }; |
95 | 92 |
96 } // namespace android_webview | 93 } // namespace android_webview |
97 | 94 |
98 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 95 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
OLD | NEW |