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

Side by Side Diff: content/renderer/render_widget.h

Issue 1587743002: RenderWidgetCompositor should be decoupled from RenderWidget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed failure: Don't create an OutputSurface when closing Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_RENDERER_RENDER_WIDGET_H_ 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_
6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
23 #include "content/common/cursors/webcursor.h" 23 #include "content/common/cursors/webcursor.h"
24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
25 #include "content/common/input/synthetic_gesture_params.h" 25 #include "content/common/input/synthetic_gesture_params.h"
26 #include "content/renderer/gpu/render_widget_compositor_delegate.h"
26 #include "content/renderer/input/render_widget_input_handler.h" 27 #include "content/renderer/input/render_widget_input_handler.h"
27 #include "content/renderer/input/render_widget_input_handler_delegate.h" 28 #include "content/renderer/input/render_widget_input_handler_delegate.h"
28 #include "content/renderer/message_delivery_policy.h" 29 #include "content/renderer/message_delivery_policy.h"
29 #include "ipc/ipc_listener.h" 30 #include "ipc/ipc_listener.h"
30 #include "ipc/ipc_sender.h" 31 #include "ipc/ipc_sender.h"
31 #include "third_party/WebKit/public/platform/WebDisplayMode.h" 32 #include "third_party/WebKit/public/platform/WebDisplayMode.h"
32 #include "third_party/WebKit/public/platform/WebRect.h" 33 #include "third_party/WebKit/public/platform/WebRect.h"
33 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 34 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
34 #include "third_party/WebKit/public/web/WebInputEvent.h" 35 #include "third_party/WebKit/public/web/WebInputEvent.h"
35 #include "third_party/WebKit/public/web/WebPopupType.h" 36 #include "third_party/WebKit/public/web/WebPopupType.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // 97 //
97 // RenderWidget is used to implement: 98 // RenderWidget is used to implement:
98 // - RenderViewImpl (deprecated) 99 // - RenderViewImpl (deprecated)
99 // - Fullscreen mode (RenderWidgetFullScreen) 100 // - Fullscreen mode (RenderWidgetFullScreen)
100 // - Popup "menus" (like the color chooser and date picker) 101 // - Popup "menus" (like the color chooser and date picker)
101 // - Widgets for frames (for out-of-process iframe support) 102 // - Widgets for frames (for out-of-process iframe support)
102 class CONTENT_EXPORT RenderWidget 103 class CONTENT_EXPORT RenderWidget
103 : public IPC::Listener, 104 : public IPC::Listener,
104 public IPC::Sender, 105 public IPC::Sender,
105 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient), 106 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
107 public RenderWidgetCompositorDelegate,
106 public RenderWidgetInputHandlerDelegate, 108 public RenderWidgetInputHandlerDelegate,
107 public base::RefCounted<RenderWidget> { 109 public base::RefCounted<RenderWidget> {
108 public: 110 public:
109 // Creates a new RenderWidget. The opener_id is the routing ID of the 111 // Creates a new RenderWidget. The opener_id is the routing ID of the
110 // RenderView that this widget lives inside. 112 // RenderView that this widget lives inside.
111 static RenderWidget* Create(int32_t opener_id, 113 static RenderWidget* Create(int32_t opener_id,
112 CompositorDependencies* compositor_deps, 114 CompositorDependencies* compositor_deps,
113 blink::WebPopupType popup_type, 115 blink::WebPopupType popup_type,
114 const blink::WebScreenInfo& screen_info); 116 const blink::WebScreenInfo& screen_info);
115 117
(...skipping 14 matching lines...) Expand all
130 132
131 CompositorDependencies* compositor_deps() const { return compositor_deps_; } 133 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
132 blink::WebWidget* webwidget() const { return webwidget_; } 134 blink::WebWidget* webwidget() const { return webwidget_; }
133 gfx::Size size() const { return size_; } 135 gfx::Size size() const { return size_; }
134 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } 136 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
135 blink::WebDisplayMode display_mode() const { return display_mode_; } 137 blink::WebDisplayMode display_mode() const { return display_mode_; }
136 bool is_hidden() const { return is_hidden_; } 138 bool is_hidden() const { return is_hidden_; }
137 // Temporary for debugging purposes... 139 // Temporary for debugging purposes...
138 bool closing() const { return closing_; } 140 bool closing() const { return closing_; }
139 bool is_swapped_out() { return is_swapped_out_; } 141 bool is_swapped_out() { return is_swapped_out_; }
140 bool for_oopif() { return for_oopif_; }
141 bool has_host_context_menu_location() { 142 bool has_host_context_menu_location() {
142 return has_host_context_menu_location_; 143 return has_host_context_menu_location_;
143 } 144 }
144 gfx::Point host_context_menu_location() { 145 gfx::Point host_context_menu_location() {
145 return host_context_menu_location_; 146 return host_context_menu_location_;
146 } 147 }
147 148
148 // ScreenInfo exposed so it can be passed to subframe RenderWidgets. 149 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
149 blink::WebScreenInfo screen_info() const { return screen_info_; } 150 blink::WebScreenInfo screen_info() const { return screen_info_; }
150 151
(...skipping 10 matching lines...) Expand all
161 void RegisterVideoHoleFrame(RenderFrameImpl* frame); 162 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
162 void UnregisterVideoHoleFrame(RenderFrameImpl* frame); 163 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
163 #endif // defined(VIDEO_HOLE) 164 #endif // defined(VIDEO_HOLE)
164 165
165 // IPC::Listener 166 // IPC::Listener
166 bool OnMessageReceived(const IPC::Message& msg) override; 167 bool OnMessageReceived(const IPC::Message& msg) override;
167 168
168 // IPC::Sender 169 // IPC::Sender
169 bool Send(IPC::Message* msg) override; 170 bool Send(IPC::Message* msg) override;
170 171
172 // RenderWidgetCompositorDelegate
173 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
174 const gfx::Vector2dF& outer_delta,
175 const gfx::Vector2dF& elastic_overscroll_delta,
176 float page_scale,
177 float top_controls_delta) override;
178 void BeginMainFrame(double frame_time_sec) override;
179 scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) override;
180 scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource() override;
181 void DidCommitAndDrawCompositorFrame() override;
182 void DidCommitCompositorFrame() override;
183 void DidCompletePageScaleAnimation() override;
184 void DidCompleteSwapBuffers() override;
185 bool ForOOPIF() const override;
186 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override;
187 bool IsClosing() const override;
188 void OnSwapBuffersAborted() override;
189 void OnSwapBuffersComplete() override;
190 void OnSwapBuffersPosted() override;
191 void RecordFrameTimingEvents(
192 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events,
193 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events)
194 override;
195 void ScheduleAnimation() override;
196 void UpdateVisualState() override;
197 void WillBeginCompositorFrame() override;
198
171 // RenderWidgetInputHandlerDelegate 199 // RenderWidgetInputHandlerDelegate
172 void FocusChangeComplete() override; 200 void FocusChangeComplete() override;
173 bool HasTouchEventHandlersAt(const gfx::Point& point) const override; 201 bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
174 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event, 202 void ObserveWheelEventAndResult(const blink::WebMouseWheelEvent& wheel_event,
175 const gfx::Vector2dF& wheel_unused_delta, 203 const gfx::Vector2dF& wheel_unused_delta,
176 bool event_processed) override; 204 bool event_processed) override;
177 void OnDidHandleKeyEvent() override; 205 void OnDidHandleKeyEvent() override;
178 void OnDidOverscroll(const DidOverscrollParams& params) override; 206 void OnDidOverscroll(const DidOverscrollParams& params) override;
179 void OnInputEventAck(scoped_ptr<InputEventAck> input_event_ack) override; 207 void OnInputEventAck(scoped_ptr<InputEventAck> input_event_ack) override;
180 void SetInputHandler(RenderWidgetInputHandler* input_handler) override; 208 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 277
250 // When paused in debugger, we send ack for mouse event early. This ensures 278 // When paused in debugger, we send ack for mouse event early. This ensures
251 // that we continue receiving mouse moves and pass them to debugger. Returns 279 // that we continue receiving mouse moves and pass them to debugger. Returns
252 // whether we are paused in mouse move event and have sent the ack. 280 // whether we are paused in mouse move event and have sent the ack.
253 bool SendAckForMouseMoveFromDebugger(); 281 bool SendAckForMouseMoveFromDebugger();
254 282
255 // When resumed from pause in debugger while handling mouse move, 283 // When resumed from pause in debugger while handling mouse move,
256 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger). 284 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
257 void IgnoreAckForMouseMoveFromDebugger(); 285 void IgnoreAckForMouseMoveFromDebugger();
258 286
259 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
260
261 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll). 287 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
262 typedef base::Callback<void()> SyntheticGestureCompletionCallback; 288 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
263 289
264 // Send a synthetic gesture to the browser to be queued to the synthetic 290 // Send a synthetic gesture to the browser to be queued to the synthetic
265 // gesture controller. 291 // gesture controller.
266 void QueueSyntheticGesture( 292 void QueueSyntheticGesture(
267 scoped_ptr<SyntheticGestureParams> gesture_params, 293 scoped_ptr<SyntheticGestureParams> gesture_params,
268 const SyntheticGestureCompletionCallback& callback); 294 const SyntheticGestureCompletionCallback& callback);
269 295
270 // Deliveres |message| together with compositor state change updates. The 296 // Deliveres |message| together with compositor state change updates. The
271 // exact behavior depends on |policy|. 297 // exact behavior depends on |policy|.
272 // This mechanism is not a drop-in replacement for IPC: messages sent this way 298 // This mechanism is not a drop-in replacement for IPC: messages sent this way
273 // will not be automatically available to BrowserMessageFilter, for example. 299 // will not be automatically available to BrowserMessageFilter, for example.
274 // FIFO ordering is preserved between messages enqueued with the same 300 // FIFO ordering is preserved between messages enqueued with the same
275 // |policy|, the ordering between messages enqueued for different policies is 301 // |policy|, the ordering between messages enqueued for different policies is
276 // undefined. 302 // undefined.
277 // 303 //
278 // |msg| message to send, ownership of |msg| is transferred. 304 // |msg| message to send, ownership of |msg| is transferred.
279 // |policy| see the comment on MessageDeliveryPolicy. 305 // |policy| see the comment on MessageDeliveryPolicy.
280 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy); 306 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
281 307
282 // Handle start and finish of IME event guard. 308 // Handle start and finish of IME event guard.
283 void OnImeEventGuardStart(ImeEventGuard* guard); 309 void OnImeEventGuardStart(ImeEventGuard* guard);
284 void OnImeEventGuardFinish(ImeEventGuard* guard); 310 void OnImeEventGuardFinish(ImeEventGuard* guard);
285 311
286 // Returns whether we currently should handle an IME event. 312 // Returns whether we currently should handle an IME event.
287 bool ShouldHandleImeEvent(); 313 bool ShouldHandleImeEvent();
288 314
289 // Called by the compositor when page scale animation completed.
290 virtual void DidCompletePageScaleAnimation() {}
291
292 // ScreenMetricsEmulator class manages screen emulation inside a render 315 // ScreenMetricsEmulator class manages screen emulation inside a render
293 // widget. This includes resizing, placing view on the screen at desired 316 // widget. This includes resizing, placing view on the screen at desired
294 // position, changing device scale factor, and scaling down the whole 317 // position, changing device scale factor, and scaling down the whole
295 // widget if required to fit into the browser window. 318 // widget if required to fit into the browser window.
296 class ScreenMetricsEmulator; 319 class ScreenMetricsEmulator;
297 320
298 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator); 321 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
299 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); 322 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
300 323
301 // Indicates that the compositor is about to begin a frame. This is primarily
302 // to signal to flow control mechanisms that a frame is beginning, not to
303 // perform actual painting work.
304 void WillBeginCompositorFrame();
305
306 // Notifies about a compositor frame commit operation having finished.
307 virtual void DidCommitCompositorFrame();
308
309 // Notifies that the draw commands for a committed frame have been issued.
310 void DidCommitAndDrawCompositorFrame();
311
312 // Notifies that the compositor has posted a swapbuffers operation to the GPU
313 // process.
314 void DidCompleteSwapBuffers();
315 324
316 void ScheduleComposite(); 325 void ScheduleComposite();
317 void ScheduleCompositeWithForcedRedraw(); 326 void ScheduleCompositeWithForcedRedraw();
318 327
319 // Called by the compositor in single-threaded mode when a swap is posted,
320 // completes or is aborted.
321 void OnSwapBuffersPosted();
322 void OnSwapBuffersComplete();
323 void OnSwapBuffersAborted();
324
325 // Checks if the selection bounds have been changed. If they are changed, 328 // Checks if the selection bounds have been changed. If they are changed,
326 // the new value will be sent to the browser process. 329 // the new value will be sent to the browser process.
327 void UpdateSelectionBounds(); 330 void UpdateSelectionBounds();
328 331
329 // Called by the compositor to forward a proto that represents serialized 332 // Called by the compositor to forward a proto that represents serialized
330 // compositor state. 333 // compositor state.
331 void ForwardCompositorProto(const std::vector<uint8_t>& proto);
332 334
333 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); 335 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
334 336
335 void OnShowHostContextMenu(ContextMenuParams* params); 337 void OnShowHostContextMenu(ContextMenuParams* params);
336 338
337 // Checks if the composition range or composition character bounds have been 339 // Checks if the composition range or composition character bounds have been
338 // changed. If they are changed, the new value will be sent to the browser 340 // changed. If they are changed, the new value will be sent to the browser
339 // process. This method does nothing when the browser process is not able to 341 // process. This method does nothing when the browser process is not able to
340 // handle composition range and composition character bounds. 342 // handle composition range and composition character bounds.
341 void UpdateCompositionInfo(bool should_update_range); 343 void UpdateCompositionInfo(bool should_update_range);
342 344
343 bool host_closing() const { return host_closing_; }
344
345 protected: 345 protected:
346 // Friend RefCounted so that the dtor can be non-public. Using this class 346 // Friend RefCounted so that the dtor can be non-public. Using this class
347 // without ref-counting is an error. 347 // without ref-counting is an error.
348 friend class base::RefCounted<RenderWidget>; 348 friend class base::RefCounted<RenderWidget>;
349 349
350 // For unit tests. 350 // For unit tests.
351 friend class RenderWidgetTest; 351 friend class RenderWidgetTest;
352 352
353 enum ResizeAck { 353 enum ResizeAck {
354 SEND_RESIZE_ACK, 354 SEND_RESIZE_ACK,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 scoped_ptr<scheduler::RenderWidgetSchedulingState> 755 scoped_ptr<scheduler::RenderWidgetSchedulingState>
756 render_widget_scheduling_state_; 756 render_widget_scheduling_state_;
757 757
758 DISALLOW_COPY_AND_ASSIGN(RenderWidget); 758 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
759 }; 759 };
760 760
761 } // namespace content 761 } // namespace content
762 762
763 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ 763 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_
OLDNEW
« no previous file with comments | « content/renderer/gpu/render_widget_compositor_unittest.cc ('k') | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698