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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 gfx::Size size() const { return size_; } | 89 gfx::Size size() const { return size_; } |
90 void ReleaseHardware(); | 90 void ReleaseHardware(); |
91 | 91 |
92 void TrimMemory(const int level, const bool visible); | 92 void TrimMemory(const int level, const bool visible); |
93 | 93 |
94 // SynchronousCompositorClient overrides. | 94 // SynchronousCompositorClient overrides. |
95 void DidInitializeCompositor( | 95 void DidInitializeCompositor( |
96 content::SynchronousCompositor* compositor) override; | 96 content::SynchronousCompositor* compositor) override; |
97 void DidDestroyCompositor( | 97 void DidDestroyCompositor( |
98 content::SynchronousCompositor* compositor) override; | 98 content::SynchronousCompositor* compositor) override; |
99 void PostInvalidate() override; | 99 void SetContinuousInvalidate(bool invalidate) override; |
100 void DidUpdateContent() override; | 100 void DidUpdateContent() override; |
101 gfx::Vector2dF GetTotalRootLayerScrollOffset() override; | 101 gfx::Vector2dF GetTotalRootLayerScrollOffset() override; |
102 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, | 102 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, |
103 const gfx::Vector2dF& max_scroll_offset_dip, | 103 const gfx::Vector2dF& max_scroll_offset_dip, |
104 const gfx::SizeF& scrollable_size_dip, | 104 const gfx::SizeF& scrollable_size_dip, |
105 float page_scale_factor, | 105 float page_scale_factor, |
106 float min_page_scale_factor, | 106 float min_page_scale_factor, |
107 float max_page_scale_factor) override; | 107 float max_page_scale_factor) override; |
108 bool IsExternalFlingActive() const override; | 108 bool IsExternalFlingActive() const override; |
109 void DidOverscroll(gfx::Vector2dF accumulated_overscroll, | 109 void DidOverscroll(gfx::Vector2dF accumulated_overscroll, |
110 gfx::Vector2dF latest_overscroll_delta, | 110 gfx::Vector2dF latest_overscroll_delta, |
111 gfx::Vector2dF current_fling_velocity) override; | 111 gfx::Vector2dF current_fling_velocity) override; |
112 | 112 |
113 void UpdateParentDrawConstraints(); | 113 void UpdateParentDrawConstraints(); |
114 void DetachFunctorFromView(); | 114 void DetachFunctorFromView(); |
115 | 115 |
116 private: | 116 private: |
117 void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); | 117 void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); |
118 bool CanOnDraw(); | 118 bool CanOnDraw(); |
119 // Posts an invalidate with fallback tick. All invalidates posted while an | 119 // Checks the continuous invalidate and block invalidate state, and schedule |
120 // invalidate is pending will be posted as a single invalidate after the | 120 // invalidates appropriately. If |force_invalidate| is true, then send a view |
121 // pending invalidate is done. | 121 // invalidate regardless of compositor expectation. |
122 void PostInvalidateWithFallback(); | 122 void EnsureContinuousInvalidation(bool force_invalidate); |
123 void CancelFallbackTick(); | |
124 void UpdateCompositorIsActive(); | |
125 bool CompositeSW(SkCanvas* canvas); | 123 bool CompositeSW(SkCanvas* canvas); |
| 124 void DidComposite(); |
126 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 125 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
127 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, | 126 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, |
128 const gfx::SizeF& scrollable_size_dip); | 127 const gfx::SizeF& scrollable_size_dip); |
129 | 128 |
130 bool CompositeHw(); | 129 bool CompositeHw(); |
131 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | 130 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); |
132 void ReturnResourceFromParent(); | 131 void ReturnResourceFromParent(); |
133 | 132 |
134 // If we call up view invalidate and OnDraw is not called before a deadline, | 133 // If we call up view invalidate and OnDraw is not called before a deadline, |
135 // then we keep ticking the SynchronousCompositor so it can make progress. | 134 // then we keep ticking the SynchronousCompositor so it can make progress. |
136 // Do this in a two stage tick due to native MessageLoop favors delayed task, | 135 // Do this in a two stage tick due to native MessageLoop favors delayed task, |
137 // so ensure delayed task is inserted only after the draw task returns. | 136 // so ensure delayed task is inserted only after the draw task returns. |
138 void PostFallbackTick(); | 137 void PostFallbackTick(); |
139 void FallbackTickFired(); | 138 void FallbackTickFired(); |
140 | 139 |
141 // Force invoke the compositor to run produce a 1x1 software frame that is | 140 // Force invoke the compositor to run produce a 1x1 software frame that is |
142 // immediately discarded. This is a hack to force invoke parts of the | 141 // immediately discarded. This is a hack to force invoke parts of the |
143 // compositor that are not directly exposed here. | 142 // compositor that are not directly exposed here. |
144 void ForceFakeCompositeSW(); | 143 void ForceFakeCompositeSW(); |
145 | 144 |
146 gfx::Vector2d max_scroll_offset() const; | 145 gfx::Vector2d max_scroll_offset() const; |
147 | 146 |
148 size_t CalculateDesiredMemoryPolicy(); | 147 size_t CalculateDesiredMemoryPolicy(); |
149 | |
150 // For debug tracing or logging. Return the string representation of this | 148 // For debug tracing or logging. Return the string representation of this |
151 // view renderer's state. | 149 // view renderer's state. |
152 std::string ToString() const; | 150 std::string ToString() const; |
153 | 151 |
154 BrowserViewRendererClient* client_; | 152 BrowserViewRendererClient* client_; |
155 SharedRendererState shared_renderer_state_; | 153 SharedRendererState shared_renderer_state_; |
156 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 154 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
157 | 155 |
158 content::SynchronousCompositor* compositor_; | 156 content::SynchronousCompositor* compositor_; |
159 | 157 |
160 bool is_paused_; | 158 bool is_paused_; |
161 bool view_visible_; | 159 bool view_visible_; |
162 bool window_visible_; // Only applicable if |attached_to_window_| is true. | 160 bool window_visible_; // Only applicable if |attached_to_window_| is true. |
163 bool attached_to_window_; | 161 bool attached_to_window_; |
164 bool hardware_enabled_; | 162 bool hardware_enabled_; |
165 float dip_scale_; | 163 float dip_scale_; |
166 float page_scale_factor_; | 164 float page_scale_factor_; |
167 bool on_new_picture_enable_; | 165 bool on_new_picture_enable_; |
168 bool clear_view_; | 166 bool clear_view_; |
169 | 167 |
170 bool offscreen_pre_raster_; | 168 bool offscreen_pre_raster_; |
171 | 169 |
172 gfx::Vector2d last_on_draw_scroll_offset_; | 170 gfx::Vector2d last_on_draw_scroll_offset_; |
173 gfx::Rect last_on_draw_global_visible_rect_; | 171 gfx::Rect last_on_draw_global_visible_rect_; |
174 | 172 |
| 173 // When true, we should continuously invalidate and keep drawing, for example |
| 174 // to drive animation. This value is set by the compositor and should always |
| 175 // reflect the expectation of the compositor and not be reused for other |
| 176 // states. |
| 177 bool compositor_needs_continuous_invalidate_; |
| 178 |
| 179 // Used to block additional invalidates while one is already pending. |
| 180 bool block_invalidates_; |
175 | 181 |
176 base::CancelableClosure post_fallback_tick_; | 182 base::CancelableClosure post_fallback_tick_; |
177 base::CancelableClosure fallback_tick_fired_; | 183 base::CancelableClosure fallback_tick_fired_; |
178 bool fallback_tick_pending_; | 184 bool fallback_tick_pending_; |
179 | 185 |
180 gfx::Size size_; | 186 gfx::Size size_; |
181 | 187 |
182 // Current scroll offset in CSS pixels. | 188 // Current scroll offset in CSS pixels. |
183 gfx::Vector2dF scroll_offset_dip_; | 189 gfx::Vector2dF scroll_offset_dip_; |
184 | 190 |
185 // Max scroll offset in CSS pixels. | 191 // Max scroll offset in CSS pixels. |
186 gfx::Vector2dF max_scroll_offset_dip_; | 192 gfx::Vector2dF max_scroll_offset_dip_; |
187 | 193 |
188 // Used to prevent rounding errors from accumulating enough to generate | 194 // Used to prevent rounding errors from accumulating enough to generate |
189 // visible skew (especially noticeable when scrolling up and down in the same | 195 // visible skew (especially noticeable when scrolling up and down in the same |
190 // spot over a period of time). | 196 // spot over a period of time). |
191 gfx::Vector2dF overscroll_rounding_error_; | 197 gfx::Vector2dF overscroll_rounding_error_; |
192 | 198 |
193 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 199 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
194 }; | 200 }; |
195 | 201 |
196 } // namespace android_webview | 202 } // namespace android_webview |
197 | 203 |
198 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 204 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
OLD | NEW |