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/global_tile_manager.h" | 8 #include "android_webview/browser/global_tile_manager.h" |
9 #include "android_webview/browser/global_tile_manager_client.h" | 9 #include "android_webview/browser/global_tile_manager_client.h" |
10 #include "android_webview/browser/shared_renderer_state.h" | 10 #include "android_webview/browser/shared_renderer_state.h" |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "content/public/browser/android/synchronous_compositor.h" |
15 #include "content/public/browser/android/synchronous_compositor_client.h" | 16 #include "content/public/browser/android/synchronous_compositor_client.h" |
16 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
18 #include "ui/gfx/vector2d_f.h" | 19 #include "ui/gfx/vector2d_f.h" |
19 | 20 |
20 class SkCanvas; | 21 class SkCanvas; |
21 class SkPicture; | 22 class SkPicture; |
22 struct AwDrawGLInfo; | 23 struct AwDrawGLInfo; |
23 struct AwDrawSWFunctionTable; | 24 struct AwDrawSWFunctionTable; |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class ContentViewCore; | 27 class ContentViewCore; |
27 class SynchronousCompositor; | |
28 struct SynchronousCompositorMemoryPolicy; | 28 struct SynchronousCompositorMemoryPolicy; |
29 class WebContents; | 29 class WebContents; |
30 } | 30 } |
31 | 31 |
32 namespace android_webview { | 32 namespace android_webview { |
33 | 33 |
34 class BrowserViewRendererClient; | 34 class BrowserViewRendererClient; |
35 | 35 |
36 // Delegate to perform rendering actions involving Java objects. | 36 // Delegate to perform rendering actions involving Java objects. |
37 class BrowserViewRendererJavaHelper { | 37 class BrowserViewRendererJavaHelper { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // returns true. A false return value indicates nothing was or will be drawn. | 74 // returns true. A false return value indicates nothing was or will be drawn. |
75 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates | 75 // |java_canvas| is the target of the draw. |is_hardware_canvas| indicates |
76 // a GL Draw maybe possible on this canvas. |scroll| if the view's current | 76 // a GL Draw maybe possible on this canvas. |scroll| if the view's current |
77 // scroll offset. |clip| is the canvas's clip bounds. |global_visible_rect| | 77 // scroll offset. |clip| is the canvas's clip bounds. |global_visible_rect| |
78 // is the intersection of the view size and the window in window coordinates. | 78 // is the intersection of the view size and the window in window coordinates. |
79 bool OnDraw(jobject java_canvas, | 79 bool OnDraw(jobject java_canvas, |
80 bool is_hardware_canvas, | 80 bool is_hardware_canvas, |
81 const gfx::Vector2d& scroll, | 81 const gfx::Vector2d& scroll, |
82 const gfx::Rect& global_visible_rect, | 82 const gfx::Rect& global_visible_rect, |
83 const gfx::Rect& clip); | 83 const gfx::Rect& clip); |
84 void DidDrawGL(scoped_ptr<DrawGLResult> result); | 84 void DidDrawDelegated(); |
85 void DidDrawDelegated(scoped_ptr<DrawGLResult> result); | |
86 | 85 |
87 // CapturePicture API methods. | 86 // CapturePicture API methods. |
88 skia::RefPtr<SkPicture> CapturePicture(int width, int height); | 87 skia::RefPtr<SkPicture> CapturePicture(int width, int height); |
89 void EnableOnNewPicture(bool enabled); | 88 void EnableOnNewPicture(bool enabled); |
90 | 89 |
91 void ClearView(); | 90 void ClearView(); |
92 | 91 |
93 // View update notifications. | 92 // View update notifications. |
94 void SetIsPaused(bool paused); | 93 void SetIsPaused(bool paused); |
95 void SetViewVisibility(bool visible); | 94 void SetViewVisibility(bool visible); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // invalidates appropriately. If |force_invalidate| is true, then send a view | 146 // invalidates appropriately. If |force_invalidate| is true, then send a view |
148 // invalidate regardless of compositor expectation. | 147 // invalidate regardless of compositor expectation. |
149 void EnsureContinuousInvalidation(bool force_invalidate); | 148 void EnsureContinuousInvalidation(bool force_invalidate); |
150 bool DrawSWInternal(jobject java_canvas, const gfx::Rect& clip_bounds); | 149 bool DrawSWInternal(jobject java_canvas, const gfx::Rect& clip_bounds); |
151 bool CompositeSW(SkCanvas* canvas); | 150 bool CompositeSW(SkCanvas* canvas); |
152 void DidComposite(bool force_invalidate); | 151 void DidComposite(bool force_invalidate); |
153 scoped_ptr<base::Value> RootLayerStateAsValue( | 152 scoped_ptr<base::Value> RootLayerStateAsValue( |
154 const gfx::Vector2dF& total_scroll_offset_dip, | 153 const gfx::Vector2dF& total_scroll_offset_dip, |
155 const gfx::SizeF& scrollable_size_dip); | 154 const gfx::SizeF& scrollable_size_dip); |
156 | 155 |
157 bool OnDrawHardwareLegacy(jobject java_canvas); | |
158 bool OnDrawHardware(jobject java_canvas); | 156 bool OnDrawHardware(jobject java_canvas); |
159 void ReturnResources(); | 157 void ReturnResources(); |
160 | 158 |
161 // If we call up view invalidate and OnDraw is not called before a deadline, | 159 // If we call up view invalidate and OnDraw is not called before a deadline, |
162 // then we keep ticking the SynchronousCompositor so it can make progress. | 160 // then we keep ticking the SynchronousCompositor so it can make progress. |
163 void FallbackTickFired(); | 161 void FallbackTickFired(); |
164 | 162 |
165 // Force invoke the compositor to run produce a 1x1 software frame that is | 163 // Force invoke the compositor to run produce a 1x1 software frame that is |
166 // immediately discarded. This is a hack to force invoke parts of the | 164 // immediately discarded. This is a hack to force invoke parts of the |
167 // compositor that are not directly exposed here. | 165 // compositor that are not directly exposed here. |
(...skipping 13 matching lines...) Expand all Loading... |
181 SharedRendererState* shared_renderer_state_; | 179 SharedRendererState* shared_renderer_state_; |
182 content::WebContents* web_contents_; | 180 content::WebContents* web_contents_; |
183 // TODO(boliu): This class should only be used on the UI thread. However in | 181 // TODO(boliu): This class should only be used on the UI thread. However in |
184 // short term to supporting HardwareRenderer, some callbacks on | 182 // short term to supporting HardwareRenderer, some callbacks on |
185 // SynchronousCompositorClient may be called on non-UI thread. These are | 183 // SynchronousCompositorClient may be called on non-UI thread. These are |
186 // used to detect this and post them back to UI thread. | 184 // used to detect this and post them back to UI thread. |
187 base::WeakPtrFactory<BrowserViewRenderer> weak_factory_on_ui_thread_; | 185 base::WeakPtrFactory<BrowserViewRenderer> weak_factory_on_ui_thread_; |
188 base::WeakPtr<BrowserViewRenderer> ui_thread_weak_ptr_; | 186 base::WeakPtr<BrowserViewRenderer> ui_thread_weak_ptr_; |
189 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 187 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
190 | 188 |
191 bool has_compositor_; | 189 content::SynchronousCompositor* compositor_; |
192 | 190 |
193 bool is_paused_; | 191 bool is_paused_; |
194 bool view_visible_; | 192 bool view_visible_; |
195 bool window_visible_; // Only applicable if |attached_to_window_| is true. | 193 bool window_visible_; // Only applicable if |attached_to_window_| is true. |
196 bool attached_to_window_; | 194 bool attached_to_window_; |
197 bool hardware_enabled_; | 195 bool hardware_enabled_; |
198 float dip_scale_; | 196 float dip_scale_; |
199 float page_scale_factor_; | 197 float page_scale_factor_; |
200 bool on_new_picture_enable_; | 198 bool on_new_picture_enable_; |
201 bool clear_view_; | 199 bool clear_view_; |
(...skipping 21 matching lines...) Expand all Loading... |
223 | 221 |
224 // Max scroll offset in CSS pixels. | 222 // Max scroll offset in CSS pixels. |
225 gfx::Vector2dF max_scroll_offset_dip_; | 223 gfx::Vector2dF max_scroll_offset_dip_; |
226 | 224 |
227 // Used to prevent rounding errors from accumulating enough to generate | 225 // Used to prevent rounding errors from accumulating enough to generate |
228 // visible skew (especially noticeable when scrolling up and down in the same | 226 // visible skew (especially noticeable when scrolling up and down in the same |
229 // spot over a period of time). | 227 // spot over a period of time). |
230 gfx::Vector2dF overscroll_rounding_error_; | 228 gfx::Vector2dF overscroll_rounding_error_; |
231 | 229 |
232 GlobalTileManager::Key tile_manager_key_; | 230 GlobalTileManager::Key tile_manager_key_; |
| 231 content::SynchronousCompositorMemoryPolicy memory_policy_; |
233 | 232 |
234 // The following 2 are used to construct a memory policy and set the memory | 233 // The following 2 are used to construct a memory policy and set the memory |
235 // policy on the shared_renderer_state_ atomically. | 234 // policy on the shared_renderer_state_ atomically. |
236 size_t num_tiles_; | 235 size_t num_tiles_; |
237 size_t num_bytes_; | 236 size_t num_bytes_; |
238 | 237 |
239 // TODO(boliu): This is a short term solution to support | 238 // TODO(boliu): This is a short term solution to support |
240 // SynchronousCompositorClient methods called on RenderThread. This is only | 239 // SynchronousCompositorClient methods called on RenderThread. This is only |
241 // used on data that must be modified immediately instead of being posted | 240 // used on data that must be modified immediately instead of being posted |
242 // back to UI. | 241 // back to UI. |
243 base::Lock render_thread_lock_; | 242 base::Lock render_thread_lock_; |
244 | 243 |
245 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 244 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
246 }; | 245 }; |
247 | 246 |
248 } // namespace android_webview | 247 } // namespace android_webview |
249 | 248 |
250 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 249 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
OLD | NEW |