Chromium Code Reviews| 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/compositor_vsync_manager.h" |
| 22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
| 23 #include "ui/compositor/layer_owner_delegate.h" | 23 #include "ui/compositor/layer_owner_delegate.h" |
| 24 #include "ui/gfx/geometry/rect_conversions.h" | 24 #include "ui/gfx/geometry/rect_conversions.h" |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 class SurfaceFactory; | 27 class SurfaceFactory; |
| 28 enum class SurfaceDrawStatus; | 28 enum class SurfaceDrawStatus; |
| 29 struct BeginFrameArgs; | |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace media { | 32 namespace media { |
| 32 class VideoFrame; | 33 class VideoFrame; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace content { | 36 namespace content { |
| 36 | 37 |
| 37 class DelegatedFrameHost; | 38 class DelegatedFrameHost; |
| 38 class ReadbackYUVInterface; | 39 class ReadbackYUVInterface; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 58 int output_surface_id, | 59 int output_surface_id, |
| 59 const cc::CompositorFrameAck& ack) = 0; | 60 const cc::CompositorFrameAck& ack) = 0; |
| 60 virtual void DelegatedFrameHostSendReclaimCompositorResources( | 61 virtual void DelegatedFrameHostSendReclaimCompositorResources( |
| 61 int output_surface_id, | 62 int output_surface_id, |
| 62 const cc::CompositorFrameAck& ack) = 0; | 63 const cc::CompositorFrameAck& ack) = 0; |
| 63 virtual void DelegatedFrameHostOnLostCompositorResources() = 0; | 64 virtual void DelegatedFrameHostOnLostCompositorResources() = 0; |
| 64 | 65 |
| 65 virtual void DelegatedFrameHostUpdateVSyncParameters( | 66 virtual void DelegatedFrameHostUpdateVSyncParameters( |
| 66 const base::TimeTicks& timebase, | 67 const base::TimeTicks& timebase, |
| 67 const base::TimeDelta& interval) = 0; | 68 const base::TimeDelta& interval) = 0; |
| 69 virtual void DelegatedFrameHostSendBeginFrame( | |
| 70 const cc::BeginFrameArgs& args) = 0; | |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state | 73 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state |
| 71 // and functionality that is associated with delegated frames being sent from | 74 // and functionality that is associated with delegated frames being sent from |
| 72 // the RenderWidget. The DelegatedFrameHost will push these changes through to | 75 // the RenderWidget. The DelegatedFrameHost will push these changes through to |
| 73 // the ui::Compositor associated with its DelegatedFrameHostClient. | 76 // the ui::Compositor associated with its DelegatedFrameHostClient. |
| 74 class CONTENT_EXPORT DelegatedFrameHost | 77 class CONTENT_EXPORT DelegatedFrameHost |
| 75 : public ui::CompositorObserver, | 78 : public ui::CompositorObserver, |
| 79 public ui::CompositorBeginFrameObserver, | |
| 76 public ui::CompositorVSyncManager::Observer, | 80 public ui::CompositorVSyncManager::Observer, |
| 77 public ui::LayerOwnerDelegate, | 81 public ui::LayerOwnerDelegate, |
| 78 public ImageTransportFactoryObserver, | 82 public ImageTransportFactoryObserver, |
| 79 public DelegatedFrameEvictorClient, | 83 public DelegatedFrameEvictorClient, |
| 80 public cc::DelegatedFrameResourceCollectionClient, | 84 public cc::DelegatedFrameResourceCollectionClient, |
| 81 public cc::SurfaceFactoryClient, | 85 public cc::SurfaceFactoryClient, |
| 82 public base::SupportsWeakPtr<DelegatedFrameHost> { | 86 public base::SupportsWeakPtr<DelegatedFrameHost> { |
| 83 public: | 87 public: |
| 84 DelegatedFrameHost(DelegatedFrameHostClient* client); | 88 DelegatedFrameHost(DelegatedFrameHostClient* client, |
| 89 bool begin_frame_scheduling_enabled); | |
| 85 ~DelegatedFrameHost() override; | 90 ~DelegatedFrameHost() override; |
| 86 | 91 |
| 87 bool CanCopyToBitmap() const; | 92 bool CanCopyToBitmap() const; |
| 88 | 93 |
| 89 // Public interface exposed to RenderWidgetHostView. | 94 // Public interface exposed to RenderWidgetHostView. |
| 90 void SwapDelegatedFrame( | 95 void SwapDelegatedFrame( |
| 91 uint32 output_surface_id, | 96 uint32 output_surface_id, |
| 92 scoped_ptr<cc::DelegatedFrameData> frame_data, | 97 scoped_ptr<cc::DelegatedFrameData> frame_data, |
| 93 float frame_device_scale_factor, | 98 float frame_device_scale_factor, |
| 94 const std::vector<ui::LatencyInfo>& latency_info); | 99 const std::vector<ui::LatencyInfo>& latency_info); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 106 void CopyFromCompositingSurfaceToVideoFrame( | 111 void CopyFromCompositingSurfaceToVideoFrame( |
| 107 const gfx::Rect& src_subrect, | 112 const gfx::Rect& src_subrect, |
| 108 const scoped_refptr<media::VideoFrame>& target, | 113 const scoped_refptr<media::VideoFrame>& target, |
| 109 const base::Callback<void(bool)>& callback); | 114 const base::Callback<void(bool)>& callback); |
| 110 bool CanCopyToVideoFrame() const; | 115 bool CanCopyToVideoFrame() const; |
| 111 bool CanSubscribeFrame() const; | 116 bool CanSubscribeFrame() const; |
| 112 void BeginFrameSubscription( | 117 void BeginFrameSubscription( |
| 113 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); | 118 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); |
| 114 void EndFrameSubscription(); | 119 void EndFrameSubscription(); |
| 115 bool HasFrameSubscriber() const { return frame_subscriber_; } | 120 bool HasFrameSubscriber() const { return frame_subscriber_; } |
| 121 void OnSetNeedsBeginFrames(bool needs_begin_frames); | |
| 116 | 122 |
| 117 // Exposed for tests. | 123 // Exposed for tests. |
| 118 cc::DelegatedFrameProvider* FrameProviderForTesting() const { | 124 cc::DelegatedFrameProvider* FrameProviderForTesting() const { |
| 119 return frame_provider_.get(); | 125 return frame_provider_.get(); |
| 120 } | 126 } |
| 121 cc::SurfaceId SurfaceIdForTesting() const { return surface_id_; } | 127 cc::SurfaceId SurfaceIdForTesting() const { return surface_id_; } |
| 122 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) { | 128 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) { |
| 123 OnCompositingDidCommit(compositor); | 129 OnCompositingDidCommit(compositor); |
| 124 } | 130 } |
| 125 bool ReleasedFrontLockActiveForTesting() const { | 131 bool ReleasedFrontLockActiveForTesting() const { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 142 DestroyedAfterCopyRequest); | 148 DestroyedAfterCopyRequest); |
| 143 | 149 |
| 144 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { | 150 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { |
| 145 return frame_subscriber_.get(); | 151 return frame_subscriber_.get(); |
| 146 } | 152 } |
| 147 bool ShouldCreateResizeLock(); | 153 bool ShouldCreateResizeLock(); |
| 148 void LockResources(); | 154 void LockResources(); |
| 149 void UnlockResources(); | 155 void UnlockResources(); |
| 150 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); | 156 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); |
| 151 | 157 |
| 158 void StartObservingBeginFrames(); | |
| 159 void StopObservingBeginFrames(); | |
| 160 | |
| 152 // Overridden from ui::CompositorObserver: | 161 // Overridden from ui::CompositorObserver: |
| 153 void OnCompositingDidCommit(ui::Compositor* compositor) override; | 162 void OnCompositingDidCommit(ui::Compositor* compositor) override; |
| 154 void OnCompositingStarted(ui::Compositor* compositor, | 163 void OnCompositingStarted(ui::Compositor* compositor, |
| 155 base::TimeTicks start_time) override; | 164 base::TimeTicks start_time) override; |
| 156 void OnCompositingEnded(ui::Compositor* compositor) override; | 165 void OnCompositingEnded(ui::Compositor* compositor) override; |
| 157 void OnCompositingAborted(ui::Compositor* compositor) override; | 166 void OnCompositingAborted(ui::Compositor* compositor) override; |
| 158 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; | 167 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; |
| 159 void OnCompositingShuttingDown(ui::Compositor* compositor) override; | 168 void OnCompositingShuttingDown(ui::Compositor* compositor) override; |
| 160 | 169 |
| 161 // Overridden from ui::CompositorVSyncManager::Observer: | 170 // Overridden from ui::CompositorVSyncManager::Observer: |
| 162 void OnUpdateVSyncParameters(base::TimeTicks timebase, | 171 void OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 163 base::TimeDelta interval) override; | 172 base::TimeDelta interval) override; |
| 164 | 173 |
| 174 // Overridden from ui::CompositorBeginFrameObserver: | |
| 175 void OnSendBeginFrame(const cc::BeginFrameArgs& args) override; | |
| 176 | |
| 165 // Overridden from ui::LayerOwnerObserver: | 177 // Overridden from ui::LayerOwnerObserver: |
| 166 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; | 178 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; |
| 167 | 179 |
| 168 // Overridden from ImageTransportFactoryObserver: | 180 // Overridden from ImageTransportFactoryObserver: |
| 169 void OnLostResources() override; | 181 void OnLostResources() override; |
| 170 | 182 |
| 171 bool ShouldSkipFrame(gfx::Size size_in_dip) const; | 183 bool ShouldSkipFrame(gfx::Size size_in_dip) const; |
| 172 | 184 |
| 173 // Lazily grab a resize lock if the aura window size doesn't match the current | 185 // Lazily grab a resize lock if the aura window size doesn't match the current |
| 174 // frame size, to give time to the renderer. | 186 // frame size, to give time to the renderer. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // the next callback in the |frame_subscriber_callbacks_| queue. | 250 // the next callback in the |frame_subscriber_callbacks_| queue. |
| 239 void DeliverResultForFrameSubscriber(bool success); | 251 void DeliverResultForFrameSubscriber(bool success); |
| 240 | 252 |
| 241 DelegatedFrameHostClient* const client_; | 253 DelegatedFrameHostClient* const client_; |
| 242 ui::Compositor* compositor_; | 254 ui::Compositor* compositor_; |
| 243 | 255 |
| 244 // True if this renders into a Surface, false if it renders into a delegated | 256 // True if this renders into a Surface, false if it renders into a delegated |
| 245 // layer. | 257 // layer. |
| 246 bool use_surfaces_; | 258 bool use_surfaces_; |
| 247 | 259 |
| 248 std::vector<base::Closure> on_compositing_did_commit_callbacks_; | |
|
danakj
2015/03/13 20:04:40
unrelated move?
simonhong
2015/03/17 16:11:34
Done.
| |
| 249 | |
| 250 // The vsync manager we are observing for changes, if any. | 260 // The vsync manager we are observing for changes, if any. |
| 251 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; | 261 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; |
| 252 | 262 |
| 263 std::vector<base::Closure> on_compositing_did_commit_callbacks_; | |
| 264 | |
| 253 // The current VSync timebase and interval. These are zero until the first | 265 // The current VSync timebase and interval. These are zero until the first |
| 254 // call to OnUpdateVSyncParameters(). | 266 // call to OnUpdateVSyncParameters(). |
| 255 base::TimeTicks vsync_timebase_; | 267 base::TimeTicks vsync_timebase_; |
| 256 base::TimeDelta vsync_interval_; | 268 base::TimeDelta vsync_interval_; |
| 257 | 269 |
| 258 // With delegated renderer, this is the last output surface, used to | 270 // With delegated renderer, this is the last output surface, used to |
| 259 // disambiguate resources with the same id coming from different output | 271 // disambiguate resources with the same id coming from different output |
| 260 // surfaces. | 272 // surfaces. |
| 261 uint32 last_output_surface_id_; | 273 uint32 last_output_surface_id_; |
| 262 | 274 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 // Callback used to pass the output request to the layer or to a function | 342 // Callback used to pass the output request to the layer or to a function |
| 331 // specified by a test. | 343 // specified by a test. |
| 332 base::Callback<void(scoped_ptr<cc::CopyOutputRequest>)> | 344 base::Callback<void(scoped_ptr<cc::CopyOutputRequest>)> |
| 333 request_copy_of_output_callback_for_testing_; | 345 request_copy_of_output_callback_for_testing_; |
| 334 | 346 |
| 335 // YUV readback pipeline. | 347 // YUV readback pipeline. |
| 336 scoped_ptr<content::ReadbackYUVInterface> | 348 scoped_ptr<content::ReadbackYUVInterface> |
| 337 yuv_readback_pipeline_; | 349 yuv_readback_pipeline_; |
| 338 | 350 |
| 339 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; | 351 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; |
| 352 | |
| 353 // True when unified BeginFrame scheduing is used. | |
|
no sievers
2015/03/13 20:30:54
nit: typo "scheduling'
What's 'unified'?
brianderson
2015/03/13 20:53:52
It's the concept of using a common code path for p
simonhong
2015/03/17 16:11:34
Done.
| |
| 354 bool begin_frame_scheduling_enabled_; | |
| 355 | |
| 356 // True when RenderWidget needs a BeginFrame. | |
|
no sievers
2015/03/13 20:30:54
nit: you mean 'need BeginFrame messages' like var
simonhong
2015/03/17 16:11:34
Done.
| |
| 357 bool needs_begin_frames_; | |
| 358 | |
| 359 // Pass |last_sent_begin_frame_args_| to compositor when |this| is added as a | |
| 360 // CompositorBeginFrameObserver. With this, Compositor can determine whether | |
| 361 // latest BeginFrameArgs can be used immediately or not. | |
| 362 cc::BeginFrameArgs last_sent_begin_frame_args_; | |
| 340 }; | 363 }; |
| 341 | 364 |
| 342 } // namespace content | 365 } // namespace content |
| 343 | 366 |
| 344 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ | 367 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ |
| OLD | NEW |