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 "cc/trees/remote_channel_main.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "cc/proto/compositor_message.pb.h" |
| 9 #include "cc/proto/compositor_message_to_impl.pb.h" |
| 10 #include "cc/proto/compositor_message_to_main.pb.h" |
| 11 #include "cc/trees/layer_tree_host.h" |
| 12 |
| 13 namespace cc { |
| 14 |
| 15 scoped_ptr<RemoteChannelMain> RemoteChannelMain::Create( |
| 16 RemoteProtoChannel* remote_proto_channel, |
| 17 ProxyMain* proxy_main, |
| 18 TaskRunnerProvider* task_runner_provider) { |
| 19 return make_scoped_ptr(new RemoteChannelMain(remote_proto_channel, proxy_main, |
| 20 task_runner_provider)); |
| 21 } |
| 22 |
| 23 RemoteChannelMain::RemoteChannelMain(RemoteProtoChannel* remote_proto_channel, |
| 24 ProxyMain* proxy_main, |
| 25 TaskRunnerProvider* task_runner_provider) |
| 26 : remote_proto_channel_(remote_proto_channel), |
| 27 proxy_main_(proxy_main), |
| 28 task_runner_provider_(task_runner_provider), |
| 29 initialized_(false) { |
| 30 DCHECK(remote_proto_channel_); |
| 31 DCHECK(proxy_main_); |
| 32 DCHECK(task_runner_provider_); |
| 33 DCHECK(task_runner_provider_->IsMainThread()); |
| 34 remote_proto_channel_->SetProtoReceiver(this); |
| 35 } |
| 36 |
| 37 RemoteChannelMain::~RemoteChannelMain() { |
| 38 DCHECK(task_runner_provider_->IsMainThread()); |
| 39 DCHECK(!initialized_); |
| 40 |
| 41 remote_proto_channel_->SetProtoReceiver(nullptr); |
| 42 } |
| 43 |
| 44 void RemoteChannelMain::OnProtoReceived( |
| 45 scoped_ptr<proto::CompositorMessage> proto) {} |
| 46 |
| 47 void RemoteChannelMain::SetThrottleFrameProductionOnImpl(bool throttle) {} |
| 48 |
| 49 void RemoteChannelMain::UpdateTopControlsStateOnImpl( |
| 50 TopControlsState constraints, |
| 51 TopControlsState current, |
| 52 bool animate) {} |
| 53 |
| 54 void RemoteChannelMain::InitializeOutputSurfaceOnImpl( |
| 55 OutputSurface* output_surface) {} |
| 56 |
| 57 void RemoteChannelMain::MainThreadHasStoppedFlingingOnImpl() { |
| 58 proto::CompositorMessage proto; |
| 59 proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl(); |
| 60 to_impl_proto->set_message_type( |
| 61 proto::CompositorMessageToImpl::MAIN_THREAD_HAS_STOPPED_FLINGING_ON_IMPL); |
| 62 |
| 63 SendMessageProto(proto); |
| 64 } |
| 65 |
| 66 void RemoteChannelMain::SetInputThrottledUntilCommitOnImpl(bool is_throttled) {} |
| 67 |
| 68 void RemoteChannelMain::SetDeferCommitsOnImpl(bool defer_commits) {} |
| 69 |
| 70 void RemoteChannelMain::FinishAllRenderingOnImpl(CompletionEvent* completion) { |
| 71 completion->Signal(); |
| 72 } |
| 73 |
| 74 void RemoteChannelMain::SetVisibleOnImpl(bool visible) {} |
| 75 |
| 76 void RemoteChannelMain::ReleaseOutputSurfaceOnImpl( |
| 77 CompletionEvent* completion) { |
| 78 completion->Signal(); |
| 79 } |
| 80 |
| 81 void RemoteChannelMain::MainFrameWillHappenOnImplForTesting( |
| 82 CompletionEvent* completion, |
| 83 bool* main_frame_will_happen) { |
| 84 // For the LayerTreeTests in remote mode, LayerTreeTest directly calls |
| 85 // RemoteChannelImpl::MainFrameWillHappenForTesting and avoids adding a |
| 86 // message type for tests to the compositor protocol. |
| 87 NOTREACHED(); |
| 88 } |
| 89 |
| 90 void RemoteChannelMain::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {} |
| 91 |
| 92 void RemoteChannelMain::SetNeedsCommitOnImpl() {} |
| 93 |
| 94 void RemoteChannelMain::BeginMainFrameAbortedOnImpl( |
| 95 CommitEarlyOutReason reason, |
| 96 base::TimeTicks main_thread_start_time) {} |
| 97 |
| 98 void RemoteChannelMain::StartCommitOnImpl( |
| 99 CompletionEvent* completion, |
| 100 LayerTreeHost* layer_tree_host, |
| 101 base::TimeTicks main_thread_start_time, |
| 102 bool hold_commit_for_activation) { |
| 103 completion->Signal(); |
| 104 } |
| 105 |
| 106 void RemoteChannelMain::SynchronouslyInitializeImpl( |
| 107 LayerTreeHost* layer_tree_host, |
| 108 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| 109 DCHECK(!initialized_); |
| 110 |
| 111 proto::CompositorMessage proto; |
| 112 proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl(); |
| 113 to_impl_proto->set_message_type( |
| 114 proto::CompositorMessageToImpl::INITIALIZE_IMPL); |
| 115 proto::InitializeImpl* initialize_impl_proto = |
| 116 to_impl_proto->mutable_initialize_impl_message(); |
| 117 proto::LayerTreeSettings* settings_proto = |
| 118 initialize_impl_proto->mutable_layer_tree_settings(); |
| 119 layer_tree_host->settings().ToProtobuf(settings_proto); |
| 120 |
| 121 SendMessageProto(proto); |
| 122 initialized_ = true; |
| 123 } |
| 124 |
| 125 void RemoteChannelMain::SynchronouslyCloseImpl() { |
| 126 DCHECK(initialized_); |
| 127 proto::CompositorMessage proto; |
| 128 proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl(); |
| 129 to_impl_proto->set_message_type(proto::CompositorMessageToImpl::CLOSE_IMPL); |
| 130 |
| 131 SendMessageProto(proto); |
| 132 initialized_ = false; |
| 133 } |
| 134 |
| 135 void RemoteChannelMain::SendMessageProto( |
| 136 const proto::CompositorMessage& proto) { |
| 137 remote_proto_channel_->SendCompositorProto(proto); |
| 138 } |
| 139 |
| 140 } // namespace cc |
OLD | NEW |