| 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 SharedRendererState* GetAwDrawGLViewContext(); | 54 // The BrowserViewRenderer client is responsible for ensuring that the |
| 55 bool RequestDrawGL(bool wait_for_completion); | 55 // SharedRendererState has been set correctly via this method. |
| 56 void SetSharedRendererState(SharedRendererState* shared_renderer_state); |
| 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. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 90 | 91 |
| 91 // Set the root layer scroll offset to |new_value|. | 92 // Set the root layer scroll offset to |new_value|. |
| 92 void ScrollTo(const gfx::Vector2d& new_value); | 93 void ScrollTo(const gfx::Vector2d& new_value); |
| 93 | 94 |
| 94 // Android views hierarchy gluing. | 95 // Android views hierarchy gluing. |
| 95 bool IsVisible() const; | 96 bool IsVisible() const; |
| 96 gfx::Rect GetScreenRect() const; | 97 gfx::Rect GetScreenRect() const; |
| 97 bool attached_to_window() const { return attached_to_window_; } | 98 bool attached_to_window() const { return attached_to_window_; } |
| 98 bool hardware_enabled() const { return hardware_enabled_; } | 99 bool hardware_enabled() const { return hardware_enabled_; } |
| 99 gfx::Size size() const { return size_; } | 100 gfx::Size size() const { return size_; } |
| 100 void ReleaseHardware(); | |
| 101 | 101 |
| 102 bool IsClientVisible() const; | 102 bool IsClientVisible() const; |
| 103 void TrimMemory(const int level, const bool visible); | 103 void TrimMemory(); |
| 104 | 104 |
| 105 // SynchronousCompositorClient overrides. | 105 // SynchronousCompositorClient overrides. |
| 106 void DidInitializeCompositor( | 106 void DidInitializeCompositor( |
| 107 content::SynchronousCompositor* compositor) override; | 107 content::SynchronousCompositor* compositor) override; |
| 108 void DidDestroyCompositor( | 108 void DidDestroyCompositor( |
| 109 content::SynchronousCompositor* compositor) override; | 109 content::SynchronousCompositor* compositor) override; |
| 110 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; | 110 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; |
| 111 void PostInvalidate() override; | 111 void PostInvalidate() override; |
| 112 void DidUpdateContent() override; | 112 void DidUpdateContent() override; |
| 113 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, | 113 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, |
| 114 const gfx::Vector2dF& max_scroll_offset_dip, | 114 const gfx::Vector2dF& max_scroll_offset_dip, |
| 115 const gfx::SizeF& scrollable_size_dip, | 115 const gfx::SizeF& scrollable_size_dip, |
| 116 float page_scale_factor, | 116 float page_scale_factor, |
| 117 float min_page_scale_factor, | 117 float min_page_scale_factor, |
| 118 float max_page_scale_factor) override; | 118 float max_page_scale_factor) override; |
| 119 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 119 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 120 const gfx::Vector2dF& latest_overscroll_delta, | 120 const gfx::Vector2dF& latest_overscroll_delta, |
| 121 const gfx::Vector2dF& current_fling_velocity) override; | 121 const gfx::Vector2dF& current_fling_velocity) override; |
| 122 | 122 |
| 123 void UpdateParentDrawConstraints(); | 123 void OnParentDrawConstraintsUpdated(); |
| 124 void DetachFunctorFromView(); | 124 void DetachFunctorFromView(); |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 127 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); |
| 128 bool CanOnDraw(); | 128 bool CanOnDraw(); |
| 129 void UpdateCompositorIsActive(); | 129 void UpdateCompositorIsActive(); |
| 130 bool CompositeSW(SkCanvas* canvas); | 130 bool CompositeSW(SkCanvas* canvas); |
| 131 scoped_ptr<base::trace_event::ConvertableToTraceFormat> RootLayerStateAsValue( | 131 scoped_ptr<base::trace_event::ConvertableToTraceFormat> RootLayerStateAsValue( |
| 132 const gfx::Vector2dF& total_scroll_offset_dip, | 132 const gfx::Vector2dF& total_scroll_offset_dip, |
| 133 const gfx::SizeF& scrollable_size_dip); | 133 const gfx::SizeF& scrollable_size_dip); |
| 134 | 134 |
| 135 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | 135 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); |
| 136 void ReturnResourceFromParent(); | 136 void ReturnResourceFromParent(); |
| 137 | 137 |
| 138 gfx::Vector2d max_scroll_offset() const; | 138 gfx::Vector2d max_scroll_offset() const; |
| 139 | 139 |
| 140 void UpdateMemoryPolicy(); | 140 void UpdateMemoryPolicy(); |
| 141 | 141 |
| 142 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); | 142 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); |
| 143 // For debug tracing or logging. Return the string representation of this | 143 // For debug tracing or logging. Return the string representation of this |
| 144 // view renderer's state. | 144 // view renderer's state. |
| 145 std::string ToString() const; | 145 std::string ToString() const; |
| 146 | 146 |
| 147 BrowserViewRendererClient* client_; | 147 BrowserViewRendererClient* const client_; |
| 148 SharedRendererState shared_renderer_state_; | 148 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 149 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 149 SharedRendererState* shared_renderer_state_; |
| 150 bool disable_page_visibility_; | 150 bool disable_page_visibility_; |
| 151 | 151 |
| 152 // The current compositor that's owned by the current RVH. | 152 // The current compositor that's owned by the current RVH. |
| 153 content::SynchronousCompositor* compositor_; | 153 content::SynchronousCompositor* compositor_; |
| 154 // A map from compositor's per-WebView unique ID to the compositor's raw | 154 // 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 | 155 // pointer. A raw pointer here is fine because the entry will be erased when |
| 156 // a compositor is destroyed. | 156 // a compositor is destroyed. |
| 157 std::map<size_t, content::SynchronousCompositor*> compositor_map_; | 157 std::map<size_t, content::SynchronousCompositor*> compositor_map_; |
| 158 | 158 |
| 159 bool is_paused_; | 159 bool is_paused_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 186 gfx::Vector2dF max_scroll_offset_dip_; | 186 gfx::Vector2dF max_scroll_offset_dip_; |
| 187 | 187 |
| 188 // Used to prevent rounding errors from accumulating enough to generate | 188 // Used to prevent rounding errors from accumulating enough to generate |
| 189 // visible skew (especially noticeable when scrolling up and down in the same | 189 // visible skew (especially noticeable when scrolling up and down in the same |
| 190 // spot over a period of time). | 190 // spot over a period of time). |
| 191 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. | 191 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. |
| 192 gfx::Vector2dF overscroll_rounding_error_; | 192 gfx::Vector2dF overscroll_rounding_error_; |
| 193 | 193 |
| 194 uint32_t next_compositor_id_; | 194 uint32_t next_compositor_id_; |
| 195 | 195 |
| 196 ParentCompositorDrawConstraints external_draw_constraints_; |
| 197 |
| 196 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 198 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 197 }; | 199 }; |
| 198 | 200 |
| 199 } // namespace android_webview | 201 } // namespace android_webview |
| 200 | 202 |
| 201 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 203 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |