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/parent_compositor_draw_constraints.h" | 8 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
9 #include "android_webview/browser/shared_renderer_state.h" | 9 #include "android_webview/browser/shared_renderer_state.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 113 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
114 const gfx::Vector2dF& latest_overscroll_delta, | 114 const gfx::Vector2dF& latest_overscroll_delta, |
115 const gfx::Vector2dF& current_fling_velocity) override; | 115 const gfx::Vector2dF& current_fling_velocity) override; |
116 | 116 |
117 void UpdateParentDrawConstraints(); | 117 void UpdateParentDrawConstraints(); |
118 void DetachFunctorFromView(); | 118 void DetachFunctorFromView(); |
119 | 119 |
120 private: | 120 private: |
121 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 121 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); |
122 bool CanOnDraw(); | 122 bool CanOnDraw(); |
| 123 // Posts an invalidate with fallback tick. All invalidates posted while an |
| 124 // invalidate is pending will be posted as a single invalidate after the |
| 125 // pending invalidate is done. |
| 126 void PostInvalidateWithFallback(); |
| 127 void CancelFallbackTick(); |
123 void UpdateCompositorIsActive(); | 128 void UpdateCompositorIsActive(); |
124 bool CompositeSW(SkCanvas* canvas); | 129 bool CompositeSW(SkCanvas* canvas); |
125 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 130 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
126 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, | 131 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, |
127 const gfx::SizeF& scrollable_size_dip); | 132 const gfx::SizeF& scrollable_size_dip); |
128 | 133 |
| 134 bool CompositeHw(); |
129 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | 135 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); |
130 void ReturnResourceFromParent(); | 136 void ReturnResourceFromParent(); |
131 | 137 |
132 // If we call up view invalidate and OnDraw is not called before a deadline, | 138 // If we call up view invalidate and OnDraw is not called before a deadline, |
133 // then we keep ticking the SynchronousCompositor so it can make progress. | 139 // then we keep ticking the SynchronousCompositor so it can make progress. |
134 // Do this in a two stage tick due to native MessageLoop favors delayed task, | 140 // Do this in a two stage tick due to native MessageLoop favors delayed task, |
135 // so ensure delayed task is inserted only after the draw task returns. | 141 // so ensure delayed task is inserted only after the draw task returns. |
136 void PostFallbackTick(); | 142 void PostFallbackTick(); |
137 void FallbackTickFired(); | 143 void FallbackTickFired(); |
138 | 144 |
| 145 // Force invoke the compositor to run produce a 1x1 software frame that is |
| 146 // immediately discarded. This is a hack to force invoke parts of the |
| 147 // compositor that are not directly exposed here. |
| 148 void ForceFakeCompositeSW(); |
| 149 |
139 gfx::Vector2d max_scroll_offset() const; | 150 gfx::Vector2d max_scroll_offset() const; |
140 | 151 |
141 void UpdateMemoryPolicy(); | 152 void UpdateMemoryPolicy(); |
142 | 153 |
143 // For debug tracing or logging. Return the string representation of this | 154 // For debug tracing or logging. Return the string representation of this |
144 // view renderer's state. | 155 // view renderer's state. |
145 std::string ToString() const; | 156 std::string ToString() const; |
146 | 157 |
147 BrowserViewRendererClient* client_; | 158 BrowserViewRendererClient* client_; |
148 SharedRendererState shared_renderer_state_; | 159 SharedRendererState shared_renderer_state_; |
(...skipping 12 matching lines...) Expand all Loading... |
161 float min_page_scale_factor_; | 172 float min_page_scale_factor_; |
162 float max_page_scale_factor_; | 173 float max_page_scale_factor_; |
163 bool on_new_picture_enable_; | 174 bool on_new_picture_enable_; |
164 bool clear_view_; | 175 bool clear_view_; |
165 | 176 |
166 bool offscreen_pre_raster_; | 177 bool offscreen_pre_raster_; |
167 | 178 |
168 gfx::Vector2d last_on_draw_scroll_offset_; | 179 gfx::Vector2d last_on_draw_scroll_offset_; |
169 gfx::Rect last_on_draw_global_visible_rect_; | 180 gfx::Rect last_on_draw_global_visible_rect_; |
170 | 181 |
| 182 base::CancelableClosure post_fallback_tick_; |
| 183 base::CancelableClosure fallback_tick_fired_; |
| 184 bool fallback_tick_pending_; |
| 185 |
171 gfx::Size size_; | 186 gfx::Size size_; |
172 | 187 |
173 gfx::SizeF scrollable_size_dip_; | 188 gfx::SizeF scrollable_size_dip_; |
174 | 189 |
175 // Current scroll offset in CSS pixels. | 190 // Current scroll offset in CSS pixels. |
176 // TODO(miletus): Make scroll_offset_dip_ a gfx::ScrollOffset. | 191 // TODO(miletus): Make scroll_offset_dip_ a gfx::ScrollOffset. |
177 gfx::Vector2dF scroll_offset_dip_; | 192 gfx::Vector2dF scroll_offset_dip_; |
178 | 193 |
179 // Max scroll offset in CSS pixels. | 194 // Max scroll offset in CSS pixels. |
180 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. | 195 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. |
181 gfx::Vector2dF max_scroll_offset_dip_; | 196 gfx::Vector2dF max_scroll_offset_dip_; |
182 | 197 |
183 // Used to prevent rounding errors from accumulating enough to generate | 198 // Used to prevent rounding errors from accumulating enough to generate |
184 // visible skew (especially noticeable when scrolling up and down in the same | 199 // visible skew (especially noticeable when scrolling up and down in the same |
185 // spot over a period of time). | 200 // spot over a period of time). |
186 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. | 201 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. |
187 gfx::Vector2dF overscroll_rounding_error_; | 202 gfx::Vector2dF overscroll_rounding_error_; |
188 | 203 |
189 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 204 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
190 }; | 205 }; |
191 | 206 |
192 } // namespace android_webview | 207 } // namespace android_webview |
193 | 208 |
194 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 209 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
OLD | NEW |