| 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" |
| 19 #include "ui/aura/client/activation_delegate.h" | 20 #include "ui/aura/client/activation_delegate.h" |
| 20 #include "ui/aura/window_delegate.h" | 21 #include "ui/aura/window_delegate.h" |
| 21 #include "ui/base/ime/text_input_client.h" | 22 #include "ui/base/ime/text_input_client.h" |
| 22 #include "ui/compositor/compositor_observer.h" | 23 #include "ui/compositor/compositor_observer.h" |
| 23 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| 24 #include "webkit/glue/webcursor.h" | 25 #include "webkit/glue/webcursor.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 114 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
| 114 int gpu_host_id) OVERRIDE; | 115 int gpu_host_id) OVERRIDE; |
| 115 virtual void AcceleratedSurfacePostSubBuffer( | 116 virtual void AcceleratedSurfacePostSubBuffer( |
| 116 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 117 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| 117 int gpu_host_id) OVERRIDE; | 118 int gpu_host_id) OVERRIDE; |
| 118 virtual void AcceleratedSurfaceSuspend() OVERRIDE; | 119 virtual void AcceleratedSurfaceSuspend() OVERRIDE; |
| 119 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; | 120 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; |
| 120 virtual void AcceleratedSurfaceNew( | 121 virtual void AcceleratedSurfaceNew( |
| 121 int32 width_in_pixel, | 122 int32 width_in_pixel, |
| 122 int32 height_in_pixel, | 123 int32 height_in_pixel, |
| 123 uint64 surface_id) OVERRIDE; | 124 uint64 surface_id, |
| 125 const std::vector<signed char>& mailbox_name) OVERRIDE; |
| 124 virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; | 126 virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE; |
| 125 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; | 127 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; |
| 126 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; | 128 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; |
| 127 virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch, | 129 virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch, |
| 128 bool processed) OVERRIDE; | 130 bool processed) OVERRIDE; |
| 129 virtual void SetHasHorizontalScrollbar( | 131 virtual void SetHasHorizontalScrollbar( |
| 130 bool has_horizontal_scrollbar) OVERRIDE; | 132 bool has_horizontal_scrollbar) OVERRIDE; |
| 131 virtual void SetScrollOffsetPinning( | 133 virtual void SetScrollOffsetPinning( |
| 132 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; | 134 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; |
| 133 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; | 135 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; | 214 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; |
| 213 virtual void OnCompositingLockStateChanged( | 215 virtual void OnCompositingLockStateChanged( |
| 214 ui::Compositor* compositor) OVERRIDE; | 216 ui::Compositor* compositor) OVERRIDE; |
| 215 | 217 |
| 216 // Overridden from ImageTransportFactoryObserver: | 218 // Overridden from ImageTransportFactoryObserver: |
| 217 virtual void OnLostResources() OVERRIDE; | 219 virtual void OnLostResources() OVERRIDE; |
| 218 | 220 |
| 219 virtual ~RenderWidgetHostViewAura(); | 221 virtual ~RenderWidgetHostViewAura(); |
| 220 | 222 |
| 221 void UpdateCursorIfOverSelf(); | 223 void UpdateCursorIfOverSelf(); |
| 222 bool ShouldFastACK(uint64 surface_id); | 224 bool ShouldFastACK(const gfx::Size& size); |
| 223 void UpdateExternalTexture(); | 225 void UpdateExternalTexture(); |
| 224 ui::InputMethod* GetInputMethod() const; | 226 ui::InputMethod* GetInputMethod() const; |
| 225 | 227 |
| 226 // Returns whether the widget needs an input grab to work properly. | 228 // Returns whether the widget needs an input grab to work properly. |
| 227 bool NeedsInputGrab(); | 229 bool NeedsInputGrab(); |
| 228 | 230 |
| 229 // Confirm existing composition text in the webpage and ask the input method | 231 // Confirm existing composition text in the webpage and ask the input method |
| 230 // to cancel its ongoing composition session. | 232 // to cancel its ongoing composition session. |
| 231 void FinishImeCompositionSession(); | 233 void FinishImeCompositionSession(); |
| 232 | 234 |
| 233 // This method computes movementX/Y and keeps track of mouse location for | 235 // This method computes movementX/Y and keeps track of mouse location for |
| 234 // mouse lock on all mouse move events. | 236 // mouse lock on all mouse move events. |
| 235 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); | 237 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); |
| 236 | 238 |
| 237 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty | 239 // If |clip| is non-empty and and doesn't contain |rect| or |clip| is empty |
| 238 // SchedulePaint() is invoked for |rect|. | 240 // SchedulePaint() is invoked for |rect|. |
| 239 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); | 241 void SchedulePaintIfNotInClip(const gfx::Rect& rect, const gfx::Rect& clip); |
| 240 | 242 |
| 241 // Helper method to determine if, in mouse locked mode, the cursor should be | 243 // Helper method to determine if, in mouse locked mode, the cursor should be |
| 242 // moved to center. | 244 // moved to center. |
| 243 bool ShouldMoveToCenter(); | 245 bool ShouldMoveToCenter(); |
| 244 | 246 |
| 245 // Run the compositing callbacks. | 247 // Run the compositing callbacks. |
| 246 void RunCompositingDidCommitCallbacks(ui::Compositor* compositor); | 248 void RunCompositingDidCommitCallbacks(); |
| 247 | 249 |
| 248 // Insert a sync point into the compositor's command stream and acknowledge | 250 // Insert a sync point into the compositor's command stream and acknowledge |
| 249 // that we have presented the accelerated surface buffer. | 251 // that we have presented the accelerated surface buffer. |
| 250 static void InsertSyncPointAndACK(int32 route_id, | 252 static void InsertSyncPointAndACK( |
| 251 int gpu_host_id, | 253 int32 route_id, |
| 252 bool presented, | 254 int gpu_host_id, |
| 253 ui::Compositor* compositor); | 255 uint64 surface_handle, |
| 256 scoped_refptr<ui::Texture> texture_to_produce); |
| 254 | 257 |
| 255 // Called when window_ gets added to a new window tree. | 258 // Called when window_ gets added to a new window tree. |
| 256 void AddingToRootWindow(); | 259 void AddingToRootWindow(); |
| 257 | 260 |
| 258 // Called when window_ is removed from the window tree. | 261 // Called when window_ is removed from the window tree. |
| 259 void RemovingFromRootWindow(); | 262 void RemovingFromRootWindow(); |
| 260 | 263 |
| 261 // After clearing |current_surface_|, and waiting for the compositor to finish | 264 // Called after commit for the last reference to the texture going away |
| 262 // using it, call this to inform the gpu process. | 265 // after it was released as the frontbuffer. |
| 263 void SetSurfaceNotInUseByCompositor(ui::Compositor* compositor); | 266 void SetSurfaceNotInUseByCompositor(scoped_refptr<ui::Texture>); |
| 264 | |
| 265 // This is called every time |current_surface_| usage changes (by thumbnailer, | |
| 266 // compositor draws, and tab visibility). Every time usage of current surface | |
| 267 // changes between "may be used" and "certain to not be used" by the ui, we | |
| 268 // inform the gpu process. | |
| 269 void AdjustSurfaceProtection(); | |
| 270 | 267 |
| 271 // Called after async thumbnailer task completes. Used to call | 268 // Called after async thumbnailer task completes. Used to call |
| 272 // AdjustSurfaceProtection. | 269 // AdjustSurfaceProtection. |
| 273 static void CopyFromCompositingSurfaceFinished( | 270 static void CopyFromCompositingSurfaceFinished( |
| 274 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, | 271 base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, |
| 275 const base::Callback<void(bool)>& callback, | 272 const base::Callback<void(bool)>& callback, |
| 273 scoped_refptr<ui::Texture>, |
| 276 bool result); | 274 bool result); |
| 277 | 275 |
| 278 ui::Compositor* GetCompositor(); | 276 ui::Compositor* GetCompositor(); |
| 279 | 277 |
| 280 // Detaches |this| from the input method object. | 278 // Detaches |this| from the input method object. |
| 281 void DetachFromInputMethod(); | 279 void DetachFromInputMethod(); |
| 282 | 280 |
| 283 // Converts |rect| from window coordinate to screen coordinate. | 281 // Converts |rect| from window coordinate to screen coordinate. |
| 284 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); | 282 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect); |
| 285 | 283 |
| 284 void SwapBuffersCompleted(int gpu_host_id, |
| 285 int route_id, |
| 286 uint64 surface_handle, |
| 287 scoped_refptr<ui::Texture> texture); |
| 288 |
| 286 // The model object. | 289 // The model object. |
| 287 RenderWidgetHostImpl* host_; | 290 RenderWidgetHostImpl* host_; |
| 288 | 291 |
| 289 aura::Window* window_; | 292 aura::Window* window_; |
| 290 | 293 |
| 291 scoped_ptr<WindowObserver> window_observer_; | 294 scoped_ptr<WindowObserver> window_observer_; |
| 292 | 295 |
| 293 // Are we in the process of closing? Tracked so fullscreen views can avoid | 296 // Are we in the process of closing? Tracked so fullscreen views can avoid |
| 294 // sending a second shutdown request to the host when they lose the focus | 297 // sending a second shutdown request to the host when they lose the focus |
| 295 // after requesting shutdown for another reason (e.g. Escape key). | 298 // after requesting shutdown for another reason (e.g. Escape key). |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 331 |
| 329 // Indicates if there is onging composition text. | 332 // Indicates if there is onging composition text. |
| 330 bool has_composition_text_; | 333 bool has_composition_text_; |
| 331 | 334 |
| 332 // Current tooltip text. | 335 // Current tooltip text. |
| 333 string16 tooltip_; | 336 string16 tooltip_; |
| 334 | 337 |
| 335 // The scale factor of the display the renderer is currently on. | 338 // The scale factor of the display the renderer is currently on. |
| 336 float device_scale_factor_; | 339 float device_scale_factor_; |
| 337 | 340 |
| 338 std::vector< base::Callback<void(ui::Compositor*)> > | 341 std::vector<base::Closure> on_compositing_did_commit_callbacks_; |
| 339 on_compositing_did_commit_callbacks_; | |
| 340 | 342 |
| 341 std::map<uint64, scoped_refptr<ui::Texture> > | 343 std::map<uint64, scoped_refptr<ui::Texture> > image_transport_clients_; |
| 342 image_transport_clients_; | |
| 343 | 344 |
| 345 // The identifier of the current frontbuffer. |
| 344 uint64 current_surface_; | 346 uint64 current_surface_; |
| 345 | 347 |
| 346 // Protected means that the |current_surface_| may be in use by ui and cannot | 348 // The damage in the previous buffer. |
| 347 // be safely discarded. Things to consider are thumbnailer, compositor draw, | 349 gfx::Rect previous_damage_rect_; |
| 348 // and tab visibility. | 350 |
| 349 bool current_surface_is_protected_; | 351 // Pending damage from previous frames that we skipped. |
| 350 bool current_surface_in_use_by_compositor_; | 352 gfx::Rect skipped_damage_; |
| 351 | 353 |
| 352 int pending_thumbnail_tasks_; | 354 int pending_thumbnail_tasks_; |
| 353 | 355 |
| 354 // This id increments every time surface_is_protected changes. We tag IPC | |
| 355 // messages which rely on protection state with this id to stay in sync. | |
| 356 uint32 protection_state_id_; | |
| 357 | |
| 358 int32 surface_route_id_; | |
| 359 | |
| 360 gfx::GLSurfaceHandle shared_surface_handle_; | 356 gfx::GLSurfaceHandle shared_surface_handle_; |
| 361 | 357 |
| 362 // If non-NULL we're in OnPaint() and this is the supplied canvas. | 358 // If non-NULL we're in OnPaint() and this is the supplied canvas. |
| 363 gfx::Canvas* paint_canvas_; | 359 gfx::Canvas* paint_canvas_; |
| 364 | 360 |
| 365 // Used to record the last position of the mouse. | 361 // Used to record the last position of the mouse. |
| 366 // While the mouse is locked, they store the last known position just as mouse | 362 // While the mouse is locked, they store the last known position just as mouse |
| 367 // lock was entered. | 363 // lock was entered. |
| 368 // Relative to the upper-left corner of the view. | 364 // Relative to the upper-left corner of the view. |
| 369 gfx::Point unlocked_mouse_position_; | 365 gfx::Point unlocked_mouse_position_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 NO_PENDING_COMMIT, | 405 NO_PENDING_COMMIT, |
| 410 }; | 406 }; |
| 411 CanLockCompositorState can_lock_compositor_; | 407 CanLockCompositorState can_lock_compositor_; |
| 412 | 408 |
| 413 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 409 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
| 414 }; | 410 }; |
| 415 | 411 |
| 416 } // namespace content | 412 } // namespace content |
| 417 | 413 |
| 418 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 414 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
| OLD | NEW |