| 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 <IOSurface/IOSurface.h> | 9 #include <IOSurface/IOSurface.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <list> | 13 #include <list> |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <utility> | 18 #include <utility> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "base/mac/scoped_nsobject.h" | 21 #include "base/mac/scoped_nsobject.h" |
| 22 #include "base/macros.h" | 22 #include "base/macros.h" |
| 23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "cc/scheduler/begin_frame_source.h" | |
| 26 #include "cc/surfaces/surface_id.h" | 25 #include "cc/surfaces/surface_id.h" |
| 27 #include "content/browser/renderer_host/browser_compositor_view_mac.h" | 26 #include "content/browser/renderer_host/browser_compositor_view_mac.h" |
| 28 #include "content/browser/renderer_host/delegated_frame_host.h" | |
| 29 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" | 27 #include "content/browser/renderer_host/input/mouse_wheel_rails_filter_mac.h" |
| 30 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 28 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 31 #include "content/common/content_export.h" | 29 #include "content/common/content_export.h" |
| 32 #include "content/common/cursors/webcursor.h" | 30 #include "content/common/cursors/webcursor.h" |
| 33 #include "content/common/edit_command.h" | 31 #include "content/common/edit_command.h" |
| 34 #include "ipc/ipc_sender.h" | 32 #include "ipc/ipc_sender.h" |
| 35 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 33 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 36 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 34 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
| 37 #include "ui/accelerated_widget_mac/display_link_mac.h" | 35 #include "ui/accelerated_widget_mac/display_link_mac.h" |
| 38 #import "ui/base/cocoa/command_dispatcher.h" | 36 #import "ui/base/cocoa/command_dispatcher.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // | 217 // |
| 220 // Comment excerpted from render_widget_host.h: | 218 // Comment excerpted from render_widget_host.h: |
| 221 // | 219 // |
| 222 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 220 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
| 223 // If the render process dies, the RenderWidgetHost* goes away and all | 221 // If the render process dies, the RenderWidgetHost* goes away and all |
| 224 // references to it must become NULL." | 222 // references to it must become NULL." |
| 225 // | 223 // |
| 226 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 224 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
| 227 class CONTENT_EXPORT RenderWidgetHostViewMac | 225 class CONTENT_EXPORT RenderWidgetHostViewMac |
| 228 : public RenderWidgetHostViewBase, | 226 : public RenderWidgetHostViewBase, |
| 229 public DelegatedFrameHostClient, | 227 public BrowserCompositorMacClient, |
| 230 public ui::AcceleratedWidgetMacNSView, | 228 public ui::AcceleratedWidgetMacNSView, |
| 231 public IPC::Sender, | 229 public IPC::Sender, |
| 232 public display::DisplayObserver, | 230 public display::DisplayObserver { |
| 233 public cc::BeginFrameObserver { | |
| 234 public: | 231 public: |
| 235 // The view will associate itself with the given widget. The native view must | 232 // The view will associate itself with the given widget. The native view must |
| 236 // be hooked up immediately to the view hierarchy, or else when it is | 233 // be hooked up immediately to the view hierarchy, or else when it is |
| 237 // deleted it will delete this out from under the caller. | 234 // deleted it will delete this out from under the caller. |
| 238 // | 235 // |
| 239 // When |is_guest_view_hack| is true, this view isn't really the view for | 236 // When |is_guest_view_hack| is true, this view isn't really the view for |
| 240 // the |widget|, a RenderWidgetHostViewGuest is. | 237 // the |widget|, a RenderWidgetHostViewGuest is. |
| 241 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated | 238 // TODO(lazyboy): Remove |is_guest_view_hack| once BrowserPlugin has migrated |
| 242 // to use RWHVChildFrame (http://crbug.com/330264). | 239 // to use RWHVChildFrame (http://crbug.com/330264). |
| 243 RenderWidgetHostViewMac(RenderWidgetHost* widget, bool is_guest_view_hack); | 240 RenderWidgetHostViewMac(RenderWidgetHost* widget, bool is_guest_view_hack); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 436 |
| 440 // Update properties, such as the scale factor for the backing store | 437 // Update properties, such as the scale factor for the backing store |
| 441 // and for any CALayers, and the screen color profile. | 438 // and for any CALayers, and the screen color profile. |
| 442 void UpdateBackingStoreProperties(); | 439 void UpdateBackingStoreProperties(); |
| 443 | 440 |
| 444 // Ensure that the display link is associated with the correct display. | 441 // Ensure that the display link is associated with the correct display. |
| 445 void UpdateDisplayLink(); | 442 void UpdateDisplayLink(); |
| 446 | 443 |
| 447 void PauseForPendingResizeOrRepaintsAndDraw(); | 444 void PauseForPendingResizeOrRepaintsAndDraw(); |
| 448 | 445 |
| 449 // DelegatedFrameHostClient implementation. | 446 // BrowserCompositorMacClient implementation. |
| 450 int DelegatedFrameHostGetGpuMemoryBufferClientId() const override; | 447 NSView* BrowserCompositorMacGetNSView() const override; |
| 451 ui::Layer* DelegatedFrameHostGetLayer() const override; | 448 SkColor BrowserCompositorMacGetGutterColor(SkColor color) const override; |
| 452 bool DelegatedFrameHostIsVisible() const override; | 449 void BrowserCompositorMacSendCompositorSwapAck( |
| 453 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; | |
| 454 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; | |
| 455 bool DelegatedFrameCanCreateResizeLock() const override; | |
| 456 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( | |
| 457 bool defer_compositor_lock) override; | |
| 458 void DelegatedFrameHostResizeLockWasReleased() override; | |
| 459 void DelegatedFrameHostSendCompositorSwapAck( | |
| 460 int output_surface_id, | 450 int output_surface_id, |
| 461 const cc::CompositorFrameAck& ack) override; | 451 const cc::CompositorFrameAck& ack) override; |
| 462 void DelegatedFrameHostSendReclaimCompositorResources( | 452 void BrowserCompositorMacSendReclaimCompositorResources( |
| 463 int output_surface_id, | 453 int output_surface_id, |
| 464 const cc::CompositorFrameAck& ack) override; | 454 const cc::CompositorFrameAck& ack) override; |
| 465 void DelegatedFrameHostOnLostCompositorResources() override; | 455 void BrowserCompositorMacOnLostCompositorResources() override; |
| 466 void DelegatedFrameHostUpdateVSyncParameters( | 456 void BrowserCompositorMacUpdateVSyncParameters( |
| 467 const base::TimeTicks& timebase, | 457 const base::TimeTicks& timebase, |
| 468 const base::TimeDelta& interval) override; | 458 const base::TimeDelta& interval) override; |
| 469 void SetBeginFrameSource(cc::BeginFrameSource* source) override; | 459 void BrowserCompositorMacSendBeginFrame( |
| 470 | 460 const cc::BeginFrameArgs& args) override; |
| 471 // cc::BeginFrameObserver implementation. | |
| 472 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | |
| 473 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | |
| 474 void OnBeginFrameSourcePausedChanged(bool paused) override; | |
| 475 | 461 |
| 476 // AcceleratedWidgetMacNSView implementation. | 462 // AcceleratedWidgetMacNSView implementation. |
| 477 NSView* AcceleratedWidgetGetNSView() const override; | 463 NSView* AcceleratedWidgetGetNSView() const override; |
| 478 void AcceleratedWidgetGetVSyncParameters( | 464 void AcceleratedWidgetGetVSyncParameters( |
| 479 base::TimeTicks* timebase, base::TimeDelta* interval) const override; | 465 base::TimeTicks* timebase, base::TimeDelta* interval) const override; |
| 480 void AcceleratedWidgetSwapCompleted() override; | 466 void AcceleratedWidgetSwapCompleted() override; |
| 481 | 467 |
| 482 // Exposed for testing. | 468 // Exposed for testing. |
| 483 cc::SurfaceId SurfaceIdForTesting() const override; | 469 cc::SurfaceId SurfaceIdForTesting() const override; |
| 484 | 470 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 RenderWidgetHostViewMac* fullscreen_parent_host_view_; | 521 RenderWidgetHostViewMac* fullscreen_parent_host_view_; |
| 536 | 522 |
| 537 // Display link for getting vsync info. | 523 // Display link for getting vsync info. |
| 538 scoped_refptr<ui::DisplayLinkMac> display_link_; | 524 scoped_refptr<ui::DisplayLinkMac> display_link_; |
| 539 | 525 |
| 540 // The current VSync timebase and interval. This is zero until the first call | 526 // The current VSync timebase and interval. This is zero until the first call |
| 541 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. | 527 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. |
| 542 base::TimeTicks vsync_timebase_; | 528 base::TimeTicks vsync_timebase_; |
| 543 base::TimeDelta vsync_interval_; | 529 base::TimeDelta vsync_interval_; |
| 544 | 530 |
| 545 // The begin frame source being observed. Null if none. | |
| 546 cc::BeginFrameSource* begin_frame_source_; | |
| 547 cc::BeginFrameArgs last_begin_frame_args_; | |
| 548 bool needs_begin_frames_; | |
| 549 | |
| 550 // The current composition character range and its bounds. | 531 // The current composition character range and its bounds. |
| 551 gfx::Range composition_range_; | 532 gfx::Range composition_range_; |
| 552 std::vector<gfx::Rect> composition_bounds_; | 533 std::vector<gfx::Rect> composition_bounds_; |
| 553 | 534 |
| 554 // The current caret bounds. | 535 // The current caret bounds. |
| 555 gfx::Rect caret_rect_; | 536 gfx::Rect caret_rect_; |
| 556 | 537 |
| 557 // The current first selection bounds. | 538 // The current first selection bounds. |
| 558 gfx::Rect first_selection_rect_; | 539 gfx::Rect first_selection_rect_; |
| 559 | 540 |
| 560 // Factory used to safely scope delayed calls to ShutdownHost(). | 541 // Factory used to safely scope delayed calls to ShutdownHost(). |
| 561 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; | 542 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; |
| 562 | 543 |
| 563 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 544 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
| 564 }; | 545 }; |
| 565 | 546 |
| 566 } // namespace content | 547 } // namespace content |
| 567 | 548 |
| 568 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 549 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
| OLD | NEW |