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_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "content/browser/compositor/delegated_frame_host.h" |
19 #include "content/browser/renderer_host/display_link_mac.h" | 20 #include "content/browser/renderer_host/display_link_mac.h" |
20 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
21 #include "content/browser/renderer_host/software_frame_manager.h" | 22 #include "content/browser/renderer_host/software_frame_manager.h" |
22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
23 #include "content/common/cursors/webcursor.h" | 24 #include "content/common/cursors/webcursor.h" |
24 #include "content/common/edit_command.h" | 25 #include "content/common/edit_command.h" |
25 #import "content/public/browser/render_widget_host_view_mac_base.h" | 26 #import "content/public/browser/render_widget_host_view_mac_base.h" |
26 #include "ipc/ipc_sender.h" | 27 #include "ipc/ipc_sender.h" |
27 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 28 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
28 #include "ui/base/cocoa/base_view.h" | 29 #include "ui/base/cocoa/base_view.h" |
29 | 30 |
30 namespace content { | 31 namespace content { |
31 class CompositingIOSurfaceMac; | 32 class CompositingIOSurfaceMac; |
32 class CompositingIOSurfaceContext; | 33 class CompositingIOSurfaceContext; |
33 class RenderWidgetHostViewMac; | 34 class RenderWidgetHostViewMac; |
34 class RenderWidgetHostViewMacEditCommandHelper; | 35 class RenderWidgetHostViewMacEditCommandHelper; |
35 class WebContents; | 36 class WebContents; |
36 } | 37 } |
37 | 38 |
| 39 namespace ui { |
| 40 class Compositor; |
| 41 class Layer; |
| 42 } |
| 43 |
38 @class CompositingIOSurfaceLayer; | 44 @class CompositingIOSurfaceLayer; |
39 @class FullscreenWindowManager; | 45 @class FullscreenWindowManager; |
40 @protocol RenderWidgetHostViewMacDelegate; | 46 @protocol RenderWidgetHostViewMacDelegate; |
41 @class ToolTip; | 47 @class ToolTip; |
42 | 48 |
43 @protocol RenderWidgetHostViewMacOwner | 49 @protocol RenderWidgetHostViewMacOwner |
44 - (content::RenderWidgetHostViewMac*)renderWidgetHostViewMac; | 50 - (content::RenderWidgetHostViewMac*)renderWidgetHostViewMac; |
45 @end | 51 @end |
46 | 52 |
47 // This is the view that lives in the Cocoa view hierarchy. In Windows-land, | 53 // This is the view that lives in the Cocoa view hierarchy. In Windows-land, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // | 213 // |
208 // Comment excerpted from render_widget_host.h: | 214 // Comment excerpted from render_widget_host.h: |
209 // | 215 // |
210 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 216 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
211 // If the render process dies, the RenderWidgetHost* goes away and all | 217 // If the render process dies, the RenderWidgetHost* goes away and all |
212 // references to it must become NULL." | 218 // references to it must become NULL." |
213 // | 219 // |
214 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 220 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
215 class CONTENT_EXPORT RenderWidgetHostViewMac | 221 class CONTENT_EXPORT RenderWidgetHostViewMac |
216 : public RenderWidgetHostViewBase, | 222 : public RenderWidgetHostViewBase, |
| 223 public DelegatedFrameHostClient, |
217 public IPC::Sender, | 224 public IPC::Sender, |
218 public SoftwareFrameManagerClient { | 225 public SoftwareFrameManagerClient { |
219 public: | 226 public: |
220 // The view will associate itself with the given widget. The native view must | 227 // The view will associate itself with the given widget. The native view must |
221 // be hooked up immediately to the view hierarchy, or else when it is | 228 // be hooked up immediately to the view hierarchy, or else when it is |
222 // deleted it will delete this out from under the caller. | 229 // deleted it will delete this out from under the caller. |
223 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); | 230 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); |
224 virtual ~RenderWidgetHostViewMac(); | 231 virtual ~RenderWidgetHostViewMac(); |
225 | 232 |
226 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } | 233 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer. | 448 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer. |
442 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_; | 449 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_; |
443 scoped_ptr<CompositingIOSurfaceMac> compositing_iosurface_; | 450 scoped_ptr<CompositingIOSurfaceMac> compositing_iosurface_; |
444 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_; | 451 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_; |
445 | 452 |
446 // Timer used to dynamically transition the compositing layer in and out of | 453 // Timer used to dynamically transition the compositing layer in and out of |
447 // asynchronous mode. | 454 // asynchronous mode. |
448 base::DelayTimer<RenderWidgetHostViewMac> | 455 base::DelayTimer<RenderWidgetHostViewMac> |
449 compositing_iosurface_layer_async_timer_; | 456 compositing_iosurface_layer_async_timer_; |
450 | 457 |
| 458 // Delegated frame management and compositior. |
| 459 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
| 460 scoped_ptr<ui::Compositor> compositor_; |
| 461 scoped_ptr<ui::Layer> root_layer_; |
| 462 |
451 // This holds the current software compositing framebuffer, if any. | 463 // This holds the current software compositing framebuffer, if any. |
452 scoped_ptr<SoftwareFrameManager> software_frame_manager_; | 464 scoped_ptr<SoftwareFrameManager> software_frame_manager_; |
453 | 465 |
454 // Whether to allow overlapping views. | 466 // Whether to allow overlapping views. |
455 bool allow_overlapping_views_; | 467 bool allow_overlapping_views_; |
456 | 468 |
457 // Whether to use the CoreAnimation path to draw content. | 469 // Whether to use the CoreAnimation path to draw content. |
458 bool use_core_animation_; | 470 bool use_core_animation_; |
459 | 471 |
460 // Latency info to send back when the next frame appears on the | 472 // Latency info to send back when the next frame appears on the |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 void PauseForPendingResizeOrRepaintsAndDraw(); | 519 void PauseForPendingResizeOrRepaintsAndDraw(); |
508 | 520 |
509 // The geometric arrangement of the layers depends on cocoa_view's size, the | 521 // The geometric arrangement of the layers depends on cocoa_view's size, the |
510 // compositing IOSurface's rounded size, and the software frame size. Update | 522 // compositing IOSurface's rounded size, and the software frame size. Update |
511 // all of them using this function when any of those parameters changes. Also | 523 // all of them using this function when any of those parameters changes. Also |
512 // update the scale factor of the layers. | 524 // update the scale factor of the layers. |
513 void LayoutLayers(); | 525 void LayoutLayers(); |
514 | 526 |
515 bool HasPendingSwapAck() const { return pending_swap_ack_; } | 527 bool HasPendingSwapAck() const { return pending_swap_ack_; } |
516 | 528 |
| 529 // DelegatedFrameHostClient implementation. |
| 530 virtual ui::Compositor* GetCompositor() const OVERRIDE; |
| 531 virtual ui::Layer* GetLayer() OVERRIDE; |
| 532 virtual RenderWidgetHostImpl* GetHost() OVERRIDE; |
| 533 virtual void SchedulePaintInRect( |
| 534 const gfx::Rect& damage_rect_in_dip) OVERRIDE; |
| 535 virtual bool IsVisible() OVERRIDE; |
| 536 virtual scoped_ptr<ResizeLock> CreateResizeLock( |
| 537 bool defer_compositor_lock) OVERRIDE; |
| 538 virtual gfx::Size DesiredFrameSize() OVERRIDE; |
| 539 virtual float CurrentDeviceScaleFactor() OVERRIDE; |
| 540 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE; |
| 541 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE; |
| 542 |
517 private: | 543 private: |
518 friend class RenderWidgetHostViewMacTest; | 544 friend class RenderWidgetHostViewMacTest; |
519 | 545 |
520 struct PendingSwapAck { | 546 struct PendingSwapAck { |
521 PendingSwapAck(int32 route_id, int gpu_host_id, int32 renderer_id) | 547 PendingSwapAck(int32 route_id, int gpu_host_id, int32 renderer_id) |
522 : route_id(route_id), | 548 : route_id(route_id), |
523 gpu_host_id(gpu_host_id), | 549 gpu_host_id(gpu_host_id), |
524 renderer_id(renderer_id) {} | 550 renderer_id(renderer_id) {} |
525 int32 route_id; | 551 int32 route_id; |
526 int gpu_host_id; | 552 int gpu_host_id; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; | 669 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; |
644 | 670 |
645 base::WeakPtrFactory<RenderWidgetHostViewMac> | 671 base::WeakPtrFactory<RenderWidgetHostViewMac> |
646 software_frame_weak_ptr_factory_; | 672 software_frame_weak_ptr_factory_; |
647 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 673 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
648 }; | 674 }; |
649 | 675 |
650 } // namespace content | 676 } // namespace content |
651 | 677 |
652 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 678 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |