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> |
| 11 | 11 |
| 12 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 12 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 13 #include "android_webview/browser/shared_renderer_state.h" | 13 #include "android_webview/browser/shared_renderer_state.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/cancelable_callback.h" | 15 #include "base/cancelable_callback.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "cc/resources/returned_resource.h" | |
|
boliu
2016/03/30 16:12:13
header not needed by BVR. Is it used by aw_content
Tobias Sargeant
2016/03/30 17:17:16
Removed. Was a leftover from when AwContents used
| |
| 18 #include "content/public/browser/android/synchronous_compositor.h" | 19 #include "content/public/browser/android/synchronous_compositor.h" |
| 19 #include "content/public/browser/android/synchronous_compositor_client.h" | 20 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 20 #include "skia/ext/refptr.h" | 21 #include "skia/ext/refptr.h" |
| 21 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 22 #include "ui/gfx/geometry/size_f.h" | 23 #include "ui/gfx/geometry/size_f.h" |
| 23 #include "ui/gfx/geometry/vector2d_f.h" | 24 #include "ui/gfx/geometry/vector2d_f.h" |
| 24 | 25 |
| 25 class SkCanvas; | 26 class SkCanvas; |
| 26 class SkPicture; | 27 class SkPicture; |
| 27 | 28 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 43 content::WebContents* web_contents); | 44 content::WebContents* web_contents); |
| 44 | 45 |
| 45 BrowserViewRenderer( | 46 BrowserViewRenderer( |
| 46 BrowserViewRendererClient* client, | 47 BrowserViewRendererClient* client, |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 48 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 48 bool disable_page_visibility); | 49 bool disable_page_visibility); |
| 49 | 50 |
| 50 ~BrowserViewRenderer() override; | 51 ~BrowserViewRenderer() override; |
| 51 | 52 |
| 52 void RegisterWithWebContents(content::WebContents* web_contents); | 53 void RegisterWithWebContents(content::WebContents* web_contents); |
| 53 | 54 void SetSharedRendererState(SharedRendererState* shared_renderer_state); |
| 54 SharedRendererState* GetAwDrawGLViewContext(); | |
| 55 bool RequestDrawGL(bool wait_for_completion); | |
| 56 | 55 |
| 57 // Called before either OnDrawHardware or OnDrawSoftware to set the view | 56 // Called before either OnDrawHardware or OnDrawSoftware to set the view |
| 58 // state of this frame. |scroll| is the view's current scroll offset. | 57 // 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 | 58 // |global_visible_rect| is the intersection of the view size and the window |
| 60 // in window coordinates. | 59 // in window coordinates. |
| 61 void PrepareToDraw(const gfx::Vector2d& scroll, | 60 void PrepareToDraw(const gfx::Vector2d& scroll, |
| 62 const gfx::Rect& global_visible_rect); | 61 const gfx::Rect& global_visible_rect); |
| 63 | 62 |
| 64 // Main handlers for view drawing. A false return value indicates no new | 63 // Main handlers for view drawing. A false return value indicates no new |
| 65 // frame is produced. | 64 // frame is produced. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 90 | 89 |
| 91 // Set the root layer scroll offset to |new_value|. | 90 // Set the root layer scroll offset to |new_value|. |
| 92 void ScrollTo(const gfx::Vector2d& new_value); | 91 void ScrollTo(const gfx::Vector2d& new_value); |
| 93 | 92 |
| 94 // Android views hierarchy gluing. | 93 // Android views hierarchy gluing. |
| 95 bool IsVisible() const; | 94 bool IsVisible() const; |
| 96 gfx::Rect GetScreenRect() const; | 95 gfx::Rect GetScreenRect() const; |
| 97 bool attached_to_window() const { return attached_to_window_; } | 96 bool attached_to_window() const { return attached_to_window_; } |
| 98 bool hardware_enabled() const { return hardware_enabled_; } | 97 bool hardware_enabled() const { return hardware_enabled_; } |
| 99 gfx::Size size() const { return size_; } | 98 gfx::Size size() const { return size_; } |
| 100 void ReleaseHardware(); | |
| 101 | 99 |
| 102 bool IsClientVisible() const; | 100 bool IsClientVisible() const; |
| 103 void TrimMemory(const int level, const bool visible); | 101 void TrimMemory(); |
| 104 | 102 |
| 105 // SynchronousCompositorClient overrides. | 103 // SynchronousCompositorClient overrides. |
| 106 void DidInitializeCompositor( | 104 void DidInitializeCompositor( |
| 107 content::SynchronousCompositor* compositor) override; | 105 content::SynchronousCompositor* compositor) override; |
| 108 void DidDestroyCompositor( | 106 void DidDestroyCompositor( |
| 109 content::SynchronousCompositor* compositor) override; | 107 content::SynchronousCompositor* compositor) override; |
| 110 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; | 108 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; |
| 111 void PostInvalidate() override; | 109 void PostInvalidate() override; |
| 112 void DidUpdateContent() override; | 110 void DidUpdateContent() override; |
| 113 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, | 111 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, |
| 114 const gfx::Vector2dF& max_scroll_offset_dip, | 112 const gfx::Vector2dF& max_scroll_offset_dip, |
| 115 const gfx::SizeF& scrollable_size_dip, | 113 const gfx::SizeF& scrollable_size_dip, |
| 116 float page_scale_factor, | 114 float page_scale_factor, |
| 117 float min_page_scale_factor, | 115 float min_page_scale_factor, |
| 118 float max_page_scale_factor) override; | 116 float max_page_scale_factor) override; |
| 119 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 117 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 120 const gfx::Vector2dF& latest_overscroll_delta, | 118 const gfx::Vector2dF& latest_overscroll_delta, |
| 121 const gfx::Vector2dF& current_fling_velocity) override; | 119 const gfx::Vector2dF& current_fling_velocity) override; |
| 122 | 120 |
| 123 void UpdateParentDrawConstraints(); | 121 void UpdateParentDrawConstraints(const ParentCompositorDrawConstraints&); |
| 124 void DetachFunctorFromView(); | 122 void DetachFunctorFromView(); |
| 125 | 123 |
| 126 private: | 124 private: |
| 127 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 125 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); |
| 128 bool CanOnDraw(); | 126 bool CanOnDraw(); |
| 129 void UpdateCompositorIsActive(); | 127 void UpdateCompositorIsActive(); |
| 130 bool CompositeSW(SkCanvas* canvas); | 128 bool CompositeSW(SkCanvas* canvas); |
| 131 scoped_ptr<base::trace_event::ConvertableToTraceFormat> RootLayerStateAsValue( | 129 scoped_ptr<base::trace_event::ConvertableToTraceFormat> RootLayerStateAsValue( |
| 132 const gfx::Vector2dF& total_scroll_offset_dip, | 130 const gfx::Vector2dF& total_scroll_offset_dip, |
| 133 const gfx::SizeF& scrollable_size_dip); | 131 const gfx::SizeF& scrollable_size_dip); |
| 134 | 132 |
| 135 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); | 133 void ReturnUnusedResource(scoped_ptr<ChildFrame> frame); |
| 136 void ReturnResourceFromParent(); | 134 void ReturnResourceFromParent(); |
| 137 | 135 |
| 138 gfx::Vector2d max_scroll_offset() const; | 136 gfx::Vector2d max_scroll_offset() const; |
| 139 | 137 |
| 140 void UpdateMemoryPolicy(); | 138 void UpdateMemoryPolicy(); |
| 141 | 139 |
| 142 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); | 140 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); |
| 143 // For debug tracing or logging. Return the string representation of this | 141 // For debug tracing or logging. Return the string representation of this |
| 144 // view renderer's state. | 142 // view renderer's state. |
| 145 std::string ToString() const; | 143 std::string ToString() const; |
| 146 | 144 |
| 147 BrowserViewRendererClient* client_; | 145 BrowserViewRendererClient* const client_; |
| 148 SharedRendererState shared_renderer_state_; | 146 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 149 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 147 SharedRendererState* shared_renderer_state_; |
| 150 bool disable_page_visibility_; | 148 bool disable_page_visibility_; |
| 151 | 149 |
| 152 // The current compositor that's owned by the current RVH. | 150 // The current compositor that's owned by the current RVH. |
| 153 content::SynchronousCompositor* compositor_; | 151 content::SynchronousCompositor* compositor_; |
| 154 // A map from compositor's per-WebView unique ID to the compositor's raw | 152 // 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 | 153 // pointer. A raw pointer here is fine because the entry will be erased when |
| 156 // a compositor is destroyed. | 154 // a compositor is destroyed. |
| 157 std::map<size_t, content::SynchronousCompositor*> compositor_map_; | 155 std::map<size_t, content::SynchronousCompositor*> compositor_map_; |
| 158 | 156 |
| 159 bool is_paused_; | 157 bool is_paused_; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 186 gfx::Vector2dF max_scroll_offset_dip_; | 184 gfx::Vector2dF max_scroll_offset_dip_; |
| 187 | 185 |
| 188 // Used to prevent rounding errors from accumulating enough to generate | 186 // Used to prevent rounding errors from accumulating enough to generate |
| 189 // visible skew (especially noticeable when scrolling up and down in the same | 187 // visible skew (especially noticeable when scrolling up and down in the same |
| 190 // spot over a period of time). | 188 // spot over a period of time). |
| 191 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. | 189 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. |
| 192 gfx::Vector2dF overscroll_rounding_error_; | 190 gfx::Vector2dF overscroll_rounding_error_; |
| 193 | 191 |
| 194 uint32_t next_compositor_id_; | 192 uint32_t next_compositor_id_; |
| 195 | 193 |
| 194 ParentCompositorDrawConstraints external_draw_constraints_; | |
| 195 | |
| 196 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 196 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 } // namespace android_webview | 199 } // namespace android_webview |
| 200 | 200 |
| 201 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 201 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |