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 8fd9743f6d11a527018c6cab91265180ca68b2e3..a80ec86d31d4f2dbf917e1dcb542e442e52ad014 100644 |
--- a/cc/trees/layer_tree_host_unittest_context.cc |
+++ b/cc/trees/layer_tree_host_unittest_context.cc |
@@ -65,6 +65,8 @@ class LayerTreeHostContextTest : public LayerTreeTest { |
} |
void LoseContext() { |
+ if (!context3d_) |
danakj
2014/08/20 18:22:10
Is this still needed?
dneto
2014/08/20 19:15:20
Yes. Otherwise 6 tests crash with null ptr except
|
+ return; |
context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
GL_INNOCENT_CONTEXT_RESET_ARB); |
context3d_ = NULL; |
@@ -594,11 +596,18 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources |
virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
- EXPECT_EQ(0, times_to_lose_on_end_query_); |
+ // In the multi-thread case, the scheduler sees the context loss and forces |
+ // re-creation of the output surface before any drawing is attempted. |
+ // In the single-thread case, we still draw even if the context is lost |
+ // during resource creation. The loss will be detected later. |
+ if (HasImplThread()) |
+ EXPECT_EQ(0, times_to_lose_on_end_query_); |
EndTest(); |
} |
virtual void AfterTest() OVERRIDE { |
+ // We have recovered from all context losses in both the single- and |
+ // multi-threaded cases. |
EXPECT_EQ(0, times_to_lose_on_end_query_); |
} |
@@ -657,6 +666,12 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
EXPECT_GE(1u, grandchild->lost_output_surface_count()); |
EndTest(); |
break; |
+ case 3: |
danakj
2014/08/20 18:22:10
did you verify that you still need this extra case
dneto
2014/08/20 19:15:20
Yes, it's still needed.
|
+ // The single thread proxy issues extra commits after context lost. |
+ // http://crbug.com/287250 |
+ if (HasImplThread()) |
+ NOTREACHED(); |
+ break; |
default: |
NOTREACHED(); |
} |
@@ -984,6 +999,7 @@ class ScrollbarLayerLostContext : public LayerTreeHostContextTest { |
EndTest(); |
break; |
case 3: |
+ case 4: |
danakj
2014/08/20 18:22:10
did you verify that you still need this extra case
|
// Single thread proxy issues extra commits after context lost. |
// http://crbug.com/287250 |
if (HasImplThread()) |
@@ -1097,7 +1113,7 @@ class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
if (HasImplThread()) |
NOTREACHED(); |
break; |
- case 6: |
+ case 7: |
danakj
2014/08/20 18:22:10
case 6? or should case 6 be up with case 5?
dneto
2014/08/20 19:15:20
Single thread case does reach case 6, so changing
danakj
2014/08/20 19:19:12
Ah ok, since we don't reach 5 we won't reach 6, su
|
NOTREACHED(); |
} |
} |
@@ -1114,16 +1130,27 @@ class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
LoseContext(); |
break; |
case 3: |
- // The resources should have been recreated. The bitmap callback should |
- // have been called once with the resource_lost flag set to true. |
- EXPECT_EQ(1, ui_resource_->lost_resource_count); |
- // Resource Id on the impl-side have been recreated as well. Note |
- // that the same UIResourceId persists after the context lost. |
- EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
- PostSetNeedsCommitToMainThread(); |
+ if (HasImplThread()) |
+ CheckForLossRecoveryThenContinue(impl); |
+ break; |
+ case 4: |
+ // In the single-threaded case, the layer tree host sees the |
+ // loss one step later. |
+ if (!HasImplThread()) |
+ CheckForLossRecoveryThenContinue(impl); |
break; |
} |
} |
+ |
+ void CheckForLossRecoveryThenContinue(LayerTreeHostImpl* impl) { |
+ // The resources should have been recreated. The bitmap callback should |
+ // have been called once with the resource_lost flag set to true. |
+ EXPECT_EQ(1, ui_resource_->lost_resource_count); |
+ // The resource id on the impl-side should have been recreated as well. |
+ // Note that the same UIResourceId persists after the context is lost. |
+ EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
+ PostSetNeedsCommitToMainThread(); |
+ } |
}; |
SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostAfterCommit); |
@@ -1450,8 +1477,18 @@ class LayerTreeHostContextTestSurfaceCreateCallback |
EXPECT_EQ(1u, layer_->output_surface_created_count()); |
break; |
case 4: |
- EXPECT_EQ(2u, layer_->output_surface_created_count()); |
- layer_tree_host()->SetNeedsCommit(); |
+ if (HasImplThread()) { |
+ EXPECT_EQ(2u, layer_->output_surface_created_count()); |
+ layer_tree_host()->SetNeedsCommit(); |
+ } |
+ break; |
+ case 5: |
+ // The single thread proxy notices the context is lost after the commit |
+ // has completed. |
+ if (!HasImplThread()) { |
+ EXPECT_EQ(2u, layer_->output_surface_created_count()); |
+ layer_tree_host()->SetNeedsCommit(); |
+ } |
break; |
} |
} |