OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_BROWSER_VIEW_RENDERER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
7 | 7 |
8 #include "android_webview/browser/browser_view_renderer_proxy.h" | |
8 #include "android_webview/browser/global_tile_manager.h" | 9 #include "android_webview/browser/global_tile_manager.h" |
9 #include "android_webview/browser/global_tile_manager_client.h" | 10 #include "android_webview/browser/global_tile_manager_client.h" |
10 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 11 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
11 #include "android_webview/browser/shared_renderer_state.h" | |
12 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/cancelable_callback.h" | 14 #include "base/cancelable_callback.h" |
15 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
16 #include "base/single_thread_task_runner.h" | |
16 #include "content/public/browser/android/synchronous_compositor.h" | 17 #include "content/public/browser/android/synchronous_compositor.h" |
17 #include "content/public/browser/android/synchronous_compositor_client.h" | 18 #include "content/public/browser/android/synchronous_compositor_client.h" |
18 #include "skia/ext/refptr.h" | 19 #include "skia/ext/refptr.h" |
19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
20 #include "ui/gfx/vector2d_f.h" | 21 #include "ui/gfx/vector2d_f.h" |
21 | 22 |
22 class SkCanvas; | 23 class SkCanvas; |
23 class SkPicture; | 24 class SkPicture; |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 struct SynchronousCompositorMemoryPolicy; | 27 struct SynchronousCompositorMemoryPolicy; |
27 class WebContents; | 28 class WebContents; |
28 } | 29 } |
29 | 30 |
30 namespace android_webview { | 31 namespace android_webview { |
31 | 32 |
33 class AwGLMethods; | |
32 class BrowserViewRendererClient; | 34 class BrowserViewRendererClient; |
33 | 35 |
34 // Delegate to perform rendering actions involving Java objects. | 36 // Delegate to perform rendering actions involving Java objects. |
35 class BrowserViewRendererJavaHelper { | 37 class BrowserViewRendererJavaHelper { |
36 public: | 38 public: |
37 static BrowserViewRendererJavaHelper* GetInstance(); | 39 static BrowserViewRendererJavaHelper* GetInstance(); |
38 | 40 |
39 typedef base::Callback<bool(SkCanvas*)> RenderMethod; | 41 typedef base::Callback<bool(SkCanvas*)> RenderMethod; |
40 | 42 |
41 // Try obtaining the native SkCanvas from |java_canvas| and call | 43 // Try obtaining the native SkCanvas from |java_canvas| and call |
(...skipping 11 matching lines...) Expand all Loading... | |
53 }; | 55 }; |
54 | 56 |
55 // Interface for all the WebView-specific content rendering operations. | 57 // Interface for all the WebView-specific content rendering operations. |
56 // Provides software and hardware rendering and the Capture Picture API. | 58 // Provides software and hardware rendering and the Capture Picture API. |
57 class BrowserViewRenderer : public content::SynchronousCompositorClient, | 59 class BrowserViewRenderer : public content::SynchronousCompositorClient, |
58 public GlobalTileManagerClient { | 60 public GlobalTileManagerClient { |
59 public: | 61 public: |
60 static void CalculateTileMemoryPolicy(); | 62 static void CalculateTileMemoryPolicy(); |
61 | 63 |
62 BrowserViewRenderer( | 64 BrowserViewRenderer( |
65 AwGLMethods* gl_methods, | |
boliu
2014/10/23 16:40:05
Hmm...sucks that we need both AwGLMethods and Brow
hush (inactive)
2014/10/24 21:31:33
In the next pathc, BVR is owned by AwContents and
| |
63 BrowserViewRendererClient* client, | 66 BrowserViewRendererClient* client, |
64 SharedRendererState* shared_renderer_state, | 67 BrowserViewRendererProxy* proxy, |
65 content::WebContents* web_contents, | 68 content::WebContents* web_contents, |
66 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); | 69 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); |
67 | 70 |
68 virtual ~BrowserViewRenderer(); | 71 virtual ~BrowserViewRenderer(); |
69 | 72 |
70 // Main handler for view drawing: performs a SW draw immediately, or sets up | 73 // Main handler for view drawing: performs a SW draw immediately, or sets up |
71 // a subsequent GL Draw (via BrowserViewRendererClient::RequestDrawGL) and | 74 // a subsequent GL Draw (via BrowserViewRendererClient::RequestDrawGL) and |
72 // returns true. A false return value indicates nothing was or will be drawn. | 75 // returns true. A false return value indicates nothing was or will be drawn. |
73 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates | 76 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates |
74 // a GL Draw maybe possible on this canvas. |scroll| if the view's current | 77 // a GL Draw maybe possible on this canvas. |scroll| if the view's current |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 gfx::Vector2dF latest_overscroll_delta, | 136 gfx::Vector2dF latest_overscroll_delta, |
134 gfx::Vector2dF current_fling_velocity) override; | 137 gfx::Vector2dF current_fling_velocity) override; |
135 | 138 |
136 // GlobalTileManagerClient overrides. | 139 // GlobalTileManagerClient overrides. |
137 virtual content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() | 140 virtual content::SynchronousCompositorMemoryPolicy GetMemoryPolicy() |
138 const override; | 141 const override; |
139 virtual void SetMemoryPolicy( | 142 virtual void SetMemoryPolicy( |
140 content::SynchronousCompositorMemoryPolicy new_policy, | 143 content::SynchronousCompositorMemoryPolicy new_policy, |
141 bool effective_immediately) override; | 144 bool effective_immediately) override; |
142 | 145 |
143 void UpdateParentDrawConstraints(); | 146 void SetParentDrawConstraints(); |
147 | |
148 // Called if commit is skipped due to pipeline stall. | |
144 void DidSkipCommitFrame(); | 149 void DidSkipCommitFrame(); |
145 | 150 |
146 private: | 151 private: |
147 void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); | 152 void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); |
148 // Checks the continuous invalidate and block invalidate state, and schedule | 153 // Checks the continuous invalidate and block invalidate state, and schedule |
149 // invalidates appropriately. If |force_invalidate| is true, then send a view | 154 // invalidates appropriately. If |force_invalidate| is true, then send a view |
150 // invalidate regardless of compositor expectation. If |skip_reschedule_tick| | 155 // invalidate regardless of compositor expectation. If |skip_reschedule_tick| |
151 // is true and if there is already a pending fallback tick, don't reschedule | 156 // is true and if there is already a pending fallback tick, don't reschedule |
152 // them. | 157 // them. |
153 void EnsureContinuousInvalidation(bool force_invalidate, | 158 void EnsureContinuousInvalidation(bool force_invalidate, |
(...skipping 26 matching lines...) Expand all Loading... | |
180 void EnforceMemoryPolicyImmediately( | 185 void EnforceMemoryPolicyImmediately( |
181 content::SynchronousCompositorMemoryPolicy policy); | 186 content::SynchronousCompositorMemoryPolicy policy); |
182 | 187 |
183 gfx::Vector2d max_scroll_offset() const; | 188 gfx::Vector2d max_scroll_offset() const; |
184 | 189 |
185 content::SynchronousCompositorMemoryPolicy CalculateDesiredMemoryPolicy(); | 190 content::SynchronousCompositorMemoryPolicy CalculateDesiredMemoryPolicy(); |
186 // For debug tracing or logging. Return the string representation of this | 191 // For debug tracing or logging. Return the string representation of this |
187 // view renderer's state. | 192 // view renderer's state. |
188 std::string ToString() const; | 193 std::string ToString() const; |
189 | 194 |
195 AwGLMethods* gl_methods_; | |
190 BrowserViewRendererClient* client_; | 196 BrowserViewRendererClient* client_; |
191 SharedRendererState* shared_renderer_state_; | 197 BrowserViewRendererProxy* proxy_; |
boliu
2014/10/23 16:40:05
Should BVR create/own the proxy? (When all the fun
hush (inactive)
2014/10/24 21:31:33
In the next patch, BVR owns proxy (currently still
| |
192 content::WebContents* web_contents_; | 198 content::WebContents* web_contents_; |
193 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 199 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
194 | 200 |
195 content::SynchronousCompositor* compositor_; | 201 content::SynchronousCompositor* compositor_; |
196 | 202 |
197 bool is_paused_; | 203 bool is_paused_; |
198 bool view_visible_; | 204 bool view_visible_; |
199 bool window_visible_; // Only applicable if |attached_to_window_| is true. | 205 bool window_visible_; // Only applicable if |attached_to_window_| is true. |
200 bool attached_to_window_; | 206 bool attached_to_window_; |
201 bool hardware_enabled_; | 207 bool hardware_enabled_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 | 248 |
243 GlobalTileManager::Key tile_manager_key_; | 249 GlobalTileManager::Key tile_manager_key_; |
244 content::SynchronousCompositorMemoryPolicy memory_policy_; | 250 content::SynchronousCompositorMemoryPolicy memory_policy_; |
245 | 251 |
246 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 252 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
247 }; | 253 }; |
248 | 254 |
249 } // namespace android_webview | 255 } // namespace android_webview |
250 | 256 |
251 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 257 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
OLD | NEW |