OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "blimp/engine/renderer/blimp_remote_compositor_bridge.h" |
| 6 |
| 7 #include "cc/blimp/compositor_proto_state.h" |
| 8 #include "cc/blimp/remote_compositor_bridge_client.h" |
| 9 #include "cc/output/swap_promise.h" |
| 10 #include "cc/proto/compositor_message.pb.h" |
| 11 |
| 12 namespace blimp { |
| 13 namespace engine { |
| 14 |
| 15 BlimpRemoteCompositorBridge::BlimpRemoteCompositorBridge( |
| 16 cc::RemoteProtoChannel* remote_proto_channel, |
| 17 scoped_refptr<base::SingleThreadTaskRunner> compositor_main_task_runner) |
| 18 : RemoteCompositorBridge(std::move(compositor_main_task_runner)), |
| 19 remote_proto_channel_(remote_proto_channel), |
| 20 scheduler_(compositor_main_task_runner_.get(), this) { |
| 21 remote_proto_channel_->SetProtoReceiver(this); |
| 22 } |
| 23 |
| 24 BlimpRemoteCompositorBridge::~BlimpRemoteCompositorBridge() = default; |
| 25 |
| 26 void BlimpRemoteCompositorBridge::BindToClient( |
| 27 cc::RemoteCompositorBridgeClient* client) { |
| 28 DCHECK(!client_); |
| 29 client_ = client; |
| 30 } |
| 31 |
| 32 void BlimpRemoteCompositorBridge::ScheduleMainFrame() { |
| 33 scheduler_.ScheduleFrameUpdate(); |
| 34 } |
| 35 |
| 36 void BlimpRemoteCompositorBridge::ProcessCompositorStateUpdate( |
| 37 std::unique_ptr<cc::CompositorProtoState> compositor_proto_state) { |
| 38 remote_proto_channel_->SendCompositorProto( |
| 39 *compositor_proto_state->compositor_message); |
| 40 scheduler_.DidSendFrameUpdateToClient(); |
| 41 |
| 42 // Activate the swap promises after the frame is queued. |
| 43 for (const auto& swap_promise : compositor_proto_state->swap_promises) |
| 44 swap_promise->DidActivate(); |
| 45 } |
| 46 |
| 47 void BlimpRemoteCompositorBridge::OnProtoReceived( |
| 48 std::unique_ptr<cc::proto::CompositorMessage> proto) { |
| 49 DCHECK(proto->frame_ack()); |
| 50 scheduler_.DidReceiveFrameUpdateAck(); |
| 51 } |
| 52 |
| 53 void BlimpRemoteCompositorBridge::StartFrameUpdate() { |
| 54 client_->BeginMainFrame(); |
| 55 } |
| 56 |
| 57 } // namespace engine |
| 58 } // namespace blimp |
OLD | NEW |