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

Unified Diff: cc/trees/layer_tree_host.cc

Issue 1513643010: cc:: Add remote mode to the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresed comments. Created 4 years, 11 months 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/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 70740935217a4482d62abd598cb54e879017a7d4..5a0c720c5c3ecf786c22c0ee6d493d096f595008 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -46,6 +46,7 @@
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/proxy_main.h"
+#include "cc/trees/remote_channel_impl.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/tree_synchronizer.h"
#include "ui/gfx/geometry/size_conversions.h"
@@ -89,6 +90,45 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded(
return layer_tree_host;
}
+scoped_ptr<LayerTreeHost> LayerTreeHost::CreateRemoteServer(
+ RemoteProtoChannel* remote_proto_channel,
+ InitParams* params) {
+ DCHECK(params->main_task_runner.get());
+ DCHECK(params->settings);
+ DCHECK(remote_proto_channel);
+
+ // Using an external begin frame source is not supported in remote mode.
vmpstr 2016/01/11 21:50:15 ... in remote server mode.
Khushal 2016/01/13 02:07:12 Done.
+ DCHECK(!params->settings->use_external_begin_frame_source);
+ DCHECK(!params->external_begin_frame_source);
+
+ scoped_ptr<LayerTreeHost> layer_tree_host(
+ new LayerTreeHost(params, CompositorMode::Remote));
+ layer_tree_host->InitializeRemoteServer(remote_proto_channel,
+ params->main_task_runner);
+ return layer_tree_host;
+}
+
+scoped_ptr<LayerTreeHost> LayerTreeHost::CreateRemoteClient(
+ RemoteProtoChannel* remote_proto_channel,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
+ InitParams* params) {
+ DCHECK(params->main_task_runner.get());
+ DCHECK(params->settings);
+ DCHECK(remote_proto_channel);
+
+ // Using an external begin frame source is not supported in remote mode.
+ // TODO(khushalsagar): Add support for providing an external begin frame
vmpstr 2016/01/11 21:50:15 File a bug for this and reference it in here, plea
Khushal 2016/01/13 02:07:12 Done.
+ // source on the client LayerTreeHost.
+ DCHECK(!params->settings->use_external_begin_frame_source);
+ DCHECK(!params->external_begin_frame_source);
+
+ scoped_ptr<LayerTreeHost> layer_tree_host(
+ new LayerTreeHost(params, CompositorMode::Remote));
+ layer_tree_host->InitializeRemoteClient(
+ remote_proto_channel, params->main_task_runner, impl_task_runner);
+ return layer_tree_host;
+}
+
LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode)
: micro_benchmark_controller_(this),
next_ui_resource_id_(1),
@@ -162,6 +202,26 @@ void LayerTreeHost::InitializeSingleThreaded(
std::move(external_begin_frame_source));
}
+void LayerTreeHost::InitializeRemoteServer(
+ RemoteProtoChannel* remote_proto_channel,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) {
+ task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr);
+ InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this,
+ task_runner_provider_.get()),
+ nullptr);
+}
+
+void LayerTreeHost::InitializeRemoteClient(
+ RemoteProtoChannel* remote_proto_channel,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
+ task_runner_provider_ =
+ TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
+ InitializeProxy(RemoteChannelImpl::Create(this, remote_proto_channel,
vmpstr 2016/01/11 21:50:15 I think it's worth putting a comment here to kind
Khushal 2016/01/13 02:07:12 Done.
+ task_runner_provider_.get()),
+ nullptr);
+}
+
void LayerTreeHost::InitializeForTesting(
scoped_ptr<TaskRunnerProvider> task_runner_provider,
scoped_ptr<Proxy> proxy_for_testing,
@@ -181,6 +241,7 @@ void LayerTreeHost::InitializeProxy(
scoped_ptr<Proxy> proxy,
scoped_ptr<BeginFrameSource> external_begin_frame_source) {
TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
+ DCHECK(task_runner_provider_);
proxy_ = std::move(proxy);
proxy_->Start(std::move(external_begin_frame_source));
@@ -226,6 +287,20 @@ LayerTreeHost::~LayerTreeHost() {
}
}
+void LayerTreeHost::ToProtobuf() {
+ DCHECK(task_runner_provider_->IsMainThread());
+ DCHECK(IsRemoteServer());
+
+ // TODO(khushalsagar, nyquist): Serialize LayerTreeHost state to proto.
vmpstr 2016/01/11 21:50:15 crbug?
Khushal 2016/01/13 02:07:12 Removed.
+}
+
+void LayerTreeHost::FromProtobuf() {
+ DCHECK(task_runner_provider_->IsMainThread());
+ DCHECK(IsRemoteClient());
+
+ // TODO(khushalsagar, nyquist): Deserialize LayerTreeHost state from proto.
vmpstr 2016/01/11 21:50:15 crbug?
Khushal 2016/01/13 02:07:12 Removed.
+}
+
void LayerTreeHost::WillBeginMainFrame() {
devtools_instrumentation::WillBeginMainThreadFrame(id(),
source_frame_number());
@@ -258,6 +333,7 @@ void LayerTreeHost::RequestMainFrameUpdate() {
// should be delayed until the LayerTreeHost::CommitComplete, which will run
// after the commit, but on the main thread.
void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
+ DCHECK(!IsRemoteServer());
DCHECK(task_runner_provider_->IsImplThread());
bool is_new_trace;
@@ -443,6 +519,7 @@ void LayerTreeHost::DidFailToInitializeOutputSurface() {
scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl(
LayerTreeHostImplClient* client) {
+ DCHECK(!IsRemoteServer());
DCHECK(task_runner_provider_->IsImplThread());
scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
settings_, client, task_runner_provider_.get(),
@@ -912,8 +989,8 @@ void LayerTreeHost::SetPaintedDeviceScaleFactor(
void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints,
TopControlsState current,
bool animate) {
- // Top controls are only used in threaded mode.
- DCHECK(IsThreaded());
+ // Top controls are only used in threaded or remote mode.
+ DCHECK(IsThreaded() || IsRemoteServer());
proxy_->UpdateTopControlsState(constraints, current, animate);
}
@@ -1276,4 +1353,15 @@ bool LayerTreeHost::IsThreaded() const {
return compositor_mode_ == CompositorMode::Threaded;
}
+bool LayerTreeHost::IsRemoteServer() const {
+ // The LayerTreeHost on the server does not have an impl task runner.
+ return compositor_mode_ == CompositorMode::Remote &&
+ !task_runner_provider_->HasImplThread();
+}
+
+bool LayerTreeHost::IsRemoteClient() const {
+ return compositor_mode_ == CompositorMode::Remote &&
+ task_runner_provider_->HasImplThread();
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698