| 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> |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // "The lifetime of the RenderWidgetHost* is tied to the render process. | 207 // "The lifetime of the RenderWidgetHost* is tied to the render process. |
| 208 // If the render process dies, the RenderWidgetHost* goes away and all | 208 // If the render process dies, the RenderWidgetHost* goes away and all |
| 209 // references to it must become NULL." | 209 // references to it must become NULL." |
| 210 // | 210 // |
| 211 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. | 211 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. |
| 212 class CONTENT_EXPORT RenderWidgetHostViewMac | 212 class CONTENT_EXPORT RenderWidgetHostViewMac |
| 213 : public RenderWidgetHostViewBase, | 213 : public RenderWidgetHostViewBase, |
| 214 public DelegatedFrameHostClient, | 214 public DelegatedFrameHostClient, |
| 215 public IPC::Sender, | 215 public IPC::Sender, |
| 216 public SoftwareFrameManagerClient, | 216 public SoftwareFrameManagerClient, |
| 217 public BrowserCompositorViewMacClient, | |
| 218 public CompositingIOSurfaceLayerClient { | 217 public CompositingIOSurfaceLayerClient { |
| 219 public: | 218 public: |
| 220 // The view will associate itself with the given widget. The native view must | 219 // 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 | 220 // be hooked up immediately to the view hierarchy, or else when it is |
| 222 // deleted it will delete this out from under the caller. | 221 // deleted it will delete this out from under the caller. |
| 223 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); | 222 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); |
| 224 virtual ~RenderWidgetHostViewMac(); | 223 virtual ~RenderWidgetHostViewMac(); |
| 225 | 224 |
| 226 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } | 225 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } |
| 227 | 226 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // IPC::Sender implementation. | 337 // IPC::Sender implementation. |
| 339 virtual bool Send(IPC::Message* message) OVERRIDE; | 338 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 340 | 339 |
| 341 // SoftwareFrameManagerClient implementation: | 340 // SoftwareFrameManagerClient implementation: |
| 342 virtual void SoftwareFrameWasFreed( | 341 virtual void SoftwareFrameWasFreed( |
| 343 uint32 output_surface_id, unsigned frame_id) OVERRIDE; | 342 uint32 output_surface_id, unsigned frame_id) OVERRIDE; |
| 344 virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE; | 343 virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE; |
| 345 | 344 |
| 346 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; | 345 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; |
| 347 | 346 |
| 348 // BrowserCompositorViewMacHelper implementation. | |
| 349 virtual void BrowserCompositorDidDrawFrame() OVERRIDE; | |
| 350 | |
| 351 // CompositingIOSurfaceLayerClient implementation. | 347 // CompositingIOSurfaceLayerClient implementation. |
| 352 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; | 348 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; |
| 353 | 349 |
| 354 // Forwards the mouse event to the renderer. | 350 // Forwards the mouse event to the renderer. |
| 355 void ForwardMouseEvent(const blink::WebMouseEvent& event); | 351 void ForwardMouseEvent(const blink::WebMouseEvent& event); |
| 356 | 352 |
| 357 void KillSelf(); | 353 void KillSelf(); |
| 358 | 354 |
| 359 void SetTextInputActive(bool active); | 355 void SetTextInputActive(bool active); |
| 360 | 356 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer. | 428 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer. |
| 433 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_; | 429 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_; |
| 434 scoped_refptr<CompositingIOSurfaceMac> compositing_iosurface_; | 430 scoped_refptr<CompositingIOSurfaceMac> compositing_iosurface_; |
| 435 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_; | 431 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_; |
| 436 | 432 |
| 437 // Delegated frame management and compositior. | 433 // Delegated frame management and compositior. |
| 438 base::scoped_nsobject<BrowserCompositorViewMac> browser_compositor_view_; | 434 base::scoped_nsobject<BrowserCompositorViewMac> browser_compositor_view_; |
| 439 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; | 435 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; |
| 440 scoped_ptr<ui::Layer> root_layer_; | 436 scoped_ptr<ui::Layer> root_layer_; |
| 441 | 437 |
| 442 // This lock is taken when the browser compositor produces a frame, and is | |
| 443 // released when that frame is displayed. It is by this mechanism that the | |
| 444 // browser compositor can exert GPU backpressure on the renderer compositor. | |
| 445 scoped_refptr<ui::CompositorLock> browser_compositor_lock_; | |
| 446 bool browser_compositor_damaged_during_lock_; | |
| 447 | |
| 448 // This holds the current software compositing framebuffer, if any. | 438 // This holds the current software compositing framebuffer, if any. |
| 449 scoped_ptr<SoftwareFrameManager> software_frame_manager_; | 439 scoped_ptr<SoftwareFrameManager> software_frame_manager_; |
| 450 | 440 |
| 451 // Latency info to send back when the next frame appears on the | 441 // Latency info to send back when the next frame appears on the |
| 452 // screen. | 442 // screen. |
| 453 std::vector<ui::LatencyInfo> pending_latency_info_; | 443 std::vector<ui::LatencyInfo> pending_latency_info_; |
| 454 | 444 |
| 455 // When taking a screenshot when using CoreAnimation, add a delay of | 445 // When taking a screenshot when using CoreAnimation, add a delay of |
| 456 // a few frames to ensure that the contents have reached the screen | 446 // a few frames to ensure that the contents have reached the screen |
| 457 // before reporting latency info. | 447 // before reporting latency info. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // all of them using this function when any of those parameters changes. Also | 492 // all of them using this function when any of those parameters changes. Also |
| 503 // update the scale factor of the layers. | 493 // update the scale factor of the layers. |
| 504 void LayoutLayers(); | 494 void LayoutLayers(); |
| 505 | 495 |
| 506 // DelegatedFrameHostClient implementation. | 496 // DelegatedFrameHostClient implementation. |
| 507 virtual ui::Compositor* GetCompositor() const OVERRIDE; | 497 virtual ui::Compositor* GetCompositor() const OVERRIDE; |
| 508 virtual ui::Layer* GetLayer() OVERRIDE; | 498 virtual ui::Layer* GetLayer() OVERRIDE; |
| 509 virtual RenderWidgetHostImpl* GetHost() OVERRIDE; | 499 virtual RenderWidgetHostImpl* GetHost() OVERRIDE; |
| 510 virtual void SchedulePaintInRect( | 500 virtual void SchedulePaintInRect( |
| 511 const gfx::Rect& damage_rect_in_dip) OVERRIDE; | 501 const gfx::Rect& damage_rect_in_dip) OVERRIDE; |
| 512 virtual void DelegatedCompositorDidSwapBuffers() OVERRIDE; | |
| 513 virtual void DelegatedCompositorAbortedSwapBuffers() OVERRIDE; | |
| 514 virtual bool IsVisible() OVERRIDE; | 502 virtual bool IsVisible() OVERRIDE; |
| 515 virtual scoped_ptr<ResizeLock> CreateResizeLock( | 503 virtual scoped_ptr<ResizeLock> CreateResizeLock( |
| 516 bool defer_compositor_lock) OVERRIDE; | 504 bool defer_compositor_lock) OVERRIDE; |
| 517 virtual gfx::Size DesiredFrameSize() OVERRIDE; | 505 virtual gfx::Size DesiredFrameSize() OVERRIDE; |
| 518 virtual float CurrentDeviceScaleFactor() OVERRIDE; | 506 virtual float CurrentDeviceScaleFactor() OVERRIDE; |
| 519 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE; | 507 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE; |
| 520 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE; | 508 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE; |
| 521 | 509 |
| 522 private: | 510 private: |
| 523 friend class RenderWidgetHostViewMacTest; | 511 friend class RenderWidgetHostViewMacTest; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 void OnDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar, | 556 void OnDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar, |
| 569 bool has_vertical_scrollbar); | 557 bool has_vertical_scrollbar); |
| 570 | 558 |
| 571 // Convert |rect| from the views coordinate (upper-left origin) into | 559 // Convert |rect| from the views coordinate (upper-left origin) into |
| 572 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays. | 560 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays. |
| 573 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect); | 561 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect); |
| 574 | 562 |
| 575 // Send updated vsync parameters to the renderer. | 563 // Send updated vsync parameters to the renderer. |
| 576 void SendVSyncParametersToRenderer(); | 564 void SendVSyncParametersToRenderer(); |
| 577 | 565 |
| 578 // Release the browser compositor lock, and request another frame from the | |
| 579 // browser compositor. Because this can be requested from inside compositor | |
| 580 // calbacks, post it as task instead of calling it directly. | |
| 581 void PostReleaseBrowserCompositorLock(); | |
| 582 void ReleaseBrowserCompositorLock(); | |
| 583 | |
| 584 // The associated view. This is weak and is inserted into the view hierarchy | 566 // The associated view. This is weak and is inserted into the view hierarchy |
| 585 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the | 567 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the |
| 586 // destructor. | 568 // destructor. |
| 587 RenderWidgetHostViewCocoa* cocoa_view_; | 569 RenderWidgetHostViewCocoa* cocoa_view_; |
| 588 | 570 |
| 589 // Indicates if the page is loading. | 571 // Indicates if the page is loading. |
| 590 bool is_loading_; | 572 bool is_loading_; |
| 591 | 573 |
| 592 // The text to be shown in the tooltip, supplied by the renderer. | 574 // The text to be shown in the tooltip, supplied by the renderer. |
| 593 base::string16 tooltip_text_; | 575 base::string16 tooltip_text_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; | 617 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; |
| 636 | 618 |
| 637 base::WeakPtrFactory<RenderWidgetHostViewMac> | 619 base::WeakPtrFactory<RenderWidgetHostViewMac> |
| 638 software_frame_weak_ptr_factory_; | 620 software_frame_weak_ptr_factory_; |
| 639 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 621 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
| 640 }; | 622 }; |
| 641 | 623 |
| 642 } // namespace content | 624 } // namespace content |
| 643 | 625 |
| 644 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 626 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
| OLD | NEW |