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( | 29 virtual void BrowserCompositorMacSendReclaimCompositorResources( |
30 int compositor_frame_sink_id, | |
31 bool is_swap_ack, | 30 bool is_swap_ack, |
32 const cc::ReturnedResourceArray& resources) = 0; | 31 const cc::ReturnedResourceArray& resources) = 0; |
33 virtual void BrowserCompositorMacSendBeginFrame( | 32 virtual void BrowserCompositorMacSendBeginFrame( |
34 const cc::BeginFrameArgs& args) = 0; | 33 const cc::BeginFrameArgs& args) = 0; |
35 }; | 34 }; |
36 | 35 |
37 // This class owns a DelegatedFrameHost, and will dynamically attach and | 36 // This class owns a DelegatedFrameHost, and will dynamically attach and |
38 // detach it from a ui::Compositor as needed. The ui::Compositor will be | 37 // detach it from a ui::Compositor as needed. The ui::Compositor will be |
39 // detached from the DelegatedFrameHost when the following conditions are | 38 // detached from the DelegatedFrameHost when the following conditions are |
40 // all met: | 39 // all met: |
(...skipping 12 matching lines...) Expand all Loading... |
53 const cc::FrameSinkId& frame_sink_id); | 52 const cc::FrameSinkId& frame_sink_id); |
54 ~BrowserCompositorMac() override; | 53 ~BrowserCompositorMac() override; |
55 | 54 |
56 // These will not return nullptr until Destroy is called. | 55 // These will not return nullptr until Destroy is called. |
57 DelegatedFrameHost* GetDelegatedFrameHost(); | 56 DelegatedFrameHost* GetDelegatedFrameHost(); |
58 | 57 |
59 // This may return nullptr, if this has detached itself from its | 58 // This may return nullptr, if this has detached itself from its |
60 // ui::Compositor. | 59 // ui::Compositor. |
61 ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); | 60 ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); |
62 | 61 |
63 void SwapCompositorFrame(uint32_t compositor_frame_sink_id, | 62 void DidCreateNewRendererCompositorFrameSink(); |
64 const cc::LocalSurfaceId& local_surface_id, | 63 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
65 cc::CompositorFrame frame); | 64 cc::CompositorFrame frame); |
66 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); | 65 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); |
67 void SetHasTransparentBackground(bool transparent); | 66 void SetHasTransparentBackground(bool transparent); |
68 void SetDisplayColorProfile(const gfx::ICCProfile& icc_profile); | 67 void SetDisplayColorProfile(const gfx::ICCProfile& icc_profile); |
69 void UpdateVSyncParameters(const base::TimeTicks& timebase, | 68 void UpdateVSyncParameters(const base::TimeTicks& timebase, |
70 const base::TimeDelta& interval); | 69 const base::TimeDelta& interval); |
71 void SetNeedsBeginFrames(bool needs_begin_frames); | 70 void SetNeedsBeginFrames(bool needs_begin_frames); |
72 | 71 |
73 // This is used to ensure that the ui::Compositor be attached to the | 72 // This is used to ensure that the ui::Compositor be attached to the |
74 // DelegatedFrameHost while the RWHImpl is visible. | 73 // DelegatedFrameHost while the RWHImpl is visible. |
75 // Note: This should be called before the RWHImpl is made visible and after | 74 // Note: This should be called before the RWHImpl is made visible and after |
(...skipping 25 matching lines...) Expand all Loading... |
101 // DelegatedFrameHostClient implementation. | 100 // DelegatedFrameHostClient implementation. |
102 ui::Layer* DelegatedFrameHostGetLayer() const override; | 101 ui::Layer* DelegatedFrameHostGetLayer() const override; |
103 bool DelegatedFrameHostIsVisible() const override; | 102 bool DelegatedFrameHostIsVisible() const override; |
104 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; | 103 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; |
105 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; | 104 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; |
106 bool DelegatedFrameCanCreateResizeLock() const override; | 105 bool DelegatedFrameCanCreateResizeLock() const override; |
107 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( | 106 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( |
108 bool defer_compositor_lock) override; | 107 bool defer_compositor_lock) override; |
109 void DelegatedFrameHostResizeLockWasReleased() override; | 108 void DelegatedFrameHostResizeLockWasReleased() override; |
110 void DelegatedFrameHostSendReclaimCompositorResources( | 109 void DelegatedFrameHostSendReclaimCompositorResources( |
111 int compositor_frame_sink_id, | |
112 bool is_swap_ack, | 110 bool is_swap_ack, |
113 const cc::ReturnedResourceArray& resources) override; | 111 const cc::ReturnedResourceArray& resources) override; |
114 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | 112 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
115 bool IsAutoResizeEnabled() const override; | 113 bool IsAutoResizeEnabled() const override; |
116 | 114 |
117 private: | 115 private: |
118 // The state of |delegated_frame_host_| and |recyclable_compositor_| to | 116 // The state of |delegated_frame_host_| and |recyclable_compositor_| to |
119 // manage being visible, hidden, or occluded. | 117 // manage being visible, hidden, or occluded. |
120 enum State { | 118 enum State { |
121 // Effects: | 119 // Effects: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 std::unique_ptr<ui::Layer> root_layer_; | 170 std::unique_ptr<ui::Layer> root_layer_; |
173 | 171 |
174 bool has_transparent_background_ = false; | 172 bool has_transparent_background_ = false; |
175 | 173 |
176 base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; | 174 base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; |
177 }; | 175 }; |
178 | 176 |
179 } // namespace content | 177 } // namespace content |
180 | 178 |
181 #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 179 #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
OLD | NEW |