| 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" |
| 11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "content/public/browser/android/synchronous_compositor.h" | 13 #include "content/public/browser/android/synchronous_compositor.h" |
| 14 #include "content/public/browser/android/synchronous_compositor_client.h" | 14 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 15 #include "skia/ext/refptr.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/geometry/vector2d_f.h" | 17 #include "ui/gfx/geometry/vector2d_f.h" |
| 17 | 18 |
| 18 class SkCanvas; | 19 class SkCanvas; |
| 19 class SkPicture; | 20 class SkPicture; |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class WebContents; | 23 class WebContents; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace android_webview { | 26 namespace android_webview { |
| 26 | 27 |
| 27 class BrowserViewRendererClient; | 28 class BrowserViewRendererClient; |
| 29 class ChildFrame; |
| 28 | 30 |
| 29 // Interface for all the WebView-specific content rendering operations. | 31 // Interface for all the WebView-specific content rendering operations. |
| 30 // Provides software and hardware rendering and the Capture Picture API. | 32 // Provides software and hardware rendering and the Capture Picture API. |
| 31 class BrowserViewRenderer : public content::SynchronousCompositorClient { | 33 class BrowserViewRenderer : public content::SynchronousCompositorClient { |
| 32 public: | 34 public: |
| 33 static void CalculateTileMemoryPolicy(); | 35 static void CalculateTileMemoryPolicy(); |
| 34 static BrowserViewRenderer* FromWebContents( | 36 static BrowserViewRenderer* FromWebContents( |
| 35 content::WebContents* web_contents); | 37 content::WebContents* web_contents); |
| 36 | 38 |
| 37 BrowserViewRenderer( | 39 BrowserViewRenderer( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 const gfx::SizeF& scrollable_size_dip, | 104 const gfx::SizeF& scrollable_size_dip, |
| 103 float page_scale_factor, | 105 float page_scale_factor, |
| 104 float min_page_scale_factor, | 106 float min_page_scale_factor, |
| 105 float max_page_scale_factor) override; | 107 float max_page_scale_factor) override; |
| 106 bool IsExternalFlingActive() const override; | 108 bool IsExternalFlingActive() const override; |
| 107 void DidOverscroll(gfx::Vector2dF accumulated_overscroll, | 109 void DidOverscroll(gfx::Vector2dF accumulated_overscroll, |
| 108 gfx::Vector2dF latest_overscroll_delta, | 110 gfx::Vector2dF latest_overscroll_delta, |
| 109 gfx::Vector2dF current_fling_velocity) override; | 111 gfx::Vector2dF current_fling_velocity) override; |
| 110 | 112 |
| 111 void UpdateParentDrawConstraints(); | 113 void UpdateParentDrawConstraints(); |
| 112 void DidSkipCommitFrame(); | |
| 113 void DetachFunctorFromView(); | 114 void DetachFunctorFromView(); |
| 114 | 115 |
| 115 private: | 116 private: |
| 116 void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); | 117 void SetTotalRootLayerScrollOffset(gfx::Vector2dF new_value_dip); |
| 117 bool CanOnDraw(); | 118 bool CanOnDraw(); |
| 118 // Checks the continuous invalidate and block invalidate state, and schedule | 119 // Checks the continuous invalidate and block invalidate state, and schedule |
| 119 // invalidates appropriately. If |force_invalidate| is true, then send a view | 120 // invalidates appropriately. If |force_invalidate| is true, then send a view |
| 120 // invalidate regardless of compositor expectation. If |skip_reschedule_tick| | 121 // invalidate regardless of compositor expectation. |
| 121 // is true and if there is already a pending fallback tick, don't reschedule | 122 void EnsureContinuousInvalidation(bool force_invalidate); |
| 122 // them. | |
| 123 void EnsureContinuousInvalidation(bool force_invalidate, | |
| 124 bool skip_reschedule_tick); | |
| 125 bool CompositeSW(SkCanvas* canvas); | 123 bool CompositeSW(SkCanvas* canvas); |
| 126 void DidComposite(); | 124 void DidComposite(); |
| 127 void DidSkipCompositeInDraw(); | |
| 128 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 125 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 129 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, | 126 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, |
| 130 const gfx::SizeF& scrollable_size_dip); | 127 const gfx::SizeF& scrollable_size_dip); |
| 131 | 128 |
| 132 scoped_ptr<cc::CompositorFrame> CompositeHw(); | 129 bool CompositeHw(); |
| 133 void ReturnUnusedResource(scoped_ptr<cc::CompositorFrame> frame); | 130 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); |
| 134 void ReturnResourceFromParent(); | 131 void ReturnResourceFromParent(); |
| 135 | 132 |
| 136 // 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, |
| 137 // then we keep ticking the SynchronousCompositor so it can make progress. | 134 // then we keep ticking the SynchronousCompositor so it can make progress. |
| 138 // 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, |
| 139 // 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. |
| 140 void PostFallbackTick(); | 137 void PostFallbackTick(); |
| 141 void FallbackTickFired(); | 138 void FallbackTickFired(); |
| 142 | 139 |
| 143 // 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 166 float dip_scale_; | 163 float dip_scale_; |
| 167 float page_scale_factor_; | 164 float page_scale_factor_; |
| 168 bool on_new_picture_enable_; | 165 bool on_new_picture_enable_; |
| 169 bool clear_view_; | 166 bool clear_view_; |
| 170 | 167 |
| 171 bool offscreen_pre_raster_; | 168 bool offscreen_pre_raster_; |
| 172 | 169 |
| 173 gfx::Vector2d last_on_draw_scroll_offset_; | 170 gfx::Vector2d last_on_draw_scroll_offset_; |
| 174 gfx::Rect last_on_draw_global_visible_rect_; | 171 gfx::Rect last_on_draw_global_visible_rect_; |
| 175 | 172 |
| 176 // The draw constraints from the parent compositor. These are only used for | |
| 177 // tiling priority. | |
| 178 ParentCompositorDrawConstraints parent_draw_constraints_; | |
| 179 | |
| 180 // When true, we should continuously invalidate and keep drawing, for example | 173 // When true, we should continuously invalidate and keep drawing, for example |
| 181 // to drive animation. This value is set by the compositor and should always | 174 // to drive animation. This value is set by the compositor and should always |
| 182 // reflect the expectation of the compositor and not be reused for other | 175 // reflect the expectation of the compositor and not be reused for other |
| 183 // states. | 176 // states. |
| 184 bool compositor_needs_continuous_invalidate_; | 177 bool compositor_needs_continuous_invalidate_; |
| 185 | 178 |
| 186 bool invalidate_after_composite_; | |
| 187 | |
| 188 // Used to block additional invalidates while one is already pending. | 179 // Used to block additional invalidates while one is already pending. |
| 189 bool block_invalidates_; | 180 bool block_invalidates_; |
| 190 | 181 |
| 191 base::CancelableClosure post_fallback_tick_; | 182 base::CancelableClosure post_fallback_tick_; |
| 192 base::CancelableClosure fallback_tick_fired_; | 183 base::CancelableClosure fallback_tick_fired_; |
| 193 bool fallback_tick_pending_; | 184 bool fallback_tick_pending_; |
| 194 | 185 |
| 195 gfx::Size size_; | 186 gfx::Size size_; |
| 196 | 187 |
| 197 // Current scroll offset in CSS pixels. | 188 // Current scroll offset in CSS pixels. |
| 198 gfx::Vector2dF scroll_offset_dip_; | 189 gfx::Vector2dF scroll_offset_dip_; |
| 199 | 190 |
| 200 // Max scroll offset in CSS pixels. | 191 // Max scroll offset in CSS pixels. |
| 201 gfx::Vector2dF max_scroll_offset_dip_; | 192 gfx::Vector2dF max_scroll_offset_dip_; |
| 202 | 193 |
| 203 // Used to prevent rounding errors from accumulating enough to generate | 194 // Used to prevent rounding errors from accumulating enough to generate |
| 204 // 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 |
| 205 // spot over a period of time). | 196 // spot over a period of time). |
| 206 gfx::Vector2dF overscroll_rounding_error_; | 197 gfx::Vector2dF overscroll_rounding_error_; |
| 207 | 198 |
| 208 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 199 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 209 }; | 200 }; |
| 210 | 201 |
| 211 } // namespace android_webview | 202 } // namespace android_webview |
| 212 | 203 |
| 213 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 204 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |