Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: android_webview/browser/browser_view_renderer.h

Issue 2036023002: Rewire Android WebView's compositor changed signal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use web_contents_ Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « android_webview/android_webview.gyp ('k') | android_webview/browser/browser_view_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <set>
12 12
13 #include "android_webview/browser/compositor_frame_producer.h" 13 #include "android_webview/browser/compositor_frame_producer.h"
14 #include "android_webview/browser/compositor_id.h"
14 #include "android_webview/browser/parent_compositor_draw_constraints.h" 15 #include "android_webview/browser/parent_compositor_draw_constraints.h"
15 #include "base/callback.h" 16 #include "base/callback.h"
16 #include "base/cancelable_callback.h" 17 #include "base/cancelable_callback.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
19 #include "content/public/browser/android/synchronous_compositor.h" 20 #include "content/public/browser/android/synchronous_compositor.h"
20 #include "content/public/browser/android/synchronous_compositor_client.h" 21 #include "content/public/browser/android/synchronous_compositor_client.h"
21 #include "third_party/skia/include/core/SkRefCnt.h" 22 #include "third_party/skia/include/core/SkRefCnt.h"
22 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
23 #include "ui/gfx/geometry/size_f.h" 24 #include "ui/gfx/geometry/size_f.h"
24 #include "ui/gfx/geometry/vector2d_f.h" 25 #include "ui/gfx/geometry/vector2d_f.h"
25 26
26 class SkCanvas; 27 class SkCanvas;
27 class SkPicture; 28 class SkPicture;
28 29
29 namespace content { 30 namespace content {
31 class RenderViewHost;
30 class WebContents; 32 class WebContents;
31 } 33 }
32 34
33 namespace android_webview { 35 namespace android_webview {
34 36
35 class BrowserViewRendererClient; 37 class BrowserViewRendererClient;
36 class ChildFrame; 38 class ChildFrame;
37 class CompositorFrameConsumer; 39 class CompositorFrameConsumer;
38 40
39 // Interface for all the WebView-specific content rendering operations. 41 // Interface for all the WebView-specific content rendering operations.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Android views hierarchy gluing. 103 // Android views hierarchy gluing.
102 bool IsVisible() const; 104 bool IsVisible() const;
103 gfx::Rect GetScreenRect() const; 105 gfx::Rect GetScreenRect() const;
104 bool attached_to_window() const { return attached_to_window_; } 106 bool attached_to_window() const { return attached_to_window_; }
105 gfx::Size size() const { return size_; } 107 gfx::Size size() const { return size_; }
106 108
107 bool IsClientVisible() const; 109 bool IsClientVisible() const;
108 void TrimMemory(); 110 void TrimMemory();
109 111
110 // SynchronousCompositorClient overrides. 112 // SynchronousCompositorClient overrides.
111 void DidInitializeCompositor( 113 void DidInitializeCompositor(content::SynchronousCompositor* compositor,
112 content::SynchronousCompositor* compositor) override; 114 int process_id,
113 void DidDestroyCompositor( 115 int routing_id) override;
114 content::SynchronousCompositor* compositor) override; 116 void DidDestroyCompositor(content::SynchronousCompositor* compositor,
115 void DidBecomeCurrent(content::SynchronousCompositor* compositor) override; 117 int process_id,
118 int routing_id) override;
116 void PostInvalidate() override; 119 void PostInvalidate() override;
117 void DidUpdateContent() override; 120 void DidUpdateContent() override;
118 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip, 121 void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset_dip,
119 const gfx::Vector2dF& max_scroll_offset_dip, 122 const gfx::Vector2dF& max_scroll_offset_dip,
120 const gfx::SizeF& scrollable_size_dip, 123 const gfx::SizeF& scrollable_size_dip,
121 float page_scale_factor, 124 float page_scale_factor,
122 float min_page_scale_factor, 125 float min_page_scale_factor,
123 float max_page_scale_factor) override; 126 float max_page_scale_factor) override;
124 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll, 127 void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll,
125 const gfx::Vector2dF& latest_overscroll_delta, 128 const gfx::Vector2dF& latest_overscroll_delta,
126 const gfx::Vector2dF& current_fling_velocity) override; 129 const gfx::Vector2dF& current_fling_velocity) override;
127 130
128 // CompositorFrameProducer overrides 131 // CompositorFrameProducer overrides
129 void OnParentDrawConstraintsUpdated( 132 void OnParentDrawConstraintsUpdated(
130 CompositorFrameConsumer* compositor_frame_consumer) override; 133 CompositorFrameConsumer* compositor_frame_consumer) override;
131 void RemoveCompositorFrameConsumer( 134 void RemoveCompositorFrameConsumer(
132 CompositorFrameConsumer* compositor_frame_consumer) override; 135 CompositorFrameConsumer* compositor_frame_consumer) override;
133 136
137 void SetActiveCompositorID(const CompositorID& compositor_id);
138
134 private: 139 private:
135 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip); 140 void SetTotalRootLayerScrollOffset(const gfx::Vector2dF& new_value_dip);
136 bool CanOnDraw(); 141 bool CanOnDraw();
137 bool CompositeSW(SkCanvas* canvas); 142 bool CompositeSW(SkCanvas* canvas);
138 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 143 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
139 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip, 144 RootLayerStateAsValue(const gfx::Vector2dF& total_scroll_offset_dip,
140 const gfx::SizeF& scrollable_size_dip); 145 const gfx::SizeF& scrollable_size_dip);
141 146
142 void ReturnUnusedResource(std::unique_ptr<ChildFrame> frame); 147 void ReturnUnusedResource(std::unique_ptr<ChildFrame> frame);
143 void ReturnResourceFromParent( 148 void ReturnResourceFromParent(
144 CompositorFrameConsumer* compositor_frame_consumer); 149 CompositorFrameConsumer* compositor_frame_consumer);
145 void ReleaseHardware(); 150 void ReleaseHardware();
146 151
147 gfx::Vector2d max_scroll_offset() const; 152 gfx::Vector2d max_scroll_offset() const;
148 153
149 void UpdateMemoryPolicy(); 154 void UpdateMemoryPolicy();
150 155
151 uint32_t GetCompositorID(content::SynchronousCompositor* compositor); 156 uint32_t GetCompositorID(content::SynchronousCompositor* compositor);
152 // For debug tracing or logging. Return the string representation of this 157 // For debug tracing or logging. Return the string representation of this
153 // view renderer's state. 158 // view renderer's state.
154 std::string ToString() const; 159 std::string ToString() const;
155 160
156 BrowserViewRendererClient* const client_; 161 BrowserViewRendererClient* const client_;
157 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 162 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
158 CompositorFrameConsumer* current_compositor_frame_consumer_; 163 CompositorFrameConsumer* current_compositor_frame_consumer_;
159 std::set<CompositorFrameConsumer*> compositor_frame_consumers_; 164 std::set<CompositorFrameConsumer*> compositor_frame_consumers_;
160 165
161 // The current compositor that's owned by the current RVH. 166 // The current compositor that's owned by the current RVH.
162 content::SynchronousCompositor* compositor_; 167 content::SynchronousCompositor* compositor_;
168 // The process id and routing id of the most recent RVH according to
169 // RVHChanged.
170 CompositorID compositor_id_;
163 // A map from compositor's per-WebView unique ID to the compositor's raw 171 // A map from compositor's per-WebView unique ID to the compositor's raw
164 // pointer. A raw pointer here is fine because the entry will be erased when 172 // pointer. A raw pointer here is fine because the entry will be erased when
165 // a compositor is destroyed. 173 // a compositor is destroyed.
166 std::map<size_t, content::SynchronousCompositor*> compositor_map_; 174 std::map<CompositorID,
175 content::SynchronousCompositor*,
176 CompositorIDComparator>
177 compositor_map_;
167 178
168 bool is_paused_; 179 bool is_paused_;
169 bool view_visible_; 180 bool view_visible_;
170 bool window_visible_; // Only applicable if |attached_to_window_| is true. 181 bool window_visible_; // Only applicable if |attached_to_window_| is true.
171 bool attached_to_window_; 182 bool attached_to_window_;
172 bool hardware_enabled_; 183 bool hardware_enabled_;
173 float dip_scale_; 184 float dip_scale_;
174 float page_scale_factor_; 185 float page_scale_factor_;
175 float min_page_scale_factor_; 186 float min_page_scale_factor_;
176 float max_page_scale_factor_; 187 float max_page_scale_factor_;
(...skipping 16 matching lines...) Expand all
193 // Max scroll offset in CSS pixels. 204 // Max scroll offset in CSS pixels.
194 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. 205 // TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset.
195 gfx::Vector2dF max_scroll_offset_dip_; 206 gfx::Vector2dF max_scroll_offset_dip_;
196 207
197 // Used to prevent rounding errors from accumulating enough to generate 208 // Used to prevent rounding errors from accumulating enough to generate
198 // visible skew (especially noticeable when scrolling up and down in the same 209 // visible skew (especially noticeable when scrolling up and down in the same
199 // spot over a period of time). 210 // spot over a period of time).
200 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset. 211 // TODO(miletus): Make overscroll_rounding_error_ a gfx::ScrollOffset.
201 gfx::Vector2dF overscroll_rounding_error_; 212 gfx::Vector2dF overscroll_rounding_error_;
202 213
203 uint32_t next_compositor_id_;
204
205 ParentCompositorDrawConstraints external_draw_constraints_; 214 ParentCompositorDrawConstraints external_draw_constraints_;
206 215
207 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer); 216 DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer);
208 }; 217 };
209 218
210 } // namespace android_webview 219 } // namespace android_webview
211 220
212 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_ 221 #endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_
OLDNEW
« no previous file with comments | « android_webview/android_webview.gyp ('k') | android_webview/browser/browser_view_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698