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

Side by Side Diff: blimp/client/core/compositor/blimp_compositor.h

Issue 2489033002: content/blimp: Remove unused compositing mode switches. (Closed)
Patch Set: test Created 4 years, 1 month 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 | blimp/client/core/compositor/blimp_compositor.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 5 #ifndef BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
6 #define BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 6 #define BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // BlimpCompositor provides the basic framework and setup to host a 71 // BlimpCompositor provides the basic framework and setup to host a
72 // LayerTreeHost. This class owns the remote client cc::LayerTreeHost, which 72 // LayerTreeHost. This class owns the remote client cc::LayerTreeHost, which
73 // performs the compositing work for the remote server LayerTreeHost. The server 73 // performs the compositing work for the remote server LayerTreeHost. The server
74 // LayerTreeHost for a BlimpCompositor is owned by the 74 // LayerTreeHost for a BlimpCompositor is owned by the
75 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a 75 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a
76 // RenderWidget, identified by a custom |render_widget_id| generated on the 76 // RenderWidget, identified by a custom |render_widget_id| generated on the
77 // engine. The lifetime of this compositor is controlled by its corresponding 77 // engine. The lifetime of this compositor is controlled by its corresponding
78 // RenderWidget. 78 // RenderWidget.
79 // This class should only be accessed from the main thread. 79 // This class should only be accessed from the main thread.
80 class BlimpCompositor : public cc::LayerTreeHostClient, 80 class BlimpCompositor : public cc::LayerTreeHostClient,
81 public cc::RemoteProtoChannel,
82 public BlimpCompositorFrameSinkProxy, 81 public BlimpCompositorFrameSinkProxy,
83 public cc::SurfaceFactoryClient, 82 public cc::SurfaceFactoryClient,
84 public cc::CompositorStateDeserializerClient { 83 public cc::CompositorStateDeserializerClient {
85 public: 84 public:
86 static std::unique_ptr<BlimpCompositor> Create( 85 static std::unique_ptr<BlimpCompositor> Create(
87 BlimpCompositorDependencies* compositor_dependencies, 86 BlimpCompositorDependencies* compositor_dependencies,
88 BlimpCompositorClient* client, 87 BlimpCompositorClient* client);
89 bool use_threaded_layer_tree_host);
90 88
91 ~BlimpCompositor() override; 89 ~BlimpCompositor() override;
92 90
93 void SetVisible(bool visible); 91 void SetVisible(bool visible);
94 bool IsVisible() const; 92 bool IsVisible() const;
95 93
96 // Requests a copy of the compositor frame. 94 // Requests a copy of the compositor frame.
97 // Setting |flush_pending_update| to true ensures that if a frame update on 95 // Setting |flush_pending_update| to true ensures that if a frame update on
98 // the main thread is pending, then it is drawn before copying from the 96 // the main thread is pending, then it is drawn before copying from the
99 // surface. 97 // surface.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void DidCommit() override {} 135 void DidCommit() override {}
138 void DidCommitAndDrawFrame() override; 136 void DidCommitAndDrawFrame() override;
139 void DidReceiveCompositorFrameAck() override {} 137 void DidReceiveCompositorFrameAck() override {}
140 void DidCompletePageScaleAnimation() override {} 138 void DidCompletePageScaleAnimation() override {}
141 139
142 // CompositorStateDeserializerClient implementation. 140 // CompositorStateDeserializerClient implementation.
143 void DidUpdateLocalState() override; 141 void DidUpdateLocalState() override;
144 142
145 protected: 143 protected:
146 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies, 144 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies,
147 BlimpCompositorClient* client, 145 BlimpCompositorClient* client);
148 bool use_threaded_layer_tree_host);
149 146
150 void Initialize(); 147 void Initialize();
151 virtual std::unique_ptr<cc::LayerTreeHostInProcess> CreateLayerTreeHost(); 148 virtual std::unique_ptr<cc::LayerTreeHostInProcess> CreateLayerTreeHost();
152 149
153 cc::AnimationHost* animation_host() { return animation_host_.get(); } 150 cc::AnimationHost* animation_host() { return animation_host_.get(); }
154 151
155 private: 152 private:
156 class FrameTrackingSwapPromise; 153 class FrameTrackingSwapPromise;
157 154
158 // RemoteProtoChannel implementation.
159 void SetProtoReceiver(ProtoReceiver* receiver) override;
160 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override;
161
162 // BlimpCompositorFrameSinkProxy implementation. 155 // BlimpCompositorFrameSinkProxy implementation.
163 void BindToProxyClient( 156 void BindToProxyClient(
164 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) override; 157 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) override;
165 void SubmitCompositorFrame(cc::CompositorFrame frame) override; 158 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
166 void UnbindProxyClient() override; 159 void UnbindProxyClient() override;
167 160
168 // SurfaceFactoryClient implementation. 161 // SurfaceFactoryClient implementation.
169 void ReturnResources(const cc::ReturnedResourceArray& resources) override; 162 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
170 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {} 163 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {}
171 164
172 void HandleCompositorMessageToImpl(
173 std::unique_ptr<cc::proto::CompositorMessage> message);
174
175 // Called when the a ContextProvider has been created by the 165 // Called when the a ContextProvider has been created by the
176 // CompositorDependencies class. If |host_| is waiting on an 166 // CompositorDependencies class. If |host_| is waiting on an
177 // CompositorFrameSink this will build one for it. 167 // CompositorFrameSink this will build one for it.
178 void OnContextProvidersCreated( 168 void OnContextProvidersCreated(
179 const scoped_refptr<cc::ContextProvider>& compositor_context_provider, 169 const scoped_refptr<cc::ContextProvider>& compositor_context_provider,
180 const scoped_refptr<cc::ContextProvider>& worker_context_provider); 170 const scoped_refptr<cc::ContextProvider>& worker_context_provider);
181 171
182 // Helper method to get the embedder dependencies. 172 // Helper method to get the embedder dependencies.
183 CompositorDependencies* GetEmbedderDeps(); 173 CompositorDependencies* GetEmbedderDeps();
184 174
185 // TODO(khushalsagar): Move all of this to the |DocumentView| or another 175 // TODO(khushalsagar): Move all of this to the |DocumentView| or another
186 // platform specific class. So we use the DelegatedFrameHostAndroid like the 176 // platform specific class. So we use the DelegatedFrameHostAndroid like the
187 // RenderWidgetHostViewAndroid. 177 // RenderWidgetHostViewAndroid.
188 void DestroyDelegatedContent(); 178 void DestroyDelegatedContent();
189 179
190 // Helper method to destroy the internal CC LayerTreeHost instance and all its 180 // Helper method to destroy the internal CC LayerTreeHost instance and all its
191 // associated state. 181 // associated state.
192 void DestroyLayerTreeHost(); 182 void DestroyLayerTreeHost();
193 183
194 // Acks a submitted CompositorFrame when it has been processed and another 184 // Acks a submitted CompositorFrame when it has been processed and another
195 // frame should be started. 185 // frame should be started.
196 void SubmitCompositorFrameAck(); 186 void SubmitCompositorFrameAck();
197 187
198 // Sends an update to the engine if the state on the client was modified and 188 // Sends an update to the engine if the state on the client was modified and
199 // an ack for a previous update sent is not pending. 189 // an ack for a previous update sent is not pending.
200 void FlushClientState(); 190 void FlushClientState();
201 191
202 // Set to true if we are using a LayerTreeHostInProcess to process frame
203 // updates from the engine.
204 const bool use_threaded_layer_tree_host_;
205
206 void MakeCopyRequestOnNextSwap( 192 void MakeCopyRequestOnNextSwap(
207 std::unique_ptr<cc::CopyOutputRequest> copy_request); 193 std::unique_ptr<cc::CopyOutputRequest> copy_request);
208 194
209 void RequestCopyOfOutputDeprecated(
210 std::unique_ptr<cc::CopyOutputRequest> copy_request);
211
212 BlimpCompositorClient* client_; 195 BlimpCompositorClient* client_;
213 196
214 BlimpCompositorDependencies* compositor_dependencies_; 197 BlimpCompositorDependencies* compositor_dependencies_;
215 198
216 cc::FrameSinkId frame_sink_id_; 199 cc::FrameSinkId frame_sink_id_;
217 200
218 std::unique_ptr<cc::AnimationHost> animation_host_; 201 std::unique_ptr<cc::AnimationHost> animation_host_;
219 std::unique_ptr<cc::LayerTreeHostInProcess> host_; 202 std::unique_ptr<cc::LayerTreeHostInProcess> host_;
220 203
221 std::unique_ptr<cc::SurfaceFactory> surface_factory_; 204 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
222 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client_; 205 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client_;
223 bool bound_to_proxy_; 206 bool bound_to_proxy_;
224 207
225 // Whether or not |host_| has asked for a new CompositorFrameSink. 208 // Whether or not |host_| has asked for a new CompositorFrameSink.
226 bool compositor_frame_sink_request_pending_; 209 bool compositor_frame_sink_request_pending_;
227 210
228 // Data for the current frame. 211 // Data for the current frame.
229 cc::LocalFrameId local_frame_id_; 212 cc::LocalFrameId local_frame_id_;
230 gfx::Size current_surface_size_; 213 gfx::Size current_surface_size_;
231 214
232 base::ThreadChecker thread_checker_; 215 base::ThreadChecker thread_checker_;
233 216
234 // Surfaces related stuff and layer which holds the delegated content from the 217 // Surfaces related stuff and layer which holds the delegated content from the
235 // compositor. 218 // compositor.
236 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 219 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
237 scoped_refptr<cc::Layer> layer_; 220 scoped_refptr<cc::Layer> layer_;
238 221
239 // To be notified of any incoming compositor protos that are specifically sent
240 // to |render_widget_id_|.
241 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_;
242
243 std::vector<std::unique_ptr<cc::CopyOutputRequest>> 222 std::vector<std::unique_ptr<cc::CopyOutputRequest>>
244 copy_requests_for_next_swap_; 223 copy_requests_for_next_swap_;
245 224
246 // The number of times a START_COMMIT proto has been received but a call to
247 // DidCommitAndDrawFrame hasn't been seen. This should track the number of
248 // outstanding commits.
249 size_t outstanding_commits_;
250
251 // When RequestCopyOfOutput is called with a request to flush any pending
252 // updates, |outstanding_commits_| is copied along with the |copy_request|
253 // into this vector. Each time DidCommitAndDrawFrame is called these entries
254 // get decremented. If they hit 0 the copy request is queued for the current
255 // |local_frame_id_|.
256 std::vector<std::pair<size_t, std::unique_ptr<cc::CopyOutputRequest>>>
257 pending_commit_trackers_;
258
259 // Stores a frame update received from the engine, when a threaded 225 // Stores a frame update received from the engine, when a threaded
260 // LayerTreeHost is used. There can only be a single frame in flight at any 226 // LayerTreeHost is used. There can only be a single frame in flight at any
261 // point. 227 // point.
262 std::unique_ptr<cc::proto::CompositorMessage> pending_frame_update_; 228 std::unique_ptr<cc::proto::CompositorMessage> pending_frame_update_;
263 229
264 // Used with a threaded LayerTreeHost to deserialize proto updates from the 230 // Used with a threaded LayerTreeHost to deserialize proto updates from the
265 // engine into the LayerTree. 231 // engine into the LayerTree.
266 std::unique_ptr<cc::CompositorStateDeserializer> 232 std::unique_ptr<cc::CompositorStateDeserializer>
267 compositor_state_deserializer_; 233 compositor_state_deserializer_;
268 234
269 // Set to true if the compositor state on the client was modified on the impl 235 // Set to true if the compositor state on the client was modified on the impl
270 // thread and an update needs to be sent to the engine. 236 // thread and an update needs to be sent to the engine.
271 bool client_state_dirty_ = false; 237 bool client_state_dirty_ = false;
272 238
273 // Set to true if a client state update was sent to the engine and an ack for 239 // Set to true if a client state update was sent to the engine and an ack for
274 // this update from the engine is pending. 240 // this update from the engine is pending.
275 bool client_state_update_ack_pending_ = false; 241 bool client_state_update_ack_pending_ = false;
276 242
277 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; 243 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_;
278 244
279 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); 245 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor);
280 }; 246 };
281 247
282 } // namespace client 248 } // namespace client
283 } // namespace blimp 249 } // namespace blimp
284 250
285 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 251 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « no previous file | blimp/client/core/compositor/blimp_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698