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

Side by Side Diff: cc/trees/layer_tree_host_in_process.cc

Issue 2340143002: cc: Rename LayerTreeHost to LayerTreeHostInProcess. (Closed)
Patch Set: tests + comment updates Created 4 years, 3 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host_in_process.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <memory> 11 #include <memory>
12 #include <stack> 12 #include <stack>
13 #include <string> 13 #include <string>
14 #include <unordered_map> 14 #include <unordered_map>
15 15
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 picture_layer_properties_size.ValueOrDefault(-1)); 117 picture_layer_properties_size.ValueOrDefault(-1));
118 value->SetInteger("DisplayItemListSize", 118 value->SetInteger("DisplayItemListSize",
119 display_item_list_size.ValueOrDefault(-1)); 119 display_item_list_size.ValueOrDefault(-1));
120 value->SetInteger("DrawingDisplayItemsSize", 120 value->SetInteger("DrawingDisplayItemsSize",
121 drawing_display_items_size.ValueOrDefault(-1)); 121 drawing_display_items_size.ValueOrDefault(-1));
122 return value; 122 return value;
123 } 123 }
124 124
125 } // namespace 125 } // namespace
126 126
127 LayerTreeHost::InitParams::InitParams() { 127 LayerTreeHostInProcess::InitParams::InitParams() {}
128 }
129 128
130 LayerTreeHost::InitParams::~InitParams() { 129 LayerTreeHostInProcess::InitParams::~InitParams() {}
131 }
132 130
133 std::unique_ptr<LayerTreeHostInterface> LayerTreeHost::CreateThreaded( 131 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded(
134 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 132 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
135 InitParams* params) { 133 InitParams* params) {
136 DCHECK(params->main_task_runner.get()); 134 DCHECK(params->main_task_runner.get());
137 DCHECK(impl_task_runner.get()); 135 DCHECK(impl_task_runner.get());
138 DCHECK(params->settings); 136 DCHECK(params->settings);
139 std::unique_ptr<LayerTreeHost> layer_tree_host( 137 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host(
140 new LayerTreeHost(params, CompositorMode::THREADED)); 138 new LayerTreeHostInProcess(params, CompositorMode::THREADED));
141 layer_tree_host->InitializeThreaded( 139 layer_tree_host->InitializeThreaded(
142 params->main_task_runner, impl_task_runner, 140 params->main_task_runner, impl_task_runner,
143 std::move(params->external_begin_frame_source)); 141 std::move(params->external_begin_frame_source));
144 return std::move(layer_tree_host); 142 return layer_tree_host;
145 } 143 }
146 144
147 std::unique_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( 145 std::unique_ptr<LayerTreeHostInProcess>
146 LayerTreeHostInProcess::CreateSingleThreaded(
148 LayerTreeHostSingleThreadClient* single_thread_client, 147 LayerTreeHostSingleThreadClient* single_thread_client,
149 InitParams* params) { 148 InitParams* params) {
150 DCHECK(params->settings); 149 DCHECK(params->settings);
151 std::unique_ptr<LayerTreeHost> layer_tree_host( 150 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host(
152 new LayerTreeHost(params, CompositorMode::SINGLE_THREADED)); 151 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED));
153 layer_tree_host->InitializeSingleThreaded( 152 layer_tree_host->InitializeSingleThreaded(
154 single_thread_client, params->main_task_runner, 153 single_thread_client, params->main_task_runner,
155 std::move(params->external_begin_frame_source)); 154 std::move(params->external_begin_frame_source));
156 return layer_tree_host; 155 return layer_tree_host;
157 } 156 }
158 157
159 std::unique_ptr<LayerTreeHostInterface> LayerTreeHost::CreateRemoteServer( 158 std::unique_ptr<LayerTreeHostInProcess>
159 LayerTreeHostInProcess::CreateRemoteServer(
160 RemoteProtoChannel* remote_proto_channel, 160 RemoteProtoChannel* remote_proto_channel,
161 InitParams* params) { 161 InitParams* params) {
162 DCHECK(params->main_task_runner.get()); 162 DCHECK(params->main_task_runner.get());
163 DCHECK(params->settings); 163 DCHECK(params->settings);
164 DCHECK(remote_proto_channel); 164 DCHECK(remote_proto_channel);
165 TRACE_EVENT0("cc.remote", "LayerTreeHost::CreateRemoteServer"); 165 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::CreateRemoteServer");
166 166
167 // Using an external begin frame source is not supported on the server in 167 // Using an external begin frame source is not supported on the server in
168 // remote mode. 168 // remote mode.
169 DCHECK(!params->settings->use_external_begin_frame_source); 169 DCHECK(!params->settings->use_external_begin_frame_source);
170 DCHECK(!params->external_begin_frame_source); 170 DCHECK(!params->external_begin_frame_source);
171 DCHECK(params->image_serialization_processor); 171 DCHECK(params->image_serialization_processor);
172 172
173 std::unique_ptr<LayerTreeHost> layer_tree_host( 173 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host(
174 new LayerTreeHost(params, CompositorMode::REMOTE)); 174 new LayerTreeHostInProcess(params, CompositorMode::REMOTE));
175 layer_tree_host->InitializeRemoteServer(remote_proto_channel, 175 layer_tree_host->InitializeRemoteServer(remote_proto_channel,
176 params->main_task_runner); 176 params->main_task_runner);
177 return std::move(layer_tree_host); 177 return layer_tree_host;
178 } 178 }
179 179
180 std::unique_ptr<LayerTreeHostInterface> LayerTreeHost::CreateRemoteClient( 180 std::unique_ptr<LayerTreeHostInProcess>
181 LayerTreeHostInProcess::CreateRemoteClient(
181 RemoteProtoChannel* remote_proto_channel, 182 RemoteProtoChannel* remote_proto_channel,
182 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 183 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
183 InitParams* params) { 184 InitParams* params) {
184 DCHECK(params->main_task_runner.get()); 185 DCHECK(params->main_task_runner.get());
185 DCHECK(params->settings); 186 DCHECK(params->settings);
186 DCHECK(remote_proto_channel); 187 DCHECK(remote_proto_channel);
187 188
188 // Using an external begin frame source is not supported in remote mode. 189 // Using an external begin frame source is not supported in remote mode.
189 // TODO(khushalsagar): Add support for providing an external begin frame 190 // TODO(khushalsagar): Add support for providing an external begin frame
190 // source on the client LayerTreeHost. crbug/576962 191 // source on the client LayerTreeHostInProcess. crbug/576962
191 DCHECK(!params->settings->use_external_begin_frame_source); 192 DCHECK(!params->settings->use_external_begin_frame_source);
192 DCHECK(!params->external_begin_frame_source); 193 DCHECK(!params->external_begin_frame_source);
193 DCHECK(params->image_serialization_processor); 194 DCHECK(params->image_serialization_processor);
194 195
195 std::unique_ptr<LayerTreeHost> layer_tree_host( 196 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host(
196 new LayerTreeHost(params, CompositorMode::REMOTE)); 197 new LayerTreeHostInProcess(params, CompositorMode::REMOTE));
197 layer_tree_host->InitializeRemoteClient( 198 layer_tree_host->InitializeRemoteClient(
198 remote_proto_channel, params->main_task_runner, impl_task_runner); 199 remote_proto_channel, params->main_task_runner, impl_task_runner);
199 return std::move(layer_tree_host); 200 return layer_tree_host;
200 } 201 }
201 202
202 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) 203 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params,
203 : LayerTreeHost( 204 CompositorMode mode)
205 : LayerTreeHostInProcess(
204 params, 206 params,
205 mode, 207 mode,
206 base::MakeUnique<LayerTree>(std::move(params->animation_host), 208 base::MakeUnique<LayerTree>(std::move(params->animation_host),
207 this)) {} 209 this)) {}
208 210
209 LayerTreeHost::LayerTreeHost(InitParams* params, 211 LayerTreeHostInProcess::LayerTreeHostInProcess(
210 CompositorMode mode, 212 InitParams* params,
211 std::unique_ptr<LayerTree> layer_tree) 213 CompositorMode mode,
214 std::unique_ptr<LayerTree> layer_tree)
212 : micro_benchmark_controller_(this), 215 : micro_benchmark_controller_(this),
213 layer_tree_(std::move(layer_tree)), 216 layer_tree_(std::move(layer_tree)),
214 compositor_mode_(mode), 217 compositor_mode_(mode),
215 ui_resource_manager_(base::MakeUnique<UIResourceManager>()), 218 ui_resource_manager_(base::MakeUnique<UIResourceManager>()),
216 client_(params->client), 219 client_(params->client),
217 source_frame_number_(0), 220 source_frame_number_(0),
218 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), 221 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
219 settings_(*params->settings), 222 settings_(*params->settings),
220 debug_state_(settings_.initial_debug_state), 223 debug_state_(settings_.initial_debug_state),
221 visible_(false), 224 visible_(false),
222 has_gpu_rasterization_trigger_(false), 225 has_gpu_rasterization_trigger_(false),
223 content_is_suitable_for_gpu_rasterization_(true), 226 content_is_suitable_for_gpu_rasterization_(true),
224 gpu_rasterization_histogram_recorded_(false), 227 gpu_rasterization_histogram_recorded_(false),
225 did_complete_scale_animation_(false), 228 did_complete_scale_animation_(false),
226 id_(s_layer_tree_host_sequence_number.GetNext() + 1), 229 id_(s_layer_tree_host_sequence_number.GetNext() + 1),
227 next_commit_forces_redraw_(false), 230 next_commit_forces_redraw_(false),
228 shared_bitmap_manager_(params->shared_bitmap_manager), 231 shared_bitmap_manager_(params->shared_bitmap_manager),
229 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), 232 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager),
230 task_graph_runner_(params->task_graph_runner), 233 task_graph_runner_(params->task_graph_runner),
231 image_serialization_processor_(params->image_serialization_processor) { 234 image_serialization_processor_(params->image_serialization_processor) {
232 DCHECK(task_graph_runner_); 235 DCHECK(task_graph_runner_);
233 DCHECK(layer_tree_); 236 DCHECK(layer_tree_);
234 237
235 rendering_stats_instrumentation_->set_record_rendering_stats( 238 rendering_stats_instrumentation_->set_record_rendering_stats(
236 debug_state_.RecordRenderingStats()); 239 debug_state_.RecordRenderingStats());
237 } 240 }
238 241
239 void LayerTreeHost::InitializeThreaded( 242 void LayerTreeHostInProcess::InitializeThreaded(
240 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 243 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
241 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 244 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
242 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { 245 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
243 task_runner_provider_ = 246 task_runner_provider_ =
244 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); 247 TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
245 std::unique_ptr<ProxyMain> proxy_main = 248 std::unique_ptr<ProxyMain> proxy_main =
246 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); 249 ProxyMain::CreateThreaded(this, task_runner_provider_.get());
247 InitializeProxy(std::move(proxy_main), 250 InitializeProxy(std::move(proxy_main),
248 std::move(external_begin_frame_source)); 251 std::move(external_begin_frame_source));
249 } 252 }
250 253
251 void LayerTreeHost::InitializeSingleThreaded( 254 void LayerTreeHostInProcess::InitializeSingleThreaded(
252 LayerTreeHostSingleThreadClient* single_thread_client, 255 LayerTreeHostSingleThreadClient* single_thread_client,
253 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 256 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
254 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { 257 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
255 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); 258 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr);
256 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, 259 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client,
257 task_runner_provider_.get()), 260 task_runner_provider_.get()),
258 std::move(external_begin_frame_source)); 261 std::move(external_begin_frame_source));
259 } 262 }
260 263
261 void LayerTreeHost::InitializeRemoteServer( 264 void LayerTreeHostInProcess::InitializeRemoteServer(
262 RemoteProtoChannel* remote_proto_channel, 265 RemoteProtoChannel* remote_proto_channel,
263 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { 266 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) {
264 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); 267 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr);
265 268
266 if (image_serialization_processor_) { 269 if (image_serialization_processor_) {
267 engine_picture_cache_ = 270 engine_picture_cache_ =
268 image_serialization_processor_->CreateEnginePictureCache(); 271 image_serialization_processor_->CreateEnginePictureCache();
272 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get());
269 } 273 }
270 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, 274 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this,
271 task_runner_provider_.get()), 275 task_runner_provider_.get()),
272 nullptr); 276 nullptr);
273 } 277 }
274 278
275 void LayerTreeHost::InitializeRemoteClient( 279 void LayerTreeHostInProcess::InitializeRemoteClient(
276 RemoteProtoChannel* remote_proto_channel, 280 RemoteProtoChannel* remote_proto_channel,
277 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 281 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
278 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 282 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
279 task_runner_provider_ = 283 task_runner_provider_ =
280 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); 284 TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
281 285
282 if (image_serialization_processor_) { 286 if (image_serialization_processor_) {
283 client_picture_cache_ = 287 client_picture_cache_ =
284 image_serialization_processor_->CreateClientPictureCache(); 288 image_serialization_processor_->CreateClientPictureCache();
289 layer_tree_->set_client_picture_cache(client_picture_cache_.get());
285 } 290 }
286 291
287 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is 292 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is
288 // owned by the LayerTreeHost. The RemoteChannelImpl pipes requests which need 293 // owned by the LayerTreeHostInProcess. The RemoteChannelImpl pipes requests
289 // to handled locally, for instance the Output Surface creation to the 294 // which need to handled locally, for instance the Output Surface creation to
290 // LayerTreeHost on the client, while the other requests are sent to the 295 // the LayerTreeHostInProcess on the client, while the other requests are sent
291 // RemoteChannelMain on the server which directs them to ProxyMain and the 296 // to the RemoteChannelMain on the server which directs them to ProxyMain and
292 // remote server LayerTreeHost. 297 // the remote server LayerTreeHostInProcess.
293 InitializeProxy(base::MakeUnique<RemoteChannelImpl>( 298 InitializeProxy(base::MakeUnique<RemoteChannelImpl>(
294 this, remote_proto_channel, task_runner_provider_.get()), 299 this, remote_proto_channel, task_runner_provider_.get()),
295 nullptr); 300 nullptr);
296 } 301 }
297 302
298 void LayerTreeHost::InitializeForTesting( 303 void LayerTreeHostInProcess::InitializeForTesting(
299 std::unique_ptr<TaskRunnerProvider> task_runner_provider, 304 std::unique_ptr<TaskRunnerProvider> task_runner_provider,
300 std::unique_ptr<Proxy> proxy_for_testing, 305 std::unique_ptr<Proxy> proxy_for_testing,
301 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { 306 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
302 task_runner_provider_ = std::move(task_runner_provider); 307 task_runner_provider_ = std::move(task_runner_provider);
303 308
304 InitializePictureCacheForTesting(); 309 InitializePictureCacheForTesting();
305 310
306 InitializeProxy(std::move(proxy_for_testing), 311 InitializeProxy(std::move(proxy_for_testing),
307 std::move(external_begin_frame_source)); 312 std::move(external_begin_frame_source));
308 } 313 }
309 314
310 void LayerTreeHost::InitializePictureCacheForTesting() { 315 void LayerTreeHostInProcess::InitializePictureCacheForTesting() {
311 if (!image_serialization_processor_) 316 if (!image_serialization_processor_)
312 return; 317 return;
313 318
314 // Initialize both engine and client cache to ensure serialization tests 319 // Initialize both engine and client cache to ensure serialization tests
315 // with a single LayerTreeHost can work correctly. 320 // with a single LayerTreeHostInProcess can work correctly.
316 engine_picture_cache_ = 321 engine_picture_cache_ =
317 image_serialization_processor_->CreateEnginePictureCache(); 322 image_serialization_processor_->CreateEnginePictureCache();
323 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get());
318 client_picture_cache_ = 324 client_picture_cache_ =
319 image_serialization_processor_->CreateClientPictureCache(); 325 image_serialization_processor_->CreateClientPictureCache();
326 layer_tree_->set_client_picture_cache(client_picture_cache_.get());
320 } 327 }
321 328
322 void LayerTreeHost::SetTaskRunnerProviderForTesting( 329 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting(
323 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { 330 std::unique_ptr<TaskRunnerProvider> task_runner_provider) {
324 DCHECK(!task_runner_provider_); 331 DCHECK(!task_runner_provider_);
325 task_runner_provider_ = std::move(task_runner_provider); 332 task_runner_provider_ = std::move(task_runner_provider);
326 } 333 }
327 334
328 void LayerTreeHost::SetUIResourceManagerForTesting( 335 void LayerTreeHostInProcess::SetUIResourceManagerForTesting(
329 std::unique_ptr<UIResourceManager> ui_resource_manager) { 336 std::unique_ptr<UIResourceManager> ui_resource_manager) {
330 ui_resource_manager_ = std::move(ui_resource_manager); 337 ui_resource_manager_ = std::move(ui_resource_manager);
331 } 338 }
332 339
333 void LayerTreeHost::InitializeProxy( 340 void LayerTreeHostInProcess::InitializeProxy(
334 std::unique_ptr<Proxy> proxy, 341 std::unique_ptr<Proxy> proxy,
335 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { 342 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
336 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); 343 TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal");
337 DCHECK(task_runner_provider_); 344 DCHECK(task_runner_provider_);
338 345
339 proxy_ = std::move(proxy); 346 proxy_ = std::move(proxy);
340 proxy_->Start(std::move(external_begin_frame_source)); 347 proxy_->Start(std::move(external_begin_frame_source));
341 348
342 layer_tree_->animation_host()->SetSupportsScrollAnimations( 349 layer_tree_->animation_host()->SetSupportsScrollAnimations(
343 proxy_->SupportsImplScrolling()); 350 proxy_->SupportsImplScrolling());
344 } 351 }
345 352
346 LayerTreeHost::~LayerTreeHost() { 353 LayerTreeHostInProcess::~LayerTreeHostInProcess() {
347 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); 354 TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess");
348 355
349 // Clear any references into the LayerTreeHost. 356 // Clear any references into the LayerTreeHostInProcess.
350 layer_tree_.reset(); 357 layer_tree_.reset();
351 358
352 if (proxy_) { 359 if (proxy_) {
353 DCHECK(task_runner_provider_->IsMainThread()); 360 DCHECK(task_runner_provider_->IsMainThread());
354 proxy_->Stop(); 361 proxy_->Stop();
355 362
356 // Proxy must be destroyed before the Task Runner Provider. 363 // Proxy must be destroyed before the Task Runner Provider.
357 proxy_ = nullptr; 364 proxy_ = nullptr;
358 } 365 }
359 } 366 }
360 367
361 int LayerTreeHost::GetId() const { 368 int LayerTreeHostInProcess::GetId() const {
362 return id_; 369 return id_;
363 } 370 }
364 371
365 int LayerTreeHost::SourceFrameNumber() const { 372 int LayerTreeHostInProcess::SourceFrameNumber() const {
366 return source_frame_number_; 373 return source_frame_number_;
367 } 374 }
368 375
369 LayerTree* LayerTreeHost::GetLayerTree() { 376 LayerTree* LayerTreeHostInProcess::GetLayerTree() {
370 return layer_tree_.get(); 377 return layer_tree_.get();
371 } 378 }
372 379
373 const LayerTree* LayerTreeHost::GetLayerTree() const { 380 const LayerTree* LayerTreeHostInProcess::GetLayerTree() const {
374 return layer_tree_.get(); 381 return layer_tree_.get();
375 } 382 }
376 383
377 UIResourceManager* LayerTreeHost::GetUIResourceManager() const { 384 UIResourceManager* LayerTreeHostInProcess::GetUIResourceManager() const {
378 return ui_resource_manager_.get(); 385 return ui_resource_manager_.get();
379 } 386 }
380 387
381 TaskRunnerProvider* LayerTreeHost::GetTaskRunnerProvider() const { 388 TaskRunnerProvider* LayerTreeHostInProcess::GetTaskRunnerProvider() const {
382 return task_runner_provider_.get(); 389 return task_runner_provider_.get();
383 } 390 }
384 391
385 SwapPromiseManager* LayerTreeHost::GetSwapPromiseManager() { 392 SwapPromiseManager* LayerTreeHostInProcess::GetSwapPromiseManager() {
386 return &swap_promise_manager_; 393 return &swap_promise_manager_;
387 } 394 }
388 395
389 const LayerTreeSettings& LayerTreeHost::GetSettings() const { 396 const LayerTreeSettings& LayerTreeHostInProcess::GetSettings() const {
390 return settings_; 397 return settings_;
391 } 398 }
392 399
393 void LayerTreeHost::SetSurfaceClientId(uint32_t client_id) { 400 void LayerTreeHostInProcess::SetSurfaceClientId(uint32_t client_id) {
394 surface_sequence_generator_.set_surface_client_id(client_id); 401 surface_sequence_generator_.set_surface_client_id(client_id);
395 } 402 }
396 403
397 void LayerTreeHost::QueueSwapPromise( 404 void LayerTreeHostInProcess::QueueSwapPromise(
398 std::unique_ptr<SwapPromise> swap_promise) { 405 std::unique_ptr<SwapPromise> swap_promise) {
399 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); 406 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise));
400 } 407 }
401 408
402 SurfaceSequenceGenerator* LayerTreeHost::GetSurfaceSequenceGenerator() { 409 SurfaceSequenceGenerator*
410 LayerTreeHostInProcess::GetSurfaceSequenceGenerator() {
403 return &surface_sequence_generator_; 411 return &surface_sequence_generator_;
404 } 412 }
405 413
406 void LayerTreeHost::WillBeginMainFrame() { 414 void LayerTreeHostInProcess::WillBeginMainFrame() {
407 devtools_instrumentation::WillBeginMainThreadFrame(GetId(), 415 devtools_instrumentation::WillBeginMainThreadFrame(GetId(),
408 SourceFrameNumber()); 416 SourceFrameNumber());
409 client_->WillBeginMainFrame(); 417 client_->WillBeginMainFrame();
410 } 418 }
411 419
412 void LayerTreeHost::DidBeginMainFrame() { 420 void LayerTreeHostInProcess::DidBeginMainFrame() {
413 client_->DidBeginMainFrame(); 421 client_->DidBeginMainFrame();
414 } 422 }
415 423
416 void LayerTreeHost::BeginMainFrameNotExpectedSoon() { 424 void LayerTreeHostInProcess::BeginMainFrameNotExpectedSoon() {
417 client_->BeginMainFrameNotExpectedSoon(); 425 client_->BeginMainFrameNotExpectedSoon();
418 } 426 }
419 427
420 void LayerTreeHost::BeginMainFrame(const BeginFrameArgs& args) { 428 void LayerTreeHostInProcess::BeginMainFrame(const BeginFrameArgs& args) {
421 client_->BeginMainFrame(args); 429 client_->BeginMainFrame(args);
422 } 430 }
423 431
424 void LayerTreeHost::DidStopFlinging() { 432 void LayerTreeHostInProcess::DidStopFlinging() {
425 proxy_->MainThreadHasStoppedFlinging(); 433 proxy_->MainThreadHasStoppedFlinging();
426 } 434 }
427 435
428 const LayerTreeDebugState& LayerTreeHost::GetDebugState() const { 436 const LayerTreeDebugState& LayerTreeHostInProcess::GetDebugState() const {
429 return debug_state_; 437 return debug_state_;
430 } 438 }
431 439
432 void LayerTreeHost::RequestMainFrameUpdate() { 440 void LayerTreeHostInProcess::RequestMainFrameUpdate() {
433 client_->UpdateLayerTreeHost(); 441 client_->UpdateLayerTreeHost();
434 } 442 }
435 443
436 // This function commits the LayerTreeHost to an impl tree. When modifying 444 // This function commits the LayerTreeHost to an impl tree. When modifying
437 // this function, keep in mind that the function *runs* on the impl thread! Any 445 // this function, keep in mind that the function *runs* on the impl thread! Any
438 // code that is logically a main thread operation, e.g. deletion of a Layer, 446 // code that is logically a main thread operation, e.g. deletion of a Layer,
439 // should be delayed until the LayerTreeHost::CommitComplete, which will run 447 // should be delayed until the LayerTreeHost::CommitComplete, which will run
440 // after the commit, but on the main thread. 448 // after the commit, but on the main thread.
441 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { 449 void LayerTreeHostInProcess::FinishCommitOnImplThread(
450 LayerTreeHostImpl* host_impl) {
442 DCHECK(!IsRemoteServer()); 451 DCHECK(!IsRemoteServer());
443 DCHECK(task_runner_provider_->IsImplThread()); 452 DCHECK(task_runner_provider_->IsImplThread());
444 453
445 bool is_new_trace; 454 bool is_new_trace;
446 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); 455 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
447 if (is_new_trace && 456 if (is_new_trace &&
448 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && 457 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() &&
449 layer_tree_->root_layer()) { 458 layer_tree_->root_layer()) {
450 LayerTreeHostCommon::CallFunctionForEveryLayer( 459 LayerTreeHostCommon::CallFunctionForEveryLayer(
451 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); 460 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); });
(...skipping 25 matching lines...) Expand all
477 // happens before GPU rasterization properties are set, since those trigger an 486 // happens before GPU rasterization properties are set, since those trigger an
478 // update of GPU rasterization status, which depends on the device scale 487 // update of GPU rasterization status, which depends on the device scale
479 // factor. (crbug.com/535700) 488 // factor. (crbug.com/535700)
480 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor()); 489 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor());
481 host_impl->SetDebugState(debug_state_); 490 host_impl->SetDebugState(debug_state_);
482 491
483 sync_tree->set_ui_resource_request_queue( 492 sync_tree->set_ui_resource_request_queue(
484 ui_resource_manager_->TakeUIResourcesRequests()); 493 ui_resource_manager_->TakeUIResourcesRequests());
485 494
486 { 495 {
487 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); 496 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties");
488 497
489 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); 498 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree);
490 499
491 // This must happen after synchronizing property trees and after push 500 // This must happen after synchronizing property trees and after push
492 // properties, which updates property tree indices, but before animation 501 // properties, which updates property tree indices, but before animation
493 // host pushes properties as animation host push properties can change 502 // host pushes properties as animation host push properties can change
494 // Animation::InEffect and we want the old InEffect value for updating 503 // Animation::InEffect and we want the old InEffect value for updating
495 // property tree scrolling and animation. 504 // property tree scrolling and animation.
496 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); 505 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread();
497 506
498 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); 507 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties");
499 DCHECK(host_impl->animation_host()); 508 DCHECK(host_impl->animation_host());
500 layer_tree_->animation_host()->PushPropertiesTo( 509 layer_tree_->animation_host()->PushPropertiesTo(
501 host_impl->animation_host()); 510 host_impl->animation_host());
502 } 511 }
503 512
504 // This must happen after synchronizing property trees and after pushing 513 // This must happen after synchronizing property trees and after pushing
505 // properties, which updates the clobber_active_value flag. 514 // properties, which updates the clobber_active_value flag.
506 sync_tree->UpdatePropertyTreeScrollOffset(layer_tree_->property_trees()); 515 sync_tree->UpdatePropertyTreeScrollOffset(layer_tree_->property_trees());
507 516
508 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); 517 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
509 layer_tree_->property_trees()->ResetAllChangeTracking(); 518 layer_tree_->property_trees()->ResetAllChangeTracking();
510 } 519 }
511 520
512 void LayerTreeHost::WillCommit() { 521 void LayerTreeHostInProcess::WillCommit() {
513 swap_promise_manager_.WillCommit(); 522 swap_promise_manager_.WillCommit();
514 client_->WillCommit(); 523 client_->WillCommit();
515 } 524 }
516 525
517 void LayerTreeHost::UpdateHudLayer() { 526 void LayerTreeHostInProcess::UpdateHudLayer() {}
518 }
519 527
520 void LayerTreeHost::CommitComplete() { 528 void LayerTreeHostInProcess::CommitComplete() {
521 source_frame_number_++; 529 source_frame_number_++;
522 client_->DidCommit(); 530 client_->DidCommit();
523 if (did_complete_scale_animation_) { 531 if (did_complete_scale_animation_) {
524 client_->DidCompletePageScaleAnimation(); 532 client_->DidCompletePageScaleAnimation();
525 did_complete_scale_animation_ = false; 533 did_complete_scale_animation_ = false;
526 } 534 }
527 } 535 }
528 536
529 void LayerTreeHost::SetOutputSurface(std::unique_ptr<OutputSurface> surface) { 537 void LayerTreeHostInProcess::SetOutputSurface(
530 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); 538 std::unique_ptr<OutputSurface> surface) {
539 TRACE_EVENT0("cc", "LayerTreeHostInProcess::SetOutputSurface");
531 DCHECK(surface); 540 DCHECK(surface);
532 541
533 DCHECK(!new_output_surface_); 542 DCHECK(!new_output_surface_);
534 new_output_surface_ = std::move(surface); 543 new_output_surface_ = std::move(surface);
535 proxy_->SetOutputSurface(new_output_surface_.get()); 544 proxy_->SetOutputSurface(new_output_surface_.get());
536 } 545 }
537 546
538 std::unique_ptr<OutputSurface> LayerTreeHost::ReleaseOutputSurface() { 547 std::unique_ptr<OutputSurface> LayerTreeHostInProcess::ReleaseOutputSurface() {
539 DCHECK(!visible_); 548 DCHECK(!visible_);
540 549
541 DidLoseOutputSurface(); 550 DidLoseOutputSurface();
542 proxy_->ReleaseOutputSurface(); 551 proxy_->ReleaseOutputSurface();
543 return std::move(current_output_surface_); 552 return std::move(current_output_surface_);
544 } 553 }
545 554
546 void LayerTreeHost::RequestNewOutputSurface() { 555 void LayerTreeHostInProcess::RequestNewOutputSurface() {
547 client_->RequestNewOutputSurface(); 556 client_->RequestNewOutputSurface();
548 } 557 }
549 558
550 void LayerTreeHost::DidInitializeOutputSurface() { 559 void LayerTreeHostInProcess::DidInitializeOutputSurface() {
551 DCHECK(new_output_surface_); 560 DCHECK(new_output_surface_);
552 current_output_surface_ = std::move(new_output_surface_); 561 current_output_surface_ = std::move(new_output_surface_);
553 client_->DidInitializeOutputSurface(); 562 client_->DidInitializeOutputSurface();
554 } 563 }
555 564
556 void LayerTreeHost::DidFailToInitializeOutputSurface() { 565 void LayerTreeHostInProcess::DidFailToInitializeOutputSurface() {
557 DCHECK(new_output_surface_); 566 DCHECK(new_output_surface_);
558 // Note: It is safe to drop all output surface references here as 567 // Note: It is safe to drop all output surface references here as
559 // LayerTreeHostImpl will not keep a pointer to either the old or 568 // LayerTreeHostInProcessImpl will not keep a pointer to either the old or
560 // new output surface after failing to initialize the new one. 569 // new output surface after failing to initialize the new one.
561 current_output_surface_ = nullptr; 570 current_output_surface_ = nullptr;
562 new_output_surface_ = nullptr; 571 new_output_surface_ = nullptr;
563 client_->DidFailToInitializeOutputSurface(); 572 client_->DidFailToInitializeOutputSurface();
564 } 573 }
565 574
566 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( 575 std::unique_ptr<LayerTreeHostImpl>
576 LayerTreeHostInProcess::CreateLayerTreeHostImpl(
567 LayerTreeHostImplClient* client) { 577 LayerTreeHostImplClient* client) {
568 DCHECK(!IsRemoteServer()); 578 DCHECK(!IsRemoteServer());
569 DCHECK(task_runner_provider_->IsImplThread()); 579 DCHECK(task_runner_provider_->IsImplThread());
570 580
571 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); 581 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread();
572 std::unique_ptr<AnimationHost> animation_host_impl = 582 std::unique_ptr<AnimationHost> animation_host_impl =
573 layer_tree_->animation_host()->CreateImplInstance( 583 layer_tree_->animation_host()->CreateImplInstance(
574 supports_impl_scrolling); 584 supports_impl_scrolling);
575 585
576 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( 586 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
577 settings_, client, task_runner_provider_.get(), 587 settings_, client, task_runner_provider_.get(),
578 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, 588 rendering_stats_instrumentation_.get(), shared_bitmap_manager_,
579 gpu_memory_buffer_manager_, task_graph_runner_, 589 gpu_memory_buffer_manager_, task_graph_runner_,
580 std::move(animation_host_impl), id_); 590 std::move(animation_host_impl), id_);
581 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); 591 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_);
582 host_impl->SetContentIsSuitableForGpuRasterization( 592 host_impl->SetContentIsSuitableForGpuRasterization(
583 content_is_suitable_for_gpu_rasterization_); 593 content_is_suitable_for_gpu_rasterization_);
584 shared_bitmap_manager_ = NULL; 594 shared_bitmap_manager_ = NULL;
585 gpu_memory_buffer_manager_ = NULL; 595 gpu_memory_buffer_manager_ = NULL;
586 task_graph_runner_ = NULL; 596 task_graph_runner_ = NULL;
587 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); 597 input_handler_weak_ptr_ = host_impl->AsWeakPtr();
588 return host_impl; 598 return host_impl;
589 } 599 }
590 600
591 void LayerTreeHost::DidLoseOutputSurface() { 601 void LayerTreeHostInProcess::DidLoseOutputSurface() {
592 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface"); 602 TRACE_EVENT0("cc", "LayerTreeHostInProcess::DidLoseOutputSurface");
593 DCHECK(task_runner_provider_->IsMainThread()); 603 DCHECK(task_runner_provider_->IsMainThread());
594 SetNeedsCommit(); 604 SetNeedsCommit();
595 } 605 }
596 606
597 void LayerTreeHost::SetDeferCommits(bool defer_commits) { 607 void LayerTreeHostInProcess::SetDeferCommits(bool defer_commits) {
598 proxy_->SetDeferCommits(defer_commits); 608 proxy_->SetDeferCommits(defer_commits);
599 } 609 }
600 610
601 DISABLE_CFI_PERF 611 DISABLE_CFI_PERF
602 void LayerTreeHost::SetNeedsAnimate() { 612 void LayerTreeHostInProcess::SetNeedsAnimate() {
603 proxy_->SetNeedsAnimate(); 613 proxy_->SetNeedsAnimate();
604 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); 614 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit();
605 } 615 }
606 616
607 DISABLE_CFI_PERF 617 DISABLE_CFI_PERF
608 void LayerTreeHost::SetNeedsUpdateLayers() { 618 void LayerTreeHostInProcess::SetNeedsUpdateLayers() {
609 proxy_->SetNeedsUpdateLayers(); 619 proxy_->SetNeedsUpdateLayers();
610 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); 620 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit();
611 } 621 }
612 622
613 void LayerTreeHost::SetNeedsCommit() { 623 void LayerTreeHostInProcess::SetNeedsCommit() {
614 proxy_->SetNeedsCommit(); 624 proxy_->SetNeedsCommit();
615 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); 625 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit();
616 } 626 }
617 627
618 void LayerTreeHost::SetNeedsRedraw() { 628 void LayerTreeHostInProcess::SetNeedsRedraw() {
619 SetNeedsRedrawRect(gfx::Rect(layer_tree_->device_viewport_size())); 629 SetNeedsRedrawRect(gfx::Rect(layer_tree_->device_viewport_size()));
620 } 630 }
621 631
622 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { 632 void LayerTreeHostInProcess::SetNeedsRedrawRect(const gfx::Rect& damage_rect) {
623 proxy_->SetNeedsRedraw(damage_rect); 633 proxy_->SetNeedsRedraw(damage_rect);
624 } 634 }
625 635
626 bool LayerTreeHost::CommitRequested() const { 636 bool LayerTreeHostInProcess::CommitRequested() const {
627 return proxy_->CommitRequested(); 637 return proxy_->CommitRequested();
628 } 638 }
629 639
630 bool LayerTreeHost::BeginMainFrameRequested() const { 640 bool LayerTreeHostInProcess::BeginMainFrameRequested() const {
631 return proxy_->BeginMainFrameRequested(); 641 return proxy_->BeginMainFrameRequested();
632 } 642 }
633 643
634 void LayerTreeHost::SetNextCommitWaitsForActivation() { 644 void LayerTreeHostInProcess::SetNextCommitWaitsForActivation() {
635 proxy_->SetNextCommitWaitsForActivation(); 645 proxy_->SetNextCommitWaitsForActivation();
636 } 646 }
637 647
638 void LayerTreeHost::SetNextCommitForcesRedraw() { 648 void LayerTreeHostInProcess::SetNextCommitForcesRedraw() {
639 next_commit_forces_redraw_ = true; 649 next_commit_forces_redraw_ = true;
640 proxy_->SetNeedsUpdateLayers(); 650 proxy_->SetNeedsUpdateLayers();
641 } 651 }
642 652
643 void LayerTreeHost::SetAnimationEvents( 653 void LayerTreeHostInProcess::SetAnimationEvents(
644 std::unique_ptr<AnimationEvents> events) { 654 std::unique_ptr<AnimationEvents> events) {
645 DCHECK(task_runner_provider_->IsMainThread()); 655 DCHECK(task_runner_provider_->IsMainThread());
646 layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); 656 layer_tree_->animation_host()->SetAnimationEvents(std::move(events));
647 } 657 }
648 658
649 void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { 659 void LayerTreeHostInProcess::SetDebugState(
660 const LayerTreeDebugState& debug_state) {
650 LayerTreeDebugState new_debug_state = 661 LayerTreeDebugState new_debug_state =
651 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); 662 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state);
652 663
653 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 664 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
654 return; 665 return;
655 666
656 debug_state_ = new_debug_state; 667 debug_state_ = new_debug_state;
657 668
658 rendering_stats_instrumentation_->set_record_rendering_stats( 669 rendering_stats_instrumentation_->set_record_rendering_stats(
659 debug_state_.RecordRenderingStats()); 670 debug_state_.RecordRenderingStats());
660 671
661 SetNeedsCommit(); 672 SetNeedsCommit();
662 } 673 }
663 674
664 void LayerTreeHost::ResetGpuRasterizationTracking() { 675 void LayerTreeHostInProcess::ResetGpuRasterizationTracking() {
665 content_is_suitable_for_gpu_rasterization_ = true; 676 content_is_suitable_for_gpu_rasterization_ = true;
666 gpu_rasterization_histogram_recorded_ = false; 677 gpu_rasterization_histogram_recorded_ = false;
667 } 678 }
668 679
669 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { 680 void LayerTreeHostInProcess::SetHasGpuRasterizationTrigger(bool has_trigger) {
670 if (has_trigger == has_gpu_rasterization_trigger_) 681 if (has_trigger == has_gpu_rasterization_trigger_)
671 return; 682 return;
672 683
673 has_gpu_rasterization_trigger_ = has_trigger; 684 has_gpu_rasterization_trigger_ = has_trigger;
674 TRACE_EVENT_INSTANT1("cc", 685 TRACE_EVENT_INSTANT1(
675 "LayerTreeHost::SetHasGpuRasterizationTrigger", 686 "cc", "LayerTreeHostInProcess::SetHasGpuRasterizationTrigger",
676 TRACE_EVENT_SCOPE_THREAD, 687 TRACE_EVENT_SCOPE_THREAD, "has_trigger", has_gpu_rasterization_trigger_);
677 "has_trigger",
678 has_gpu_rasterization_trigger_);
679 } 688 }
680 689
681 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { 690 void LayerTreeHostInProcess::ApplyPageScaleDeltaFromImplSide(
691 float page_scale_delta) {
682 DCHECK(CommitRequested()); 692 DCHECK(CommitRequested());
683 if (page_scale_delta == 1.f) 693 if (page_scale_delta == 1.f)
684 return; 694 return;
685 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta; 695 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta;
686 layer_tree_->SetPageScaleFromImplSide(page_scale); 696 layer_tree_->SetPageScaleFromImplSide(page_scale);
687 } 697 }
688 698
689 void LayerTreeHost::SetVisible(bool visible) { 699 void LayerTreeHostInProcess::SetVisible(bool visible) {
690 if (visible_ == visible) 700 if (visible_ == visible)
691 return; 701 return;
692 visible_ = visible; 702 visible_ = visible;
693 proxy_->SetVisible(visible); 703 proxy_->SetVisible(visible);
694 } 704 }
695 705
696 bool LayerTreeHost::IsVisible() const { 706 bool LayerTreeHostInProcess::IsVisible() const {
697 return visible_; 707 return visible_;
698 } 708 }
699 709
700 void LayerTreeHost::NotifyInputThrottledUntilCommit() { 710 void LayerTreeHostInProcess::NotifyInputThrottledUntilCommit() {
701 proxy_->NotifyInputThrottledUntilCommit(); 711 proxy_->NotifyInputThrottledUntilCommit();
702 } 712 }
703 713
704 void LayerTreeHost::LayoutAndUpdateLayers() { 714 void LayerTreeHostInProcess::LayoutAndUpdateLayers() {
705 DCHECK(IsSingleThreaded()); 715 DCHECK(IsSingleThreaded());
706 // This function is only valid when not using the scheduler. 716 // This function is only valid when not using the scheduler.
707 DCHECK(!settings_.single_thread_proxy_scheduler); 717 DCHECK(!settings_.single_thread_proxy_scheduler);
708 RequestMainFrameUpdate(); 718 RequestMainFrameUpdate();
709 UpdateLayers(); 719 UpdateLayers();
710 } 720 }
711 721
712 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { 722 void LayerTreeHostInProcess::Composite(base::TimeTicks frame_begin_time) {
713 DCHECK(IsSingleThreaded()); 723 DCHECK(IsSingleThreaded());
714 // This function is only valid when not using the scheduler. 724 // This function is only valid when not using the scheduler.
715 DCHECK(!settings_.single_thread_proxy_scheduler); 725 DCHECK(!settings_.single_thread_proxy_scheduler);
716 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); 726 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
717 727
718 proxy->CompositeImmediately(frame_begin_time); 728 proxy->CompositeImmediately(frame_begin_time);
719 } 729 }
720 730
721 bool LayerTreeHost::UpdateLayers() { 731 bool LayerTreeHostInProcess::UpdateLayers() {
722 if (!layer_tree_->root_layer()) 732 if (!layer_tree_->root_layer())
723 return false; 733 return false;
724 DCHECK(!layer_tree_->root_layer()->parent()); 734 DCHECK(!layer_tree_->root_layer()->parent());
725 bool result = DoUpdateLayers(layer_tree_->root_layer()); 735 bool result = DoUpdateLayers(layer_tree_->root_layer());
726 micro_benchmark_controller_.DidUpdateLayers(); 736 micro_benchmark_controller_.DidUpdateLayers();
727 return result || next_commit_forces_redraw_; 737 return result || next_commit_forces_redraw_;
728 } 738 }
729 739
730 void LayerTreeHost::DidCompletePageScaleAnimation() { 740 void LayerTreeHostInProcess::DidCompletePageScaleAnimation() {
731 did_complete_scale_animation_ = true; 741 did_complete_scale_animation_ = true;
732 } 742 }
733 743
734 void LayerTreeHost::RecordGpuRasterizationHistogram() { 744 void LayerTreeHostInProcess::RecordGpuRasterizationHistogram() {
735 // Gpu rasterization is only supported for Renderer compositors. 745 // Gpu rasterization is only supported for Renderer compositors.
736 // Checking for IsSingleThreaded() to exclude Browser compositors. 746 // Checking for IsSingleThreaded() to exclude Browser compositors.
737 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded()) 747 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded())
738 return; 748 return;
739 749
740 // Record how widely gpu rasterization is enabled. 750 // Record how widely gpu rasterization is enabled.
741 // This number takes device/gpu whitelisting/backlisting into account. 751 // This number takes device/gpu whitelisting/backlisting into account.
742 // Note that we do not consider the forced gpu rasterization mode, which is 752 // Note that we do not consider the forced gpu rasterization mode, which is
743 // mostly used for debugging purposes. 753 // mostly used for debugging purposes.
744 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled", 754 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled",
745 settings_.gpu_rasterization_enabled); 755 settings_.gpu_rasterization_enabled);
746 if (settings_.gpu_rasterization_enabled) { 756 if (settings_.gpu_rasterization_enabled) {
747 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered", 757 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered",
748 has_gpu_rasterization_trigger_); 758 has_gpu_rasterization_trigger_);
749 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent", 759 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent",
750 content_is_suitable_for_gpu_rasterization_); 760 content_is_suitable_for_gpu_rasterization_);
751 // Record how many pages actually get gpu rasterization when enabled. 761 // Record how many pages actually get gpu rasterization when enabled.
752 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed", 762 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed",
753 (has_gpu_rasterization_trigger_ && 763 (has_gpu_rasterization_trigger_ &&
754 content_is_suitable_for_gpu_rasterization_)); 764 content_is_suitable_for_gpu_rasterization_));
755 } 765 }
756 766
757 gpu_rasterization_histogram_recorded_ = true; 767 gpu_rasterization_histogram_recorded_ = true;
758 } 768 }
759 769
760 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { 770 bool LayerTreeHostInProcess::DoUpdateLayers(Layer* root_layer) {
761 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", 771 TRACE_EVENT1("cc", "LayerTreeHostInProcess::DoUpdateLayers",
762 SourceFrameNumber()); 772 "source_frame_number", SourceFrameNumber());
763 773
764 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo()); 774 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo());
765 UpdateHudLayer(); 775 UpdateHudLayer();
766 776
767 Layer* root_scroll = 777 Layer* root_scroll =
768 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer); 778 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer);
769 Layer* page_scale_layer = layer_tree_->page_scale_layer(); 779 Layer* page_scale_layer = layer_tree_->page_scale_layer();
770 if (!page_scale_layer && root_scroll) 780 if (!page_scale_layer && root_scroll)
771 page_scale_layer = root_scroll->parent(); 781 page_scale_layer = root_scroll->parent();
772 782
773 if (layer_tree_->hud_layer()) { 783 if (layer_tree_->hud_layer()) {
774 layer_tree_->hud_layer()->PrepareForCalculateDrawProperties( 784 layer_tree_->hud_layer()->PrepareForCalculateDrawProperties(
775 layer_tree_->device_viewport_size(), 785 layer_tree_->device_viewport_size(),
776 layer_tree_->device_scale_factor()); 786 layer_tree_->device_scale_factor());
777 } 787 }
778 788
779 gfx::Transform identity_transform; 789 gfx::Transform identity_transform;
780 LayerList update_layer_list; 790 LayerList update_layer_list;
781 791
782 { 792 {
783 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::BuildPropertyTrees"); 793 TRACE_EVENT0("cc",
784 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), 794 "LayerTreeHostInProcess::UpdateLayers::BuildPropertyTrees");
785 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees"); 795 TRACE_EVENT0(
796 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
797 "LayerTreeHostInProcessCommon::ComputeVisibleRectsWithPropertyTrees");
786 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); 798 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer);
787 bool can_render_to_separate_surface = true; 799 bool can_render_to_separate_surface = true;
788 PropertyTrees* property_trees = layer_tree_->property_trees(); 800 PropertyTrees* property_trees = layer_tree_->property_trees();
789 if (!settings_.use_layer_lists) { 801 if (!settings_.use_layer_lists) {
790 // If use_layer_lists is set, then the property trees should have been 802 // If use_layer_lists is set, then the property trees should have been
791 // built by the client already. 803 // built by the client already.
792 PropertyTreeBuilder::BuildPropertyTrees( 804 PropertyTreeBuilder::BuildPropertyTrees(
793 root_layer, page_scale_layer, 805 root_layer, page_scale_layer,
794 layer_tree_->inner_viewport_scroll_layer(), 806 layer_tree_->inner_viewport_scroll_layer(),
795 layer_tree_->outer_viewport_scroll_layer(), 807 layer_tree_->outer_viewport_scroll_layer(),
796 layer_tree_->overscroll_elasticity_layer(), 808 layer_tree_->overscroll_elasticity_layer(),
797 layer_tree_->elastic_overscroll(), layer_tree_->page_scale_factor(), 809 layer_tree_->elastic_overscroll(), layer_tree_->page_scale_factor(),
798 layer_tree_->device_scale_factor(), 810 layer_tree_->device_scale_factor(),
799 gfx::Rect(layer_tree_->device_viewport_size()), identity_transform, 811 gfx::Rect(layer_tree_->device_viewport_size()), identity_transform,
800 property_trees); 812 property_trees);
801 TRACE_EVENT_INSTANT1("cc", 813 TRACE_EVENT_INSTANT1(
802 "LayerTreeHost::UpdateLayers_BuiltPropertyTrees", 814 "cc", "LayerTreeHostInProcess::UpdateLayers_BuiltPropertyTrees",
803 TRACE_EVENT_SCOPE_THREAD, "property_trees", 815 TRACE_EVENT_SCOPE_THREAD, "property_trees",
804 property_trees->AsTracedValue()); 816 property_trees->AsTracedValue());
805 } else { 817 } else {
806 TRACE_EVENT_INSTANT1("cc", 818 TRACE_EVENT_INSTANT1(
807 "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees", 819 "cc", "LayerTreeHostInProcess::UpdateLayers_ReceivedPropertyTrees",
808 TRACE_EVENT_SCOPE_THREAD, "property_trees", 820 TRACE_EVENT_SCOPE_THREAD, "property_trees",
809 property_trees->AsTracedValue()); 821 property_trees->AsTracedValue());
810 } 822 }
811 draw_property_utils::UpdatePropertyTrees(property_trees, 823 draw_property_utils::UpdatePropertyTrees(property_trees,
812 can_render_to_separate_surface); 824 can_render_to_separate_surface);
813 draw_property_utils::FindLayersThatNeedUpdates( 825 draw_property_utils::FindLayersThatNeedUpdates(
814 layer_tree_.get(), property_trees->transform_tree, 826 layer_tree_.get(), property_trees->transform_tree,
815 property_trees->effect_tree, &update_layer_list); 827 property_trees->effect_tree, &update_layer_list);
816 } 828 }
817 829
818 for (const auto& layer : update_layer_list) 830 for (const auto& layer : update_layer_list)
819 layer->SavePaintProperties(); 831 layer->SavePaintProperties();
820 832
821 bool content_is_suitable_for_gpu = true; 833 bool content_is_suitable_for_gpu = true;
822 bool did_paint_content = layer_tree_->UpdateLayers( 834 bool did_paint_content = layer_tree_->UpdateLayers(
823 update_layer_list, &content_is_suitable_for_gpu); 835 update_layer_list, &content_is_suitable_for_gpu);
824 836
825 if (content_is_suitable_for_gpu) { 837 if (content_is_suitable_for_gpu) {
826 ++num_consecutive_frames_suitable_for_gpu_; 838 ++num_consecutive_frames_suitable_for_gpu_;
827 if (num_consecutive_frames_suitable_for_gpu_ >= 839 if (num_consecutive_frames_suitable_for_gpu_ >=
828 kNumFramesToConsiderBeforeGpuRasterization) { 840 kNumFramesToConsiderBeforeGpuRasterization) {
829 content_is_suitable_for_gpu_rasterization_ = true; 841 content_is_suitable_for_gpu_rasterization_ = true;
830 } 842 }
831 } else { 843 } else {
832 num_consecutive_frames_suitable_for_gpu_ = 0; 844 num_consecutive_frames_suitable_for_gpu_ = 0;
833 content_is_suitable_for_gpu_rasterization_ = false; 845 content_is_suitable_for_gpu_rasterization_ = false;
834 } 846 }
835 return did_paint_content; 847 return did_paint_content;
836 } 848 }
837 849
838 void LayerTreeHost::ApplyViewportDeltas(ScrollAndScaleSet* info) { 850 void LayerTreeHostInProcess::ApplyViewportDeltas(ScrollAndScaleSet* info) {
839 gfx::Vector2dF inner_viewport_scroll_delta; 851 gfx::Vector2dF inner_viewport_scroll_delta;
840 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID) 852 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID)
841 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta; 853 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta;
842 854
843 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f && 855 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f &&
844 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) 856 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta)
845 return; 857 return;
846 858
847 // Preemptively apply the scroll offset and scale delta here before sending 859 // Preemptively apply the scroll offset and scale delta here before sending
848 // it to the client. If the client comes back and sets it to the same 860 // it to the client. If the client comes back and sets it to the same
(...skipping 10 matching lines...) Expand all
859 layer_tree_->elastic_overscroll() + info->elastic_overscroll_delta); 871 layer_tree_->elastic_overscroll() + info->elastic_overscroll_delta);
860 // TODO(ccameron): pass the elastic overscroll here so that input events 872 // TODO(ccameron): pass the elastic overscroll here so that input events
861 // may be translated appropriately. 873 // may be translated appropriately.
862 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), 874 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(),
863 info->elastic_overscroll_delta, 875 info->elastic_overscroll_delta,
864 info->page_scale_delta, 876 info->page_scale_delta,
865 info->top_controls_delta); 877 info->top_controls_delta);
866 SetNeedsUpdateLayers(); 878 SetNeedsUpdateLayers();
867 } 879 }
868 880
869 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { 881 void LayerTreeHostInProcess::ApplyScrollAndScale(ScrollAndScaleSet* info) {
870 for (auto& swap_promise : info->swap_promises) { 882 for (auto& swap_promise : info->swap_promises) {
871 TRACE_EVENT_WITH_FLOW1("input,benchmark", 883 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow",
872 "LatencyInfo.Flow",
873 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), 884 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()),
874 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, 885 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
875 "step", "Main thread scroll update"); 886 "step", "Main thread scroll update");
876 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); 887 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise));
877 } 888 }
878 889
879 if (layer_tree_->root_layer()) { 890 if (layer_tree_->root_layer()) {
880 for (size_t i = 0; i < info->scrolls.size(); ++i) { 891 for (size_t i = 0; i < info->scrolls.size(); ++i) {
881 Layer* layer = layer_tree_->LayerById(info->scrolls[i].layer_id); 892 Layer* layer = layer_tree_->LayerById(info->scrolls[i].layer_id);
882 if (!layer) 893 if (!layer)
883 continue; 894 continue;
884 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( 895 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta(
885 layer->scroll_offset(), info->scrolls[i].scroll_delta)); 896 layer->scroll_offset(), info->scrolls[i].scroll_delta));
886 SetNeedsUpdateLayers(); 897 SetNeedsUpdateLayers();
887 } 898 }
888 } 899 }
889 900
890 // This needs to happen after scroll deltas have been sent to prevent top 901 // This needs to happen after scroll deltas have been sent to prevent top
891 // controls from clamping the layout viewport both on the compositor and 902 // controls from clamping the layout viewport both on the compositor and
892 // on the main thread. 903 // on the main thread.
893 ApplyViewportDeltas(info); 904 ApplyViewportDeltas(info);
894 } 905 }
895 906
896 const base::WeakPtr<InputHandler>& LayerTreeHost::GetInputHandler() const { 907 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler()
908 const {
897 return input_handler_weak_ptr_; 909 return input_handler_weak_ptr_;
898 } 910 }
899 911
900 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, 912 void LayerTreeHostInProcess::UpdateTopControlsState(
901 TopControlsState current, 913 TopControlsState constraints,
902 bool animate) { 914 TopControlsState current,
915 bool animate) {
903 // Top controls are only used in threaded or remote mode. 916 // Top controls are only used in threaded or remote mode.
904 DCHECK(IsThreaded() || IsRemoteServer()); 917 DCHECK(IsThreaded() || IsRemoteServer());
905 proxy_->UpdateTopControlsState(constraints, current, animate); 918 proxy_->UpdateTopControlsState(constraints, current, animate);
906 } 919 }
907 920
908 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 921 void LayerTreeHostInProcess::AnimateLayers(base::TimeTicks monotonic_time) {
909 AnimationHost* animation_host = layer_tree_->animation_host(); 922 AnimationHost* animation_host = layer_tree_->animation_host();
910 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); 923 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents();
911 924
912 if (animation_host->AnimateLayers(monotonic_time)) 925 if (animation_host->AnimateLayers(monotonic_time))
913 animation_host->UpdateAnimationState(true, events.get()); 926 animation_host->UpdateAnimationState(true, events.get());
914 927
915 if (!events->events_.empty()) 928 if (!events->events_.empty())
916 layer_tree_->property_trees()->needs_rebuild = true; 929 layer_tree_->property_trees()->needs_rebuild = true;
917 } 930 }
918 931
919 int LayerTreeHost::ScheduleMicroBenchmark( 932 int LayerTreeHostInProcess::ScheduleMicroBenchmark(
920 const std::string& benchmark_name, 933 const std::string& benchmark_name,
921 std::unique_ptr<base::Value> value, 934 std::unique_ptr<base::Value> value,
922 const MicroBenchmark::DoneCallback& callback) { 935 const MicroBenchmark::DoneCallback& callback) {
923 return micro_benchmark_controller_.ScheduleRun(benchmark_name, 936 return micro_benchmark_controller_.ScheduleRun(benchmark_name,
924 std::move(value), callback); 937 std::move(value), callback);
925 } 938 }
926 939
927 bool LayerTreeHost::SendMessageToMicroBenchmark( 940 bool LayerTreeHostInProcess::SendMessageToMicroBenchmark(
928 int id, 941 int id,
929 std::unique_ptr<base::Value> value) { 942 std::unique_ptr<base::Value> value) {
930 return micro_benchmark_controller_.SendMessage(id, std::move(value)); 943 return micro_benchmark_controller_.SendMessage(id, std::move(value));
931 } 944 }
932 945
933 void LayerTreeHost::SetLayerTreeMutator( 946 void LayerTreeHostInProcess::SetLayerTreeMutator(
934 std::unique_ptr<LayerTreeMutator> mutator) { 947 std::unique_ptr<LayerTreeMutator> mutator) {
935 proxy_->SetMutator(std::move(mutator)); 948 proxy_->SetMutator(std::move(mutator));
936 } 949 }
937 950
938 bool LayerTreeHost::IsSingleThreaded() const { 951 bool LayerTreeHostInProcess::IsSingleThreaded() const {
939 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || 952 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED ||
940 !task_runner_provider_->HasImplThread()); 953 !task_runner_provider_->HasImplThread());
941 return compositor_mode_ == CompositorMode::SINGLE_THREADED; 954 return compositor_mode_ == CompositorMode::SINGLE_THREADED;
942 } 955 }
943 956
944 bool LayerTreeHost::IsThreaded() const { 957 bool LayerTreeHostInProcess::IsThreaded() const {
945 DCHECK(compositor_mode_ != CompositorMode::THREADED || 958 DCHECK(compositor_mode_ != CompositorMode::THREADED ||
946 task_runner_provider_->HasImplThread()); 959 task_runner_provider_->HasImplThread());
947 return compositor_mode_ == CompositorMode::THREADED; 960 return compositor_mode_ == CompositorMode::THREADED;
948 } 961 }
949 962
950 bool LayerTreeHost::IsRemoteServer() const { 963 bool LayerTreeHostInProcess::IsRemoteServer() const {
951 // The LayerTreeHost on the server does not have an impl task runner. 964 // The LayerTreeHostInProcess on the server does not have an impl task runner.
952 return compositor_mode_ == CompositorMode::REMOTE && 965 return compositor_mode_ == CompositorMode::REMOTE &&
953 !task_runner_provider_->HasImplThread(); 966 !task_runner_provider_->HasImplThread();
954 } 967 }
955 968
956 bool LayerTreeHost::IsRemoteClient() const { 969 bool LayerTreeHostInProcess::IsRemoteClient() const {
957 return compositor_mode_ == CompositorMode::REMOTE && 970 return compositor_mode_ == CompositorMode::REMOTE &&
958 task_runner_provider_->HasImplThread(); 971 task_runner_provider_->HasImplThread();
959 } 972 }
960 973
961 void LayerTreeHost::ToProtobufForCommit( 974 void LayerTreeHostInProcess::ToProtobufForCommit(
962 proto::LayerTreeHost* proto, 975 proto::LayerTreeHost* proto,
963 std::vector<std::unique_ptr<SwapPromise>>* swap_promises) { 976 std::vector<std::unique_ptr<SwapPromise>>* swap_promises) {
964 DCHECK(engine_picture_cache_); 977 DCHECK(engine_picture_cache_);
965 // Not all fields are serialized, as they are either not needed for a commit, 978 // Not all fields are serialized, as they are either not needed for a commit,
966 // or implementation isn't ready yet. 979 // or implementation isn't ready yet.
967 // Unsupported items: 980 // Unsupported items:
968 // - animations 981 // - animations
969 // - UI resources 982 // - UI resources
970 // - instrumentation of stats 983 // - instrumentation of stats
971 // - histograms 984 // - histograms
972 // Skipped items: 985 // Skipped items:
973 // - SwapPromise as they are mostly used for perf measurements. 986 // - SwapPromise as they are mostly used for perf measurements.
974 // - The bitmap and GPU memory related items. 987 // - The bitmap and GPU memory related items.
975 // Other notes: 988 // Other notes:
976 // - The output surfaces are only valid on the client-side so they are 989 // - The output surfaces are only valid on the client-side so they are
977 // therefore not serialized. 990 // therefore not serialized.
978 // - LayerTreeSettings are needed only during construction of the 991 // - LayerTreeSettings are needed only during construction of the
979 // LayerTreeHost, so they are serialized outside of the LayerTreeHost 992 // LayerTreeHostInProcess, so they are serialized outside of the
993 // LayerTreeHostInProcess
980 // serialization. 994 // serialization.
981 // - The |visible_| flag will be controlled from the client separately and 995 // - The |visible_| flag will be controlled from the client separately and
982 // will need special handling outside of the serialization of the 996 // will need special handling outside of the serialization of the
983 // LayerTreeHost. 997 // LayerTreeHostInProcess.
984 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. 998 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376.
985 TRACE_EVENT0("cc.remote", "LayerTreeHost::ToProtobufForCommit"); 999 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::ToProtobufForCommit");
986 *swap_promises = swap_promise_manager_.TakeSwapPromises(); 1000 *swap_promises = swap_promise_manager_.TakeSwapPromises();
987 1001
988 proto->set_source_frame_number(source_frame_number_); 1002 proto->set_source_frame_number(source_frame_number_);
989 1003
990 // Serialize the LayerTree before serializing the properties. During layer 1004 // Serialize the LayerTree before serializing the properties. During layer
991 // property serialization, we clear the list |layer_that_should_properties_| 1005 // property serialization, we clear the list |layer_that_should_properties_|
992 // from the LayerTree. 1006 // from the LayerTree.
993 layer_tree_->ToProtobuf(proto->mutable_layer_tree()); 1007 layer_tree_->ToProtobuf(proto->mutable_layer_tree());
994 1008
995 LayerProtoConverter::SerializeLayerProperties(this, 1009 LayerProtoConverter::SerializeLayerProperties(this,
996 proto->mutable_layer_updates()); 1010 proto->mutable_layer_updates());
997 1011
998 std::vector<PictureData> pictures = 1012 std::vector<PictureData> pictures =
999 engine_picture_cache_->CalculateCacheUpdateAndFlush(); 1013 engine_picture_cache_->CalculateCacheUpdateAndFlush();
1000 proto::PictureDataVectorToSkPicturesProto(pictures, 1014 proto::PictureDataVectorToSkPicturesProto(pictures,
1001 proto->mutable_pictures()); 1015 proto->mutable_pictures());
1002 1016
1003 debug_state_.ToProtobuf(proto->mutable_debug_state()); 1017 debug_state_.ToProtobuf(proto->mutable_debug_state());
1004 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); 1018 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_);
1005 proto->set_content_is_suitable_for_gpu_rasterization( 1019 proto->set_content_is_suitable_for_gpu_rasterization(
1006 content_is_suitable_for_gpu_rasterization_); 1020 content_is_suitable_for_gpu_rasterization_);
1007 proto->set_id(id_); 1021 proto->set_id(id_);
1008 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); 1022 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_);
1009 1023
1010 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 1024 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
1011 "cc.remote", "LayerTreeHostProto", source_frame_number_, 1025 "cc.remote", "LayerTreeHostProto", source_frame_number_,
1012 ComputeLayerTreeHostProtoSizeSplitAsValue(proto)); 1026 ComputeLayerTreeHostProtoSizeSplitAsValue(proto));
1013 } 1027 }
1014 1028
1015 void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { 1029 void LayerTreeHostInProcess::FromProtobufForCommit(
1030 const proto::LayerTreeHost& proto) {
1016 DCHECK(client_picture_cache_); 1031 DCHECK(client_picture_cache_);
1017 source_frame_number_ = proto.source_frame_number(); 1032 source_frame_number_ = proto.source_frame_number();
1018 1033
1019 layer_tree_->FromProtobuf(proto.layer_tree()); 1034 layer_tree_->FromProtobuf(proto.layer_tree());
1020 1035
1021 // Ensure ClientPictureCache contains all the necessary SkPictures before 1036 // Ensure ClientPictureCache contains all the necessary SkPictures before
1022 // deserializing the properties. 1037 // deserializing the properties.
1023 proto::SkPictures proto_pictures = proto.pictures(); 1038 proto::SkPictures proto_pictures = proto.pictures();
1024 std::vector<PictureData> pictures = 1039 std::vector<PictureData> pictures =
1025 SkPicturesProtoToPictureDataVector(proto_pictures); 1040 SkPicturesProtoToPictureDataVector(proto_pictures);
1026 client_picture_cache_->ApplyCacheUpdate(pictures); 1041 client_picture_cache_->ApplyCacheUpdate(pictures);
1027 1042
1028 LayerProtoConverter::DeserializeLayerProperties(layer_tree_->root_layer(), 1043 LayerProtoConverter::DeserializeLayerProperties(layer_tree_->root_layer(),
1029 proto.layer_updates()); 1044 proto.layer_updates());
1030 1045
1031 // The deserialization is finished, so now clear the cache. 1046 // The deserialization is finished, so now clear the cache.
1032 client_picture_cache_->Flush(); 1047 client_picture_cache_->Flush();
1033 1048
1034 debug_state_.FromProtobuf(proto.debug_state()); 1049 debug_state_.FromProtobuf(proto.debug_state());
1035 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); 1050 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger();
1036 content_is_suitable_for_gpu_rasterization_ = 1051 content_is_suitable_for_gpu_rasterization_ =
1037 proto.content_is_suitable_for_gpu_rasterization(); 1052 proto.content_is_suitable_for_gpu_rasterization();
1038 id_ = proto.id(); 1053 id_ = proto.id();
1039 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); 1054 next_commit_forces_redraw_ = proto.next_commit_forces_redraw();
1040 } 1055 }
1041 1056
1042 } // namespace cc 1057 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698