Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Unified Diff: cc/trees/remote_channel_main.cc

Issue 1513643010: cc:: Add remote mode to the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use LayerTreeSettings::ToProtobuf, update comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/remote_channel_main.cc
diff --git a/cc/trees/remote_channel_main.cc b/cc/trees/remote_channel_main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dbd21f391cd9fbc371a3aaefddc79abfe7baadd2
--- /dev/null
+++ b/cc/trees/remote_channel_main.cc
@@ -0,0 +1,140 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/trees/remote_channel_main.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "cc/proto/compositor_message.pb.h"
+#include "cc/proto/compositor_message_to_impl.pb.h"
+#include "cc/proto/compositor_message_to_main.pb.h"
+#include "cc/trees/layer_tree_host.h"
+
+namespace cc {
+
+scoped_ptr<RemoteChannelMain> RemoteChannelMain::Create(
+ RemoteProtoChannel* remote_proto_channel,
+ ProxyMain* proxy_main,
+ TaskRunnerProvider* task_runner_provider) {
+ return make_scoped_ptr(new RemoteChannelMain(remote_proto_channel, proxy_main,
+ task_runner_provider));
+}
+
+RemoteChannelMain::RemoteChannelMain(RemoteProtoChannel* remote_proto_channel,
+ ProxyMain* proxy_main,
+ TaskRunnerProvider* task_runner_provider)
+ : remote_proto_channel_(remote_proto_channel),
+ proxy_main_(proxy_main),
+ task_runner_provider_(task_runner_provider),
+ initialized_(false) {
+ DCHECK(remote_proto_channel_);
+ DCHECK(proxy_main_);
+ DCHECK(task_runner_provider_);
+ DCHECK(task_runner_provider_->IsMainThread());
+ remote_proto_channel_->SetProtoReceiver(this);
+}
+
+RemoteChannelMain::~RemoteChannelMain() {
+ DCHECK(task_runner_provider_->IsMainThread());
+ DCHECK(!initialized_);
+
+ remote_proto_channel_->SetProtoReceiver(nullptr);
+}
+
+void RemoteChannelMain::OnProtoReceived(
+ scoped_ptr<proto::CompositorMessage> proto) {}
+
+void RemoteChannelMain::SetThrottleFrameProductionOnImpl(bool throttle) {}
+
+void RemoteChannelMain::UpdateTopControlsStateOnImpl(
+ TopControlsState constraints,
+ TopControlsState current,
+ bool animate) {}
+
+void RemoteChannelMain::InitializeOutputSurfaceOnImpl(
+ OutputSurface* output_surface) {}
+
+void RemoteChannelMain::MainThreadHasStoppedFlingingOnImpl() {
+ proto::CompositorMessage proto;
+ proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl();
+ to_impl_proto->set_message_type(
+ proto::CompositorMessageToImpl::MainThreadHasStoppedFlingingOnImpl);
+
+ SendMessageProto(proto);
+}
+
+void RemoteChannelMain::SetInputThrottledUntilCommitOnImpl(bool is_throttled) {}
+
+void RemoteChannelMain::SetDeferCommitsOnImpl(bool defer_commits) {}
+
+void RemoteChannelMain::FinishAllRenderingOnImpl(CompletionEvent* completion) {
+ completion->Signal();
+}
+
+void RemoteChannelMain::SetVisibleOnImpl(bool visible) {}
+
+void RemoteChannelMain::ReleaseOutputSurfaceOnImpl(
+ CompletionEvent* completion) {
+ completion->Signal();
+}
+
+void RemoteChannelMain::MainFrameWillHappenOnImplForTesting(
+ CompletionEvent* completion,
+ bool* main_frame_will_happen) {
+ // For the LayerTreeTests in remote mode, LayerTreeTest directly calls
+ // RemoteChannelImpl::MainFrameWillHappenForTesting and avoids adding a
+ // message type for tests to the compositor protocol.
+ NOTREACHED();
+}
+
+void RemoteChannelMain::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {}
+
+void RemoteChannelMain::SetNeedsCommitOnImpl() {}
+
+void RemoteChannelMain::BeginMainFrameAbortedOnImpl(
+ CommitEarlyOutReason reason,
+ base::TimeTicks main_thread_start_time) {}
+
+void RemoteChannelMain::StartCommitOnImpl(
+ CompletionEvent* completion,
+ LayerTreeHost* layer_tree_host,
+ base::TimeTicks main_thread_start_time,
+ bool hold_commit_for_activation) {
+ completion->Signal();
+}
+
+void RemoteChannelMain::SynchronouslyInitializeImpl(
+ LayerTreeHost* layer_tree_host,
+ scoped_ptr<BeginFrameSource> external_begin_frame_source) {
+ DCHECK(!initialized_);
+
+ proto::CompositorMessage proto;
+ proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl();
+ to_impl_proto->set_message_type(
+ proto::CompositorMessageToImpl::InitializeImpl);
+ proto::InitializeImpl* initialize_impl_proto =
+ to_impl_proto->mutable_initialize_impl_message();
+ proto::LayerTreeSettings* settings_proto =
+ initialize_impl_proto->mutable_layer_tree_settings();
+ layer_tree_host->settings().ToProtobuf(settings_proto);
+
+ SendMessageProto(proto);
+ initialized_ = true;
+}
+
+void RemoteChannelMain::SynchronouslyCloseImpl() {
+ DCHECK(initialized_);
+ proto::CompositorMessage proto;
+ proto::CompositorMessageToImpl* to_impl_proto = proto.mutable_to_impl();
+ to_impl_proto->set_message_type(proto::CompositorMessageToImpl::CloseImpl);
+
+ SendMessageProto(proto);
+ initialized_ = false;
+}
+
+void RemoteChannelMain::SendMessageProto(
+ const proto::CompositorMessage& proto) {
+ remote_proto_channel_->SendCompositorProto(proto);
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698