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/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" |
14 #include "content/browser/renderer_host/image_transport_factory.h" | 15 #include "content/browser/renderer_host/image_transport_factory.h" |
15 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 16 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
17 #include "ui/aura/client/activation_delegate.h" | 18 #include "ui/aura/client/activation_delegate.h" |
18 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
19 #include "ui/base/ime/text_input_client.h" | 20 #include "ui/base/ime/text_input_client.h" |
20 #include "ui/compositor/compositor_observer.h" | 21 #include "ui/compositor/compositor_observer.h" |
21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
22 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
23 | 24 |
(...skipping 18 matching lines...) Expand all Loading... |
42 class RenderWidgetHostImpl; | 43 class RenderWidgetHostImpl; |
43 class RenderWidgetHostView; | 44 class RenderWidgetHostView; |
44 | 45 |
45 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 46 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
46 class RenderWidgetHostViewAura | 47 class RenderWidgetHostViewAura |
47 : public RenderWidgetHostViewBase, | 48 : public RenderWidgetHostViewBase, |
48 public ui::CompositorObserver, | 49 public ui::CompositorObserver, |
49 public ui::TextInputClient, | 50 public ui::TextInputClient, |
50 public aura::WindowDelegate, | 51 public aura::WindowDelegate, |
51 public aura::client::ActivationDelegate, | 52 public aura::client::ActivationDelegate, |
52 public ImageTransportFactoryObserver { | 53 public ImageTransportFactoryObserver, |
| 54 public base::SupportsWeakPtr<RenderWidgetHostViewAura> { |
53 public: | 55 public: |
54 // RenderWidgetHostView implementation. | 56 // RenderWidgetHostView implementation. |
55 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; | 57 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; |
56 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; | 58 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; |
57 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 59 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
58 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; | 60 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; |
59 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 61 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
60 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; | 62 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; |
61 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | 63 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
62 virtual bool HasFocus() const OVERRIDE; | 64 virtual bool HasFocus() const OVERRIDE; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 233 |
232 // Insert a sync point into the compositor's command stream and acknowledge | 234 // Insert a sync point into the compositor's command stream and acknowledge |
233 // that we have presented the accelerated surface buffer. | 235 // that we have presented the accelerated surface buffer. |
234 static void InsertSyncPointAndACK(int32 route_id, | 236 static void InsertSyncPointAndACK(int32 route_id, |
235 int gpu_host_id, | 237 int gpu_host_id, |
236 ui::Compositor* compositor); | 238 ui::Compositor* compositor); |
237 | 239 |
238 // Called when window_ is removed from the window tree. | 240 // Called when window_ is removed from the window tree. |
239 void RemovingFromRootWindow(); | 241 void RemovingFromRootWindow(); |
240 | 242 |
| 243 // After clearing |current_surface_|, and waiting for the compositor to finish |
| 244 // using it, call this to inform the gpu process. |
| 245 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); |
| 246 |
| 247 // This is called every time |current_surface_| usage changes (by thumbnailer, |
| 248 // compositor draws, and tab visibility). Every time usage of current surface |
| 249 // changes between "may be used" and "certain to not be used" by the ui, we |
| 250 // inform the gpu process. |
| 251 void AdjustSurfaceProtection(); |
| 252 |
| 253 // Called after async thumbnailer task completes. Used to call |
| 254 // AdjustSurfaceProtection. |
| 255 void CopyFromCompositingSurfaceFinished(base::Callback<void(bool)> callback, |
| 256 bool result); |
| 257 |
241 ui::Compositor* GetCompositor(); | 258 ui::Compositor* GetCompositor(); |
242 | 259 |
243 // Detaches |this| from the input method object. | 260 // Detaches |this| from the input method object. |
244 void DetachFromInputMethod(); | 261 void DetachFromInputMethod(); |
245 | 262 |
246 // Converts |rect| from window coordinate to screen coordinate. | 263 // Converts |rect| from window coordinate to screen coordinate. |
247 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); | 264 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); |
248 | 265 |
249 // The model object. | 266 // The model object. |
250 RenderWidgetHostImpl* host_; | 267 RenderWidgetHostImpl* host_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 on_compositing_did_commit_callbacks_; | 316 on_compositing_did_commit_callbacks_; |
300 | 317 |
301 std::vector< base::Callback<void(ui::Compositor*)> > | 318 std::vector< base::Callback<void(ui::Compositor*)> > |
302 on_compositing_will_start_callbacks_; | 319 on_compositing_will_start_callbacks_; |
303 | 320 |
304 std::map<uint64, scoped_refptr<ui::Texture> > | 321 std::map<uint64, scoped_refptr<ui::Texture> > |
305 image_transport_clients_; | 322 image_transport_clients_; |
306 | 323 |
307 uint64 current_surface_; | 324 uint64 current_surface_; |
308 | 325 |
| 326 // Protected means that the |current_surface_| may be in use by ui and cannot |
| 327 // be safely discarded. Things to consider are thumbnailer, compositor draw, |
| 328 // and tab visibility. |
| 329 bool current_surface_is_protected_; |
| 330 bool current_surface_in_use_by_compositor_; |
| 331 |
| 332 int pending_thumbnail_tasks_; |
| 333 |
| 334 // This id increments every time surface_is_protected changes. We tag IPC |
| 335 // messages which rely on protection state with this id to stay in sync. |
| 336 uint32 protection_state_id_; |
| 337 |
| 338 int32 surface_route_id_; |
| 339 |
309 gfx::GLSurfaceHandle shared_surface_handle_; | 340 gfx::GLSurfaceHandle shared_surface_handle_; |
310 | 341 |
311 // If non-NULL we're in OnPaint() and this is the supplied canvas. | 342 // If non-NULL we're in OnPaint() and this is the supplied canvas. |
312 gfx::Canvas* paint_canvas_; | 343 gfx::Canvas* paint_canvas_; |
313 | 344 |
314 // Used to record the last position of the mouse. | 345 // Used to record the last position of the mouse. |
315 // While the mouse is locked, they store the last known position just as mouse | 346 // While the mouse is locked, they store the last known position just as mouse |
316 // lock was entered. | 347 // lock was entered. |
317 // Relative to the upper-left corner of the view. | 348 // Relative to the upper-left corner of the view. |
318 gfx::Point unlocked_mouse_position_; | 349 gfx::Point unlocked_mouse_position_; |
(...skipping 22 matching lines...) Expand all Loading... |
341 | 372 |
342 // This lock is for waiting for a front surface to become available to draw. | 373 // This lock is for waiting for a front surface to become available to draw. |
343 scoped_refptr<aura::CompositorLock> released_front_lock_; | 374 scoped_refptr<aura::CompositorLock> released_front_lock_; |
344 | 375 |
345 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 376 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
346 }; | 377 }; |
347 | 378 |
348 } // namespace content | 379 } // namespace content |
349 | 380 |
350 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 381 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |