| 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 <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 10 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void TrimMemory(const int level, const bool visible); | 100 void TrimMemory(const int level, const bool visible); |
| 101 | 101 |
| 102 // SynchronousCompositorClient overrides. | 102 // SynchronousCompositorClient overrides. |
| 103 void DidInitializeCompositor( | 103 void DidInitializeCompositor( |
| 104 content::SynchronousCompositor* compositor) override; | 104 content::SynchronousCompositor* compositor) override; |
| 105 void DidDestroyCompositor( | 105 void DidDestroyCompositor( |
| 106 content::SynchronousCompositor* compositor) override; | 106 content::SynchronousCompositor* compositor) override; |
| 107 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; | 107 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; |
| 108 void PostInvalidate() override; | 108 void PostInvalidate() override; |
| 109 void DidUpdateContent() override; | 109 void DidUpdateContent() override; |
| 110 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, | 110 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_css, |
| 111 const gfx::Vector2dF& max_scroll_offset_dip, | 111 const gfx::Vector2dF& max_scroll_offset_css, |
| 112 const gfx::SizeF& scrollable_size_dip, | 112 const gfx::SizeF& scrollable_size_css, |
| 113 float page_scale_factor, | 113 float page_scale_factor, |
| 114 float min_page_scale_factor, | 114 float min_page_scale_factor, |
| 115 float max_page_scale_factor) override; | 115 float max_page_scale_factor) override; |
| 116 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 116 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 117 const gfx::Vector2dF& latest_overscroll_delta, | 117 const gfx::Vector2dF& latest_overscroll_delta, |
| 118 const gfx::Vector2dF& current_fling_velocity) override; | 118 const gfx::Vector2dF& current_fling_velocity) override; |
| 119 | 119 |
| 120 void UpdateParentDrawConstraints(); | 120 void UpdateParentDrawConstraints(); |
| 121 void DetachFunctorFromView(); | 121 void DetachFunctorFromView(); |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 124 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_css); |
| 125 bool CanOnDraw(); | 125 bool CanOnDraw(); |
| 126 // Posts an invalidate with fallback tick. All invalidates posted while an | 126 // Posts an invalidate with fallback tick. All invalidates posted while an |
| 127 // invalidate is pending will be posted as a single invalidate after the | 127 // invalidate is pending will be posted as a single invalidate after the |
| 128 // pending invalidate is done. | 128 // pending invalidate is done. |
| 129 void PostInvalidateWithFallback(); | 129 void PostInvalidateWithFallback(); |
| 130 void CancelFallbackTick(); | 130 void CancelFallbackTick(); |
| 131 void UpdateCompositorIsActive(); | 131 void UpdateCompositorIsActive(); |
| 132 bool CompositeSW(SkCanvas* canvas); | 132 bool CompositeSW(SkCanvas* canvas); |
| 133 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 133 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 134 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, | 134 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_css, |
| 135 const gfx::SizeF& scrollable_size_dip); | 135 const gfx::SizeF& scrollable_size_css); |
| 136 | 136 |
| 137 bool CompositeHw(); | 137 bool CompositeHw(); |
| 138 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | 138 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); |
| 139 void ReturnResourceFromParent(); | 139 void ReturnResourceFromParent(); |
| 140 | 140 |
| 141 // If we call up view invalidate and OnDraw is not called before a deadline, | 141 // If we call up view invalidate and OnDraw is not called before a deadline, |
| 142 // then we keep ticking the SynchronousCompositor so it can make progress. | 142 // then we keep ticking the SynchronousCompositor so it can make progress. |
| 143 // Do this in a two stage tick due to native MessageLoop favors delayed task, | 143 // Do this in a two stage tick due to native MessageLoop favors delayed task, |
| 144 // so ensure delayed task is inserted only after the draw task returns. | 144 // so ensure delayed task is inserted only after the draw task returns. |
| 145 void PostFallbackTick(); | 145 void PostFallbackTick(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 gfx::Vector2d last_on_draw_scroll_offset_; | 188 gfx::Vector2d last_on_draw_scroll_offset_; |
| 189 gfx::Rect last_on_draw_global_visible_rect_; | 189 gfx::Rect last_on_draw_global_visible_rect_; |
| 190 | 190 |
| 191 base::CancelableClosure post_fallback_tick_; | 191 base::CancelableClosure post_fallback_tick_; |
| 192 base::CancelableClosure fallback_tick_fired_; | 192 base::CancelableClosure fallback_tick_fired_; |
| 193 bool fallback_tick_pending_; | 193 bool fallback_tick_pending_; |
| 194 | 194 |
| 195 gfx::Size size_; | 195 gfx::Size size_; |
| 196 | 196 |
| 197 gfx::SizeF scrollable_size_dip_; | 197 gfx::SizeF scrollable_size_css_; |
| 198 | 198 |
| 199 // Current scroll offset in CSS pixels. | 199 // Current scroll offset in CSS pixels. |
| 200 // TODO(miletus): Make scroll_offset_dip_ a gfx::ScrollOffset. | 200 // TODO(miletus): Make scroll_offset_css_ a gfx::ScrollOffset. |
| 201 gfx::Vector2dF scroll_offset_dip_; | 201 gfx::Vector2dF scroll_offset_css_; |
| 202 | 202 |
| 203 // Max scroll offset in CSS pixels. | 203 // Max scroll offset in CSS pixels. |
| 204 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. | 204 // TODO(miletus): Make max_scroll_offset_css_ a gfx::ScrollOffset. |
| 205 gfx::Vector2dF max_scroll_offset_dip_; | 205 gfx::Vector2dF max_scroll_offset_css_; |
| 206 | 206 |
| 207 // Used to prevent rounding errors from accumulating enough to generate | 207 // Used to prevent rounding errors from accumulating enough to generate |
| 208 // visible skew (especially noticeable when scrolling up and down in the same | 208 // visible skew (especially noticeable when scrolling up and down in the same |
| 209 // spot over a period of time). | 209 // spot over a period of time). |
| 210 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. | 210 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. |
| 211 gfx::Vector2dF overscroll_rounding_error_; | 211 gfx::Vector2dF overscroll_rounding_error_; |
| 212 | 212 |
| 213 unsigned int next_compositor_id_; | 213 unsigned int next_compositor_id_; |
| 214 | 214 |
| 215 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 215 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 } // namespace android_webview | 218 } // namespace android_webview |
| 219 | 219 |
| 220 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 220 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |