Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.h

Issue 316103004: Mac ÜC: Enable GPU back-pressure from the browser to the renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dip
Patch Set: Simplify Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser_compositor_view_mac.h"
19 #include "content/browser/compositor/delegated_frame_host.h" 20 #include "content/browser/compositor/delegated_frame_host.h"
20 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" 21 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h"
21 #include "content/browser/renderer_host/display_link_mac.h" 22 #include "content/browser/renderer_host/display_link_mac.h"
22 #include "content/browser/renderer_host/render_widget_host_view_base.h" 23 #include "content/browser/renderer_host/render_widget_host_view_base.h"
23 #include "content/browser/renderer_host/software_frame_manager.h" 24 #include "content/browser/renderer_host/software_frame_manager.h"
24 #include "content/common/content_export.h" 25 #include "content/common/content_export.h"
25 #include "content/common/cursors/webcursor.h" 26 #include "content/common/cursors/webcursor.h"
26 #include "content/common/edit_command.h" 27 #include "content/common/edit_command.h"
27 #import "content/public/browser/render_widget_host_view_mac_base.h" 28 #import "content/public/browser/render_widget_host_view_mac_base.h"
28 #include "ipc/ipc_sender.h" 29 #include "ipc/ipc_sender.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // "The lifetime of the RenderWidgetHost* is tied to the render process. 207 // "The lifetime of the RenderWidgetHost* is tied to the render process.
207 // If the render process dies, the RenderWidgetHost* goes away and all 208 // If the render process dies, the RenderWidgetHost* goes away and all
208 // references to it must become NULL." 209 // references to it must become NULL."
209 // 210 //
210 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h. 211 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
211 class CONTENT_EXPORT RenderWidgetHostViewMac 212 class CONTENT_EXPORT RenderWidgetHostViewMac
212 : public RenderWidgetHostViewBase, 213 : public RenderWidgetHostViewBase,
213 public DelegatedFrameHostClient, 214 public DelegatedFrameHostClient,
214 public IPC::Sender, 215 public IPC::Sender,
215 public SoftwareFrameManagerClient, 216 public SoftwareFrameManagerClient,
217 public BrowserCompositorViewMacClient,
216 public CompositingIOSurfaceLayerClient { 218 public CompositingIOSurfaceLayerClient {
217 public: 219 public:
218 // The view will associate itself with the given widget. The native view must 220 // The view will associate itself with the given widget. The native view must
219 // be hooked up immediately to the view hierarchy, or else when it is 221 // be hooked up immediately to the view hierarchy, or else when it is
220 // deleted it will delete this out from under the caller. 222 // deleted it will delete this out from under the caller.
221 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); 223 explicit RenderWidgetHostViewMac(RenderWidgetHost* widget);
222 virtual ~RenderWidgetHostViewMac(); 224 virtual ~RenderWidgetHostViewMac();
223 225
224 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; } 226 RenderWidgetHostViewCocoa* cocoa_view() const { return cocoa_view_; }
225 227
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // IPC::Sender implementation. 338 // IPC::Sender implementation.
337 virtual bool Send(IPC::Message* message) OVERRIDE; 339 virtual bool Send(IPC::Message* message) OVERRIDE;
338 340
339 // SoftwareFrameManagerClient implementation: 341 // SoftwareFrameManagerClient implementation:
340 virtual void SoftwareFrameWasFreed( 342 virtual void SoftwareFrameWasFreed(
341 uint32 output_surface_id, unsigned frame_id) OVERRIDE; 343 uint32 output_surface_id, unsigned frame_id) OVERRIDE;
342 virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE; 344 virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE;
343 345
344 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; 346 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE;
345 347
348 // BrowserCompositorViewMacHelper implementation.
349 virtual void BrowserCompositorDidDrawFrame() OVERRIDE;
350
346 // CompositingIOSurfaceLayerClient implementation. 351 // CompositingIOSurfaceLayerClient implementation.
347 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; 352 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE;
348 353
349 // Forwards the mouse event to the renderer. 354 // Forwards the mouse event to the renderer.
350 void ForwardMouseEvent(const blink::WebMouseEvent& event); 355 void ForwardMouseEvent(const blink::WebMouseEvent& event);
351 356
352 void KillSelf(); 357 void KillSelf();
353 358
354 void SetTextInputActive(bool active); 359 void SetTextInputActive(bool active);
355 360
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer. 446 // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer.
442 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_; 447 base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_;
443 scoped_refptr<CompositingIOSurfaceMac> compositing_iosurface_; 448 scoped_refptr<CompositingIOSurfaceMac> compositing_iosurface_;
444 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_; 449 scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_;
445 450
446 // Delegated frame management and compositior. 451 // Delegated frame management and compositior.
447 base::scoped_nsobject<BrowserCompositorViewMac> browser_compositor_view_; 452 base::scoped_nsobject<BrowserCompositorViewMac> browser_compositor_view_;
448 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; 453 scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
449 scoped_ptr<ui::Layer> root_layer_; 454 scoped_ptr<ui::Layer> root_layer_;
450 455
456 // This lock is taken when the browser compositor produces a frame, and is
457 // released when that frame is displayed. It is by this mechanism that the
458 // browser compositor can exert GPU backpressure on the renderer compositor.
459 scoped_refptr<ui::CompositorLock> browser_compositor_lock_;
460 bool browser_compositor_damaged_during_lock_;
461
451 // This holds the current software compositing framebuffer, if any. 462 // This holds the current software compositing framebuffer, if any.
452 scoped_ptr<SoftwareFrameManager> software_frame_manager_; 463 scoped_ptr<SoftwareFrameManager> software_frame_manager_;
453 464
454 // Whether to allow overlapping views. 465 // Whether to allow overlapping views.
455 bool allow_overlapping_views_; 466 bool allow_overlapping_views_;
456 467
457 // Whether to use the CoreAnimation path to draw content. 468 // Whether to use the CoreAnimation path to draw content.
458 bool use_core_animation_; 469 bool use_core_animation_;
459 470
460 // Latency info to send back when the next frame appears on the 471 // Latency info to send back when the next frame appears on the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // all of them using this function when any of those parameters changes. Also 522 // all of them using this function when any of those parameters changes. Also
512 // update the scale factor of the layers. 523 // update the scale factor of the layers.
513 void LayoutLayers(); 524 void LayoutLayers();
514 525
515 // DelegatedFrameHostClient implementation. 526 // DelegatedFrameHostClient implementation.
516 virtual ui::Compositor* GetCompositor() const OVERRIDE; 527 virtual ui::Compositor* GetCompositor() const OVERRIDE;
517 virtual ui::Layer* GetLayer() OVERRIDE; 528 virtual ui::Layer* GetLayer() OVERRIDE;
518 virtual RenderWidgetHostImpl* GetHost() OVERRIDE; 529 virtual RenderWidgetHostImpl* GetHost() OVERRIDE;
519 virtual void SchedulePaintInRect( 530 virtual void SchedulePaintInRect(
520 const gfx::Rect& damage_rect_in_dip) OVERRIDE; 531 const gfx::Rect& damage_rect_in_dip) OVERRIDE;
532 virtual void DelegatedCompositorDidSwapBuffers() OVERRIDE;
533 virtual void DelegatedCompositorAbortedSwapBuffers() OVERRIDE;
521 virtual bool IsVisible() OVERRIDE; 534 virtual bool IsVisible() OVERRIDE;
522 virtual scoped_ptr<ResizeLock> CreateResizeLock( 535 virtual scoped_ptr<ResizeLock> CreateResizeLock(
523 bool defer_compositor_lock) OVERRIDE; 536 bool defer_compositor_lock) OVERRIDE;
524 virtual gfx::Size DesiredFrameSize() OVERRIDE; 537 virtual gfx::Size DesiredFrameSize() OVERRIDE;
525 virtual float CurrentDeviceScaleFactor() OVERRIDE; 538 virtual float CurrentDeviceScaleFactor() OVERRIDE;
526 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE; 539 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) OVERRIDE;
527 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE; 540 virtual DelegatedFrameHost* GetDelegatedFrameHost() const OVERRIDE;
528 541
529 private: 542 private:
530 friend class RenderWidgetHostViewMacTest; 543 friend class RenderWidgetHostViewMacTest;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 void OnDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar, 596 void OnDidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar,
584 bool has_vertical_scrollbar); 597 bool has_vertical_scrollbar);
585 598
586 // Convert |rect| from the views coordinate (upper-left origin) into 599 // Convert |rect| from the views coordinate (upper-left origin) into
587 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays. 600 // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays.
588 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect); 601 gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect);
589 602
590 // Send updated vsync parameters to the renderer. 603 // Send updated vsync parameters to the renderer.
591 void SendVSyncParametersToRenderer(); 604 void SendVSyncParametersToRenderer();
592 605
606 // Release the browser compositor lock, and request another frame from the
607 // browser compositor. Because this can be requested from inside compositor
608 // calbacks, post it as task instead of calling it directly.
609 void PostReleaseBrowserCompositorLock();
610 void ReleaseBrowserCompositorLock();
611
593 // The associated view. This is weak and is inserted into the view hierarchy 612 // The associated view. This is weak and is inserted into the view hierarchy
594 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the 613 // to own this RenderWidgetHostViewMac object. Set to nil at the start of the
595 // destructor. 614 // destructor.
596 RenderWidgetHostViewCocoa* cocoa_view_; 615 RenderWidgetHostViewCocoa* cocoa_view_;
597 616
598 // Indicates if the page is loading. 617 // Indicates if the page is loading.
599 bool is_loading_; 618 bool is_loading_;
600 619
601 // The text to be shown in the tooltip, supplied by the renderer. 620 // The text to be shown in the tooltip, supplied by the renderer.
602 base::string16 tooltip_text_; 621 base::string16 tooltip_text_;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; 670 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
652 671
653 base::WeakPtrFactory<RenderWidgetHostViewMac> 672 base::WeakPtrFactory<RenderWidgetHostViewMac>
654 software_frame_weak_ptr_factory_; 673 software_frame_weak_ptr_factory_;
655 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); 674 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac);
656 }; 675 };
657 676
658 } // namespace content 677 } // namespace content
659 678
660 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ 679 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698