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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/blimp/compositor_proto_state.h" | 9 #include "cc/blimp/compositor_proto_state.h" |
10 #include "cc/blimp/compositor_proto_state_sink.h" | 10 #include "cc/blimp/compositor_proto_state_sink.h" |
11 #include "cc/output/begin_frame_args.h" | 11 #include "cc/output/begin_frame_args.h" |
12 #include "cc/output/compositor_frame_sink.h" | 12 #include "cc/output/compositor_frame_sink.h" |
13 #include "cc/proto/compositor_message.pb.h" | |
14 #include "cc/proto/layer_tree_host.pb.h" | |
13 #include "cc/trees/layer_tree.h" | 15 #include "cc/trees/layer_tree.h" |
14 #include "cc/trees/layer_tree_host_client.h" | 16 #include "cc/trees/layer_tree_host_client.h" |
15 #include "cc/trees/layer_tree_host_common.h" | 17 #include "cc/trees/layer_tree_host_common.h" |
16 #include "cc/trees/task_runner_provider.h" | 18 #include "cc/trees/task_runner_provider.h" |
17 | 19 |
18 namespace cc { | 20 namespace cc { |
19 namespace { | 21 namespace { |
20 // We use a 16ms default frame interval because the rate at which the engine | 22 // We use a 16ms default frame interval because the rate at which the engine |
21 // produces main frames doesn't matter. | 23 // produces main frames doesn't matter. |
22 base::TimeDelta kDefaultFrameInterval = base::TimeDelta::FromMilliseconds(16); | 24 base::TimeDelta kDefaultFrameInterval = base::TimeDelta::FromMilliseconds(16); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 if (max_pipeline_stage_for_current_frame_ < current_pipeline_stage_) { | 369 if (max_pipeline_stage_for_current_frame_ < current_pipeline_stage_) { |
368 // There is nothing to commit so break the swap promises. | 370 // There is nothing to commit so break the swap promises. |
369 swap_promise_manager_.BreakSwapPromises( | 371 swap_promise_manager_.BreakSwapPromises( |
370 SwapPromise::DidNotSwapReason::COMMIT_NO_UPDATE); | 372 SwapPromise::DidNotSwapReason::COMMIT_NO_UPDATE); |
371 | 373 |
372 // For the client, the commit was successful. | 374 // For the client, the commit was successful. |
373 MainFrameComplete(); | 375 MainFrameComplete(); |
374 return; | 376 return; |
375 } | 377 } |
376 | 378 |
377 // TODO(khushalsagar): Serialize current state/reset dirty state tracking and | |
378 // return the result to the state sink instead. | |
379 std::unique_ptr<CompositorProtoState> compositor_state = | 379 std::unique_ptr<CompositorProtoState> compositor_state = |
380 base::MakeUnique<CompositorProtoState>(); | 380 base::MakeUnique<CompositorProtoState>(); |
381 compositor_state->swap_promises = swap_promise_manager_.TakeSwapPromises(); | |
382 compositor_state->compositor_message = | |
383 base::MakeUnique<proto::CompositorMessage>(); | |
384 SerializeCurrentState( | |
385 compositor_state->compositor_message->mutable_layer_tree_host()); | |
381 compositor_proto_state_sink_->ProcessCompositorStateUpdate( | 386 compositor_proto_state_sink_->ProcessCompositorStateUpdate( |
382 std::move(compositor_state)); | 387 std::move(compositor_state)); |
383 | 388 |
384 MainFrameComplete(); | 389 MainFrameComplete(); |
385 | 390 |
386 // We can not wait for updates dispatched from the client about the state of | 391 // We can not wait for updates dispatched from the client about the state of |
387 // drawing or swaps for frames sent. Since these calls can be used by the | 392 // drawing or swaps for frames sent. Since these calls can be used by the |
388 // LayerTreeHostClient to throttle further frame updates, so dispatch them | 393 // LayerTreeHostClient to throttle further frame updates, so dispatch them |
389 // right after the update is processed by the state sink. | 394 // right after the update is processed by the state sink. |
390 // TODO(khushalsagar): We can not really know what these callbacks end up | 395 // TODO(khushalsagar): We can not really know what these callbacks end up |
(...skipping 17 matching lines...) Expand all Loading... | |
408 | 413 |
409 client_->DidCommit(); | 414 client_->DidCommit(); |
410 client_->DidBeginMainFrame(); | 415 client_->DidBeginMainFrame(); |
411 } | 416 } |
412 | 417 |
413 void LayerTreeHostRemote::DispatchDrawAndSwapCallbacks() { | 418 void LayerTreeHostRemote::DispatchDrawAndSwapCallbacks() { |
414 client_->DidCommitAndDrawFrame(); | 419 client_->DidCommitAndDrawFrame(); |
415 client_->DidCompleteSwapBuffers(); | 420 client_->DidCompleteSwapBuffers(); |
416 } | 421 } |
417 | 422 |
423 void LayerTreeHostRemote::SerializeCurrentState( | |
424 proto::LayerTreeHost* layer_tree_host_proto) { | |
425 // Serialize the LayerTree. | |
426 layer_tree_->ToProtobuf(layer_tree_host_proto->mutable_layer_tree(), true); | |
ajuma
2016/09/29 20:55:33
Instead of passing |true| here, please create a va
Khushal
2016/10/04 09:11:50
Done.
| |
427 | |
428 // Serialize the dirty layers. | |
429 for (auto* layer : layer_tree_->LayersThatShouldPushProperties()) | |
430 layer->ToLayerPropertiesProto( | |
431 layer_tree_host_proto->mutable_layer_updates(), true); | |
432 layer_tree_->LayersThatShouldPushProperties().clear(); | |
433 | |
434 // TODO(khushalsagar): Deal with picture caching. | |
435 } | |
436 | |
418 } // namespace cc | 437 } // namespace cc |
OLD | NEW |