| 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 "blimp/engine/renderer/blimp_remote_compositor_bridge.h" | 5 #include "blimp/engine/renderer/blimp_remote_compositor_bridge.h" |
| 6 | 6 |
| 7 #include "cc/blimp/compositor_proto_state.h" | 7 #include "cc/blimp/compositor_proto_state.h" |
| 8 #include "cc/blimp/remote_compositor_bridge_client.h" | 8 #include "cc/blimp/remote_compositor_bridge_client.h" |
| 9 #include "cc/output/swap_promise.h" | 9 #include "cc/output/swap_promise.h" |
| 10 #include "cc/proto/compositor_message.pb.h" | 10 #include "cc/proto/compositor_message.pb.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 DCHECK(!client_); | 28 DCHECK(!client_); |
| 29 client_ = client; | 29 client_ = client; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void BlimpRemoteCompositorBridge::ScheduleMainFrame() { | 32 void BlimpRemoteCompositorBridge::ScheduleMainFrame() { |
| 33 scheduler_.ScheduleFrameUpdate(); | 33 scheduler_.ScheduleFrameUpdate(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void BlimpRemoteCompositorBridge::ProcessCompositorStateUpdate( | 36 void BlimpRemoteCompositorBridge::ProcessCompositorStateUpdate( |
| 37 std::unique_ptr<cc::CompositorProtoState> compositor_proto_state) { | 37 std::unique_ptr<cc::CompositorProtoState> compositor_proto_state) { |
| 38 compositor_proto_state->compositor_message->set_client_state_update_ack( |
| 39 client_state_update_ack_pending_); |
| 40 client_state_update_ack_pending_ = false; |
| 41 |
| 38 remote_proto_channel_->SendCompositorProto( | 42 remote_proto_channel_->SendCompositorProto( |
| 39 *compositor_proto_state->compositor_message); | 43 *compositor_proto_state->compositor_message); |
| 40 scheduler_.DidSendFrameUpdateToClient(); | 44 scheduler_.DidSendFrameUpdateToClient(); |
| 41 | 45 |
| 42 // Activate the swap promises after the frame is queued. | 46 // Activate the swap promises after the frame is queued. |
| 43 for (const auto& swap_promise : compositor_proto_state->swap_promises) | 47 for (const auto& swap_promise : compositor_proto_state->swap_promises) |
| 44 swap_promise->DidActivate(); | 48 swap_promise->DidActivate(); |
| 45 } | 49 } |
| 46 | 50 |
| 47 void BlimpRemoteCompositorBridge::OnProtoReceived( | 51 void BlimpRemoteCompositorBridge::OnProtoReceived( |
| 48 std::unique_ptr<cc::proto::CompositorMessage> proto) { | 52 std::unique_ptr<cc::proto::CompositorMessage> proto) { |
| 49 DCHECK(proto->frame_ack()); | 53 if (proto->frame_ack()) |
| 50 scheduler_.DidReceiveFrameUpdateAck(); | 54 scheduler_.DidReceiveFrameUpdateAck(); |
| 55 |
| 56 if (proto->has_client_state_update()) { |
| 57 DCHECK(!client_state_update_ack_pending_); |
| 58 |
| 59 client_->ApplyStateUpdateFromClient(proto->client_state_update()); |
| 60 |
| 61 // If applying the delta resulted in a frame request, run the main frame |
| 62 // first so the ack sent to the client includes the frame with the deltas |
| 63 // applied. |
| 64 if (scheduler_.needs_frame_update()) { |
| 65 client_state_update_ack_pending_ = true; |
| 66 } else { |
| 67 cc::proto::CompositorMessage message; |
| 68 message.set_client_state_update_ack(true); |
| 69 remote_proto_channel_->SendCompositorProto(message); |
| 70 } |
| 71 } |
| 51 } | 72 } |
| 52 | 73 |
| 53 void BlimpRemoteCompositorBridge::StartFrameUpdate() { | 74 void BlimpRemoteCompositorBridge::StartFrameUpdate() { |
| 54 client_->BeginMainFrame(); | 75 client_->BeginMainFrame(); |
| 76 |
| 77 // If the frame resulted in an update to the client, the ack should have gone |
| 78 // with it. If it is still pending, this means the main frame was aborted so |
| 79 // send the ack now. |
| 80 if (client_state_update_ack_pending_) { |
| 81 client_state_update_ack_pending_ = false; |
| 82 cc::proto::CompositorMessage message; |
| 83 message.set_client_state_update_ack(true); |
| 84 remote_proto_channel_->SendCompositorProto(message); |
| 85 } |
| 55 } | 86 } |
| 56 | 87 |
| 57 } // namespace engine | 88 } // namespace engine |
| 58 } // namespace blimp | 89 } // namespace blimp |
| OLD | NEW |