| 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" |
| (...skipping 63 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(const DrawGLResult& result); | 84 void DidDrawGL(scoped_ptr<DrawGLResult> result); |
| 85 void DidDrawDelegated(scoped_ptr<DrawGLResult> result); |
| 85 | 86 |
| 86 // CapturePicture API methods. | 87 // CapturePicture API methods. |
| 87 skia::RefPtr<SkPicture> CapturePicture(int width, int height); | 88 skia::RefPtr<SkPicture> CapturePicture(int width, int height); |
| 88 void EnableOnNewPicture(bool enabled); | 89 void EnableOnNewPicture(bool enabled); |
| 89 | 90 |
| 90 void ClearView(); | 91 void ClearView(); |
| 91 | 92 |
| 92 // View update notifications. | 93 // View update notifications. |
| 93 void SetIsPaused(bool paused); | 94 void SetIsPaused(bool paused); |
| 94 void SetViewVisibility(bool visible); | 95 void SetViewVisibility(bool visible); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // invalidates appropriately. If |force_invalidate| is true, then send a view | 147 // invalidates appropriately. If |force_invalidate| is true, then send a view |
| 147 // invalidate regardless of compositor expectation. | 148 // invalidate regardless of compositor expectation. |
| 148 void EnsureContinuousInvalidation(bool force_invalidate); | 149 void EnsureContinuousInvalidation(bool force_invalidate); |
| 149 bool DrawSWInternal(jobject java_canvas, const gfx::Rect& clip_bounds); | 150 bool DrawSWInternal(jobject java_canvas, const gfx::Rect& clip_bounds); |
| 150 bool CompositeSW(SkCanvas* canvas); | 151 bool CompositeSW(SkCanvas* canvas); |
| 151 void DidComposite(bool force_invalidate); | 152 void DidComposite(bool force_invalidate); |
| 152 scoped_ptr<base::Value> RootLayerStateAsValue( | 153 scoped_ptr<base::Value> RootLayerStateAsValue( |
| 153 const gfx::Vector2dF& total_scroll_offset_dip, | 154 const gfx::Vector2dF& total_scroll_offset_dip, |
| 154 const gfx::SizeF& scrollable_size_dip); | 155 const gfx::SizeF& scrollable_size_dip); |
| 155 | 156 |
| 157 bool OnDrawHardwareLegacy(jobject java_canvas); |
| 158 bool OnDrawHardware(jobject java_canvas); |
| 159 void ReturnResources(); |
| 160 |
| 156 // If we call up view invalidate and OnDraw is not called before a deadline, | 161 // If we call up view invalidate and OnDraw is not called before a deadline, |
| 157 // then we keep ticking the SynchronousCompositor so it can make progress. | 162 // then we keep ticking the SynchronousCompositor so it can make progress. |
| 158 void FallbackTickFired(); | 163 void FallbackTickFired(); |
| 159 | 164 |
| 160 // Force invoke the compositor to run produce a 1x1 software frame that is | 165 // Force invoke the compositor to run produce a 1x1 software frame that is |
| 161 // immediately discarded. This is a hack to force invoke parts of the | 166 // immediately discarded. This is a hack to force invoke parts of the |
| 162 // compositor that are not directly exposed here. | 167 // compositor that are not directly exposed here. |
| 163 void ForceFakeCompositeSW(); | 168 void ForceFakeCompositeSW(); |
| 164 | 169 |
| 165 void EnforceMemoryPolicyImmediately( | 170 void EnforceMemoryPolicyImmediately( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 186 bool has_compositor_; | 191 bool has_compositor_; |
| 187 | 192 |
| 188 bool is_paused_; | 193 bool is_paused_; |
| 189 bool view_visible_; | 194 bool view_visible_; |
| 190 bool window_visible_; // Only applicable if |attached_to_window_| is true. | 195 bool window_visible_; // Only applicable if |attached_to_window_| is true. |
| 191 bool attached_to_window_; | 196 bool attached_to_window_; |
| 192 float dip_scale_; | 197 float dip_scale_; |
| 193 float page_scale_factor_; | 198 float page_scale_factor_; |
| 194 bool on_new_picture_enable_; | 199 bool on_new_picture_enable_; |
| 195 bool clear_view_; | 200 bool clear_view_; |
| 201 gfx::Vector2d scroll_offset_; |
| 202 gfx::Rect global_visible_rect_; |
| 196 | 203 |
| 197 // When true, we should continuously invalidate and keep drawing, for example | 204 // When true, we should continuously invalidate and keep drawing, for example |
| 198 // to drive animation. This value is set by the compositor and should always | 205 // to drive animation. This value is set by the compositor and should always |
| 199 // reflect the expectation of the compositor and not be reused for other | 206 // reflect the expectation of the compositor and not be reused for other |
| 200 // states. | 207 // states. |
| 201 bool compositor_needs_continuous_invalidate_; | 208 bool compositor_needs_continuous_invalidate_; |
| 202 | 209 |
| 203 // Used to block additional invalidates while one is already pending. | 210 // Used to block additional invalidates while one is already pending. |
| 204 bool block_invalidates_; | 211 bool block_invalidates_; |
| 205 | 212 |
| 206 // Holds a callback to FallbackTickFired while it is pending. | 213 // Holds a callback to FallbackTickFired while it is pending. |
| 207 base::CancelableClosure fallback_tick_; | 214 base::CancelableClosure fallback_tick_; |
| 208 | 215 |
| 209 int width_; | 216 int width_; |
| 210 int height_; | 217 int height_; |
| 211 | 218 |
| 212 DrawGLInput draw_gl_input_; | 219 unsigned int current_frame_id_; |
| 213 | 220 |
| 214 // Current scroll offset in CSS pixels. | 221 // Current scroll offset in CSS pixels. |
| 215 gfx::Vector2dF scroll_offset_dip_; | 222 gfx::Vector2dF scroll_offset_dip_; |
| 216 | 223 |
| 217 // Max scroll offset in CSS pixels. | 224 // Max scroll offset in CSS pixels. |
| 218 gfx::Vector2dF max_scroll_offset_dip_; | 225 gfx::Vector2dF max_scroll_offset_dip_; |
| 219 | 226 |
| 220 // Used to prevent rounding errors from accumulating enough to generate | 227 // Used to prevent rounding errors from accumulating enough to generate |
| 221 // visible skew (especially noticeable when scrolling up and down in the same | 228 // visible skew (especially noticeable when scrolling up and down in the same |
| 222 // spot over a period of time). | 229 // spot over a period of time). |
| 223 gfx::Vector2dF overscroll_rounding_error_; | 230 gfx::Vector2dF overscroll_rounding_error_; |
| 224 | 231 |
| 225 GlobalTileManager::Key tile_manager_key_; | 232 GlobalTileManager::Key tile_manager_key_; |
| 226 | 233 |
| 227 // The following 2 are used to construct a memory policy and set the memory | 234 // The following 2 are used to construct a memory policy and set the memory |
| 228 // policy on the shared_renderer_state_ atomically. | 235 // policy on the shared_renderer_state_ atomically. |
| 229 size_t num_tiles_; | 236 size_t num_tiles_; |
| 230 size_t num_bytes_; | 237 size_t num_bytes_; |
| 231 | 238 |
| 232 // TODO(boliu): This is a short term solution to support | 239 // TODO(boliu): This is a short term solution to support |
| 233 // SynchronousCompositorClient methods called on RenderThread. This is only | 240 // SynchronousCompositorClient methods called on RenderThread. This is only |
| 234 // used on data that must be modified immediately instead of being posted | 241 // used on data that must be modified immediately instead of being posted |
| 235 // back to UI. | 242 // back to UI. |
| 236 base::Lock render_thread_lock_; | 243 base::Lock render_thread_lock_; |
| 237 | 244 |
| 245 bool hardware_enabled_; |
| 246 |
| 238 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 247 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 239 }; | 248 }; |
| 240 | 249 |
| 241 } // namespace android_webview | 250 } // namespace android_webview |
| 242 | 251 |
| 243 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 252 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |