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

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

Issue 2693423005: DelegatedFrameHost should use CompositorFrameSinkSupport (Closed)
Patch Set: c Created 3 years, 10 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
« no previous file with comments | « no previous file | content/browser/renderer_host/delegated_frame_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "cc/output/copy_output_result.h" 13 #include "cc/output/copy_output_result.h"
14 #include "cc/surfaces/surface_factory_client.h" 14 #include "cc/scheduler/begin_frame_source.h"
15 #include "cc/surfaces/compositor_frame_sink_support_client.h"
15 #include "content/browser/compositor/image_transport_factory.h" 16 #include "content/browser/compositor/image_transport_factory.h"
16 #include "content/browser/compositor/owned_mailbox.h" 17 #include "content/browser/compositor/owned_mailbox.h"
17 #include "content/browser/renderer_host/delegated_frame_evictor.h" 18 #include "content/browser/renderer_host/delegated_frame_evictor.h"
18 #include "content/browser/renderer_host/dip_util.h" 19 #include "content/browser/renderer_host/dip_util.h"
19 #include "content/browser/renderer_host/render_widget_host_impl.h" 20 #include "content/browser/renderer_host/render_widget_host_impl.h"
20 #include "content/browser/renderer_host/render_widget_host_view_base.h" 21 #include "content/browser/renderer_host/render_widget_host_view_base.h"
21 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
22 #include "ui/compositor/compositor.h" 23 #include "ui/compositor/compositor.h"
23 #include "ui/compositor/compositor_observer.h" 24 #include "ui/compositor/compositor_observer.h"
24 #include "ui/compositor/compositor_vsync_manager.h" 25 #include "ui/compositor/compositor_vsync_manager.h"
25 #include "ui/compositor/layer.h" 26 #include "ui/compositor/layer.h"
26 #include "ui/events/event.h" 27 #include "ui/events/event.h"
27 #include "ui/gfx/geometry/rect_conversions.h" 28 #include "ui/gfx/geometry/rect_conversions.h"
28 29
29 namespace base { 30 namespace base {
30 class TickClock; 31 class TickClock;
31 } 32 }
32 33
33 namespace cc { 34 namespace cc {
35 class CompositorFrameSinkSupport;
34 class LocalSurfaceIdAllocator; 36 class LocalSurfaceIdAllocator;
35 class SurfaceFactory;
36 } 37 }
37 38
38 namespace media { 39 namespace media {
39 class VideoFrame; 40 class VideoFrame;
40 } 41 }
41 42
42 namespace display_compositor { 43 namespace display_compositor {
43 class ReadbackYUVInterface; 44 class ReadbackYUVInterface;
44 } 45 }
45 46
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state 82 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state
82 // and functionality that is associated with delegated frames being sent from 83 // and functionality that is associated with delegated frames being sent from
83 // the RenderWidget. The DelegatedFrameHost will push these changes through to 84 // the RenderWidget. The DelegatedFrameHost will push these changes through to
84 // the ui::Compositor associated with its DelegatedFrameHostClient. 85 // the ui::Compositor associated with its DelegatedFrameHostClient.
85 class CONTENT_EXPORT DelegatedFrameHost 86 class CONTENT_EXPORT DelegatedFrameHost
86 : public ui::CompositorObserver, 87 : public ui::CompositorObserver,
87 public ui::CompositorVSyncManager::Observer, 88 public ui::CompositorVSyncManager::Observer,
88 public ui::ContextFactoryObserver, 89 public ui::ContextFactoryObserver,
89 public DelegatedFrameEvictorClient, 90 public DelegatedFrameEvictorClient,
90 public cc::SurfaceFactoryClient, 91 public NON_EXPORTED_BASE(cc::CompositorFrameSinkSupportClient),
92 public cc::ExternalBeginFrameSourceClient,
91 public base::SupportsWeakPtr<DelegatedFrameHost> { 93 public base::SupportsWeakPtr<DelegatedFrameHost> {
92 public: 94 public:
93 DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id, 95 DelegatedFrameHost(const cc::FrameSinkId& frame_sink_id,
94 DelegatedFrameHostClient* client); 96 DelegatedFrameHostClient* client);
95 ~DelegatedFrameHost() override; 97 ~DelegatedFrameHost() override;
96 98
97 // ui::CompositorObserver implementation. 99 // ui::CompositorObserver implementation.
98 void OnCompositingDidCommit(ui::Compositor* compositor) override; 100 void OnCompositingDidCommit(ui::Compositor* compositor) override;
99 void OnCompositingStarted(ui::Compositor* compositor, 101 void OnCompositingStarted(ui::Compositor* compositor,
100 base::TimeTicks start_time) override; 102 base::TimeTicks start_time) override;
101 void OnCompositingEnded(ui::Compositor* compositor) override; 103 void OnCompositingEnded(ui::Compositor* compositor) override;
102 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; 104 void OnCompositingLockStateChanged(ui::Compositor* compositor) override;
103 void OnCompositingShuttingDown(ui::Compositor* compositor) override; 105 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
104 106
105 // ui::CompositorVSyncManager::Observer implementation. 107 // ui::CompositorVSyncManager::Observer implementation.
106 void OnUpdateVSyncParameters(base::TimeTicks timebase, 108 void OnUpdateVSyncParameters(base::TimeTicks timebase,
107 base::TimeDelta interval) override; 109 base::TimeDelta interval) override;
108 110
109 // ImageTransportFactoryObserver implementation. 111 // ImageTransportFactoryObserver implementation.
110 void OnLostResources() override; 112 void OnLostResources() override;
111 113
112 // DelegatedFrameEvictorClient implementation. 114 // DelegatedFrameEvictorClient implementation.
113 void EvictDelegatedFrame() override; 115 void EvictDelegatedFrame() override;
114 116
115 // cc::SurfaceFactoryClient implementation. 117 // cc::CompositorFrameSinkSupportClient implementation.
116 void ReturnResources(const cc::ReturnedResourceArray& resources) override; 118 void DidReceiveCompositorFrameAck() override;
119 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
120 void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
117 void WillDrawSurface(const cc::LocalSurfaceId& id, 121 void WillDrawSurface(const cc::LocalSurfaceId& id,
118 const gfx::Rect& damage_rect) override; 122 const gfx::Rect& damage_rect) override;
119 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
120 123
121 bool CanCopyToBitmap() const; 124 bool CanCopyToBitmap() const;
122 125
123 // Public interface exposed to RenderWidgetHostView. 126 // Public interface exposed to RenderWidgetHostView.
124 127
125 void SwapDelegatedFrame(uint32_t compositor_frame_sink_id, 128 void SwapDelegatedFrame(uint32_t compositor_frame_sink_id,
126 cc::CompositorFrame frame); 129 cc::CompositorFrame frame);
127 void ClearDelegatedFrame(); 130 void ClearDelegatedFrame();
128 void WasHidden(); 131 void WasHidden();
129 void WasShown(const ui::LatencyInfo& latency_info); 132 void WasShown(const ui::LatencyInfo& latency_info);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 base::WeakPtr<DelegatedFrameHost> rwhva, 239 base::WeakPtr<DelegatedFrameHost> rwhva,
237 const base::Callback<void(bool)>& callback, 240 const base::Callback<void(bool)>& callback,
238 scoped_refptr<OwnedMailbox> subscriber_texture, 241 scoped_refptr<OwnedMailbox> subscriber_texture,
239 std::unique_ptr<cc::SingleReleaseCallback> release_callback, 242 std::unique_ptr<cc::SingleReleaseCallback> release_callback,
240 bool result); 243 bool result);
241 static void ReturnSubscriberTexture( 244 static void ReturnSubscriberTexture(
242 base::WeakPtr<DelegatedFrameHost> rwhva, 245 base::WeakPtr<DelegatedFrameHost> rwhva,
243 scoped_refptr<OwnedMailbox> subscriber_texture, 246 scoped_refptr<OwnedMailbox> subscriber_texture,
244 const gpu::SyncToken& sync_token); 247 const gpu::SyncToken& sync_token);
245 248
246 void SendReclaimCompositorResources(uint32_t compositor_frame_sink_id,
247 bool is_swap_ack);
248 void SurfaceDrawn(uint32_t compositor_frame_sink_id);
249
250 // Called to consult the current |frame_subscriber_|, to determine and maybe 249 // Called to consult the current |frame_subscriber_|, to determine and maybe
251 // initiate a copy-into-video-frame request. 250 // initiate a copy-into-video-frame request.
252 void AttemptFrameSubscriberCapture(const gfx::Rect& damage_rect); 251 void AttemptFrameSubscriberCapture(const gfx::Rect& damage_rect);
253 252
253 // cc::ExternalBeginFrameSource implementation.
254 void OnNeedsBeginFrames(bool needs_begin_frames) override;
255 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override;
256
257 void CreateCompositorFrameSinkSupport();
258 void ResetCompositorFrameSinkSupport();
259
254 const cc::FrameSinkId frame_sink_id_; 260 const cc::FrameSinkId frame_sink_id_;
255 cc::LocalSurfaceId local_surface_id_; 261 cc::LocalSurfaceId local_surface_id_;
256 DelegatedFrameHostClient* const client_; 262 DelegatedFrameHostClient* const client_;
257 ui::Compositor* compositor_; 263 ui::Compositor* compositor_;
258 264
259 // The vsync manager we are observing for changes, if any. 265 // The vsync manager we are observing for changes, if any.
260 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; 266 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_;
261 267
262 // The current VSync timebase and interval. These are zero until the first 268 // The current VSync timebase and interval. These are zero until the first
263 // call to SetVSyncParameters(). 269 // call to SetVSyncParameters().
264 base::TimeTicks vsync_timebase_; 270 base::TimeTicks vsync_timebase_;
265 base::TimeDelta vsync_interval_; 271 base::TimeDelta vsync_interval_;
266 272
267 // Overridable tick clock used for testing functions using current time. 273 // Overridable tick clock used for testing functions using current time.
268 std::unique_ptr<base::TickClock> tick_clock_; 274 std::unique_ptr<base::TickClock> tick_clock_;
269 275
270 // With delegated renderer, this is the last output surface, used to 276 // With delegated renderer, this is the last output surface, used to
271 // disambiguate resources with the same id coming from different output 277 // disambiguate resources with the same id coming from different output
272 // surfaces. 278 // surfaces.
273 uint32_t last_compositor_frame_sink_id_; 279 uint32_t last_compositor_frame_sink_id_;
274 280
275 // The number of delegated frame acks that are pending, to delay resource
276 // returns until the acks are sent.
277 int pending_delegated_ack_count_;
278
279 // True after a delegated frame has been skipped, until a frame is not 281 // True after a delegated frame has been skipped, until a frame is not
280 // skipped. 282 // skipped.
281 bool skipped_frames_; 283 bool skipped_frames_;
282 std::vector<ui::LatencyInfo> skipped_latency_info_list_; 284 std::vector<ui::LatencyInfo> skipped_latency_info_list_;
283 285
284 std::unique_ptr<ui::Layer> right_gutter_; 286 std::unique_ptr<ui::Layer> right_gutter_;
285 std::unique_ptr<ui::Layer> bottom_gutter_; 287 std::unique_ptr<ui::Layer> bottom_gutter_;
286 288
287 // This is the last root background color from a swapped frame. 289 // This is the last root background color from a swapped frame.
288 SkColor background_color_; 290 SkColor background_color_;
289 291
290 // State for rendering into a Surface. 292 // State for rendering into a Surface.
291 std::unique_ptr<cc::LocalSurfaceIdAllocator> id_allocator_; 293 std::unique_ptr<cc::LocalSurfaceIdAllocator> id_allocator_;
292 std::unique_ptr<cc::SurfaceFactory> surface_factory_; 294 std::unique_ptr<cc::CompositorFrameSinkSupport> support_;
293 gfx::Size current_surface_size_; 295 gfx::Size current_surface_size_;
294 float current_scale_factor_; 296 float current_scale_factor_;
295 cc::ReturnedResourceArray surface_returned_resources_; 297 cc::ReturnedResourceArray surface_returned_resources_;
296 298
297 // This lock is the one waiting for a frame of the right size to come back 299 // This lock is the one waiting for a frame of the right size to come back
298 // from the renderer/GPU process. It is set from the moment the aura window 300 // from the renderer/GPU process. It is set from the moment the aura window
299 // got resized, to the moment we committed the renderer frame of the same 301 // got resized, to the moment we committed the renderer frame of the same
300 // size. It keeps track of the size we expect from the renderer, and locks the 302 // size. It keeps track of the size we expect from the renderer, and locks the
301 // compositor, as well as the UI for a short time to give a chance to the 303 // compositor, as well as the UI for a short time to give a chance to the
302 // renderer of producing a frame of the right size. 304 // renderer of producing a frame of the right size.
(...skipping 24 matching lines...) Expand all
327 329
328 // Callback used to pass the output request to the layer or to a function 330 // Callback used to pass the output request to the layer or to a function
329 // specified by a test. 331 // specified by a test.
330 base::Callback<void(std::unique_ptr<cc::CopyOutputRequest>)> 332 base::Callback<void(std::unique_ptr<cc::CopyOutputRequest>)>
331 request_copy_of_output_callback_for_testing_; 333 request_copy_of_output_callback_for_testing_;
332 334
333 // YUV readback pipeline. 335 // YUV readback pipeline.
334 std::unique_ptr<display_compositor::ReadbackYUVInterface> 336 std::unique_ptr<display_compositor::ReadbackYUVInterface>
335 yuv_readback_pipeline_; 337 yuv_readback_pipeline_;
336 338
339 std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_;
340
341 bool needs_begin_frame_ = false;
342
337 std::unique_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; 343 std::unique_ptr<DelegatedFrameEvictor> delegated_frame_evictor_;
338 }; 344 };
339 345
340 } // namespace content 346 } // namespace content
341 347
342 #endif // CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_ 348 #endif // CONTENT_BROWSER_RENDERER_HOST_DELEGATED_FRAME_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/delegated_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698