Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 BrowserViewRenderer( | 45 BrowserViewRenderer( |
| 46 BrowserViewRendererClient* client, | 46 BrowserViewRendererClient* client, |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 48 bool disable_page_visibility); | 48 bool disable_page_visibility); |
| 49 | 49 |
| 50 ~BrowserViewRenderer() override; | 50 ~BrowserViewRenderer() override; |
| 51 | 51 |
| 52 void RegisterWithWebContents(content::WebContents* web_contents); | 52 void RegisterWithWebContents(content::WebContents* web_contents); |
| 53 | 53 |
| 54 void SetSharedRendererState(SharedRendererState* shared_renderer_state); | |
| 54 SharedRendererState* GetAwDrawGLViewContext(); | 55 SharedRendererState* GetAwDrawGLViewContext(); |
| 55 bool RequestDrawGL(bool wait_for_completion); | 56 bool RequestDrawGL(bool wait_for_completion); |
| 56 | 57 |
| 57 // Called before either OnDrawHardware or OnDrawSoftware to set the view | 58 // Called before either OnDrawHardware or OnDrawSoftware to set the view |
| 58 // state of this frame. |scroll| is the view's current scroll offset. | 59 // state of this frame. |scroll| is the view's current scroll offset. |
| 59 // |global_visible_rect| is the intersection of the view size and the window | 60 // |global_visible_rect| is the intersection of the view size and the window |
| 60 // in window coordinates. | 61 // in window coordinates. |
| 61 void PrepareToDraw(const gfx::Vector2d& scroll, | 62 void PrepareToDraw(const gfx::Vector2d& scroll, |
| 62 const gfx::Rect& global_visible_rect); | 63 const gfx::Rect& global_visible_rect); |
| 63 | 64 |
| 64 // Main handlers for view drawing. A false return value indicates no new | 65 // Main handlers for view drawing. A false return value indicates no new |
| 65 // frame is produced. | 66 // frame is produced. |
| 66 bool OnDrawHardware(); | 67 scoped_ptr<ChildFrame> OnDrawHardware( |
| 68 const ParentCompositorDrawConstraints& parent_draw_constraints); | |
| 67 bool OnDrawSoftware(SkCanvas* canvas); | 69 bool OnDrawSoftware(SkCanvas* canvas); |
| 68 | 70 |
| 69 // CapturePicture API methods. | 71 // CapturePicture API methods. |
| 70 skia::RefPtr<SkPicture> CapturePicture(int width, int height); | 72 skia::RefPtr<SkPicture> CapturePicture(int width, int height); |
| 71 void EnableOnNewPicture(bool enabled); | 73 void EnableOnNewPicture(bool enabled); |
| 72 | 74 |
| 73 void ClearView(); | 75 void ClearView(); |
| 74 | 76 |
| 75 void SetOffscreenPreRaster(bool enabled); | 77 void SetOffscreenPreRaster(bool enabled); |
| 78 bool offscreen_pre_raster() { | |
| 79 return offscreen_pre_raster_; | |
| 80 } | |
| 76 | 81 |
| 77 // View update notifications. | 82 // View update notifications. |
| 78 void SetIsPaused(bool paused); | 83 void SetIsPaused(bool paused); |
| 79 void SetViewVisibility(bool visible); | 84 void SetViewVisibility(bool visible); |
| 80 void SetWindowVisibility(bool visible); | 85 void SetWindowVisibility(bool visible); |
| 81 void OnSizeChanged(int width, int height); | 86 void OnSizeChanged(int width, int height); |
| 82 void OnAttachedToWindow(int width, int height); | 87 void OnAttachedToWindow(int width, int height); |
| 83 void OnDetachedFromWindow(); | 88 void OnDetachedFromWindow(); |
| 84 void OnComputeScroll(base::TimeTicks animation_time); | 89 void OnComputeScroll(base::TimeTicks animation_time); |
| 85 | 90 |
| 86 // Sets the scale for logical<->physical pixel conversions. | 91 // Sets the scale for logical<->physical pixel conversions. |
| 87 void SetDipScale(float dip_scale); | 92 void SetDipScale(float dip_scale); |
| 88 float dip_scale() const { return dip_scale_; } | 93 float dip_scale() const { return dip_scale_; } |
| 89 float page_scale_factor() const { return page_scale_factor_; } | 94 float page_scale_factor() const { return page_scale_factor_; } |
| 90 | 95 |
| 91 // Set the root layer scroll offset to |new_value|. | 96 // Set the root layer scroll offset to |new_value|. |
| 92 void ScrollTo(const gfx::Vector2d& new_value); | 97 void ScrollTo(const gfx::Vector2d& new_value); |
| 93 | 98 |
| 94 // Android views hierarchy gluing. | 99 // Android views hierarchy gluing. |
| 95 bool IsVisible() const; | 100 bool IsVisible() const; |
| 96 gfx::Rect GetScreenRect() const; | 101 gfx::Rect GetScreenRect() const; |
| 97 bool attached_to_window() const { return attached_to_window_; } | 102 bool attached_to_window() const { return attached_to_window_; } |
| 98 bool hardware_enabled() const { return hardware_enabled_; } | 103 bool hardware_enabled() const { return hardware_enabled_; } |
| 99 gfx::Size size() const { return size_; } | 104 gfx::Size size() const { return size_; } |
| 100 void ReleaseHardware(); | |
| 101 | 105 |
| 102 bool IsClientVisible() const; | 106 bool IsClientVisible() const; |
| 103 void TrimMemory(const int level, const bool visible); | 107 void TrimMemory(const int level, const bool visible); |
| 104 | 108 |
| 105 // SynchronousCompositorClient overrides. | 109 // SynchronousCompositorClient overrides. |
| 106 void DidInitializeCompositor( | 110 void DidInitializeCompositor( |
| 107 content::SynchronousCompositor* compositor) override; | 111 content::SynchronousCompositor* compositor) override; |
| 108 void DidDestroyCompositor( | 112 void DidDestroyCompositor( |
| 109 content::SynchronousCompositor* compositor) override; | 113 content::SynchronousCompositor* compositor) override; |
| 110 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; | 114 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; |
| 111 void PostInvalidate() override; | 115 void PostInvalidate() override; |
| 112 void DidUpdateContent() override; | 116 void DidUpdateContent() override; |
| 113 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, | 117 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, |
| 114 const gfx::Vector2dF& max_scroll_offset_dip, | 118 const gfx::Vector2dF& max_scroll_offset_dip, |
| 115 const gfx::SizeF& scrollable_size_dip, | 119 const gfx::SizeF& scrollable_size_dip, |
| 116 float page_scale_factor, | 120 float page_scale_factor, |
| 117 float min_page_scale_factor, | 121 float min_page_scale_factor, |
| 118 float max_page_scale_factor) override; | 122 float max_page_scale_factor) override; |
| 119 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 123 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 120 const gfx::Vector2dF& latest_overscroll_delta, | 124 const gfx::Vector2dF& latest_overscroll_delta, |
| 121 const gfx::Vector2dF& current_fling_velocity) override; | 125 const gfx::Vector2dF& current_fling_velocity) override; |
| 122 | 126 |
| 123 void UpdateParentDrawConstraints(); | 127 void UpdateParentDrawConstraints(); |
| 124 void DetachFunctorFromView(); | 128 void DetachFunctorFromView(); |
| 125 | 129 |
| 130 gfx::Vector2d last_on_draw_scroll_offset() { | |
|
boliu
2016/03/23 20:42:32
I was wrong. last_on_draw_scroll_offset_ can be re
Tobias Sargeant
2016/03/24 16:53:05
Done.
| |
| 131 return last_on_draw_scroll_offset_; | |
| 132 } | |
| 133 | |
| 134 gfx::Rect GetInterestRect(bool is_layer) const; | |
| 135 void UpdateMemoryPolicy(gfx::Rect interest_rect); | |
|
boliu
2016/03/23 20:42:32
GetInterestRect and UpdateMemoryPolicy can be merg
boliu
2016/03/23 20:46:11
As in SetParentDrawConstraints will also do the Up
| |
| 136 | |
| 137 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | |
| 138 void ReturnResourceFromParent(uint32_t compositor_id, | |
| 139 uint32_t output_surface_id, | |
| 140 cc::ReturnedResourceArray* resources); | |
| 141 | |
| 126 private: | 142 private: |
| 127 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 143 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); |
| 128 bool CanOnDraw(); | 144 bool CanOnDraw(); |
| 129 void UpdateCompositorIsActive(); | 145 void UpdateCompositorIsActive(); |
| 130 bool CompositeSW(SkCanvas* canvas); | 146 bool CompositeSW(SkCanvas* canvas); |
| 131 scoped_ptr<base::trace_event::ConvertableToTraceFormat> RootLayerStateAsValue( | 147 scoped_ptr<base::trace_event::ConvertableToTraceFormat> RootLayerStateAsValue( |
| 132 const gfx::Vector2dF& total_scroll_offset_dip, | 148 const gfx::Vector2dF& total_scroll_offset_dip, |
| 133 const gfx::SizeF& scrollable_size_dip); | 149 const gfx::SizeF& scrollable_size_dip); |
| 134 | 150 |
| 135 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | |
| 136 void ReturnResourceFromParent(); | |
| 137 | |
| 138 gfx::Vector2d max_scroll_offset() const; | 151 gfx::Vector2d max_scroll_offset() const; |
| 139 | 152 |
| 140 void UpdateMemoryPolicy(); | |
| 141 | |
| 142 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); | 153 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); |
| 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_; |
|
boliu
2016/03/23 20:42:32
should remove this from this patch, only one usage
| |
| 149 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 160 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 150 bool disable_page_visibility_; | 161 bool disable_page_visibility_; |
| 151 | 162 |
| 152 // The current compositor that's owned by the current RVH. | 163 // The current compositor that's owned by the current RVH. |
| 153 content::SynchronousCompositor* compositor_; | 164 content::SynchronousCompositor* compositor_; |
| 154 // A map from compositor's per-WebView unique ID to the compositor's raw | 165 // A map from compositor's per-WebView unique ID to the compositor's raw |
| 155 // pointer. A raw pointer here is fine because the entry will be erased when | 166 // pointer. A raw pointer here is fine because the entry will be erased when |
| 156 // a compositor is destroyed. | 167 // a compositor is destroyed. |
| 157 std::map<size_t, content::SynchronousCompositor*> compositor_map_; | 168 std::map<size_t, content::SynchronousCompositor*> compositor_map_; |
| 158 | 169 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 179 | 190 |
| 180 // Current scroll offset in CSS pixels. | 191 // Current scroll offset in CSS pixels. |
| 181 // TODO(miletus): Make scroll_offset_dip_ a gfx::ScrollOffset. | 192 // TODO(miletus): Make scroll_offset_dip_ a gfx::ScrollOffset. |
| 182 gfx::Vector2dF scroll_offset_dip_; | 193 gfx::Vector2dF scroll_offset_dip_; |
| 183 | 194 |
| 184 // Max scroll offset in CSS pixels. | 195 // Max scroll offset in CSS pixels. |
| 185 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. | 196 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. |
| 186 gfx::Vector2dF max_scroll_offset_dip_; | 197 gfx::Vector2dF max_scroll_offset_dip_; |
| 187 | 198 |
| 188 // Used to prevent rounding errors from accumulating enough to generate | 199 // Used to prevent rounding errors from accumulating enough to generate |
| 189 // visible skew (especially noticeable when scrolling up and down in the same | 200 // visible skew (especially noticeable when scrolling up and down in the |
| 201 // same | |
|
boliu
2016/03/23 20:42:32
undo this change
Tobias Sargeant
2016/03/24 16:53:05
Done.
| |
| 190 // spot over a period of time). | 202 // spot over a period of time). |
| 191 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. | 203 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. |
| 192 gfx::Vector2dF overscroll_rounding_error_; | 204 gfx::Vector2dF overscroll_rounding_error_; |
| 193 | 205 |
| 194 uint32_t next_compositor_id_; | 206 uint32_t next_compositor_id_; |
| 195 | 207 |
| 196 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 208 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 197 }; | 209 }; |
| 198 | 210 |
| 199 } // namespace android_webview | 211 } // namespace android_webview |
| 200 | 212 |
| 201 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 213 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |