| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const gfx::Vector2dF& max_scroll_offset_dip, | 120 const gfx::Vector2dF& max_scroll_offset_dip, |
| 118 const gfx::SizeF& scrollable_size_dip, | 121 const gfx::SizeF& scrollable_size_dip, |
| 119 float page_scale_factor, | 122 float page_scale_factor, |
| 120 float min_page_scale_factor, | 123 float min_page_scale_factor, |
| 121 float max_page_scale_factor) override; | 124 float max_page_scale_factor) override; |
| 122 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, | 125 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, |
| 123 const gfx::Vector2dF& latest_overscroll_delta, | 126 const gfx::Vector2dF& latest_overscroll_delta, |
| 124 const gfx::Vector2dF& current_fling_velocity) override; | 127 const gfx::Vector2dF& current_fling_velocity) override; |
| 125 | 128 |
| 126 // CompositorFrameProducer overrides | 129 // CompositorFrameProducer overrides |
| 127 void OnParentDrawConstraintsUpdated() override; | 130 void OnParentDrawConstraintsUpdated( |
| 128 void OnCompositorFrameConsumerWillDestroy() override; | 131 CompositorFrameConsumer* compositor_frame_consumer) override; |
| 132 void RemoveCompositorFrameConsumer( |
| 133 CompositorFrameConsumer* compositor_frame_consumer) override; |
| 129 | 134 |
| 130 private: | 135 private: |
| 131 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); | 136 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); |
| 132 bool CanOnDraw(); | 137 bool CanOnDraw(); |
| 133 void UpdateCompositorIsActive(); | 138 void UpdateCompositorIsActive(); |
| 134 bool CompositeSW(SkCanvas* canvas); | 139 bool CompositeSW(SkCanvas* canvas); |
| 135 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 140 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 136 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, | 141 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, |
| 137 const gfx::SizeF& scrollable_size_dip); | 142 const gfx::SizeF& scrollable_size_dip); |
| 138 | 143 |
| 139 void ReturnUnusedResource(std::unique_ptr<ChildFrame> frame); | 144 void ReturnUnusedResource(std::unique_ptr<ChildFrame> frame); |
| 140 void ReturnResourceFromParent( | 145 void ReturnResourceFromParent( |
| 141 CompositorFrameConsumer* compositor_frame_consumer); | 146 CompositorFrameConsumer* compositor_frame_consumer); |
| 142 void ReleaseHardware(); | 147 void ReleaseHardware(); |
| 143 | 148 |
| 144 gfx::Vector2d max_scroll_offset() const; | 149 gfx::Vector2d max_scroll_offset() const; |
| 145 | 150 |
| 146 void UpdateMemoryPolicy(); | 151 void UpdateMemoryPolicy(); |
| 147 | 152 |
| 148 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); | 153 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); |
| 149 // For debug tracing or logging. Return the string representation of this | 154 // For debug tracing or logging. Return the string representation of this |
| 150 // view renderer's state. | 155 // view renderer's state. |
| 151 std::string ToString() const; | 156 std::string ToString() const; |
| 152 | 157 |
| 153 BrowserViewRendererClient* const client_; | 158 BrowserViewRendererClient* const client_; |
| 154 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 159 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 155 CompositorFrameConsumer* compositor_frame_consumer_; | 160 CompositorFrameConsumer* current_compositor_frame_consumer_; |
| 161 std::set<CompositorFrameConsumer*> compositor_frame_consumers_; |
| 156 | 162 |
| 157 // The current compositor that's owned by the current RVH. | 163 // The current compositor that's owned by the current RVH. |
| 158 content::SynchronousCompositor* compositor_; | 164 content::SynchronousCompositor* compositor_; |
| 159 // 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 |
| 160 // 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 |
| 161 // a compositor is destroyed. | 167 // a compositor is destroyed. |
| 162 std::map<size_t, content::SynchronousCompositor*> compositor_map_; | 168 std::map<size_t, content::SynchronousCompositor*> compositor_map_; |
| 163 | 169 |
| 164 bool is_paused_; | 170 bool is_paused_; |
| 165 bool view_visible_; | 171 bool view_visible_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 uint32_t next_compositor_id_; | 205 uint32_t next_compositor_id_; |
| 200 | 206 |
| 201 ParentCompositorDrawConstraints external_draw_constraints_; | 207 ParentCompositorDrawConstraints external_draw_constraints_; |
| 202 | 208 |
| 203 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); | 209 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); |
| 204 }; | 210 }; |
| 205 | 211 |
| 206 } // namespace android_webview | 212 } // namespace android_webview |
| 207 | 213 |
| 208 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ | 214 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ |
| OLD | NEW |