summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorkhushalsagar <khushalsagar@chromium.org>2015-12-07 18:19:01 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-08 02:20:04 +0000
commit19458bd9c403dddf7bfcb08ba106327792fa3a8a (patch)
tree6fa87e204e79a27a09a1c19b463538e40ed6fe6f /cc
parentf48e75b866dfd2d45612ec298ebaf62ea9593120 (diff)
downloadchromium_src-19458bd9c403dddf7bfcb08ba106327792fa3a8a.zip
chromium_src-19458bd9c403dddf7bfcb08ba106327792fa3a8a.tar.gz
chromium_src-19458bd9c403dddf7bfcb08ba106327792fa3a8a.tar.bz2
cc: Introduce CompositorMode enum.
The compositor can currently be run in single threaded or threaded mode. The LayerTreeHost needs to be aware of the mode it is running in for 2 reasons: 1) To safely cast Proxy to SingleThreadProxy to make calls which are supported only in single threaded mode. 2) To make decisions which require excluding browser compositors which run only in single threaded mode. The LayerTreeHost checks if it has the impl task runner to know the mode of operation. Using the enum will make the purpose of this check explicit at the call sites and allow the addition of the remote mode to the compositor which will be run in the renderer but will not have an impl task runner since all impl thread operations will be run on the client compositor. BUG=550687 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1464313007 Cr-Commit-Position: refs/heads/master@{#363708}
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/layers/layer_unittest.cc2
-rw-r--r--cc/layers/texture_layer_unittest.cc2
-rw-r--r--cc/test/fake_layer_tree_host.cc2
-rw-r--r--cc/test/layer_tree_test.cc17
-rw-r--r--cc/trees/compositor_mode.h23
-rw-r--r--cc/trees/layer_tree_host.cc32
-rw-r--r--cc/trees/layer_tree_host.h8
9 files changed, 70 insertions, 18 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 88e3524..df0083a 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -471,6 +471,7 @@ component("cc") {
"trees/blocking_task_runner.h",
"trees/channel_impl.h",
"trees/channel_main.h",
+ "trees/compositor_mode.h",
"trees/damage_tracker.cc",
"trees/damage_tracker.h",
"trees/draw_property_utils.cc",
diff --git a/cc/cc.gyp b/cc/cc.gyp
index e0db087..508ff1c 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -533,6 +533,7 @@
'trees/blocking_task_runner.h',
'trees/channel_impl.h',
'trees/channel_main.h',
+ 'trees/compositor_mode.h',
'trees/damage_tracker.cc',
'trees/damage_tracker.h',
'trees/draw_property_utils.cc',
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index 212dff1..4ac0309 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -47,7 +47,7 @@ class MockLayerTreeHost : public LayerTreeHost {
public:
MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client,
LayerTreeHost::InitParams* params)
- : LayerTreeHost(params) {
+ : LayerTreeHost(params, CompositorMode::SingleThreaded) {
InitializeSingleThreaded(single_thread_client,
base::ThreadTaskRunnerHandle::Get(), nullptr);
}
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index 7c982c8..c7c64b6 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -74,7 +74,7 @@ class MockLayerTreeHost : public LayerTreeHost {
private:
MockLayerTreeHost(FakeLayerTreeHostClient* client,
LayerTreeHost::InitParams* params)
- : LayerTreeHost(params) {
+ : LayerTreeHost(params, CompositorMode::SingleThreaded) {
InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(),
nullptr);
}
diff --git a/cc/test/fake_layer_tree_host.cc b/cc/test/fake_layer_tree_host.cc
index 741a1b4..b2b6a3f 100644
--- a/cc/test/fake_layer_tree_host.cc
+++ b/cc/test/fake_layer_tree_host.cc
@@ -10,7 +10,7 @@
namespace cc {
FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client,
LayerTreeHost::InitParams* params)
- : LayerTreeHost(params),
+ : LayerTreeHost(params, CompositorMode::SingleThreaded),
client_(client),
host_impl_(*params->settings,
&task_runner_provider_,
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index a8241ae..d7f7024 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -678,6 +678,7 @@ class LayerTreeHostForTesting : public LayerTreeHost {
public:
static scoped_ptr<LayerTreeHostForTesting> Create(
TestHooks* test_hooks,
+ CompositorMode mode,
LayerTreeHostClientForTesting* client,
SharedBitmapManager* shared_bitmap_manager,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
@@ -693,11 +694,12 @@ class LayerTreeHostForTesting : public LayerTreeHost {
params.task_graph_runner = task_graph_runner;
params.settings = &settings;
scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
- new LayerTreeHostForTesting(test_hooks, &params));
+ new LayerTreeHostForTesting(test_hooks, &params, mode));
scoped_ptr<TaskRunnerProvider> task_runner_provider =
TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
scoped_ptr<Proxy> proxy;
- if (impl_task_runner.get()) {
+ if (mode == CompositorMode::Threaded) {
+ DCHECK(impl_task_runner.get());
proxy = ThreadProxyForTest::Create(
test_hooks, layer_tree_host.get(), task_runner_provider.get(),
std::move(external_begin_frame_source));
@@ -735,8 +737,11 @@ class LayerTreeHostForTesting : public LayerTreeHost {
private:
LayerTreeHostForTesting(TestHooks* test_hooks,
- LayerTreeHost::InitParams* params)
- : LayerTreeHost(params), test_hooks_(test_hooks), test_started_(false) {}
+ LayerTreeHost::InitParams* params,
+ CompositorMode mode)
+ : LayerTreeHost(params, mode),
+ test_hooks_(test_hooks),
+ test_started_(false) {}
TestHooks* test_hooks_;
bool test_started_;
@@ -915,8 +920,10 @@ void LayerTreeTest::DoBeginTest() {
}
DCHECK(!impl_thread_ || impl_thread_->task_runner().get());
+ CompositorMode mode =
+ impl_thread_ ? CompositorMode::Threaded : CompositorMode::SingleThreaded;
layer_tree_host_ = LayerTreeHostForTesting::Create(
- this, client_.get(), shared_bitmap_manager_.get(),
+ this, mode, client_.get(), shared_bitmap_manager_.get(),
gpu_memory_buffer_manager_.get(), task_graph_runner_.get(), settings_,
base::ThreadTaskRunnerHandle::Get(),
impl_thread_ ? impl_thread_->task_runner() : NULL,
diff --git a/cc/trees/compositor_mode.h b/cc/trees/compositor_mode.h
new file mode 100644
index 0000000..6494419
--- /dev/null
+++ b/cc/trees/compositor_mode.h
@@ -0,0 +1,23 @@
+// 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.
+
+#ifndef CC_TREES_COMPOSITOR_MODE_H_
+#define CC_TREES_COMPOSITOR_MODE_H_
+
+namespace cc {
+
+// The LayerTreeHost uses the CompositorMode to determine the current mode of
+// operation, which is needed to:
+// 1) Safely cast Proxy to SingleThreadProxy to allow operations only supported
+// in SingleThreaded mode.
+// 2) Make decisions restricted to either browser(SingleThreaded) or renderer
+// compositors(Threaded).
+enum CompositorMode {
+ SingleThreaded,
+ Threaded,
+};
+
+} // namespace cc
+
+#endif // CC_TREES_COMPOSITOR_MODE_H_
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index a62b978..b5f0231 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -66,7 +66,8 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded(
DCHECK(params->main_task_runner.get());
DCHECK(impl_task_runner.get());
DCHECK(params->settings);
- scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(params));
+ scoped_ptr<LayerTreeHost> layer_tree_host(
+ new LayerTreeHost(params, CompositorMode::Threaded));
layer_tree_host->InitializeThreaded(
params->main_task_runner, impl_task_runner,
std::move(params->external_begin_frame_source));
@@ -77,16 +78,18 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded(
LayerTreeHostSingleThreadClient* single_thread_client,
InitParams* params) {
DCHECK(params->settings);
- scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(params));
+ scoped_ptr<LayerTreeHost> layer_tree_host(
+ new LayerTreeHost(params, CompositorMode::SingleThreaded));
layer_tree_host->InitializeSingleThreaded(
single_thread_client, params->main_task_runner,
std::move(params->external_begin_frame_source));
return layer_tree_host;
}
-LayerTreeHost::LayerTreeHost(InitParams* params)
+LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode)
: micro_benchmark_controller_(this),
next_ui_resource_id_(1),
+ compositor_mode_(mode),
needs_full_tree_sync_(true),
needs_meta_info_recomputation_(true),
client_(params->client),
@@ -674,7 +677,7 @@ void LayerTreeHost::NotifyInputThrottledUntilCommit() {
}
void LayerTreeHost::LayoutAndUpdateLayers() {
- DCHECK(!task_runner_provider_->HasImplThread());
+ DCHECK(IsSingleThreaded());
// This function is only valid when not using the scheduler.
DCHECK(!settings_.single_thread_proxy_scheduler);
SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
@@ -692,7 +695,7 @@ void LayerTreeHost::LayoutAndUpdateLayers() {
}
void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
- DCHECK(!task_runner_provider_->HasImplThread());
+ DCHECK(IsSingleThreaded());
// This function is only valid when not using the scheduler.
DCHECK(!settings_.single_thread_proxy_scheduler);
SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
@@ -732,9 +735,8 @@ static Layer* FindFirstScrollableLayer(Layer* layer) {
void LayerTreeHost::RecordGpuRasterizationHistogram() {
// Gpu rasterization is only supported for Renderer compositors.
- // Checking for proxy_->HasImplThread() to exclude Browser compositors.
- if (gpu_rasterization_histogram_recorded_ ||
- !task_runner_provider_->HasImplThread())
+ // Checking for IsThreaded() to exclude Browser compositors.
+ if (gpu_rasterization_histogram_recorded_ || IsThreaded())
return;
// Record how widely gpu rasterization is enabled.
@@ -896,7 +898,7 @@ void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints,
TopControlsState current,
bool animate) {
// Top controls are only used in threaded mode.
- DCHECK(task_runner_provider_->HasImplThread());
+ DCHECK(IsThreaded());
proxy_->UpdateTopControlsState(constraints, current, animate);
}
@@ -1247,4 +1249,16 @@ bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const {
: false;
}
+bool LayerTreeHost::IsSingleThreaded() const {
+ DCHECK(compositor_mode_ != CompositorMode::SingleThreaded ||
+ !task_runner_provider_->HasImplThread());
+ return compositor_mode_ == CompositorMode::SingleThreaded;
+}
+
+bool LayerTreeHost::IsThreaded() const {
+ DCHECK(compositor_mode_ != CompositorMode::Threaded ||
+ task_runner_provider_->HasImplThread());
+ return compositor_mode_ == CompositorMode::Threaded;
+}
+
} // namespace cc
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index 9c8e1ec..3bfd73c 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -33,6 +33,7 @@
#include "cc/resources/resource_format.h"
#include "cc/resources/scoped_ui_resource.h"
#include "cc/surfaces/surface_sequence.h"
+#include "cc/trees/compositor_mode.h"
#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_settings.h"
@@ -359,7 +360,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
bool HasActiveAnimation(const Layer* layer) const;
protected:
- explicit LayerTreeHost(InitParams* params);
+ LayerTreeHost(InitParams* params, CompositorMode mode);
void InitializeThreaded(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
@@ -397,6 +398,9 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
bool AnimateLayersRecursive(Layer* current, base::TimeTicks time);
+ bool IsSingleThreaded() const;
+ bool IsThreaded() const;
+
struct UIResourceClientData {
UIResourceClient* client;
gfx::Size size;
@@ -417,6 +421,8 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
void SetPropertyTreesNeedRebuild();
+ const CompositorMode compositor_mode_;
+
bool needs_full_tree_sync_;
bool needs_meta_info_recomputation_;