Chromium Code Reviews| 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 DCHECK(remote_proto_channel_); | |
|
Wez
2016/10/19 22:15:27
nit: No need to DCHECK if you're about to de-ref.
Khushal
2016/10/20 01:29:33
Done.
| |
| 22 remote_proto_channel_->SetProtoReceiver(this); | |
| 23 } | |
| 24 | |
| 25 BlimpRemoteCompositorBridge::~BlimpRemoteCompositorBridge() = default; | |
| 26 | |
| 27 void BlimpRemoteCompositorBridge::BindToClient( | |
| 28 cc::RemoteCompositorBridgeClient* client) { | |
| 29 DCHECK(!client_); | |
| 30 client_ = client; | |
| 31 } | |
| 32 | |
| 33 void BlimpRemoteCompositorBridge::ScheduleMainFrame() { | |
| 34 scheduler_.SetNeedsFrameUpdate(); | |
| 35 } | |
| 36 | |
| 37 void BlimpRemoteCompositorBridge::ProcessCompositorStateUpdate( | |
| 38 std::unique_ptr<cc::CompositorProtoState> compositor_proto_state) { | |
| 39 remote_proto_channel_->SendCompositorProto( | |
| 40 *compositor_proto_state->compositor_message); | |
| 41 scheduler_.DidSendFrameUpdateToClient(); | |
| 42 | |
| 43 // Activate the swap promises after the frame is queued. | |
| 44 for (const auto& swap_promise : compositor_proto_state->swap_promises) | |
| 45 swap_promise->DidActivate(); | |
| 46 } | |
| 47 | |
| 48 void BlimpRemoteCompositorBridge::OnProtoReceived( | |
| 49 std::unique_ptr<cc::proto::CompositorMessage> proto) { | |
| 50 DCHECK(proto->frame_ack()); | |
| 51 scheduler_.DidReceiveFrameUpdateAck(); | |
| 52 } | |
| 53 | |
| 54 void BlimpRemoteCompositorBridge::StartFrameUpdate() { | |
| 55 client_->BeginMainFrame(); | |
| 56 } | |
| 57 | |
| 58 } // namespace engine | |
| 59 } // namespace blimp | |
| OLD | NEW |