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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 348093004: Make cc output surface creation async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sievers review Created 6 years, 6 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_unittest_context.cc
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 548ff36029ec9d518bb8765b9cfe31e2475b6158..27234e6746160a5aecddeef030173485fa53a455 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -60,7 +60,8 @@ class LayerTreeHostContextTest : public LayerTreeTest {
times_create_failed_(0),
committed_at_least_once_(false),
context_should_support_io_surface_(false),
- fallback_context_works_(false) {
+ fallback_context_works_(false),
+ async_output_surface_creation_(false) {
media::InitializeMediaLibraryForTesting();
}
@@ -150,6 +151,7 @@ class LayerTreeHostContextTest : public LayerTreeTest {
bool committed_at_least_once_;
bool context_should_support_io_surface_;
bool fallback_context_works_;
+ bool async_output_surface_creation_;
};
class LayerTreeHostContextTestLostContextSucceeds
@@ -165,6 +167,24 @@ class LayerTreeHostContextTestLostContextSucceeds
virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
+ virtual void RequestNewOutputSurface(bool fallback) OVERRIDE {
+ if (async_output_surface_creation_) {
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeHostContextTestLostContextSucceeds::
+ CreateAndSetOutputSurface,
+ base::Unretained(this),
+ fallback));
+ } else {
+ CreateAndSetOutputSurface(fallback);
+ }
+ }
+
+ void CreateAndSetOutputSurface(bool fallback) {
+ layer_tree_host()->SetOutputSurface(
+ LayerTreeHostContextTest::CreateOutputSurface(fallback));
+ }
+
virtual void DidInitializeOutputSurface() OVERRIDE {
if (first_initialized_)
++num_losses_;
@@ -174,7 +194,7 @@ class LayerTreeHostContextTestLostContextSucceeds
recovered_context_ = true;
}
- virtual void AfterTest() OVERRIDE { EXPECT_EQ(7u, test_case_); }
+ virtual void AfterTest() OVERRIDE { EXPECT_EQ(11u, test_case_); }
virtual void DidCommitAndDrawFrame() OVERRIDE {
// If the last frame had a context loss, then we'll commit again to
@@ -208,24 +228,35 @@ class LayerTreeHostContextTestLostContextSucceeds
0, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
+ false, // async_output_surface_creation
},
{
0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
+ false, // async_output_surface_creation
},
{
1, // times_to_lose_during_commit
0, // times_to_lose_during_draw
3, // times_to_fail_recreate
false, // fallback_context_works
+ false, // async_output_surface_creation
},
{
0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
3, // times_to_fail_recreate
false, // fallback_context_works
+ false, // async_output_surface_creation
+ },
+ {
+ 0, // times_to_lose_during_commit
+ 1, // times_to_lose_during_draw
+ 3, // times_to_fail_recreate
+ false, // fallback_context_works
+ true, // async_output_surface_creation
},
// Losing the context and recreating it any number of times should
// succeed.
@@ -234,20 +265,44 @@ class LayerTreeHostContextTestLostContextSucceeds
0, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
+ false, // async_output_surface_creation
+ },
+ {
+ 0, // times_to_lose_during_commit
+ 10, // times_to_lose_during_draw
+ 0, // times_to_fail_recreate
+ false, // fallback_context_works
+ false, // async_output_surface_creation
+ },
+ {
+ 10, // times_to_lose_during_commit
+ 0, // times_to_lose_during_draw
+ 0, // times_to_fail_recreate
+ false, // fallback_context_works
+ true, // async_output_surface_creation
},
{
0, // times_to_lose_during_commit
10, // times_to_lose_during_draw
0, // times_to_fail_recreate
false, // fallback_context_works
+ true, // async_output_surface_creation
},
// Losing the context, failing to reinitialize it, and making a fallback
// context should work.
{
+ 0, // times_to_lose_during_commit
+ 1, // times_to_lose_during_draw
+ 0, // times_to_fail_recreate
+ true, // fallback_context_works
+ false, // async_output_surface_creation
+ },
+ {
0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
0, // times_to_fail_recreate
true, // fallback_context_works
+ true, // async_output_surface_creation
},
};
@@ -263,6 +318,8 @@ class LayerTreeHostContextTestLostContextSucceeds
times_to_lose_during_draw_ = kTests[test_case_].times_to_lose_during_draw;
times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate;
fallback_context_works_ = kTests[test_case_].fallback_context_works;
+ async_output_surface_creation_ =
+ kTests[test_case_].async_output_surface_creation;
++test_case_;
return true;
}
@@ -272,6 +329,7 @@ class LayerTreeHostContextTestLostContextSucceeds
int times_to_lose_during_draw;
int times_to_fail_recreate;
bool fallback_context_works;
+ bool async_output_surface_creation;
};
protected:

Powered by Google App Engine
This is Rietveld 408576698