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

Side by Side Diff: content/browser/compositor/delegated_frame_host.h

Issue 864333004: Clean up DelegatedFrameHost's interface to its client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorprate review feedback Created 5 years, 11 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
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_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"
(...skipping 26 matching lines...) Expand all
37 class ReadbackYUVInterface; 37 class ReadbackYUVInterface;
38 class RenderWidgetHostViewFrameSubscriber; 38 class RenderWidgetHostViewFrameSubscriber;
39 class RenderWidgetHostImpl; 39 class RenderWidgetHostImpl;
40 class ResizeLock; 40 class ResizeLock;
41 41
42 // The DelegatedFrameHostClient is the interface from the DelegatedFrameHost, 42 // The DelegatedFrameHostClient is the interface from the DelegatedFrameHost,
43 // which manages delegated frames, and the ui::Compositor being used to 43 // which manages delegated frames, and the ui::Compositor being used to
44 // display them. 44 // display them.
45 class CONTENT_EXPORT DelegatedFrameHostClient { 45 class CONTENT_EXPORT DelegatedFrameHostClient {
46 public: 46 public:
47 virtual ui::Layer* GetLayer() = 0; 47 virtual bool DelegatedFrameHostIsVisible() const = 0;
48 virtual RenderWidgetHostImpl* GetHost() = 0; 48 virtual gfx::Size DelegatedFrameHostDesiredSizeInDIP() const = 0;
49 virtual bool IsVisible() = 0; 49
50 virtual scoped_ptr<ResizeLock> CreateResizeLock( 50 virtual bool DelegatedFrameCanCreateResizeLock() const = 0;
51 virtual scoped_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock(
51 bool defer_compositor_lock) = 0; 52 bool defer_compositor_lock) = 0;
52 virtual gfx::Size DesiredFrameSize() = 0; 53 virtual void DelegatedFrameHostResizeLockWasReleased() = 0;
53 54
54 // TODO(ccameron): It is likely that at least one of these two functions is 55 virtual void DelegatedFrameHostSendCompositorSwapAck(
55 // redundant. Find which one, and delete it. 56 int output_surface_id,
56 virtual float CurrentDeviceScaleFactor() = 0; 57 const cc::CompositorFrameAck& ack) = 0;
57 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) = 0; 58 virtual void DelegatedFrameHostSendReclaimCompositorResources(
59 int output_surface_id,
60 const cc::CompositorFrameAck& ack) = 0;
61 virtual void DelegatedFrameHostOnLostCompositorResources() = 0;
58 62
59 // These are to be overridden for testing only. 63 virtual void DelegatedFrameHostUpdateVSyncParameters(
60 // TODO(ccameron): This is convoluted. Make the tests that need to override 64 const base::TimeTicks& timebase,
61 // these functions test DelegatedFrameHost directly (rather than do it 65 const base::TimeDelta& interval) = 0;
62 // through RenderWidgetHostViewAura).
63 virtual DelegatedFrameHost* GetDelegatedFrameHost() const = 0;
64 virtual bool ShouldCreateResizeLock();
65 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
66 }; 66 };
67 67
68 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state 68 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state
69 // and functionality that is associated with delegated frames being sent from 69 // and functionality that is associated with delegated frames being sent from
70 // the RenderWidget. The DelegatedFrameHost will push these changes through to 70 // the RenderWidget. The DelegatedFrameHost will push these changes through to
71 // the ui::Compositor associated with its DelegatedFrameHostClient. 71 // the ui::Compositor associated with its DelegatedFrameHostClient.
72 class CONTENT_EXPORT DelegatedFrameHost 72 class CONTENT_EXPORT DelegatedFrameHost
73 : public ui::CompositorObserver, 73 : public ui::CompositorObserver,
74 public ui::CompositorVSyncManager::Observer, 74 public ui::CompositorVSyncManager::Observer,
75 public ui::LayerOwnerDelegate, 75 public ui::LayerOwnerDelegate,
76 public ImageTransportFactoryObserver, 76 public ImageTransportFactoryObserver,
77 public DelegatedFrameEvictorClient, 77 public DelegatedFrameEvictorClient,
78 public cc::DelegatedFrameResourceCollectionClient, 78 public cc::DelegatedFrameResourceCollectionClient,
79 public cc::SurfaceFactoryClient, 79 public cc::SurfaceFactoryClient,
80 public base::SupportsWeakPtr<DelegatedFrameHost> { 80 public base::SupportsWeakPtr<DelegatedFrameHost> {
81 public: 81 public:
82 DelegatedFrameHost(DelegatedFrameHostClient* client); 82 DelegatedFrameHost(DelegatedFrameHostClient* client, ui::Layer* layer);
83 ~DelegatedFrameHost() override; 83 ~DelegatedFrameHost() override;
84 84
85 bool CanCopyToBitmap() const; 85 bool CanCopyToBitmap() const;
86 86
87 // Public interface exposed to RenderWidgetHostView. 87 // Public interface exposed to RenderWidgetHostView.
88 void SwapDelegatedFrame( 88 void SwapDelegatedFrame(
89 uint32 output_surface_id, 89 uint32 output_surface_id,
90 scoped_ptr<cc::DelegatedFrameData> frame_data, 90 scoped_ptr<cc::DelegatedFrameData> frame_data,
91 float frame_device_scale_factor, 91 float frame_device_scale_factor,
92 const std::vector<ui::LatencyInfo>& latency_info); 92 const std::vector<ui::LatencyInfo>& latency_info);
(...skipping 20 matching lines...) Expand all
113 bool HasFrameSubscriber() const { return frame_subscriber_; } 113 bool HasFrameSubscriber() const { return frame_subscriber_; }
114 114
115 // Exposed for tests. 115 // Exposed for tests.
116 cc::DelegatedFrameProvider* FrameProviderForTesting() const { 116 cc::DelegatedFrameProvider* FrameProviderForTesting() const {
117 return frame_provider_.get(); 117 return frame_provider_.get();
118 } 118 }
119 cc::SurfaceId SurfaceIdForTesting() const { return surface_id_; } 119 cc::SurfaceId SurfaceIdForTesting() const { return surface_id_; }
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(); }
124 bool ReleasedFrontLockActiveForTesting() const { 123 bool ReleasedFrontLockActiveForTesting() const {
125 return !!released_front_lock_.get(); 124 return !!released_front_lock_.get();
126 } 125 }
126 void SetRequestCopyOfOutputCallbackForTesting(
127 const base::Callback<void(scoped_ptr<cc::CopyOutputRequest>)>& callback) {
128 request_copy_of_output_callback_for_testing_ = callback;
129 }
127 130
128 private: 131 private:
129 friend class DelegatedFrameHostClient; 132 friend class DelegatedFrameHostClient;
130 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, 133 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
131 SkippedDelegatedFrames); 134 SkippedDelegatedFrames);
132 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest, 135 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraTest,
133 DiscardDelegatedFramesWithLocking); 136 DiscardDelegatedFramesWithLocking);
134 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest, 137 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraCopyRequestTest,
135 DestroyedAfterCopyRequest); 138 DestroyedAfterCopyRequest);
136 139
137 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { 140 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
138 return frame_subscriber_.get(); 141 return frame_subscriber_.get();
139 } 142 }
140 bool ShouldCreateResizeLock(); 143 bool ShouldCreateResizeLock();
141 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
142
143 void LockResources(); 144 void LockResources();
144 void UnlockResources(); 145 void UnlockResources();
146 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
145 147
146 // Overridden from ui::CompositorObserver: 148 // Overridden from ui::CompositorObserver:
147 void OnCompositingDidCommit(ui::Compositor* compositor) override; 149 void OnCompositingDidCommit(ui::Compositor* compositor) override;
148 void OnCompositingStarted(ui::Compositor* compositor, 150 void OnCompositingStarted(ui::Compositor* compositor,
149 base::TimeTicks start_time) override; 151 base::TimeTicks start_time) override;
150 void OnCompositingEnded(ui::Compositor* compositor) override; 152 void OnCompositingEnded(ui::Compositor* compositor) override;
151 void OnCompositingAborted(ui::Compositor* compositor) override; 153 void OnCompositingAborted(ui::Compositor* compositor) override;
152 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; 154 void OnCompositingLockStateChanged(ui::Compositor* compositor) override;
153 void OnCompositingShuttingDown(ui::Compositor* compositor) override; 155 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
154 156
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void EvictDelegatedFrame() override; 221 void EvictDelegatedFrame() override;
220 222
221 // cc::DelegatedFrameProviderClient implementation. 223 // cc::DelegatedFrameProviderClient implementation.
222 void UnusedResourcesAreAvailable() override; 224 void UnusedResourcesAreAvailable() override;
223 225
224 // cc::SurfaceFactoryClient implementation. 226 // cc::SurfaceFactoryClient implementation.
225 void ReturnResources(const cc::ReturnedResourceArray& resources) override; 227 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
226 228
227 void DidReceiveFrameFromRenderer(const gfx::Rect& damage_rect); 229 void DidReceiveFrameFromRenderer(const gfx::Rect& damage_rect);
228 230
229 DelegatedFrameHostClient* client_; 231 DelegatedFrameHostClient* const client_;
232 ui::Layer* const layer_;
230 233
231 ui::Compositor* compositor_; 234 ui::Compositor* compositor_;
232 235
233 // True if this renders into a Surface, false if it renders into a delegated 236 // True if this renders into a Surface, false if it renders into a delegated
234 // layer. 237 // layer.
235 bool use_surfaces_; 238 bool use_surfaces_;
236 239
237 std::vector<base::Closure> on_compositing_did_commit_callbacks_; 240 std::vector<base::Closure> on_compositing_did_commit_callbacks_;
238 241
239 // The vsync manager we are observing for changes, if any. 242 // The vsync manager we are observing for changes, if any.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 NO_PENDING_COMMIT, 301 NO_PENDING_COMMIT,
299 }; 302 };
300 CanLockCompositorState can_lock_compositor_; 303 CanLockCompositorState can_lock_compositor_;
301 304
302 base::TimeTicks last_draw_ended_; 305 base::TimeTicks last_draw_ended_;
303 306
304 // Subscriber that listens to frame presentation events. 307 // Subscriber that listens to frame presentation events.
305 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; 308 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
306 std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_; 309 std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_;
307 310
311 // Callback used to pass the output request to the layer or to a function
312 // specified by a test.
313 base::Callback<void(scoped_ptr<cc::CopyOutputRequest>)>
314 request_copy_of_output_callback_for_testing_;
315
308 // YUV readback pipeline. 316 // YUV readback pipeline.
309 scoped_ptr<content::ReadbackYUVInterface> 317 scoped_ptr<content::ReadbackYUVInterface>
310 yuv_readback_pipeline_; 318 yuv_readback_pipeline_;
311 319
312 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; 320 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_;
313 }; 321 };
314 322
315 } // namespace content 323 } // namespace content
316 324
317 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ 325 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698