Chromium Code Reviews| 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" |
| 11 | 11 |
| 12 namespace blimp { | 12 namespace blimp { |
| 13 namespace engine { | 13 namespace engine { |
| 14 | 14 |
| 15 BlimpRemoteCompositorBridge::BlimpRemoteCompositorBridge( | 15 BlimpRemoteCompositorBridge::BlimpRemoteCompositorBridge( |
| 16 cc::RemoteProtoChannel* remote_proto_channel, | 16 cc::RemoteProtoChannel* remote_proto_channel, |
| 17 scoped_refptr<base::SingleThreadTaskRunner> compositor_main_task_runner) | 17 scoped_refptr<base::SingleThreadTaskRunner> compositor_main_task_runner) |
| 18 : RemoteCompositorBridge(std::move(compositor_main_task_runner)), | 18 : RemoteCompositorBridge(std::move(compositor_main_task_runner)), |
| 19 remote_proto_channel_(remote_proto_channel), | 19 remote_proto_channel_(remote_proto_channel), |
| 20 scheduler_(compositor_main_task_runner_.get(), this) { | 20 scheduler_(compositor_main_task_runner_.get(), this) { |
| 21 remote_proto_channel_->SetProtoReceiver(this); | 21 remote_proto_channel_->SetProtoReceiver(this); |
| 22 } | 22 } |
| 23 | 23 |
| 24 BlimpRemoteCompositorBridge::~BlimpRemoteCompositorBridge() = default; | 24 BlimpRemoteCompositorBridge::~BlimpRemoteCompositorBridge() { |
| 25 remote_proto_channel_->SetProtoReceiver(nullptr); | |
|
David Trainor- moved to gerrit
2016/11/03 05:34:59
Nice catch.
Khushal
2016/11/03 06:17:28
I'm the one who had missed it earlier. :P There is
| |
| 26 } | |
| 25 | 27 |
| 26 void BlimpRemoteCompositorBridge::BindToClient( | 28 void BlimpRemoteCompositorBridge::BindToClient( |
| 27 cc::RemoteCompositorBridgeClient* client) { | 29 cc::RemoteCompositorBridgeClient* client) { |
| 28 DCHECK(!client_); | 30 DCHECK(!client_); |
| 29 client_ = client; | 31 client_ = client; |
| 30 } | 32 } |
| 31 | 33 |
| 32 void BlimpRemoteCompositorBridge::ScheduleMainFrame() { | 34 void BlimpRemoteCompositorBridge::ScheduleMainFrame() { |
| 33 scheduler_.ScheduleFrameUpdate(); | 35 scheduler_.ScheduleFrameUpdate(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 void BlimpRemoteCompositorBridge::ProcessCompositorStateUpdate( | 38 void BlimpRemoteCompositorBridge::ProcessCompositorStateUpdate( |
| 37 std::unique_ptr<cc::CompositorProtoState> compositor_proto_state) { | 39 std::unique_ptr<cc::CompositorProtoState> compositor_proto_state) { |
| 40 compositor_proto_state->compositor_message->set_client_state_update_ack( | |
| 41 client_state_update_ack_pending_); | |
| 42 client_state_update_ack_pending_ = false; | |
| 43 | |
| 38 remote_proto_channel_->SendCompositorProto( | 44 remote_proto_channel_->SendCompositorProto( |
| 39 *compositor_proto_state->compositor_message); | 45 *compositor_proto_state->compositor_message); |
| 40 scheduler_.DidSendFrameUpdateToClient(); | 46 scheduler_.DidSendFrameUpdateToClient(); |
| 41 | 47 |
| 42 // Activate the swap promises after the frame is queued. | 48 // Activate the swap promises after the frame is queued. |
| 43 for (const auto& swap_promise : compositor_proto_state->swap_promises) | 49 for (const auto& swap_promise : compositor_proto_state->swap_promises) |
| 44 swap_promise->DidActivate(); | 50 swap_promise->DidActivate(); |
| 45 } | 51 } |
| 46 | 52 |
| 47 void BlimpRemoteCompositorBridge::OnProtoReceived( | 53 void BlimpRemoteCompositorBridge::OnProtoReceived( |
| 48 std::unique_ptr<cc::proto::CompositorMessage> proto) { | 54 std::unique_ptr<cc::proto::CompositorMessage> proto) { |
| 49 DCHECK(proto->frame_ack()); | 55 if (proto->frame_ack()) |
| 50 scheduler_.DidReceiveFrameUpdateAck(); | 56 scheduler_.DidReceiveFrameUpdateAck(); |
| 57 | |
| 58 if (proto->has_client_state_update()) { | |
| 59 DCHECK(!client_state_update_ack_pending_); | |
| 60 | |
| 61 client_->ApplyStateUpdateFromClient(proto->client_state_update()); | |
| 62 | |
| 63 // If applying the delta resulted in a frame request, run the main frame | |
| 64 // first so the ack sent to the client includes the frame with the deltas | |
| 65 // applied. | |
| 66 if (scheduler_.needs_frame_update()) { | |
| 67 client_state_update_ack_pending_ = true; | |
| 68 } else { | |
| 69 cc::proto::CompositorMessage message; | |
| 70 message.set_client_state_update_ack(true); | |
| 71 remote_proto_channel_->SendCompositorProto(message); | |
| 72 } | |
| 73 } | |
| 51 } | 74 } |
| 52 | 75 |
| 53 void BlimpRemoteCompositorBridge::StartFrameUpdate() { | 76 void BlimpRemoteCompositorBridge::StartFrameUpdate() { |
| 54 client_->BeginMainFrame(); | 77 client_->BeginMainFrame(); |
| 78 | |
| 79 // If the frame resulted in an update to the client, the ack should have gone | |
| 80 // with it. If it is still pending, this means the main frame was aborted so | |
| 81 // send the ack now. | |
| 82 if (client_state_update_ack_pending_) { | |
| 83 client_state_update_ack_pending_ = false; | |
| 84 cc::proto::CompositorMessage message; | |
| 85 message.set_client_state_update_ack(true); | |
| 86 remote_proto_channel_->SendCompositorProto(message); | |
| 87 } | |
| 55 } | 88 } |
| 56 | 89 |
| 57 } // namespace engine | 90 } // namespace engine |
| 58 } // namespace blimp | 91 } // namespace blimp |
| OLD | NEW |