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

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

Issue 775143003: cc: Implement unified BeginFrame on aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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"
11 #include "cc/surfaces/surface_factory_client.h" 11 #include "cc/surfaces/surface_factory_client.h"
12 #include "content/browser/compositor/image_transport_factory.h" 12 #include "content/browser/compositor/image_transport_factory.h"
13 #include "content/browser/compositor/owned_mailbox.h" 13 #include "content/browser/compositor/owned_mailbox.h"
14 #include "content/browser/renderer_host/delegated_frame_evictor.h" 14 #include "content/browser/renderer_host/delegated_frame_evictor.h"
15 #include "content/browser/renderer_host/dip_util.h" 15 #include "content/browser/renderer_host/dip_util.h"
16 #include "content/browser/renderer_host/render_widget_host_impl.h" 16 #include "content/browser/renderer_host/render_widget_host_impl.h"
17 #include "content/browser/renderer_host/render_widget_host_view_base.h" 17 #include "content/browser/renderer_host/render_widget_host_view_base.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "ui/base/compositor/compositor_begin_frame_observer.h"
19 #include "ui/compositor/compositor.h" 20 #include "ui/compositor/compositor.h"
20 #include "ui/compositor/compositor_observer.h" 21 #include "ui/compositor/compositor_observer.h"
21 #include "ui/compositor/compositor_vsync_manager.h" 22 #include "ui/compositor/compositor_vsync_manager.h"
22 #include "ui/compositor/layer.h" 23 #include "ui/compositor/layer.h"
23 #include "ui/compositor/layer_owner_delegate.h" 24 #include "ui/compositor/layer_owner_delegate.h"
24 #include "ui/gfx/rect_conversions.h" 25 #include "ui/gfx/rect_conversions.h"
25 26
26 namespace cc { 27 namespace cc {
27 class SurfaceFactory; 28 class SurfaceFactory;
29 struct BeginFrameArgs;
28 } 30 }
29 31
30 namespace media { 32 namespace media {
31 class VideoFrame; 33 class VideoFrame;
32 } 34 }
33 35
34 namespace content { 36 namespace content {
35 37
36 class DelegatedFrameHost; 38 class DelegatedFrameHost;
37 class ReadbackYUVInterface; 39 class ReadbackYUVInterface;
(...skipping 19 matching lines...) Expand all
57 virtual float CurrentDeviceScaleFactor() = 0; 59 virtual float CurrentDeviceScaleFactor() = 0;
58 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) = 0; 60 virtual gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) = 0;
59 61
60 // These are to be overridden for testing only. 62 // These are to be overridden for testing only.
61 // TODO(ccameron): This is convoluted. Make the tests that need to override 63 // TODO(ccameron): This is convoluted. Make the tests that need to override
62 // these functions test DelegatedFrameHost directly (rather than do it 64 // these functions test DelegatedFrameHost directly (rather than do it
63 // through RenderWidgetHostViewAura). 65 // through RenderWidgetHostViewAura).
64 virtual DelegatedFrameHost* GetDelegatedFrameHost() const = 0; 66 virtual DelegatedFrameHost* GetDelegatedFrameHost() const = 0;
65 virtual bool ShouldCreateResizeLock(); 67 virtual bool ShouldCreateResizeLock();
66 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); 68 virtual void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
69
70 virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) = 0;
67 }; 71 };
68 72
69 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state 73 // The DelegatedFrameHost is used to host all of the RenderWidgetHostView state
70 // and functionality that is associated with delegated frames being sent from 74 // and functionality that is associated with delegated frames being sent from
71 // the RenderWidget. The DelegatedFrameHost will push these changes through to 75 // the RenderWidget. The DelegatedFrameHost will push these changes through to
72 // the ui::Compositor associated with its DelegatedFrameHostClient. 76 // the ui::Compositor associated with its DelegatedFrameHostClient.
73 class CONTENT_EXPORT DelegatedFrameHost 77 class CONTENT_EXPORT DelegatedFrameHost
74 : public ui::CompositorObserver, 78 : public ui::CompositorObserver,
79 public ui::CompositorBeginFrameObserver,
75 public ui::CompositorVSyncManager::Observer, 80 public ui::CompositorVSyncManager::Observer,
76 public ui::LayerOwnerDelegate, 81 public ui::LayerOwnerDelegate,
77 public ImageTransportFactoryObserver, 82 public ImageTransportFactoryObserver,
78 public DelegatedFrameEvictorClient, 83 public DelegatedFrameEvictorClient,
79 public cc::DelegatedFrameResourceCollectionClient, 84 public cc::DelegatedFrameResourceCollectionClient,
80 public cc::SurfaceFactoryClient, 85 public cc::SurfaceFactoryClient,
81 public base::SupportsWeakPtr<DelegatedFrameHost> { 86 public base::SupportsWeakPtr<DelegatedFrameHost> {
82 public: 87 public:
83 DelegatedFrameHost(DelegatedFrameHostClient* client); 88 DelegatedFrameHost(DelegatedFrameHostClient* client);
84 ~DelegatedFrameHost() override; 89 ~DelegatedFrameHost() override;
(...skipping 20 matching lines...) Expand all
105 void CopyFromCompositingSurfaceToVideoFrame( 110 void CopyFromCompositingSurfaceToVideoFrame(
106 const gfx::Rect& src_subrect, 111 const gfx::Rect& src_subrect,
107 const scoped_refptr<media::VideoFrame>& target, 112 const scoped_refptr<media::VideoFrame>& target,
108 const base::Callback<void(bool)>& callback); 113 const base::Callback<void(bool)>& callback);
109 bool CanCopyToVideoFrame() const; 114 bool CanCopyToVideoFrame() const;
110 bool CanSubscribeFrame() const; 115 bool CanSubscribeFrame() const;
111 void BeginFrameSubscription( 116 void BeginFrameSubscription(
112 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber); 117 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber);
113 void EndFrameSubscription(); 118 void EndFrameSubscription();
114 bool HasFrameSubscriber() const { return frame_subscriber_; } 119 bool HasFrameSubscriber() const { return frame_subscriber_; }
120 void OnSetNeedsBeginFrames(bool needs_begin_frames);
115 121
116 // Exposed for tests. 122 // Exposed for tests.
117 cc::DelegatedFrameProvider* FrameProviderForTesting() const { 123 cc::DelegatedFrameProvider* FrameProviderForTesting() const {
118 return frame_provider_.get(); 124 return frame_provider_.get();
119 } 125 }
120 cc::SurfaceId SurfaceIdForTesting() const { return surface_id_; } 126 cc::SurfaceId SurfaceIdForTesting() const { return surface_id_; }
121 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) { 127 void OnCompositingDidCommitForTesting(ui::Compositor* compositor) {
122 OnCompositingDidCommit(compositor); 128 OnCompositingDidCommit(compositor);
123 } 129 }
124 bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); } 130 bool ShouldCreateResizeLockForTesting() { return ShouldCreateResizeLock(); }
(...skipping 12 matching lines...) Expand all
137 143
138 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const { 144 RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
139 return frame_subscriber_.get(); 145 return frame_subscriber_.get();
140 } 146 }
141 bool ShouldCreateResizeLock(); 147 bool ShouldCreateResizeLock();
142 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); 148 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
143 149
144 void LockResources(); 150 void LockResources();
145 void UnlockResources(); 151 void UnlockResources();
146 152
153 void StartObservingBeginFrames();
154 void StopObservingBeginFrames();
155
156 void SetVSyncParams(base::TimeTicks timebase, base::TimeDelta interval);
157
147 // Overridden from ui::CompositorObserver: 158 // Overridden from ui::CompositorObserver:
148 void OnCompositingDidCommit(ui::Compositor* compositor) override; 159 void OnCompositingDidCommit(ui::Compositor* compositor) override;
149 void OnCompositingStarted(ui::Compositor* compositor, 160 void OnCompositingStarted(ui::Compositor* compositor,
150 base::TimeTicks start_time) override; 161 base::TimeTicks start_time) override;
151 void OnCompositingEnded(ui::Compositor* compositor) override; 162 void OnCompositingEnded(ui::Compositor* compositor) override;
152 void OnCompositingAborted(ui::Compositor* compositor) override; 163 void OnCompositingAborted(ui::Compositor* compositor) override;
153 void OnCompositingLockStateChanged(ui::Compositor* compositor) override; 164 void OnCompositingLockStateChanged(ui::Compositor* compositor) override;
154 165
166 // Overridden from ui::CompositorBeginFrameObserver:
167 void OnSendBeginFrame(const cc::BeginFrameArgs& args) override;
168
155 // Overridden from ui::CompositorVSyncManager::Observer: 169 // Overridden from ui::CompositorVSyncManager::Observer:
156 void OnUpdateVSyncParameters(base::TimeTicks timebase, 170 void OnUpdateVSyncParameters(base::TimeTicks timebase,
157 base::TimeDelta interval) override; 171 base::TimeDelta interval) override;
158 172
159 // Overridden from ui::LayerOwnerObserver: 173 // Overridden from ui::LayerOwnerObserver:
160 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override; 174 void OnLayerRecreated(ui::Layer* old_layer, ui::Layer* new_layer) override;
161 175
162 // Overridden from ImageTransportFactoryObserver: 176 // Overridden from ImageTransportFactoryObserver:
163 void OnLostResources() override; 177 void OnLostResources() override;
164 178
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 314
301 // Subscriber that listens to frame presentation events. 315 // Subscriber that listens to frame presentation events.
302 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; 316 scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
303 std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_; 317 std::vector<scoped_refptr<OwnedMailbox> > idle_frame_subscriber_textures_;
304 318
305 // YUV readback pipeline. 319 // YUV readback pipeline.
306 scoped_ptr<content::ReadbackYUVInterface> 320 scoped_ptr<content::ReadbackYUVInterface>
307 yuv_readback_pipeline_; 321 yuv_readback_pipeline_;
308 322
309 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_; 323 scoped_ptr<DelegatedFrameEvictor> delegated_frame_evictor_;
324
325 // True when unified BeginFrame scheduing is used.
326 bool begin_frame_scheduling_enabled_;
327
328 // True when RenderWidget needs a BeginFrame.
329 bool needs_begin_frames_;
330
331 // Pass |last_sent_begin_frame_args_| to compositor when |this| is added as a
332 // CompositorBeginFrameObserver. With this, Compositor can determine whether
333 // latest BeginFrameArgs can be used immediately or not.
334 cc::BeginFrameArgs last_sent_begin_frame_args_;
310 }; 335 };
311 336
312 } // namespace content 337 } // namespace content
313 338
314 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_ 339 #endif // CONTENT_BROWSER_COMPOSITOR_DELEGATED_FRAME_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698