| Index: content/browser/compositor/delegated_frame_surface_host.h
|
| diff --git a/content/browser/compositor/delegated_frame_host.h b/content/browser/compositor/delegated_frame_surface_host.h
|
| similarity index 64%
|
| copy from content/browser/compositor/delegated_frame_host.h
|
| copy to content/browser/compositor/delegated_frame_surface_host.h
|
| index a7404723608e94ac6d9d078f5dc6a580deb71436..767f72133e2a920d448f1d096afe7d8c260993c9 100644
|
| --- a/content/browser/compositor/delegated_frame_host.h
|
| +++ b/content/browser/compositor/delegated_frame_surface_host.h
|
| @@ -2,12 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_
|
| -#define CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_
|
| +#ifndef CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_SURFACE_HOST_H_
|
| +#define CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_SURFACE_HOST_H_
|
|
|
| #include "cc/layers/delegated_frame_provider.h"
|
| -#include "cc/layers/delegated_frame_resource_collection.h"
|
| #include "cc/output/copy_output_result.h"
|
| +#include "cc/surfaces/surface_factory_client.h"
|
| +#include "content/browser/compositor/delegated_frame_host.h"
|
| #include "content/browser/compositor/image_transport_factory.h"
|
| #include "content/browser/compositor/owned_mailbox.h"
|
| #include "content/browser/renderer_host/delegated_frame_evictor.h"
|
| @@ -21,100 +22,60 @@
|
| #include "ui/compositor/layer_owner_delegate.h"
|
| #include "ui/gfx/rect_conversions.h"
|
|
|
| -namespace media {
|
| -class VideoFrame;
|
| +namespace cc {
|
| +class SurfaceFactory;
|
| }
|
|
|
| namespace content {
|
|
|
| -class DelegatedFrameHost;
|
| class ReadbackYUVInterface;
|
| -class RenderWidgetHostViewFrameSubscriber;
|
| -class RenderWidgetHostImpl;
|
| -class ResizeLock;
|
| -
|
| -// The DelegatedFrameHostClient is the interface from the DelegatedFrameHost,
|
| -// which manages delegated frames, and the ui::Compositor being used to
|
| -// display them.
|
| -class CONTENT_EXPORT DelegatedFrameHostClient {
|
| - public:
|
| - virtual ui::Compositor* GetCompositor() const = 0;
|
| - virtual ui::Layer* GetLayer() = 0;
|
| - virtual RenderWidgetHostImpl* GetHost() = 0;
|
| - virtual void SchedulePaintInRect(const gfx::Rect& damage_rect_in_dip) = 0;
|
| - virtual bool IsVisible() = 0;
|
| - virtual scoped_ptr<ResizeLock> CreateResizeLock(
|
| - bool defer_compositor_lock) = 0;
|
| - virtual gfx::Size DesiredFrameSize() = 0;
|
| -
|
| - // TODO(ccameron): It is likely that at least one of these two functions is
|
| - // redundant. Find which one, and delete it.
|
| - virtual float CurrentDeviceScaleFactor() = 0;
|
| - virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) = 0;
|
| -
|
| - // These are to be overridden for testing only.
|
| - // TODO(ccameron): This is convoluted. Make the tests that need to override
|
| - // these functions test DelegatedFrameHost directly (rather than do it
|
| - // through RenderWidgetHostViewAura).
|
| - virtual DelegatedFrameHost* GetDelegatedFrameHost() const = 0;
|
| - virtual bool ShouldCreateResizeLock();
|
| - virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
|
| -};
|
|
|
| -// The DelegatedFrameHost is used to host all of the RenderWidgetHostView state
|
| -// and functionality that is associated with delegated frames being sent from
|
| -// the RenderWidget. The DelegatedFrameHost will push these changes through to
|
| -// the ui::Compositor associated with its DelegatedFrameHostClient.
|
| -class CONTENT_EXPORT DelegatedFrameHost
|
| - : public ui::CompositorObserver,
|
| +class CONTENT_EXPORT DelegatedFrameSurfaceHost
|
| + : public DelegatedFrameHost,
|
| + public ui::CompositorObserver,
|
| public ui::CompositorVSyncManager::Observer,
|
| public ui::LayerOwnerDelegate,
|
| public ImageTransportFactoryObserver,
|
| public DelegatedFrameEvictorClient,
|
| - public cc::DelegatedFrameResourceCollectionClient,
|
| - public base::SupportsWeakPtr<DelegatedFrameHost> {
|
| + public cc::SurfaceFactoryClient,
|
| + public base::SupportsWeakPtr<DelegatedFrameSurfaceHost> {
|
| public:
|
| - DelegatedFrameHost(DelegatedFrameHostClient* client);
|
| - virtual ~DelegatedFrameHost();
|
| -
|
| - bool CanCopyToBitmap() const;
|
| + DelegatedFrameSurfaceHost(DelegatedFrameHostClient* client);
|
| + virtual ~DelegatedFrameSurfaceHost();
|
|
|
| // Public interface exposed to RenderWidgetHostView.
|
| - void SwapDelegatedFrame(
|
| + virtual bool CanCopyToBitmap() const OVERRIDE;
|
| + virtual void SwapDelegatedFrame(
|
| uint32 output_surface_id,
|
| scoped_ptr<cc::DelegatedFrameData> frame_data,
|
| float frame_device_scale_factor,
|
| - const std::vector<ui::LatencyInfo>& latency_info);
|
| - void WasHidden();
|
| - void WasShown();
|
| - void WasResized();
|
| - gfx::Size GetRequestedRendererSize() const;
|
| - void AddedToWindow();
|
| - void RemovingFromWindow();
|
| - void CopyFromCompositingSurface(
|
| + const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
|
| + virtual void WasHidden() OVERRIDE;
|
| + virtual void WasShown() OVERRIDE;
|
| + virtual void WasResized() OVERRIDE;
|
| + virtual gfx::Size GetRequestedRendererSize() const OVERRIDE;
|
| + virtual void AddedToWindow() OVERRIDE;
|
| + virtual void RemovingFromWindow() OVERRIDE;
|
| + virtual void CopyFromCompositingSurface(
|
| const gfx::Rect& src_subrect,
|
| const gfx::Size& dst_size,
|
| const base::Callback<void(bool, const SkBitmap&)>& callback,
|
| - const SkColorType color_type);
|
| - void CopyFromCompositingSurfaceToVideoFrame(
|
| + const SkColorType color_type) OVERRIDE;
|
| + virtual void CopyFromCompositingSurfaceToVideoFrame(
|
| const gfx::Rect& src_subrect,
|
| const scoped_refptr<media::VideoFrame>& target,
|
| - const base::Callback<void(bool)>& callback);
|
| - bool CanCopyToVideoFrame() const;
|
| - bool CanSubscribeFrame() const;
|
| - void BeginFrameSubscription(
|
| - scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber);
|
| - void EndFrameSubscription();
|
| - bool HasFrameSubscriber() const { return frame_subscriber_; }
|
| -
|
| - // Exposed for tests.
|
| - cc::DelegatedFrameProvider* FrameProviderForTesting() const {
|
| - return frame_provider_.get();
|
| - }
|
| - void OnCompositingDidCommitForTesting(ui::Compositor* compositor) {
|
| - OnCompositingDidCommit(compositor);
|
| - }
|
| - bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); }
|
| + const base::Callback<void(bool)>& callback) OVERRIDE;
|
| + virtual bool CanCopyToVideoFrame() const OVERRIDE;
|
| + virtual bool CanSubscribeFrame() const OVERRIDE;
|
| + virtual void BeginFrameSubscription(
|
| + scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE;
|
| + virtual void EndFrameSubscription() OVERRIDE;
|
| + virtual bool HasFrameSubscriber() const OVERRIDE;
|
| + virtual void SetLayerOwner(ui::LayerOwner* layer_owner) OVERRIDE;
|
| +
|
| + virtual cc::DelegatedFrameProvider* FrameProviderForTesting() const OVERRIDE;
|
| + virtual void OnCompositingDidCommitForTesting(
|
| + ui::Compositor* compositor) OVERRIDE;
|
|
|
| private:
|
| friend class DelegatedFrameHostClient;
|
| @@ -128,11 +89,12 @@ class CONTENT_EXPORT DelegatedFrameHost
|
| RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
|
| return frame_subscriber_.get();
|
| }
|
| - bool ShouldCreateResizeLock();
|
| - void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
|
| + virtual bool ShouldCreateResizeLock() OVERRIDE;
|
| + virtual void RequestCopyOfOutput(
|
| + scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE;
|
|
|
| - void LockResources();
|
| - void UnlockResources();
|
| + virtual void LockResources() OVERRIDE;
|
| + virtual void UnlockResources() OVERRIDE;
|
|
|
| // Overridden from ui::CompositorObserver:
|
| virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE;
|
| @@ -187,19 +149,19 @@ class CONTENT_EXPORT DelegatedFrameHost
|
| const base::Callback<void(bool, const SkBitmap&)>& callback,
|
| scoped_ptr<cc::CopyOutputResult> result);
|
| static void CopyFromCompositingSurfaceHasResultForVideo(
|
| - base::WeakPtr<DelegatedFrameHost> rwhva,
|
| + base::WeakPtr<DelegatedFrameSurfaceHost> rwhva,
|
| scoped_refptr<OwnedMailbox> subscriber_texture,
|
| scoped_refptr<media::VideoFrame> video_frame,
|
| const base::Callback<void(bool)>& callback,
|
| scoped_ptr<cc::CopyOutputResult> result);
|
| static void CopyFromCompositingSurfaceFinishedForVideo(
|
| - base::WeakPtr<DelegatedFrameHost> rwhva,
|
| + base::WeakPtr<DelegatedFrameSurfaceHost> rwhva,
|
| const base::Callback<void(bool)>& callback,
|
| scoped_refptr<OwnedMailbox> subscriber_texture,
|
| scoped_ptr<cc::SingleReleaseCallback> release_callback,
|
| bool result);
|
| static void ReturnSubscriberTexture(
|
| - base::WeakPtr<DelegatedFrameHost> rwhva,
|
| + base::WeakPtr<DelegatedFrameSurfaceHost> rwhva,
|
| scoped_refptr<OwnedMailbox> subscriber_texture,
|
| uint32 sync_point);
|
|
|
| @@ -209,8 +171,9 @@ class CONTENT_EXPORT DelegatedFrameHost
|
| // DelegatedFrameEvictorClient implementation.
|
| virtual void EvictDelegatedFrame() OVERRIDE;
|
|
|
| - // cc::DelegatedFrameProviderClient implementation.
|
| - virtual void UnusedResourcesAreAvailable() OVERRIDE;
|
| + // cc::SurfaceFactoryClient implementation.
|
| + virtual void ReturnResources(
|
| + const cc::ReturnedResourceArray& resources) OVERRIDE;
|
|
|
| void DidReceiveFrameFromRenderer();
|
|
|
| @@ -235,13 +198,11 @@ class CONTENT_EXPORT DelegatedFrameHost
|
| bool skipped_frames_;
|
| std::vector<ui::LatencyInfo> skipped_latency_info_list_;
|
|
|
| - // Holds delegated resources that have been given to a DelegatedFrameProvider,
|
| - // and gives back resources when they are no longer in use for return to the
|
| - // renderer.
|
| - scoped_refptr<cc::DelegatedFrameResourceCollection> resource_collection_;
|
| -
|
| - // Provides delegated frame updates to the cc::DelegatedRendererLayer.
|
| - scoped_refptr<cc::DelegatedFrameProvider> frame_provider_;
|
| + scoped_ptr<cc::SurfaceIdAllocator> id_allocator_;
|
| + scoped_ptr<cc::SurfaceFactory> surface_factory_;
|
| + cc::SurfaceId surface_id_;
|
| + gfx::Size current_surface_size_;
|
| + cc::ReturnedResourceArray surface_returned_resources_;
|
|
|
| // This lock is the one waiting for a frame of the right size to come back
|
| // from the renderer/GPU process. It is set from the moment the aura window
|
| @@ -275,12 +236,11 @@ class CONTENT_EXPORT DelegatedFrameHost
|
| std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_;
|
|
|
| // YUV readback pipeline.
|
| - scoped_ptr<content::ReadbackYUVInterface>
|
| - yuv_readback_pipeline_;
|
| + scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_;
|
|
|
| scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_;
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_
|
| +#endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_SURFACE_HOST_H_
|
|
|