Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: content/browser/compositor/delegated_frame_host.h

Issue 417943004: Use Surfaces to hold delegated renderer contents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/compositor/delegated_frame_host.h
diff --git a/content/browser/compositor/delegated_frame_host.h b/content/browser/compositor/delegated_frame_host.h
index a7404723608e94ac6d9d078f5dc6a580deb71436..8c883c9c05f56197e08628e7fa715bec78506305 100644
--- a/content/browser/compositor/delegated_frame_host.h
+++ b/content/browser/compositor/delegated_frame_host.h
@@ -8,6 +8,7 @@
#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/image_transport_factory.h"
#include "content/browser/compositor/owned_mailbox.h"
#include "content/browser/renderer_host/delegated_frame_evictor.h"
@@ -18,9 +19,14 @@
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/compositor_vsync_manager.h"
#include "ui/compositor/layer.h"
+#include "ui/compositor/layer_owner.h"
#include "ui/compositor/layer_owner_delegate.h"
#include "ui/gfx/rect_conversions.h"
+namespace cc {
+class SurfaceFactory;
+}
+
namespace media {
class VideoFrame;
}
@@ -28,7 +34,6 @@ class VideoFrame;
namespace content {
class DelegatedFrameHost;
-class ReadbackYUVInterface;
class RenderWidgetHostViewFrameSubscriber;
class RenderWidgetHostImpl;
class ResizeLock;
@@ -65,55 +70,45 @@ class CONTENT_EXPORT DelegatedFrameHostClient {
// 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,
- public ui::CompositorVSyncManager::Observer,
- public ui::LayerOwnerDelegate,
- public ImageTransportFactoryObserver,
- public DelegatedFrameEvictorClient,
- public cc::DelegatedFrameResourceCollectionClient,
- public base::SupportsWeakPtr<DelegatedFrameHost> {
+class CONTENT_EXPORT DelegatedFrameHost {
public:
- DelegatedFrameHost(DelegatedFrameHostClient* client);
- virtual ~DelegatedFrameHost();
+ static DelegatedFrameHost* Create(DelegatedFrameHostClient* client);
- bool CanCopyToBitmap() const;
+ virtual ~DelegatedFrameHost() {}
// Public interface exposed to RenderWidgetHostView.
- void SwapDelegatedFrame(
+ virtual bool CanCopyToBitmap() const = 0;
+ 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) = 0;
+ virtual void WasHidden() = 0;
+ virtual void WasShown() = 0;
+ virtual void WasResized() = 0;
+ virtual gfx::Size GetRequestedRendererSize() const = 0;
+ virtual void AddedToWindow() = 0;
+ virtual void RemovingFromWindow() = 0;
+ 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) = 0;
+ 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_; }
+ const base::Callback<void(bool)>& callback) = 0;
+ virtual bool CanCopyToVideoFrame() const = 0;
+ virtual bool CanSubscribeFrame() const = 0;
+ virtual void BeginFrameSubscription(
+ scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) = 0;
+ virtual void EndFrameSubscription() = 0;
+ virtual bool HasFrameSubscriber() const = 0;
+ virtual void SetLayerOwner(ui::LayerOwner* layer_owner) = 0;
// Exposed for tests.
- cc::DelegatedFrameProvider* FrameProviderForTesting() const {
- return frame_provider_.get();
- }
- void OnCompositingDidCommitForTesting(ui::Compositor* compositor) {
- OnCompositingDidCommit(compositor);
- }
+ virtual cc::DelegatedFrameProvider* FrameProviderForTesting() const = 0;
+ virtual void OnCompositingDidCommitForTesting(ui::Compositor* compositor) = 0;
bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); }
private:
@@ -125,160 +120,12 @@ class CONTENT_EXPORT DelegatedFrameHost
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest,
DestroyedAfterCopyRequest);
- RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
- return frame_subscriber_.get();
- }
- bool ShouldCreateResizeLock();
- void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
-
- void LockResources();
- void UnlockResources();
-
- // Overridden from ui::CompositorObserver:
- virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE;
- virtual void OnCompositingStarted(ui::Compositor* compositor,
- base::TimeTicks start_time) OVERRIDE;
- virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE;
- virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE;
- virtual void OnCompositingLockStateChanged(
- ui::Compositor* compositor) OVERRIDE;
-
- // Overridden from ui::CompositorVSyncManager::Observer:
- virtual void OnUpdateVSyncParameters(base::TimeTicks timebase,
- base::TimeDelta interval) OVERRIDE;
-
- // Overridden from ui::LayerOwnerObserver:
- virtual void OnLayerRecreated(ui::Layer* old_layer,
- ui::Layer* new_layer) OVERRIDE;
-
- // Overridden from ImageTransportFactoryObserver:
- virtual void OnLostResources() OVERRIDE;
-
- bool ShouldSkipFrame(gfx::Size size_in_dip) const;
-
- // Lazily grab a resize lock if the aura window size doesn't match the current
- // frame size, to give time to the renderer.
- void MaybeCreateResizeLock();
-
- // Checks if the resize lock can be released because we received an new frame.
- void CheckResizeLock();
-
- // Run all on compositing commit callbacks.
- void RunOnCommitCallbacks();
-
- // Add on compositing commit callback.
- void AddOnCommitCallbackAndDisableLocks(const base::Closure& callback);
-
- // Called after async thumbnailer task completes. Scales and crops the result
- // of the copy.
- static void CopyFromCompositingSurfaceHasResult(
- const gfx::Size& dst_size_in_pixel,
- const SkColorType color_type,
- const base::Callback<void(bool, const SkBitmap&)>& callback,
- scoped_ptr<cc::CopyOutputResult> result);
- static void PrepareTextureCopyOutputResult(
- const gfx::Size& dst_size_in_pixel,
- const SkColorType color_type,
- const base::Callback<void(bool, const SkBitmap&)>& callback,
- scoped_ptr<cc::CopyOutputResult> result);
- static void PrepareBitmapCopyOutputResult(
- const gfx::Size& dst_size_in_pixel,
- const SkColorType color_type,
- const base::Callback<void(bool, const SkBitmap&)>& callback,
- scoped_ptr<cc::CopyOutputResult> result);
- static void CopyFromCompositingSurfaceHasResultForVideo(
- base::WeakPtr<DelegatedFrameHost> 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,
- 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,
- scoped_refptr<OwnedMailbox> subscriber_texture,
- uint32 sync_point);
-
- void SendDelegatedFrameAck(uint32 output_surface_id);
- void SendReturnedDelegatedResources(uint32 output_surface_id);
-
- // DelegatedFrameEvictorClient implementation.
- virtual void EvictDelegatedFrame() OVERRIDE;
-
- // cc::DelegatedFrameProviderClient implementation.
- virtual void UnusedResourcesAreAvailable() OVERRIDE;
-
- void DidReceiveFrameFromRenderer();
-
- DelegatedFrameHostClient* client_;
-
- std::vector<base::Closure> on_compositing_did_commit_callbacks_;
-
- // The vsync manager we are observing for changes, if any.
- scoped_refptr<ui::CompositorVSyncManager> vsync_manager_;
-
- // With delegated renderer, this is the last output surface, used to
- // disambiguate resources with the same id coming from different output
- // surfaces.
- uint32 last_output_surface_id_;
-
- // The number of delegated frame acks that are pending, to delay resource
- // returns until the acks are sent.
- int pending_delegated_ack_count_;
-
- // True after a delegated frame has been skipped, until a frame is not
- // skipped.
- 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_;
-
- // 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
- // got resized, to the moment we committed the renderer frame of the same
- // size. It keeps track of the size we expect from the renderer, and locks the
- // compositor, as well as the UI for a short time to give a chance to the
- // renderer of producing a frame of the right size.
- scoped_ptr<ResizeLock> resize_lock_;
-
- // Keeps track of the current frame size.
- gfx::Size current_frame_size_in_dip_;
-
- // This lock is for waiting for a front surface to become available to draw.
- scoped_refptr<ui::CompositorLock> released_front_lock_;
-
- enum CanLockCompositorState {
- YES_CAN_LOCK,
- // We locked, so at some point we'll need to kick a frame.
- YES_DID_LOCK,
- // No. A lock timed out, we need to kick a new frame before locking again.
- NO_PENDING_RENDERER_FRAME,
- // No. We've got a frame, but it hasn't been committed.
- NO_PENDING_COMMIT,
- };
- CanLockCompositorState can_lock_compositor_;
-
- base::TimeTicks last_draw_ended_;
-
- // Subscriber that listens to frame presentation events.
- scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
- std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_;
-
- // YUV readback pipeline.
- scoped_ptr<content::ReadbackYUVInterface>
- yuv_readback_pipeline_;
+ virtual bool ShouldCreateResizeLock() = 0;
+ virtual void RequestCopyOfOutput(
+ scoped_ptr<cc::CopyOutputRequest> request) = 0;
- scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_;
+ virtual void LockResources() = 0;
+ virtual void UnlockResources() = 0;
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698