| 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/rect_conversions.h" | 23 #include "ui/gfx/rect_conversions.h" |
| 25 | 24 |
| 26 namespace cc { | 25 namespace cc { |
| 27 class SurfaceFactory; | 26 class SurfaceFactory; |
| 27 struct BeginFrameArgs; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace media { | 30 namespace media { |
| 31 class VideoFrame; | 31 class VideoFrame; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 class DelegatedFrameHost; | 36 class DelegatedFrameHost; |
| 37 class ReadbackYUVInterface; | 37 class ReadbackYUVInterface; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 65 virtual bool ShouldCreateResizeLock(); | 65 virtual bool ShouldCreateResizeLock(); |
| 66 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); | 66 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state | 69 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state |
| 70 // and functionality that is associated with delegated frames being sent from | 70 // and functionality that is associated with delegated frames being sent from |
| 71 // the RenderWidget. The DelegatedFrameHost will push these changes through to | 71 // the RenderWidget. The DelegatedFrameHost will push these changes through to |
| 72 // the ui::Compositor associated with its DelegatedFrameHostClient. | 72 // the ui::Compositor associated with its DelegatedFrameHostClient. |
| 73 class CONTENT_EXPORT DelegatedFrameHost | 73 class CONTENT_EXPORT DelegatedFrameHost |
| 74 : public ui::CompositorObserver, | 74 : public ui::CompositorObserver, |
| 75 public ui::CompositorVSyncManager::Observer, | |
| 76 public ui::LayerOwnerDelegate, | 75 public ui::LayerOwnerDelegate, |
| 77 public ImageTransportFactoryObserver, | 76 public ImageTransportFactoryObserver, |
| 78 public DelegatedFrameEvictorClient, | 77 public DelegatedFrameEvictorClient, |
| 79 public cc::DelegatedFrameResourceCollectionClient, | 78 public cc::DelegatedFrameResourceCollectionClient, |
| 80 public cc::SurfaceFactoryClient, | 79 public cc::SurfaceFactoryClient, |
| 81 public base::SupportsWeakPtr<DelegatedFrameHost> { | 80 public base::SupportsWeakPtr<DelegatedFrameHost> { |
| 82 public: | 81 public: |
| 83 DelegatedFrameHost(DelegatedFrameHostClient* client); | 82 DelegatedFrameHost(DelegatedFrameHostClient* client); |
| 84 virtual ~DelegatedFrameHost(); | 83 virtual ~DelegatedFrameHost(); |
| 85 | 84 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 105 void CopyFromCompositingSurfaceToVideoFrame( | 104 void CopyFromCompositingSurfaceToVideoFrame( |
| 106 const gfx::Rect& src_subrect, | 105 const gfx::Rect& src_subrect, |
| 107 const scoped_refptr<media::VideoFrame>& target, | 106 const scoped_refptr<media::VideoFrame>& target, |
| 108 const base::Callback<void(bool)>& callback); | 107 const base::Callback<void(bool)>& callback); |
| 109 bool CanCopyToVideoFrame() const; | 108 bool CanCopyToVideoFrame() const; |
| 110 bool CanSubscribeFrame() const; | 109 bool CanSubscribeFrame() const; |
| 111 void BeginFrameSubscription( | 110 void BeginFrameSubscription( |
| 112 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); | 111 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); |
| 113 void EndFrameSubscription(); | 112 void EndFrameSubscription(); |
| 114 bool HasFrameSubscriber() const { return frame_subscriber_; } | 113 bool HasFrameSubscriber() const { return frame_subscriber_; } |
| 114 void UpdateVSyncParameters(const cc::BeginFrameArgs& args); |
| 115 | 115 |
| 116 // Exposed for tests. | 116 // Exposed for tests. |
| 117 cc::DelegatedFrameProvider* FrameProviderForTesting() const { | 117 cc::DelegatedFrameProvider* FrameProviderForTesting() const { |
| 118 return frame_provider_.get(); | 118 return frame_provider_.get(); |
| 119 } | 119 } |
| 120 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) { | 120 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) { |
| 121 OnCompositingDidCommit(compositor); | 121 OnCompositingDidCommit(compositor); |
| 122 } | 122 } |
| 123 bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); } | 123 bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); } |
| 124 bool ReleasedFrontLockActiveForTesting() const { | 124 bool ReleasedFrontLockActiveForTesting() const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 145 | 145 |
| 146 // Overridden from ui::CompositorObserver: | 146 // Overridden from ui::CompositorObserver: |
| 147 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; | 147 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; |
| 148 virtual void OnCompositingStarted(ui::Compositor* compositor, | 148 virtual void OnCompositingStarted(ui::Compositor* compositor, |
| 149 base::TimeTicks start_time) OVERRIDE; | 149 base::TimeTicks start_time) OVERRIDE; |
| 150 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; | 150 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; |
| 151 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; | 151 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; |
| 152 virtual void OnCompositingLockStateChanged( | 152 virtual void OnCompositingLockStateChanged( |
| 153 ui::Compositor* compositor) OVERRIDE; | 153 ui::Compositor* compositor) OVERRIDE; |
| 154 | 154 |
| 155 // Overridden from ui::CompositorVSyncManager::Observer: | |
| 156 virtual void OnUpdateVSyncParameters(base::TimeTicks timebase, | |
| 157 base::TimeDelta interval) OVERRIDE; | |
| 158 | |
| 159 // Overridden from ui::LayerOwnerObserver: | 155 // Overridden from ui::LayerOwnerObserver: |
| 160 virtual void OnLayerRecreated(ui::Layer* old_layer, | 156 virtual void OnLayerRecreated(ui::Layer* old_layer, |
| 161 ui::Layer* new_layer) OVERRIDE; | 157 ui::Layer* new_layer) OVERRIDE; |
| 162 | 158 |
| 163 // Overridden from ImageTransportFactoryObserver: | 159 // Overridden from ImageTransportFactoryObserver: |
| 164 virtual void OnLostResources() OVERRIDE; | 160 virtual void OnLostResources() OVERRIDE; |
| 165 | 161 |
| 166 bool ShouldSkipFrame(gfx::Size size_in_dip) const; | 162 bool ShouldSkipFrame(gfx::Size size_in_dip) const; |
| 167 | 163 |
| 168 // Lazily grab a resize lock if the aura window size doesn't match the current | 164 // Lazily grab a resize lock if the aura window size doesn't match the current |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void DidReceiveFrameFromRenderer(const gfx::Rect& damage_rect); | 224 void DidReceiveFrameFromRenderer(const gfx::Rect& damage_rect); |
| 229 | 225 |
| 230 DelegatedFrameHostClient* client_; | 226 DelegatedFrameHostClient* client_; |
| 231 | 227 |
| 232 // True if this renders into a Surface, false if it renders into a delegated | 228 // True if this renders into a Surface, false if it renders into a delegated |
| 233 // layer. | 229 // layer. |
| 234 bool use_surfaces_; | 230 bool use_surfaces_; |
| 235 | 231 |
| 236 std::vector<base::Closure> on_compositing_did_commit_callbacks_; | 232 std::vector<base::Closure> on_compositing_did_commit_callbacks_; |
| 237 | 233 |
| 238 // The vsync manager we are observing for changes, if any. | |
| 239 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; | |
| 240 | |
| 241 // The current VSync timebase and interval. These are zero until the first | 234 // The current VSync timebase and interval. These are zero until the first |
| 242 // call to OnUpdateVSyncParameters(). | 235 // call to OnUpdateVSyncParameters(). |
| 243 base::TimeTicks vsync_timebase_; | 236 base::TimeTicks vsync_timebase_; |
| 244 base::TimeDelta vsync_interval_; | 237 base::TimeDelta vsync_interval_; |
| 245 | 238 |
| 246 // With delegated renderer, this is the last output surface, used to | 239 // With delegated renderer, this is the last output surface, used to |
| 247 // disambiguate resources with the same id coming from different output | 240 // disambiguate resources with the same id coming from different output |
| 248 // surfaces. | 241 // surfaces. |
| 249 uint32 last_output_surface_id_; | 242 uint32 last_output_surface_id_; |
| 250 | 243 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // YUV readback pipeline. | 299 // YUV readback pipeline. |
| 307 scoped_ptr<content::ReadbackYUVInterface> | 300 scoped_ptr<content::ReadbackYUVInterface> |
| 308 yuv_readback_pipeline_; | 301 yuv_readback_pipeline_; |
| 309 | 302 |
| 310 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; | 303 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; |
| 311 }; | 304 }; |
| 312 | 305 |
| 313 } // namespace content | 306 } // namespace content |
| 314 | 307 |
| 315 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ | 308 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ |
| OLD | NEW |