OLD | NEW |
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_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "content/browser/renderer_host/image_transport_factory.h" | 17 #include "content/browser/renderer_host/image_transport_factory.h" |
17 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "third_party/skia/include/core/SkRegion.h" |
19 #include "ui/aura/client/activation_delegate.h" | 21 #include "ui/aura/client/activation_delegate.h" |
20 #include "ui/aura/window_delegate.h" | 22 #include "ui/aura/window_delegate.h" |
21 #include "ui/base/ime/text_input_client.h" | 23 #include "ui/base/ime/text_input_client.h" |
22 #include "ui/compositor/compositor_observer.h" | 24 #include "ui/compositor/compositor_observer.h" |
23 #include "ui/gfx/display_observer.h" | 25 #include "ui/gfx/display_observer.h" |
24 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
25 #include "webkit/glue/webcursor.h" | 27 #include "webkit/glue/webcursor.h" |
26 | 28 |
27 namespace aura { | 29 namespace aura { |
28 class WindowTracker; | 30 class WindowTracker; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 skia::PlatformBitmap* output) OVERRIDE; | 116 skia::PlatformBitmap* output) OVERRIDE; |
115 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; | 117 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; |
116 virtual void AcceleratedSurfaceBuffersSwapped( | 118 virtual void AcceleratedSurfaceBuffersSwapped( |
117 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 119 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
118 int gpu_host_id) OVERRIDE; | 120 int gpu_host_id) OVERRIDE; |
119 virtual void AcceleratedSurfacePostSubBuffer( | 121 virtual void AcceleratedSurfacePostSubBuffer( |
120 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 122 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
121 int gpu_host_id) OVERRIDE; | 123 int gpu_host_id) OVERRIDE; |
122 virtual void AcceleratedSurfaceSuspend() OVERRIDE; | 124 virtual void AcceleratedSurfaceSuspend() OVERRIDE; |
123 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; | 125 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; |
124 virtual void AcceleratedSurfaceNew( | 126 virtual void AcceleratedSurfaceNew(int32 width_in_pixel, |
125 int32 width_in_pixel, | 127 int32 height_in_pixel, |
126 int32 height_in_pixel, | 128 uint64 surface_id, |
127 uint64 surface_id) OVERRIDE; | 129 const std::string& mailbox_name) OVERRIDE; |
128 virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; | 130 virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; |
129 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; | 131 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; |
130 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; | 132 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; |
131 virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch, | 133 virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch, |
132 bool processed) OVERRIDE; | 134 bool processed) OVERRIDE; |
133 virtual void SetHasHorizontalScrollbar( | 135 virtual void SetHasHorizontalScrollbar( |
134 bool has_horizontal_scrollbar) OVERRIDE; | 136 bool has_horizontal_scrollbar) OVERRIDE; |
135 virtual void SetScrollOffsetPinning( | 137 virtual void SetScrollOffsetPinning( |
136 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; | 138 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; |
137 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; | 139 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; | 224 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; |
223 virtual void OnCompositingLockStateChanged( | 225 virtual void OnCompositingLockStateChanged( |
224 ui::Compositor* compositor) OVERRIDE; | 226 ui::Compositor* compositor) OVERRIDE; |
225 | 227 |
226 // Overridden from ImageTransportFactoryObserver: | 228 // Overridden from ImageTransportFactoryObserver: |
227 virtual void OnLostResources() OVERRIDE; | 229 virtual void OnLostResources() OVERRIDE; |
228 | 230 |
229 virtual ~RenderWidgetHostViewAura(); | 231 virtual ~RenderWidgetHostViewAura(); |
230 | 232 |
231 void UpdateCursorIfOverSelf(); | 233 void UpdateCursorIfOverSelf(); |
232 bool ShouldFastACK(uint64 surface_id); | 234 bool ShouldSkipFrame(const gfx::Size& size); |
233 void UpdateExternalTexture(); | 235 void UpdateExternalTexture(); |
234 ui::InputMethod* GetInputMethod() const; | 236 ui::InputMethod* GetInputMethod() const; |
235 | 237 |
236 // Returns whether the widget needs an input grab to work properly. | 238 // Returns whether the widget needs an input grab to work properly. |
237 bool NeedsInputGrab(); | 239 bool NeedsInputGrab(); |
238 | 240 |
239 // Confirm existing composition text in the webpage and ask the input method | 241 // Confirm existing composition text in the webpage and ask the input method |
240 // to cancel its ongoing composition session. | 242 // to cancel its ongoing composition session. |
241 void FinishImeCompositionSession(); | 243 void FinishImeCompositionSession(); |
242 | 244 |
243 // This method computes movementX/Y and keeps track of mouse location for | 245 // This method computes movementX/Y and keeps track of mouse location for |
244 // mouse lock on all mouse move events. | 246 // mouse lock on all mouse move events. |
245 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); | 247 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); |
246 | 248 |
247 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty | 249 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty |
248 // SchedulePaint() is invoked for |rect|. | 250 // SchedulePaint() is invoked for |rect|. |
249 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); | 251 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); |
250 | 252 |
251 // Helper method to determine if, in mouse locked mode, the cursor should be | 253 // Helper method to determine if, in mouse locked mode, the cursor should be |
252 // moved to center. | 254 // moved to center. |
253 bool ShouldMoveToCenter(); | 255 bool ShouldMoveToCenter(); |
254 | 256 |
255 // Run the compositing callbacks. | 257 // Run the compositing callbacks. |
256 void RunCompositingDidCommitCallbacks(ui::Compositor* compositor); | 258 void RunCompositingDidCommitCallbacks(); |
| 259 |
| 260 struct BufferPresentedParams { |
| 261 BufferPresentedParams(int route_id, |
| 262 int gpu_host_id, |
| 263 uint64 surface_handle) |
| 264 : route_id(route_id), |
| 265 gpu_host_id(gpu_host_id), |
| 266 surface_handle(surface_handle) { |
| 267 } |
| 268 |
| 269 int32 route_id; |
| 270 int gpu_host_id; |
| 271 uint64 surface_handle; |
| 272 scoped_refptr<ui::Texture> texture_to_produce; |
| 273 }; |
257 | 274 |
258 // Insert a sync point into the compositor's command stream and acknowledge | 275 // Insert a sync point into the compositor's command stream and acknowledge |
259 // that we have presented the accelerated surface buffer. | 276 // that we have presented the accelerated surface buffer. |
260 static void InsertSyncPointAndACK(int32 route_id, | 277 static void InsertSyncPointAndACK(const BufferPresentedParams& params); |
261 int gpu_host_id, | |
262 bool presented, | |
263 ui::Compositor* compositor); | |
264 | 278 |
265 // Called when window_ gets added to a new window tree. | 279 // Called when window_ gets added to a new window tree. |
266 void AddingToRootWindow(); | 280 void AddingToRootWindow(); |
267 | 281 |
268 // Called when window_ is removed from the window tree. | 282 // Called when window_ is removed from the window tree. |
269 void RemovingFromRootWindow(); | 283 void RemovingFromRootWindow(); |
270 | 284 |
271 // After clearing |current_surface_|, and waiting for the compositor to finish | 285 // Called after commit for the last reference to the texture going away |
272 // using it, call this to inform the gpu process. | 286 // after it was released as the frontbuffer. |
273 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); | 287 void SetSurfaceNotInUseByCompositor(scoped_refptr<ui::Texture>); |
274 | |
275 // This is called every time |current_surface_| usage changes (by thumbnailer, | |
276 // compositor draws, and tab visibility). Every time usage of current surface | |
277 // changes between "may be used" and "certain to not be used" by the ui, we | |
278 // inform the gpu process. | |
279 void AdjustSurfaceProtection(); | |
280 | 288 |
281 // Called after async thumbnailer task completes. Used to call | 289 // Called after async thumbnailer task completes. Used to call |
282 // AdjustSurfaceProtection. | 290 // AdjustSurfaceProtection. |
283 static void CopyFromCompositingSurfaceFinished( | 291 static void CopyFromCompositingSurfaceFinished( |
284 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, | 292 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, |
285 const base::Callback<void(bool)>& callback, | 293 const base::Callback<void(bool)>& callback, |
286 bool result); | 294 bool result); |
287 | 295 |
288 ui::Compositor* GetCompositor(); | 296 ui::Compositor* GetCompositor(); |
289 | 297 |
290 // Detaches |this| from the input method object. | 298 // Detaches |this| from the input method object. |
291 void DetachFromInputMethod(); | 299 void DetachFromInputMethod(); |
292 | 300 |
293 // Converts |rect| from window coordinate to screen coordinate. | 301 // Converts |rect| from window coordinate to screen coordinate. |
294 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); | 302 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); |
295 | 303 |
| 304 bool SwapBuffersPrepare(const gfx::Rect& surface_rect, |
| 305 const gfx::Rect& damage_rect, |
| 306 BufferPresentedParams& params); |
| 307 |
| 308 void SwapBuffersCompleted(const BufferPresentedParams& params); |
| 309 |
296 // The model object. | 310 // The model object. |
297 RenderWidgetHostImpl* host_; | 311 RenderWidgetHostImpl* host_; |
298 | 312 |
299 aura::Window* window_; | 313 aura::Window* window_; |
300 | 314 |
301 scoped_ptr<WindowObserver> window_observer_; | 315 scoped_ptr<WindowObserver> window_observer_; |
302 | 316 |
303 // Are we in the process of closing? Tracked so fullscreen views can avoid | 317 // Are we in the process of closing? Tracked so fullscreen views can avoid |
304 // sending a second shutdown request to the host when they lose the focus | 318 // sending a second shutdown request to the host when they lose the focus |
305 // after requesting shutdown for another reason (e.g. Escape key). | 319 // after requesting shutdown for another reason (e.g. Escape key). |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 352 |
339 // Indicates if there is onging composition text. | 353 // Indicates if there is onging composition text. |
340 bool has_composition_text_; | 354 bool has_composition_text_; |
341 | 355 |
342 // Current tooltip text. | 356 // Current tooltip text. |
343 string16 tooltip_; | 357 string16 tooltip_; |
344 | 358 |
345 // The scale factor of the display the renderer is currently on. | 359 // The scale factor of the display the renderer is currently on. |
346 float device_scale_factor_; | 360 float device_scale_factor_; |
347 | 361 |
348 std::vector< base::Callback<void(ui::Compositor*)> > | 362 std::vector<base::Closure> on_compositing_did_commit_callbacks_; |
349 on_compositing_did_commit_callbacks_; | |
350 | 363 |
351 std::map<uint64, scoped_refptr<ui::Texture> > | 364 std::map<uint64, scoped_refptr<ui::Texture> > image_transport_clients_; |
352 image_transport_clients_; | |
353 | 365 |
| 366 // The identifier of the current frontbuffer. |
354 uint64 current_surface_; | 367 uint64 current_surface_; |
355 | 368 |
356 // Protected means that the |current_surface_| may be in use by ui and cannot | 369 // The damage in the previous buffer. |
357 // be safely discarded. Things to consider are thumbnailer, compositor draw, | 370 SkRegion previous_damage_; |
358 // and tab visibility. | 371 |
359 bool current_surface_is_protected_; | 372 // Pending damage from previous frames that we skipped. |
360 bool current_surface_in_use_by_compositor_; | 373 SkRegion skipped_damage_; |
| 374 |
| 375 // The size of the previously received frame. |
| 376 gfx::Size previous_surface_size_; |
361 | 377 |
362 int pending_thumbnail_tasks_; | 378 int pending_thumbnail_tasks_; |
363 | 379 |
364 // This id increments every time surface_is_protected changes. We tag IPC | |
365 // messages which rely on protection state with this id to stay in sync. | |
366 uint32 protection_state_id_; | |
367 | |
368 int32 surface_route_id_; | |
369 | |
370 gfx::GLSurfaceHandle shared_surface_handle_; | 380 gfx::GLSurfaceHandle shared_surface_handle_; |
371 | 381 |
372 // If non-NULL we're in OnPaint() and this is the supplied canvas. | 382 // If non-NULL we're in OnPaint() and this is the supplied canvas. |
373 gfx::Canvas* paint_canvas_; | 383 gfx::Canvas* paint_canvas_; |
374 | 384 |
375 // Used to record the last position of the mouse. | 385 // Used to record the last position of the mouse. |
376 // While the mouse is locked, they store the last known position just as mouse | 386 // While the mouse is locked, they store the last known position just as mouse |
377 // lock was entered. | 387 // lock was entered. |
378 // Relative to the upper-left corner of the view. | 388 // Relative to the upper-left corner of the view. |
379 gfx::Point unlocked_mouse_position_; | 389 gfx::Point unlocked_mouse_position_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 NO_PENDING_COMMIT, | 429 NO_PENDING_COMMIT, |
420 }; | 430 }; |
421 CanLockCompositorState can_lock_compositor_; | 431 CanLockCompositorState can_lock_compositor_; |
422 | 432 |
423 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 433 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
424 }; | 434 }; |
425 | 435 |
426 } // namespace content | 436 } // namespace content |
427 | 437 |
428 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 438 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |