| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
| 12 #include "content/browser/renderer_host/delegated_frame_host.h" | 12 #include "content/browser/renderer_host/delegated_frame_host.h" |
| 13 #include "ui/compositor/compositor.h" | 13 #include "ui/compositor/compositor.h" |
| 14 #include "ui/compositor/compositor_observer.h" | 14 #include "ui/compositor/compositor_observer.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 class AcceleratedWidgetMac; | 17 class AcceleratedWidgetMac; |
| 18 class AcceleratedWidgetMacNSView; | 18 class AcceleratedWidgetMacNSView; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 class RecyclableCompositorMac; | 23 class RecyclableCompositorMac; |
| 24 | 24 |
| 25 class BrowserCompositorMacClient { | 25 class BrowserCompositorMacClient { |
| 26 public: | 26 public: |
| 27 virtual NSView* BrowserCompositorMacGetNSView() const = 0; | 27 virtual NSView* BrowserCompositorMacGetNSView() const = 0; |
| 28 virtual SkColor BrowserCompositorMacGetGutterColor(SkColor color) const = 0; | 28 virtual SkColor BrowserCompositorMacGetGutterColor(SkColor color) const = 0; |
| 29 virtual void BrowserCompositorMacSendReclaimCompositorResources( | |
| 30 bool is_swap_ack, | |
| 31 const cc::ReturnedResourceArray& resources) = 0; | |
| 32 virtual void BrowserCompositorMacSendBeginFrame( | 29 virtual void BrowserCompositorMacSendBeginFrame( |
| 33 const cc::BeginFrameArgs& args) = 0; | 30 const cc::BeginFrameArgs& args) = 0; |
| 34 }; | 31 }; |
| 35 | 32 |
| 36 // This class owns a DelegatedFrameHost, and will dynamically attach and | 33 // This class owns a DelegatedFrameHost, and will dynamically attach and |
| 37 // detach it from a ui::Compositor as needed. The ui::Compositor will be | 34 // detach it from a ui::Compositor as needed. The ui::Compositor will be |
| 38 // detached from the DelegatedFrameHost when the following conditions are | 35 // detached from the DelegatedFrameHost when the following conditions are |
| 39 // all met: | 36 // all met: |
| 40 // - There are no outstanding copy requests | 37 // - There are no outstanding copy requests |
| 41 // - The RenderWidgetHostImpl providing frames to the DelegatedFrameHost | 38 // - The RenderWidgetHostImpl providing frames to the DelegatedFrameHost |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 const cc::FrameSinkId& frame_sink_id); | 49 const cc::FrameSinkId& frame_sink_id); |
| 53 ~BrowserCompositorMac() override; | 50 ~BrowserCompositorMac() override; |
| 54 | 51 |
| 55 // These will not return nullptr until Destroy is called. | 52 // These will not return nullptr until Destroy is called. |
| 56 DelegatedFrameHost* GetDelegatedFrameHost(); | 53 DelegatedFrameHost* GetDelegatedFrameHost(); |
| 57 | 54 |
| 58 // This may return nullptr, if this has detached itself from its | 55 // This may return nullptr, if this has detached itself from its |
| 59 // ui::Compositor. | 56 // ui::Compositor. |
| 60 ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); | 57 ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); |
| 61 | 58 |
| 62 void DidCreateNewRendererCompositorFrameSink(); | 59 void DidCreateNewRendererCompositorFrameSink( |
| 60 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink); |
| 63 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, | 61 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
| 64 cc::CompositorFrame frame); | 62 cc::CompositorFrame frame); |
| 65 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); | 63 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); |
| 66 void SetHasTransparentBackground(bool transparent); | 64 void SetHasTransparentBackground(bool transparent); |
| 67 void SetDisplayColorProfile(const gfx::ICCProfile& icc_profile); | 65 void SetDisplayColorProfile(const gfx::ICCProfile& icc_profile); |
| 68 void UpdateVSyncParameters(const base::TimeTicks& timebase, | 66 void UpdateVSyncParameters(const base::TimeTicks& timebase, |
| 69 const base::TimeDelta& interval); | 67 const base::TimeDelta& interval); |
| 70 void SetNeedsBeginFrames(bool needs_begin_frames); | 68 void SetNeedsBeginFrames(bool needs_begin_frames); |
| 71 | 69 |
| 72 // This is used to ensure that the ui::Compositor be attached to the | 70 // This is used to ensure that the ui::Compositor be attached to the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 98 static void DisableRecyclingForShutdown(); | 96 static void DisableRecyclingForShutdown(); |
| 99 | 97 |
| 100 // DelegatedFrameHostClient implementation. | 98 // DelegatedFrameHostClient implementation. |
| 101 ui::Layer* DelegatedFrameHostGetLayer() const override; | 99 ui::Layer* DelegatedFrameHostGetLayer() const override; |
| 102 bool DelegatedFrameHostIsVisible() const override; | 100 bool DelegatedFrameHostIsVisible() const override; |
| 103 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; | 101 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; |
| 104 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; | 102 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; |
| 105 bool DelegatedFrameCanCreateResizeLock() const override; | 103 bool DelegatedFrameCanCreateResizeLock() const override; |
| 106 std::unique_ptr<CompositorResizeLock> DelegatedFrameHostCreateResizeLock() | 104 std::unique_ptr<CompositorResizeLock> DelegatedFrameHostCreateResizeLock() |
| 107 override; | 105 override; |
| 108 void DelegatedFrameHostSendReclaimCompositorResources( | |
| 109 bool is_swap_ack, | |
| 110 const cc::ReturnedResourceArray& resources) override; | |
| 111 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | 106 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 112 bool IsAutoResizeEnabled() const override; | 107 bool IsAutoResizeEnabled() const override; |
| 113 | 108 |
| 114 private: | 109 private: |
| 115 // The state of |delegated_frame_host_| and |recyclable_compositor_| to | 110 // The state of |delegated_frame_host_| and |recyclable_compositor_| to |
| 116 // manage being visible, hidden, or occluded. | 111 // manage being visible, hidden, or occluded. |
| 117 enum State { | 112 enum State { |
| 118 // Effects: | 113 // Effects: |
| 119 // - |recyclable_compositor_| exists and is attached to | 114 // - |recyclable_compositor_| exists and is attached to |
| 120 // |delegated_frame_host_|. | 115 // |delegated_frame_host_|. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 bool ns_view_attached_to_window_ = false; | 157 bool ns_view_attached_to_window_ = false; |
| 163 | 158 |
| 164 BrowserCompositorMacClient* client_ = nullptr; | 159 BrowserCompositorMacClient* client_ = nullptr; |
| 165 ui::AcceleratedWidgetMacNSView* accelerated_widget_mac_ns_view_ = nullptr; | 160 ui::AcceleratedWidgetMacNSView* accelerated_widget_mac_ns_view_ = nullptr; |
| 166 std::unique_ptr<RecyclableCompositorMac> recyclable_compositor_; | 161 std::unique_ptr<RecyclableCompositorMac> recyclable_compositor_; |
| 167 | 162 |
| 168 std::unique_ptr<DelegatedFrameHost> delegated_frame_host_; | 163 std::unique_ptr<DelegatedFrameHost> delegated_frame_host_; |
| 169 std::unique_ptr<ui::Layer> root_layer_; | 164 std::unique_ptr<ui::Layer> root_layer_; |
| 170 | 165 |
| 171 bool has_transparent_background_ = false; | 166 bool has_transparent_background_ = false; |
| 167 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink_ = |
| 168 nullptr; |
| 172 | 169 |
| 173 base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; | 170 base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; |
| 174 }; | 171 }; |
| 175 | 172 |
| 176 } // namespace content | 173 } // namespace content |
| 177 | 174 |
| 178 #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 175 #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| OLD | NEW |