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

Side by Side Diff: content/browser/compositor/delegated_frame_layer_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_LAYER_HOST_H_
6 #define CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ 6 #define CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_LAYER_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 "content/browser/compositor/delegated_frame_host.h"
11 #include "content/browser/compositor/image_transport_factory.h" 12 #include "content/browser/compositor/image_transport_factory.h"
12 #include "content/browser/compositor/owned_mailbox.h" 13 #include "content/browser/compositor/owned_mailbox.h"
13 #include "content/browser/renderer_host/delegated_frame_evictor.h" 14 #include "content/browser/renderer_host/delegated_frame_evictor.h"
14 #include "content/browser/renderer_host/dip_util.h" 15 #include "content/browser/renderer_host/dip_util.h"
15 #include "content/browser/renderer_host/render_widget_host_impl.h" 16 #include "content/browser/renderer_host/render_widget_host_impl.h"
16 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
17 #include "ui/compositor/compositor.h" 18 #include "ui/compositor/compositor.h"
18 #include "ui/compositor/compositor_observer.h" 19 #include "ui/compositor/compositor_observer.h"
19 #include "ui/compositor/compositor_vsync_manager.h" 20 #include "ui/compositor/compositor_vsync_manager.h"
20 #include "ui/compositor/layer.h" 21 #include "ui/compositor/layer.h"
21 #include "ui/compositor/layer_owner_delegate.h" 22 #include "ui/compositor/layer_owner_delegate.h"
22 #include "ui/gfx/rect_conversions.h" 23 #include "ui/gfx/rect_conversions.h"
23 24
24 namespace media {
25 class VideoFrame;
26 }
27
28 namespace content { 25 namespace content {
29 26
30 class DelegatedFrameHost;
31 class ReadbackYUVInterface; 27 class ReadbackYUVInterface;
32 class RenderWidgetHostViewFrameSubscriber;
33 class RenderWidgetHostImpl;
34 class ResizeLock;
35 28
36 // The DelegatedFrameHostClient is the interface from the DelegatedFrameHost, 29 class CONTENT_EXPORT DelegatedFrameLayerHost
37 // which manages delegated frames, and the ui::Compositor being used to 30 : public DelegatedFrameHost,
38 // display them. 31 public ui::CompositorObserver,
39 class CONTENT_EXPORT DelegatedFrameHostClient {
40 public:
41 virtual ui::Compositor* GetCompositor() const = 0;
42 virtual ui::Layer* GetLayer() = 0;
43 virtual RenderWidgetHostImpl* GetHost() = 0;
44 virtual void SchedulePaintInRect(const gfx::Rect& damage_rect_in_dip) = 0;
45 virtual bool IsVisible() = 0;
46 virtual scoped_ptr<ResizeLock> CreateResizeLock(
47 bool defer_compositor_lock) = 0;
48 virtual gfx::Size DesiredFrameSize() = 0;
49
50 // TODO(ccameron): It is likely that at least one of these two functions is
51 // redundant. Find which one, and delete it.
52 virtual float CurrentDeviceScaleFactor() = 0;
53 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) = 0;
54
55 // These are to be overridden for testing only.
56 // TODO(ccameron): This is convoluted. Make the tests that need to override
57 // these functions test DelegatedFrameHost directly (rather than do it
58 // through RenderWidgetHostViewAura).
59 virtual DelegatedFrameHost* GetDelegatedFrameHost() const = 0;
60 virtual bool ShouldCreateResizeLock();
61 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
62 };
63
64 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state
65 // and functionality that is associated with delegated frames being sent from
66 // the RenderWidget. The DelegatedFrameHost will push these changes through to
67 // the ui::Compositor associated with its DelegatedFrameHostClient.
68 class CONTENT_EXPORT DelegatedFrameHost
69 : public ui::CompositorObserver,
70 public ui::CompositorVSyncManager::Observer, 32 public ui::CompositorVSyncManager::Observer,
71 public ui::LayerOwnerDelegate, 33 public ui::LayerOwnerDelegate,
72 public ImageTransportFactoryObserver, 34 public ImageTransportFactoryObserver,
73 public DelegatedFrameEvictorClient, 35 public DelegatedFrameEvictorClient,
74 public cc::DelegatedFrameResourceCollectionClient, 36 public cc::DelegatedFrameResourceCollectionClient,
75 public base::SupportsWeakPtr<DelegatedFrameHost> { 37 public base::SupportsWeakPtr<DelegatedFrameLayerHost> {
76 public: 38 public:
77 DelegatedFrameHost(DelegatedFrameHostClient* client); 39 DelegatedFrameLayerHost(DelegatedFrameHostClient* client);
78 virtual ~DelegatedFrameHost(); 40 virtual ~DelegatedFrameLayerHost();
79
80 bool CanCopyToBitmap() const;
81 41
82 // Public interface exposed to RenderWidgetHostView. 42 // Public interface exposed to RenderWidgetHostView.
83 void SwapDelegatedFrame( 43 virtual bool CanCopyToBitmap() const OVERRIDE;
44 virtual void SwapDelegatedFrame(
84 uint32 output_surface_id, 45 uint32 output_surface_id,
85 scoped_ptr<cc::DelegatedFrameData> frame_data, 46 scoped_ptr<cc::DelegatedFrameData> frame_data,
86 float frame_device_scale_factor, 47 float frame_device_scale_factor,
87 const std::vector<ui::LatencyInfo>& latency_info); 48 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
88 void WasHidden(); 49 virtual void WasHidden() OVERRIDE;
89 void WasShown(); 50 virtual void WasShown() OVERRIDE;
90 void WasResized(); 51 virtual void WasResized() OVERRIDE;
91 gfx::Size GetRequestedRendererSize() const; 52 virtual gfx::Size GetRequestedRendererSize() const OVERRIDE;
92 void AddedToWindow(); 53 virtual void AddedToWindow() OVERRIDE;
93 void RemovingFromWindow(); 54 virtual void RemovingFromWindow() OVERRIDE;
94 void CopyFromCompositingSurface( 55 virtual void CopyFromCompositingSurface(
95 const gfx::Rect& src_subrect, 56 const gfx::Rect& src_subrect,
96 const gfx::Size& dst_size, 57 const gfx::Size& dst_size,
97 const base::Callback<void(bool, const SkBitmap&)>& callback, 58 const base::Callback<void(bool, const SkBitmap&)>& callback,
98 const SkColorType color_type); 59 const SkColorType color_type) OVERRIDE;
99 void CopyFromCompositingSurfaceToVideoFrame( 60 virtual void CopyFromCompositingSurfaceToVideoFrame(
100 const gfx::Rect& src_subrect, 61 const gfx::Rect& src_subrect,
101 const scoped_refptr<media::VideoFrame>& target, 62 const scoped_refptr<media::VideoFrame>& target,
102 const base::Callback<void(bool)>& callback); 63 const base::Callback<void(bool)>& callback) OVERRIDE;
103 bool CanCopyToVideoFrame() const; 64 virtual bool CanCopyToVideoFrame() const OVERRIDE;
104 bool CanSubscribeFrame() const; 65 virtual bool CanSubscribeFrame() const OVERRIDE;
105 void BeginFrameSubscription( 66 virtual void BeginFrameSubscription(
106 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); 67 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE;
107 void EndFrameSubscription(); 68 virtual void EndFrameSubscription() OVERRIDE;
108 bool HasFrameSubscriber() const { return frame_subscriber_; } 69 virtual bool HasFrameSubscriber() const OVERRIDE;
70 virtual void SetLayerOwner(ui::LayerOwner* layer_owner) OVERRIDE;
109 71
110 // Exposed for tests. 72 virtual cc::DelegatedFrameProvider* FrameProviderForTesting() const OVERRIDE;
111 cc::DelegatedFrameProvider* FrameProviderForTesting() const { 73 virtual void OnCompositingDidCommitForTesting(
112 return frame_provider_.get(); 74 ui::Compositor* compositor) OVERRIDE;
113 }
114 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) {
115 OnCompositingDidCommit(compositor);
116 }
117 bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); }
118 75
119 private: 76 private:
120 friend class DelegatedFrameHostClient; 77 friend class DelegatedFrameHostClient;
121 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, 78 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
122 SkippedDelegatedFrames); 79 SkippedDelegatedFrames);
123 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, 80 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
124 DiscardDelegatedFramesWithLocking); 81 DiscardDelegatedFramesWithLocking);
125 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest, 82 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest,
126 DestroyedAfterCopyRequest); 83 DestroyedAfterCopyRequest);
127 84
128 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { 85 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
129 return frame_subscriber_.get(); 86 return frame_subscriber_.get();
130 } 87 }
131 bool ShouldCreateResizeLock(); 88 virtual bool ShouldCreateResizeLock() OVERRIDE;
132 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); 89 virtual void RequestCopyOfOutput(
90 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE;
133 91
134 void LockResources(); 92 virtual void LockResources() OVERRIDE;
135 void UnlockResources(); 93 virtual void UnlockResources() OVERRIDE;
136 94
137 // Overridden from ui::CompositorObserver: 95 // Overridden from ui::CompositorObserver:
138 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE; 96 virtual void OnCompositingDidCommit(ui::Compositor* compositor) OVERRIDE;
139 virtual void OnCompositingStarted(ui::Compositor* compositor, 97 virtual void OnCompositingStarted(ui::Compositor* compositor,
140 base::TimeTicks start_time) OVERRIDE; 98 base::TimeTicks start_time) OVERRIDE;
141 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; 99 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE;
142 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE; 100 virtual void OnCompositingAborted(ui::Compositor* compositor) OVERRIDE;
143 virtual void OnCompositingLockStateChanged( 101 virtual void OnCompositingLockStateChanged(
144 ui::Compositor* compositor) OVERRIDE; 102 ui::Compositor* compositor) OVERRIDE;
145 103
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const gfx::Size& dst_size_in_pixel, 138 const gfx::Size& dst_size_in_pixel,
181 const SkColorType color_type, 139 const SkColorType color_type,
182 const base::Callback<void(bool, const SkBitmap&)>& callback, 140 const base::Callback<void(bool, const SkBitmap&)>& callback,
183 scoped_ptr<cc::CopyOutputResult> result); 141 scoped_ptr<cc::CopyOutputResult> result);
184 static void PrepareBitmapCopyOutputResult( 142 static void PrepareBitmapCopyOutputResult(
185 const gfx::Size& dst_size_in_pixel, 143 const gfx::Size& dst_size_in_pixel,
186 const SkColorType color_type, 144 const SkColorType color_type,
187 const base::Callback<void(bool, const SkBitmap&)>& callback, 145 const base::Callback<void(bool, const SkBitmap&)>& callback,
188 scoped_ptr<cc::CopyOutputResult> result); 146 scoped_ptr<cc::CopyOutputResult> result);
189 static void CopyFromCompositingSurfaceHasResultForVideo( 147 static void CopyFromCompositingSurfaceHasResultForVideo(
190 base::WeakPtr<DelegatedFrameHost> rwhva, 148 base::WeakPtr<DelegatedFrameLayerHost> rwhva,
191 scoped_refptr<OwnedMailbox> subscriber_texture, 149 scoped_refptr<OwnedMailbox> subscriber_texture,
192 scoped_refptr<media::VideoFrame> video_frame, 150 scoped_refptr<media::VideoFrame> video_frame,
193 const base::Callback<void(bool)>& callback, 151 const base::Callback<void(bool)>& callback,
194 scoped_ptr<cc::CopyOutputResult> result); 152 scoped_ptr<cc::CopyOutputResult> result);
195 static void CopyFromCompositingSurfaceFinishedForVideo( 153 static void CopyFromCompositingSurfaceFinishedForVideo(
196 base::WeakPtr<DelegatedFrameHost> rwhva, 154 base::WeakPtr<DelegatedFrameLayerHost> rwhva,
197 const base::Callback<void(bool)>& callback, 155 const base::Callback<void(bool)>& callback,
198 scoped_refptr<OwnedMailbox> subscriber_texture, 156 scoped_refptr<OwnedMailbox> subscriber_texture,
199 scoped_ptr<cc::SingleReleaseCallback> release_callback, 157 scoped_ptr<cc::SingleReleaseCallback> release_callback,
200 bool result); 158 bool result);
201 static void ReturnSubscriberTexture( 159 static void ReturnSubscriberTexture(
202 base::WeakPtr<DelegatedFrameHost> rwhva, 160 base::WeakPtr<DelegatedFrameLayerHost> rwhva,
203 scoped_refptr<OwnedMailbox> subscriber_texture, 161 scoped_refptr<OwnedMailbox> subscriber_texture,
204 uint32 sync_point); 162 uint32 sync_point);
205 163
206 void SendDelegatedFrameAck(uint32 output_surface_id); 164 void SendDelegatedFrameAck(uint32 output_surface_id);
207 void SendReturnedDelegatedResources(uint32 output_surface_id); 165 void SendReturnedDelegatedResources(uint32 output_surface_id);
208 166
209 // DelegatedFrameEvictorClient implementation. 167 // DelegatedFrameEvictorClient implementation.
210 virtual void EvictDelegatedFrame() OVERRIDE; 168 virtual void EvictDelegatedFrame() OVERRIDE;
211 169
212 // cc::DelegatedFrameProviderClient implementation. 170 // cc::DelegatedFrameProviderClient implementation.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 }; 226 };
269 CanLockCompositorState can_lock_compositor_; 227 CanLockCompositorState can_lock_compositor_;
270 228
271 base::TimeTicks last_draw_ended_; 229 base::TimeTicks last_draw_ended_;
272 230
273 // Subscriber that listens to frame presentation events. 231 // Subscriber that listens to frame presentation events.
274 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; 232 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
275 std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_; 233 std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_;
276 234
277 // YUV readback pipeline. 235 // YUV readback pipeline.
278 scoped_ptr<content::ReadbackYUVInterface> 236 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_;
279 yuv_readback_pipeline_;
280 237
281 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; 238 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_;
282 }; 239 };
283 240
284 } // namespace content 241 } // namespace content
285 242
286 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ 243 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_LAYER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698