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 ui::Layer* DelegatedFrameHostGetLayer() const override; | 447 NSView* BrowserCompositorMacGetNSView() const override; |
451 bool DelegatedFrameHostIsVisible() const override; | 448 bool BrowserCompositorMacIsVisible() const override; |
452 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; | 449 SkColor BrowserCompositorMacGetGutterColor(SkColor color) const override; |
453 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; | 450 void BrowserCompositorMacSendCompositorSwapAck( |
454 bool DelegatedFrameCanCreateResizeLock() const override; | |
455 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( | |
456 bool defer_compositor_lock) override; | |
457 void DelegatedFrameHostResizeLockWasReleased() override; | |
458 void DelegatedFrameHostSendCompositorSwapAck( | |
459 int output_surface_id, | 451 int output_surface_id, |
460 const cc::CompositorFrameAck& ack) override; | 452 const cc::CompositorFrameAck& ack) override; |
461 void DelegatedFrameHostSendReclaimCompositorResources( | 453 void BrowserCompositorMacSendReclaimCompositorResources( |
462 int output_surface_id, | 454 int output_surface_id, |
463 const cc::CompositorFrameAck& ack) override; | 455 const cc::CompositorFrameAck& ack) override; |
464 void DelegatedFrameHostOnLostCompositorResources() override; | 456 void BrowserCompositorMacOnLostCompositorResources() override; |
465 void DelegatedFrameHostUpdateVSyncParameters( | 457 void BrowserCompositorMacUpdateVSyncParameters( |
466 const base::TimeTicks& timebase, | 458 const base::TimeTicks& timebase, |
467 const base::TimeDelta& interval) override; | 459 const base::TimeDelta& interval) override; |
468 void SetBeginFrameSource(cc::BeginFrameSource* source) override; | 460 void BrowserCompositorMacSendBeginFrame( |
469 | 461 const cc::BeginFrameArgs& args) override; |
470 // cc::BeginFrameObserver implementation. | |
471 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | |
472 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | |
473 void OnBeginFrameSourcePausedChanged(bool paused) override; | |
474 | 462 |
475 // AcceleratedWidgetMacNSView implementation. | 463 // AcceleratedWidgetMacNSView implementation. |
476 NSView* AcceleratedWidgetGetNSView() const override; | 464 NSView* AcceleratedWidgetGetNSView() const override; |
477 void AcceleratedWidgetGetVSyncParameters( | 465 void AcceleratedWidgetGetVSyncParameters( |
478 base::TimeTicks* timebase, base::TimeDelta* interval) const override; | 466 base::TimeTicks* timebase, base::TimeDelta* interval) const override; |
479 void AcceleratedWidgetSwapCompleted() override; | 467 void AcceleratedWidgetSwapCompleted() override; |
480 | 468 |
481 // Exposed for testing. | 469 // Exposed for testing. |
482 cc::SurfaceId SurfaceIdForTesting() const override; | 470 cc::SurfaceId SurfaceIdForTesting() const override; |
483 | 471 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 RenderWidgetHostViewMac* fullscreen_parent_host_view_; | 522 RenderWidgetHostViewMac* fullscreen_parent_host_view_; |
535 | 523 |
536 // Display link for getting vsync info. | 524 // Display link for getting vsync info. |
537 scoped_refptr<ui::DisplayLinkMac> display_link_; | 525 scoped_refptr<ui::DisplayLinkMac> display_link_; |
538 | 526 |
539 // The current VSync timebase and interval. This is zero until the first call | 527 // The current VSync timebase and interval. This is zero until the first call |
540 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. | 528 // to SendVSyncParametersToRenderer(), and refreshed regularly thereafter. |
541 base::TimeTicks vsync_timebase_; | 529 base::TimeTicks vsync_timebase_; |
542 base::TimeDelta vsync_interval_; | 530 base::TimeDelta vsync_interval_; |
543 | 531 |
544 // The begin frame source being observed. Null if none. | |
545 cc::BeginFrameSource* begin_frame_source_; | |
546 cc::BeginFrameArgs last_begin_frame_args_; | |
547 bool needs_begin_frames_; | |
548 | |
549 // The current composition character range and its bounds. | 532 // The current composition character range and its bounds. |
550 gfx::Range composition_range_; | 533 gfx::Range composition_range_; |
551 std::vector<gfx::Rect> composition_bounds_; | 534 std::vector<gfx::Rect> composition_bounds_; |
552 | 535 |
553 // The current caret bounds. | 536 // The current caret bounds. |
554 gfx::Rect caret_rect_; | 537 gfx::Rect caret_rect_; |
555 | 538 |
556 // The current first selection bounds. | 539 // The current first selection bounds. |
557 gfx::Rect first_selection_rect_; | 540 gfx::Rect first_selection_rect_; |
558 | 541 |
559 // Factory used to safely scope delayed calls to ShutdownHost(). | 542 // Factory used to safely scope delayed calls to ShutdownHost(). |
560 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; | 543 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; |
561 | 544 |
562 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 545 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
563 }; | 546 }; |
564 | 547 |
565 } // namespace content | 548 } // namespace content |
566 | 549 |
567 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 550 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |