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