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_COMPOSITOR_DELEGATED_FRAME_HOST_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ |
6 #define CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ |
7 | 7 |
8 #include "cc/layers/delegated_frame_provider.h" | 8 #include "cc/layers/delegated_frame_provider.h" |
9 #include "cc/layers/delegated_frame_resource_collection.h" | 9 #include "cc/layers/delegated_frame_resource_collection.h" |
10 #include "cc/output/copy_output_result.h" | 10 #include "cc/output/copy_output_result.h" |
11 #include "cc/surfaces/surface_factory_client.h" | 11 #include "cc/surfaces/surface_factory_client.h" |
12 #include "content/browser/compositor/image_transport_factory.h" | 12 #include "content/browser/compositor/image_transport_factory.h" |
13 #include "content/browser/compositor/owned_mailbox.h" | 13 #include "content/browser/compositor/owned_mailbox.h" |
14 #include "content/browser/renderer_host/delegated_frame_evictor.h" | 14 #include "content/browser/renderer_host/delegated_frame_evictor.h" |
15 #include "content/browser/renderer_host/dip_util.h" | 15 #include "content/browser/renderer_host/dip_util.h" |
16 #include "content/browser/renderer_host/render_widget_host_impl.h" | 16 #include "content/browser/renderer_host/render_widget_host_impl.h" |
17 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
19 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
20 #include "ui/compositor/compositor_observer.h" | 20 #include "ui/compositor/compositor_observer.h" |
| 21 #include "ui/compositor/compositor_vsync_manager.h" |
21 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
22 #include "ui/compositor/layer_owner_delegate.h" | 23 #include "ui/compositor/layer_owner_delegate.h" |
23 #include "ui/gfx/geometry/rect_conversions.h" | 24 #include "ui/gfx/geometry/rect_conversions.h" |
24 | 25 |
25 namespace cc { | 26 namespace cc { |
26 class SurfaceFactory; | 27 class SurfaceFactory; |
27 enum class SurfaceDrawStatus; | 28 enum class SurfaceDrawStatus; |
28 } | 29 } |
29 | 30 |
30 namespace media { | 31 namespace media { |
(...skipping 22 matching lines...) Expand all Loading... |
53 bool defer_compositor_lock) = 0; | 54 bool defer_compositor_lock) = 0; |
54 virtual void DelegatedFrameHostResizeLockWasReleased() = 0; | 55 virtual void DelegatedFrameHostResizeLockWasReleased() = 0; |
55 | 56 |
56 virtual void DelegatedFrameHostSendCompositorSwapAck( | 57 virtual void DelegatedFrameHostSendCompositorSwapAck( |
57 int output_surface_id, | 58 int output_surface_id, |
58 const cc::CompositorFrameAck& ack) = 0; | 59 const cc::CompositorFrameAck& ack) = 0; |
59 virtual void DelegatedFrameHostSendReclaimCompositorResources( | 60 virtual void DelegatedFrameHostSendReclaimCompositorResources( |
60 int output_surface_id, | 61 int output_surface_id, |
61 const cc::CompositorFrameAck& ack) = 0; | 62 const cc::CompositorFrameAck& ack) = 0; |
62 virtual void DelegatedFrameHostOnLostCompositorResources() = 0; | 63 virtual void DelegatedFrameHostOnLostCompositorResources() = 0; |
| 64 |
| 65 virtual void DelegatedFrameHostUpdateVSyncParameters( |
| 66 const base::TimeTicks& timebase, |
| 67 const base::TimeDelta& interval) = 0; |
63 }; | 68 }; |
64 | 69 |
65 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state | 70 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state |
66 // and functionality that is associated with delegated frames being sent from | 71 // and functionality that is associated with delegated frames being sent from |
67 // the RenderWidget. The DelegatedFrameHost will push these changes through to | 72 // the RenderWidget. The DelegatedFrameHost will push these changes through to |
68 // the ui::Compositor associated with its DelegatedFrameHostClient. | 73 // the ui::Compositor associated with its DelegatedFrameHostClient. |
69 class CONTENT_EXPORT DelegatedFrameHost | 74 class CONTENT_EXPORT DelegatedFrameHost |
70 : public ui::CompositorObserver, | 75 : public ui::CompositorObserver, |
| 76 public ui::CompositorVSyncManager::Observer, |
71 public ui::LayerOwnerDelegate, | 77 public ui::LayerOwnerDelegate, |
72 public ImageTransportFactoryObserver, | 78 public ImageTransportFactoryObserver, |
73 public DelegatedFrameEvictorClient, | 79 public DelegatedFrameEvictorClient, |
74 public cc::DelegatedFrameResourceCollectionClient, | 80 public cc::DelegatedFrameResourceCollectionClient, |
75 public cc::SurfaceFactoryClient, | 81 public cc::SurfaceFactoryClient, |
76 public base::SupportsWeakPtr<DelegatedFrameHost> { | 82 public base::SupportsWeakPtr<DelegatedFrameHost> { |
77 public: | 83 public: |
78 DelegatedFrameHost(DelegatedFrameHostClient* client); | 84 DelegatedFrameHost(DelegatedFrameHostClient* client); |
79 ~DelegatedFrameHost() override; | 85 ~DelegatedFrameHost() override; |
80 | 86 |
81 bool CanCopyToBitmap() const; | 87 bool CanCopyToBitmap() const; |
82 | 88 |
83 // Public interface exposed to RenderWidgetHostView. | 89 // Public interface exposed to RenderWidgetHostView. |
84 void SwapDelegatedFrame( | 90 void SwapDelegatedFrame( |
85 uint32 output_surface_id, | 91 uint32 output_surface_id, |
86 scoped_ptr<cc::DelegatedFrameData> frame_data, | 92 scoped_ptr<cc::DelegatedFrameData> frame_data, |
87 float frame_device_scale_factor, | 93 float frame_device_scale_factor, |
88 const std::vector<ui::LatencyInfo>& latency_info); | 94 const std::vector<ui::LatencyInfo>& latency_info); |
89 void WasHidden(); | 95 void WasHidden(); |
90 void WasShown(const ui::LatencyInfo& latency_info); | 96 void WasShown(const ui::LatencyInfo& latency_info); |
91 void WasResized(); | 97 void WasResized(); |
92 bool HasSavedFrame(); | 98 bool HasSavedFrame(); |
93 gfx::Size GetRequestedRendererSize() const; | 99 gfx::Size GetRequestedRendererSize() const; |
94 void SetCompositor(ui::Compositor* compositor); | 100 void SetCompositor(ui::Compositor* compositor); |
95 void ResetCompositor(); | 101 void ResetCompositor(); |
96 void SetVSyncParameters(base::TimeTicks timebase, base::TimeDelta interval); | |
97 // Note: |src_subset| is specified in DIP dimensions while |output_size| | 102 // Note: |src_subset| is specified in DIP dimensions while |output_size| |
98 // expects pixels. | 103 // expects pixels. |
99 void CopyFromCompositingSurface(const gfx::Rect& src_subrect, | 104 void CopyFromCompositingSurface(const gfx::Rect& src_subrect, |
100 const gfx::Size& output_size, | 105 const gfx::Size& output_size, |
101 ReadbackRequestCallback& callback, | 106 ReadbackRequestCallback& callback, |
102 const SkColorType color_type); | 107 const SkColorType color_type); |
103 void CopyFromCompositingSurfaceToVideoFrame( | 108 void CopyFromCompositingSurfaceToVideoFrame( |
104 const gfx::Rect& src_subrect, | 109 const gfx::Rect& src_subrect, |
105 const scoped_refptr<media::VideoFrame>& target, | 110 const scoped_refptr<media::VideoFrame>& target, |
106 const base::Callback<void(bool)>& callback); | 111 const base::Callback<void(bool)>& callback); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 151 |
147 // Overridden from ui::CompositorObserver: | 152 // Overridden from ui::CompositorObserver: |
148 void OnCompositingDidCommit(ui::Compositor* compositor) override; | 153 void OnCompositingDidCommit(ui::Compositor* compositor) override; |
149 void OnCompositingStarted(ui::Compositor* compositor, | 154 void OnCompositingStarted(ui::Compositor* compositor, |
150 base::TimeTicks start_time) override; | 155 base::TimeTicks start_time) override; |
151 void OnCompositingEnded(ui::Compositor* compositor) override; | 156 void OnCompositingEnded(ui::Compositor* compositor) override; |
152 void OnCompositingAborted(ui::Compositor* compositor) override; | 157 void OnCompositingAborted(ui::Compositor* compositor) override; |
153 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; | 158 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; |
154 void OnCompositingShuttingDown(ui::Compositor* compositor) override; | 159 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
155 | 160 |
| 161 // Overridden from ui::CompositorVSyncManager::Observer: |
| 162 void OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 163 base::TimeDelta interval) override; |
| 164 |
156 // Overridden from ui::LayerOwnerObserver: | 165 // Overridden from ui::LayerOwnerObserver: |
157 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; | 166 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; |
158 | 167 |
159 // Overridden from ImageTransportFactoryObserver: | 168 // Overridden from ImageTransportFactoryObserver: |
160 void OnLostResources() override; | 169 void OnLostResources() override; |
161 | 170 |
162 bool ShouldSkipFrame(gfx::Size size_in_dip) const; | 171 bool ShouldSkipFrame(gfx::Size size_in_dip) const; |
163 | 172 |
164 // Lazily grab a resize lock if the aura window size doesn't match the current | 173 // Lazily grab a resize lock if the aura window size doesn't match the current |
165 // frame size, to give time to the renderer. | 174 // frame size, to give time to the renderer. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 236 |
228 DelegatedFrameHostClient* const client_; | 237 DelegatedFrameHostClient* const client_; |
229 ui::Compositor* compositor_; | 238 ui::Compositor* compositor_; |
230 | 239 |
231 // True if this renders into a Surface, false if it renders into a delegated | 240 // True if this renders into a Surface, false if it renders into a delegated |
232 // layer. | 241 // layer. |
233 bool use_surfaces_; | 242 bool use_surfaces_; |
234 | 243 |
235 std::vector<base::Closure> on_compositing_did_commit_callbacks_; | 244 std::vector<base::Closure> on_compositing_did_commit_callbacks_; |
236 | 245 |
| 246 // The vsync manager we are observing for changes, if any. |
| 247 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; |
| 248 |
237 // The current VSync timebase and interval. These are zero until the first | 249 // The current VSync timebase and interval. These are zero until the first |
238 // call to UpdateVSyncParameters(). | 250 // call to OnUpdateVSyncParameters(). |
239 base::TimeTicks vsync_timebase_; | 251 base::TimeTicks vsync_timebase_; |
240 base::TimeDelta vsync_interval_; | 252 base::TimeDelta vsync_interval_; |
241 | 253 |
242 // With delegated renderer, this is the last output surface, used to | 254 // With delegated renderer, this is the last output surface, used to |
243 // disambiguate resources with the same id coming from different output | 255 // disambiguate resources with the same id coming from different output |
244 // surfaces. | 256 // surfaces. |
245 uint32 last_output_surface_id_; | 257 uint32 last_output_surface_id_; |
246 | 258 |
247 // The number of delegated frame acks that are pending, to delay resource | 259 // The number of delegated frame acks that are pending, to delay resource |
248 // returns until the acks are sent. | 260 // returns until the acks are sent. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // YUV readback pipeline. | 320 // YUV readback pipeline. |
309 scoped_ptr<content::ReadbackYUVInterface> | 321 scoped_ptr<content::ReadbackYUVInterface> |
310 yuv_readback_pipeline_; | 322 yuv_readback_pipeline_; |
311 | 323 |
312 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; | 324 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; |
313 }; | 325 }; |
314 | 326 |
315 } // namespace content | 327 } // namespace content |
316 | 328 |
317 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ | 329 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ |
OLD | NEW |