summaryrefslogtreecommitdiffstats
path: root/cc/test/layer_tree_test.cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-07 05:01:32 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-07 05:01:32 +0000
commit943528e092b0a1c242c75af60c7b08385908e954 (patch)
tree02904b3b722389bbe339cfd4a892c57a65016fbd /cc/test/layer_tree_test.cc
parent341acce17f767566e8602902055a29996e85ff64 (diff)
downloadchromium_src-943528e092b0a1c242c75af60c7b08385908e954.zip
chromium_src-943528e092b0a1c242c75af60c7b08385908e954.tar.gz
chromium_src-943528e092b0a1c242c75af60c7b08385908e954.tar.bz2
Introduce separate client and init path for single-threaded cc
The chromium compositor can be used in either a single-threaded fashion or multi-threaded. The requirements, APIs and responsibilities of the embedder are different for these two modes. Some users of cc only use one path or the other. This adds a separate client interface and initialization path for code that only uses the single threaded path. Having a dedicated client for the single threaded path will make it possible to get rid of the WebGraphicsContext3DSwapBuffersClient which will then make it easier to break cc's dependency on WGC3D. R=piman BUG=181120 Review URL: https://codereview.chromium.org/61823008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/layer_tree_test.cc')
-rw-r--r--cc/test/layer_tree_test.cc110
1 files changed, 60 insertions, 50 deletions
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 79b3445..292f7bb 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -20,7 +20,9 @@
#include "cc/test/occlusion_tracker_test_common.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/tiled_layer_test_common.h"
+#include "cc/trees/layer_tree_host_client.h"
#include "cc/trees/layer_tree_host_impl.h"
+#include "cc/trees/layer_tree_host_single_thread_client.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/frame_time.h"
@@ -194,57 +196,9 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
bool notify_ready_to_activate_was_blocked_;
};
-// Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
-class LayerTreeHostForTesting : public LayerTreeHost {
- public:
- static scoped_ptr<LayerTreeHostForTesting> Create(
- TestHooks* test_hooks,
- LayerTreeHostClient* host_client,
- const LayerTreeSettings& settings,
- scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
- scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
- new LayerTreeHostForTesting(test_hooks, host_client, settings));
- bool success = layer_tree_host->Initialize(impl_task_runner);
- EXPECT_TRUE(success);
- return layer_tree_host.Pass();
- }
-
- virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
- LayerTreeHostImplClient* host_impl_client) OVERRIDE {
- return LayerTreeHostImplForTesting::Create(
- test_hooks_,
- settings(),
- host_impl_client,
- proxy(),
- rendering_stats_instrumentation()).PassAs<LayerTreeHostImpl>();
- }
-
- virtual void SetNeedsCommit() OVERRIDE {
- if (!test_started_)
- return;
- LayerTreeHost::SetNeedsCommit();
- }
-
- void set_test_started(bool started) { test_started_ = started; }
-
- virtual void DidDeferCommit() OVERRIDE {
- test_hooks_->DidDeferCommit();
- }
-
- private:
- LayerTreeHostForTesting(TestHooks* test_hooks,
- LayerTreeHostClient* client,
- const LayerTreeSettings& settings)
- : LayerTreeHost(client, NULL, settings),
- test_hooks_(test_hooks),
- test_started_(false) {}
-
- TestHooks* test_hooks_;
- bool test_started_;
-};
-
// Implementation of LayerTreeHost callback interface.
-class LayerTreeHostClientForTesting : public LayerTreeHostClient {
+class LayerTreeHostClientForTesting : public LayerTreeHostClient,
+ public LayerTreeHostSingleThreadClient {
public:
static scoped_ptr<LayerTreeHostClientForTesting> Create(
TestHooks* test_hooks) {
@@ -305,6 +259,9 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient {
test_hooks_->ScheduleComposite();
}
+ virtual void DidPostSwapBuffers() OVERRIDE {}
+ virtual void DidAbortSwapBuffers() OVERRIDE {}
+
virtual scoped_refptr<ContextProvider> OffscreenContextProvider() OVERRIDE {
return test_hooks_->OffscreenContextProvider();
}
@@ -316,6 +273,59 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient {
TestHooks* test_hooks_;
};
+// Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
+class LayerTreeHostForTesting : public LayerTreeHost {
+ public:
+ static scoped_ptr<LayerTreeHostForTesting> Create(
+ TestHooks* test_hooks,
+ LayerTreeHostClientForTesting* client,
+ const LayerTreeSettings& settings,
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
+ scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
+ new LayerTreeHostForTesting(test_hooks, client, settings));
+ bool success;
+ if (impl_task_runner.get())
+ success = layer_tree_host->InitializeThreaded(impl_task_runner);
+ else
+ success = layer_tree_host->InitializeSingleThreaded(client);
+ EXPECT_TRUE(success);
+ return layer_tree_host.Pass();
+ }
+
+ virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
+ LayerTreeHostImplClient* host_impl_client) OVERRIDE {
+ return LayerTreeHostImplForTesting::Create(
+ test_hooks_,
+ settings(),
+ host_impl_client,
+ proxy(),
+ rendering_stats_instrumentation()).PassAs<LayerTreeHostImpl>();
+ }
+
+ virtual void SetNeedsCommit() OVERRIDE {
+ if (!test_started_)
+ return;
+ LayerTreeHost::SetNeedsCommit();
+ }
+
+ void set_test_started(bool started) { test_started_ = started; }
+
+ virtual void DidDeferCommit() OVERRIDE {
+ test_hooks_->DidDeferCommit();
+ }
+
+ private:
+ LayerTreeHostForTesting(TestHooks* test_hooks,
+ LayerTreeHostClient* client,
+ const LayerTreeSettings& settings)
+ : LayerTreeHost(client, NULL, settings),
+ test_hooks_(test_hooks),
+ test_started_(false) {}
+
+ TestHooks* test_hooks_;
+ bool test_started_;
+};
+
LayerTreeTest::LayerTreeTest()
: beginning_(false),
end_when_begin_returns_(false),