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/IOSurfaceAPI.h> | 9 #include <IOSurface/IOSurfaceAPI.h> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/mac/scoped_nsobject.h" | 16 #include "base/mac/scoped_nsobject.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "cc/scheduler/begin_frame_manager.h" |
20 #include "content/browser/compositor/browser_compositor_view_mac.h" | 21 #include "content/browser/compositor/browser_compositor_view_mac.h" |
21 #include "content/browser/compositor/delegated_frame_host.h" | 22 #include "content/browser/compositor/delegated_frame_host.h" |
22 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" | 23 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" |
23 #include "content/browser/renderer_host/display_link_mac.h" | 24 #include "content/browser/renderer_host/display_link_mac.h" |
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 25 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
25 #include "content/browser/renderer_host/software_frame_manager.h" | 26 #include "content/browser/renderer_host/software_frame_manager.h" |
26 #include "content/common/content_export.h" | 27 #include "content/common/content_export.h" |
27 #include "content/common/cursors/webcursor.h" | 28 #include "content/common/cursors/webcursor.h" |
28 #include "content/common/edit_command.h" | 29 #include "content/common/edit_command.h" |
29 #import "content/public/browser/render_widget_host_view_mac_base.h" | 30 #import "content/public/browser/render_widget_host_view_mac_base.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // references to it must become NULL." | 215 // references to it must become NULL." |
215 // | 216 // |
216 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 217 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
217 class CONTENT_EXPORT RenderWidgetHostViewMac | 218 class CONTENT_EXPORT RenderWidgetHostViewMac |
218 : public RenderWidgetHostViewBase, | 219 : public RenderWidgetHostViewBase, |
219 public DelegatedFrameHostClient, | 220 public DelegatedFrameHostClient, |
220 public BrowserCompositorViewMacClient, | 221 public BrowserCompositorViewMacClient, |
221 public IPC::Sender, | 222 public IPC::Sender, |
222 public SoftwareFrameManagerClient, | 223 public SoftwareFrameManagerClient, |
223 public CompositingIOSurfaceLayerClient, | 224 public CompositingIOSurfaceLayerClient, |
224 public gfx::DisplayObserver { | 225 public gfx::DisplayObserver, |
| 226 public cc::BeginFrameManager::Observer, |
| 227 public DisplayLinkMac::Observer { |
225 public: | 228 public: |
226 // The view will associate itself with the given widget. The native view must | 229 // The view will associate itself with the given widget. The native view must |
227 // be hooked up immediately to the view hierarchy, or else when it is | 230 // be hooked up immediately to the view hierarchy, or else when it is |
228 // deleted it will delete this out from under the caller. | 231 // deleted it will delete this out from under the caller. |
229 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); | 232 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); |
230 virtual ~RenderWidgetHostViewMac(); | 233 virtual ~RenderWidgetHostViewMac(); |
231 | 234 |
232 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } | 235 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } |
233 | 236 |
234 // |delegate| is used to separate out the logic from the NSResponder delegate. | 237 // |delegate| is used to separate out the logic from the NSResponder delegate. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 // CompositingIOSurfaceLayerClient implementation. | 355 // CompositingIOSurfaceLayerClient implementation. |
353 virtual bool AcceleratedLayerShouldAckImmediately() const OVERRIDE; | 356 virtual bool AcceleratedLayerShouldAckImmediately() const OVERRIDE; |
354 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; | 357 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; |
355 | 358 |
356 // gfx::DisplayObserver implementation. | 359 // gfx::DisplayObserver implementation. |
357 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; | 360 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; |
358 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; | 361 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; |
359 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 362 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
360 uint32_t metrics) OVERRIDE; | 363 uint32_t metrics) OVERRIDE; |
361 | 364 |
| 365 // cc::BeginFrameManager::Observer implementation. |
| 366 virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) OVERRIDE; |
| 367 |
| 368 // DisplayLinkMac::Observer implementation. |
| 369 virtual void OnVSync(base::TimeTicks timebase, |
| 370 base::TimDelta interval) OVERRIDE; |
| 371 |
362 // Forwards the mouse event to the renderer. | 372 // Forwards the mouse event to the renderer. |
363 void ForwardMouseEvent(const blink::WebMouseEvent& event); | 373 void ForwardMouseEvent(const blink::WebMouseEvent& event); |
364 | 374 |
365 void KillSelf(); | 375 void KillSelf(); |
366 | 376 |
367 void SetTextInputActive(bool active); | 377 void SetTextInputActive(bool active); |
368 | 378 |
369 // Sends completed plugin IME notification and text back to the renderer. | 379 // Sends completed plugin IME notification and text back to the renderer. |
370 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id); | 380 void PluginImeCompositionCompleted(const base::string16& text, int plugin_id); |
371 | 381 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 void OnPluginFocusChanged(bool focused, int plugin_id); | 588 void OnPluginFocusChanged(bool focused, int plugin_id); |
579 void OnStartPluginIme(); | 589 void OnStartPluginIme(); |
580 | 590 |
581 // Convert |rect| from the views coordinate (upper-left origin) into | 591 // Convert |rect| from the views coordinate (upper-left origin) into |
582 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays. | 592 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays. |
583 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect); | 593 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect); |
584 | 594 |
585 // Send updated vsync parameters to the renderer. | 595 // Send updated vsync parameters to the renderer. |
586 void SendVSyncParametersToRenderer(); | 596 void SendVSyncParametersToRenderer(); |
587 | 597 |
| 598 // Called when RenderWidget want to get BeginFrame message. |
| 599 void OnSetNeedsBeginFrame(bool enabled); |
| 600 |
588 // The associated view. This is weak and is inserted into the view hierarchy | 601 // The associated view. This is weak and is inserted into the view hierarchy |
589 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the | 602 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the |
590 // destructor. | 603 // destructor. |
591 RenderWidgetHostViewCocoa* cocoa_view_; | 604 RenderWidgetHostViewCocoa* cocoa_view_; |
592 | 605 |
593 // Indicates if the page is loading. | 606 // Indicates if the page is loading. |
594 bool is_loading_; | 607 bool is_loading_; |
595 | 608 |
596 // Whether it's allowed to pause waiting for a new frame. | 609 // Whether it's allowed to pause waiting for a new frame. |
597 bool allow_pause_for_resize_or_repaint_; | 610 bool allow_pause_for_resize_or_repaint_; |
(...skipping 27 matching lines...) Expand all Loading... |
625 // The current composition character range and its bounds. | 638 // The current composition character range and its bounds. |
626 gfx::Range composition_range_; | 639 gfx::Range composition_range_; |
627 std::vector<gfx::Rect> composition_bounds_; | 640 std::vector<gfx::Rect> composition_bounds_; |
628 | 641 |
629 // The current caret bounds. | 642 // The current caret bounds. |
630 gfx::Rect caret_rect_; | 643 gfx::Rect caret_rect_; |
631 | 644 |
632 // Subscriber that listens to frame presentation events. | 645 // Subscriber that listens to frame presentation events. |
633 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; | 646 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; |
634 | 647 |
| 648 // True when corresponding RenderWidget needs BeginFrame. |
| 649 bool needs_begin_frame_; |
| 650 |
| 651 // True when --enable-begin-frame-scheduling is used. |
| 652 bool begin_frame_scheduling_is_enabled_; |
| 653 |
| 654 // Pass |last_begin_frame_args_| to BeginFrameManager when |this| is added |
| 655 // as its observer. With this, BeginFrameManager can determine whether latest |
| 656 // BeginFrameArgs is used immediately or not. |
| 657 cc::BeginFrameArgs last_begin_frame_args_; |
| 658 |
635 base::WeakPtrFactory<RenderWidgetHostViewMac> | 659 base::WeakPtrFactory<RenderWidgetHostViewMac> |
636 software_frame_weak_ptr_factory_; | 660 software_frame_weak_ptr_factory_; |
637 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 661 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
638 }; | 662 }; |
639 | 663 |
640 } // namespace content | 664 } // namespace content |
641 | 665 |
642 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 666 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |