| 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 output_surface_id, | 30 int compositor_frame_sink_id, |
| 31 bool is_swap_ack, | 31 bool is_swap_ack, |
| 32 const cc::ReturnedResourceArray& resources) = 0; | 32 const cc::ReturnedResourceArray& resources) = 0; |
| 33 virtual void BrowserCompositorMacOnLostCompositorResources() = 0; | 33 virtual void BrowserCompositorMacOnLostCompositorResources() = 0; |
| 34 virtual void BrowserCompositorMacSendBeginFrame( | 34 virtual void BrowserCompositorMacSendBeginFrame( |
| 35 const cc::BeginFrameArgs& args) = 0; | 35 const cc::BeginFrameArgs& args) = 0; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // This class owns a DelegatedFrameHost, and will dynamically attach and | 38 // This class owns a DelegatedFrameHost, and will dynamically attach and |
| 39 // detach it from a ui::Compositor as needed. The ui::Compositor will be | 39 // detach it from a ui::Compositor as needed. The ui::Compositor will be |
| 40 // detached from the DelegatedFrameHost when the following conditions are | 40 // detached from the DelegatedFrameHost when the following conditions are |
| (...skipping 13 matching lines...) Expand all Loading... |
| 54 bool ns_view_attached_to_window); | 54 bool ns_view_attached_to_window); |
| 55 ~BrowserCompositorMac() override; | 55 ~BrowserCompositorMac() override; |
| 56 | 56 |
| 57 // These will not return nullptr until Destroy is called. | 57 // These will not return nullptr until Destroy is called. |
| 58 DelegatedFrameHost* GetDelegatedFrameHost(); | 58 DelegatedFrameHost* GetDelegatedFrameHost(); |
| 59 | 59 |
| 60 // This may return nullptr, if this has detached itself from its | 60 // This may return nullptr, if this has detached itself from its |
| 61 // ui::Compositor. | 61 // ui::Compositor. |
| 62 ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); | 62 ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac(); |
| 63 | 63 |
| 64 void SwapCompositorFrame(uint32_t output_surface_id, | 64 void SwapCompositorFrame(uint32_t compositor_frame_sink_id, |
| 65 cc::CompositorFrame frame); | 65 cc::CompositorFrame frame); |
| 66 void SetHasTransparentBackground(bool transparent); | 66 void SetHasTransparentBackground(bool transparent); |
| 67 void SetDisplayColorSpace(const gfx::ColorSpace& color_space); | 67 void SetDisplayColorSpace(const gfx::ColorSpace& color_space); |
| 68 void UpdateVSyncParameters(const base::TimeTicks& timebase, | 68 void UpdateVSyncParameters(const base::TimeTicks& timebase, |
| 69 const base::TimeDelta& interval); | 69 const base::TimeDelta& interval); |
| 70 void SetNeedsBeginFrames(bool needs_begin_frames); | 70 void SetNeedsBeginFrames(bool needs_begin_frames); |
| 71 | 71 |
| 72 // 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 |
| 73 // DelegatedFrameHost while the RWHImpl is visible. | 73 // DelegatedFrameHost while the RWHImpl is visible. |
| 74 // 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... |
| 100 // DelegatedFrameHostClient implementation. | 100 // DelegatedFrameHostClient implementation. |
| 101 ui::Layer* DelegatedFrameHostGetLayer() const override; | 101 ui::Layer* DelegatedFrameHostGetLayer() const override; |
| 102 bool DelegatedFrameHostIsVisible() const override; | 102 bool DelegatedFrameHostIsVisible() const override; |
| 103 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; | 103 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override; |
| 104 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; | 104 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override; |
| 105 bool DelegatedFrameCanCreateResizeLock() const override; | 105 bool DelegatedFrameCanCreateResizeLock() const override; |
| 106 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( | 106 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock( |
| 107 bool defer_compositor_lock) override; | 107 bool defer_compositor_lock) override; |
| 108 void DelegatedFrameHostResizeLockWasReleased() override; | 108 void DelegatedFrameHostResizeLockWasReleased() override; |
| 109 void DelegatedFrameHostSendReclaimCompositorResources( | 109 void DelegatedFrameHostSendReclaimCompositorResources( |
| 110 int output_surface_id, | 110 int compositor_frame_sink_id, |
| 111 bool is_swap_ack, | 111 bool is_swap_ack, |
| 112 const cc::ReturnedResourceArray& resources) override; | 112 const cc::ReturnedResourceArray& resources) override; |
| 113 void DelegatedFrameHostOnLostCompositorResources() override; | 113 void DelegatedFrameHostOnLostCompositorResources() override; |
| 114 void SetBeginFrameSource(cc::BeginFrameSource* source) override; | 114 void SetBeginFrameSource(cc::BeginFrameSource* source) override; |
| 115 bool IsAutoResizeEnabled() const override; | 115 bool IsAutoResizeEnabled() const override; |
| 116 | 116 |
| 117 // cc::BeginFrameObserver implementation. | 117 // cc::BeginFrameObserver implementation. |
| 118 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | 118 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 119 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 119 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 120 void OnBeginFrameSourcePausedChanged(bool paused) override; | 120 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 cc::BeginFrameSource* begin_frame_source_ = nullptr; | 182 cc::BeginFrameSource* begin_frame_source_ = nullptr; |
| 183 cc::BeginFrameArgs last_begin_frame_args_; | 183 cc::BeginFrameArgs last_begin_frame_args_; |
| 184 bool needs_begin_frames_ = false; | 184 bool needs_begin_frames_ = false; |
| 185 | 185 |
| 186 base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; | 186 base::WeakPtrFactory<BrowserCompositorMac> weak_factory_; |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 } // namespace content | 189 } // namespace content |
| 190 | 190 |
| 191 #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 191 #endif // CONTENT_BROWSER_RENDERER_HOST_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| OLD | NEW |