| 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 #include <set> |
| 11 | 12 |
| 12 #include "android_webview/browser/compositor_frame_producer.h" | 13 #include "android_webview/browser/compositor_frame_producer.h" |
| 13 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 14 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/cancelable_callback.h" | 16 #include "base/cancelable_callback.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 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 "third_party/skia/include/core/SkRefCnt.h" | 21 #include "third_party/skia/include/core/SkRefCnt.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 45 content::WebContents* web_contents); | 46 content::WebContents* web_contents); |
| 46 | 47 |
| 47 BrowserViewRenderer( | 48 BrowserViewRenderer( |
| 48 BrowserViewRendererClient* client, | 49 BrowserViewRendererClient* client, |
| 49 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); | 50 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); |
| 50 | 51 |
| 51 ~BrowserViewRenderer() override; | 52 ~BrowserViewRenderer() override; |
| 52 | 53 |
| 53 void RegisterWithWebContents(content::WebContents* web_contents); | 54 void RegisterWithWebContents(content::WebContents* web_contents); |
| 54 | 55 |
| 55 // The BrowserViewRenderer client is responsible for ensuring that the | 56 // The BrowserViewRenderer client is responsible for ensuring that |
| 56 // CompositorFrameConsumer has been set correctly via this method. | 57 // the current compositor frame consumer has been set correctly via |
| 57 void SetCompositorFrameConsumer( | 58 // this method. The consumer is added to the set of registered |
| 59 // consumers if it is not already registered. |
| 60 void SetCurrentCompositorFrameConsumer( |
| 58 CompositorFrameConsumer* compositor_frame_consumer); | 61 CompositorFrameConsumer* compositor_frame_consumer); |
| 59 | 62 |
| 60 // Called before either OnDrawHardware or OnDrawSoftware to set the view | 63 // Called before either OnDrawHardware or OnDrawSoftware to set the view |
| 61 // state of this frame. |scroll| is the view's current scroll offset. | 64 // state of this frame. |scroll| is the view's current scroll offset. |
| 62 // |global_visible_rect| is the intersection of the view size and the window | 65 // |global_visible_rect| is the intersection of the view size and the window |
| 63 // in window coordinates. | 66 // in window coordinates. |
| 64 void PrepareToDraw(const gfx::Vector2d& scroll, | 67 void PrepareToDraw(const gfx::Vector2d& scroll, |
| 65 const gfx::Rect& global_visible_rect); | 68 const gfx::Rect& global_visible_rect); |
| 66 | 69 |
| 67 // Main handlers for view drawing. A false return value indicates no new | 70 // Main handlers for view drawing. A false return value indicates no new |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 const gfx::Vector2dF& max_scroll_offset_dip, | 119 const gfx::Vector2dF& max_scroll_offset_dip, |
| 117 const gfx::SizeF& scrollable_size_dip, | 120 const gfx::SizeF& scrollable_size_dip, |
| 118 float page_scale_factor, | 121 float page_scale_factor, |
| 119 float min_page_scale_factor, | 122 float min_page_scale_factor, |
| 120 float max_page_scale_factor) override; | 123 float max_page_scale_factor) override; |
| 121 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 124 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 122 const gfx::Vector2dF& latest_overscroll_delta, | 125 const gfx::Vector2dF& latest_overscroll_delta, |
| 123 const gfx::Vector2dF& current_fling_velocity) override; | 126 const gfx::Vector2dF& current_fling_velocity) override; |
| 124 | 127 |
| 125 // CompositorFrameProducer overrides | 128 // CompositorFrameProducer overrides |
| 126 void OnParentDrawConstraintsUpdated() override; | 129 void OnParentDrawConstraintsUpdated( |
| 127 void OnCompositorFrameConsumerWillDestroy() override; | 130 CompositorFrameConsumer* compositor_frame_consumer) override; |
| 131 void RemoveCompositorFrameConsumer( |
| 132 CompositorFrameConsumer* compositor_frame_consumer) override; |
| 128 | 133 |
| 129 private: | 134 private: |
| 130 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 135 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); |
| 131 bool CanOnDraw(); | 136 bool CanOnDraw(); |
| 132 void UpdateCompositorIsActive(); | 137 void UpdateCompositorIsActive(); |
| 133 bool CompositeSW(SkCanvas* canvas); | 138 bool CompositeSW(SkCanvas* canvas); |
| 134 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 139 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 135 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, | 140 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, |
| 136 const gfx::SizeF& scrollable_size_dip); | 141 const gfx::SizeF& scrollable_size_dip); |
| 137 | 142 |
| 138 void ReturnUnusedResource(std::unique_ptr<ChildFrame> frame); | 143 void ReturnUnusedResource(std::unique_ptr<ChildFrame> frame); |
| 139 void ReturnResourceFromParent( | 144 void ReturnResourceFromParent( |
| 140 CompositorFrameConsumer* compositor_frame_consumer); | 145 CompositorFrameConsumer* compositor_frame_consumer); |
| 141 void ReleaseHardware(); | 146 void ReleaseHardware(); |
| 142 | 147 |
| 143 gfx::Vector2d max_scroll_offset() const; | 148 gfx::Vector2d max_scroll_offset() const; |
| 144 | 149 |
| 145 void UpdateMemoryPolicy(); | 150 void UpdateMemoryPolicy(); |
| 146 | 151 |
| 147 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); | 152 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); |
| 148 // For debug tracing or logging. Return the string representation of this | 153 // For debug tracing or logging. Return the string representation of this |
| 149 // view renderer's state. | 154 // view renderer's state. |
| 150 std::string ToString() const; | 155 std::string ToString() const; |
| 151 | 156 |
| 152 BrowserViewRendererClient* const client_; | 157 BrowserViewRendererClient* const client_; |
| 153 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 158 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 154 CompositorFrameConsumer* compositor_frame_consumer_; | 159 CompositorFrameConsumer* current_compositor_frame_consumer_; |
| 160 std::set<CompositorFrameConsumer*> compositor_frame_consumers_; |
| 155 | 161 |
| 156 // The current compositor that's owned by the current RVH. | 162 // The current compositor that's owned by the current RVH. |
| 157 content::SynchronousCompositor* compositor_; | 163 content::SynchronousCompositor* compositor_; |
| 158 // A map from compositor's per-WebView unique ID to the compositor's raw | 164 // A map from compositor's per-WebView unique ID to the compositor's raw |
| 159 // pointer. A raw pointer here is fine because the entry will be erased when | 165 // pointer. A raw pointer here is fine because the entry will be erased when |
| 160 // a compositor is destroyed. | 166 // a compositor is destroyed. |
| 161 std::map<size_t, content::SynchronousCompositor*> compositor_map_; | 167 std::map<size_t, content::SynchronousCompositor*> compositor_map_; |
| 162 | 168 |
| 163 bool is_paused_; | 169 bool is_paused_; |
| 164 bool view_visible_; | 170 bool view_visible_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 uint32_t next_compositor_id_; | 204 uint32_t next_compositor_id_; |
| 199 | 205 |
| 200 ParentCompositorDrawConstraints external_draw_constraints_; | 206 ParentCompositorDrawConstraints external_draw_constraints_; |
| 201 | 207 |
| 202 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 208 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 203 }; | 209 }; |
| 204 | 210 |
| 205 } // namespace android_webview | 211 } // namespace android_webview |
| 206 | 212 |
| 207 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 213 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |