| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/blimp/layer_tree_host_remote.h" | 5 #include "cc/blimp/layer_tree_host_remote.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 10 #include "cc/blimp/compositor_proto_state.h" | 10 #include "cc/blimp/compositor_proto_state.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 MainFrameComplete(); | 401 MainFrameComplete(); |
| 402 | 402 |
| 403 // We can not wait for updates dispatched from the client about the state of | 403 // We can not wait for updates dispatched from the client about the state of |
| 404 // drawing or swaps for frames sent. Since these calls can be used by the | 404 // drawing or swaps for frames sent. Since these calls can be used by the |
| 405 // LayerTreeHostClient to throttle further frame updates, so dispatch them | 405 // LayerTreeHostClient to throttle further frame updates, so dispatch them |
| 406 // right after the update is processed by the bridge. | 406 // right after the update is processed by the bridge. |
| 407 // TODO(khushalsagar): We can not really know what these callbacks end up | 407 // TODO(khushalsagar): We can not really know what these callbacks end up |
| 408 // being used for. Consider migrating clients to understand/cope with the fact | 408 // being used for. Consider migrating clients to understand/cope with the fact |
| 409 // that there is no actual compositing happening here. | 409 // that there is no actual compositing happening here. |
| 410 task_runner_provider_->MainThreadTaskRunner()->PostTask( | 410 task_runner_provider_->MainThreadTaskRunner()->PostTask( |
| 411 FROM_HERE, base::Bind(&LayerTreeHostRemote::DispatchDrawAndSwapCallbacks, | 411 FROM_HERE, |
| 412 weak_factory_.GetWeakPtr())); | 412 base::Bind(&LayerTreeHostRemote::DispatchDrawAndSubmitCallbacks, |
| 413 weak_factory_.GetWeakPtr())); |
| 413 } | 414 } |
| 414 | 415 |
| 415 void LayerTreeHostRemote::MainFrameComplete() { | 416 void LayerTreeHostRemote::MainFrameComplete() { |
| 416 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); | 417 DCHECK_EQ(current_pipeline_stage_, FramePipelineStage::COMMIT); |
| 417 | 418 |
| 418 current_pipeline_stage_ = FramePipelineStage::NONE; | 419 current_pipeline_stage_ = FramePipelineStage::NONE; |
| 419 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; | 420 max_pipeline_stage_for_current_frame_ = FramePipelineStage::NONE; |
| 420 source_frame_number_++; | 421 source_frame_number_++; |
| 421 | 422 |
| 422 client_->DidCommit(); | 423 client_->DidCommit(); |
| 423 client_->DidBeginMainFrame(); | 424 client_->DidBeginMainFrame(); |
| 424 } | 425 } |
| 425 | 426 |
| 426 void LayerTreeHostRemote::DispatchDrawAndSwapCallbacks() { | 427 void LayerTreeHostRemote::DispatchDrawAndSubmitCallbacks() { |
| 427 client_->DidCommitAndDrawFrame(); | 428 client_->DidCommitAndDrawFrame(); |
| 428 client_->DidCompleteSwapBuffers(); | 429 client_->DidReceiveCompositorFrameAck(); |
| 429 } | 430 } |
| 430 | 431 |
| 431 void LayerTreeHostRemote::SetTaskRunnerProviderForTesting( | 432 void LayerTreeHostRemote::SetTaskRunnerProviderForTesting( |
| 432 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { | 433 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { |
| 433 task_runner_provider_ = std::move(task_runner_provider); | 434 task_runner_provider_ = std::move(task_runner_provider); |
| 434 } | 435 } |
| 435 | 436 |
| 436 void LayerTreeHostRemote::SerializeCurrentState( | 437 void LayerTreeHostRemote::SerializeCurrentState( |
| 437 proto::LayerTreeHost* layer_tree_host_proto) { | 438 proto::LayerTreeHost* layer_tree_host_proto) { |
| 438 // We need to serialize only the inputs received from the embedder. | 439 // We need to serialize only the inputs received from the embedder. |
| 439 const bool inputs_only = true; | 440 const bool inputs_only = true; |
| 440 | 441 |
| 441 // Serialize the LayerTree. | 442 // Serialize the LayerTree. |
| 442 layer_tree_->ToProtobuf(layer_tree_host_proto->mutable_layer_tree(), | 443 layer_tree_->ToProtobuf(layer_tree_host_proto->mutable_layer_tree(), |
| 443 inputs_only); | 444 inputs_only); |
| 444 | 445 |
| 445 // Serialize the dirty layers. | 446 // Serialize the dirty layers. |
| 446 for (auto* layer : layer_tree_->LayersThatShouldPushProperties()) | 447 for (auto* layer : layer_tree_->LayersThatShouldPushProperties()) |
| 447 layer->ToLayerPropertiesProto( | 448 layer->ToLayerPropertiesProto( |
| 448 layer_tree_host_proto->mutable_layer_updates(), inputs_only); | 449 layer_tree_host_proto->mutable_layer_updates(), inputs_only); |
| 449 layer_tree_->LayersThatShouldPushProperties().clear(); | 450 layer_tree_->LayersThatShouldPushProperties().clear(); |
| 450 | 451 |
| 451 std::vector<PictureData> pictures = | 452 std::vector<PictureData> pictures = |
| 452 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 453 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
| 453 proto::PictureDataVectorToSkPicturesProto( | 454 proto::PictureDataVectorToSkPicturesProto( |
| 454 pictures, layer_tree_host_proto->mutable_pictures()); | 455 pictures, layer_tree_host_proto->mutable_pictures()); |
| 455 } | 456 } |
| 456 | 457 |
| 457 } // namespace cc | 458 } // namespace cc |
| OLD | NEW |