Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
| 10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 times_to_fail_recreate_(0), | 58 times_to_fail_recreate_(0), |
| 59 times_to_expect_create_failed_(0), | 59 times_to_expect_create_failed_(0), |
| 60 times_create_failed_(0), | 60 times_create_failed_(0), |
| 61 committed_at_least_once_(false), | 61 committed_at_least_once_(false), |
| 62 context_should_support_io_surface_(false), | 62 context_should_support_io_surface_(false), |
| 63 fallback_context_works_(false) { | 63 fallback_context_works_(false) { |
| 64 media::InitializeMediaLibraryForTesting(); | 64 media::InitializeMediaLibraryForTesting(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void LoseContext() { | 67 void LoseContext() { |
| 68 if (!context3d_) | |
|
dneto
2014/08/15 17:44:31
Case #4 in LayerTreeHostContextTestLostContextSucc
| |
| 69 return; | |
| 68 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 70 context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 69 GL_INNOCENT_CONTEXT_RESET_ARB); | 71 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 70 context3d_ = NULL; | 72 context3d_ = NULL; |
| 71 } | 73 } |
| 72 | 74 |
| 73 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { | 75 virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() { |
| 74 return TestWebGraphicsContext3D::Create(); | 76 return TestWebGraphicsContext3D::Create(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) | 79 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 93 if (delegating_renderer()) | 95 if (delegating_renderer()) |
| 94 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 96 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| 95 else | 97 else |
| 96 return FakeOutputSurface::Create3d(context3d.Pass()); | 98 return FakeOutputSurface::Create3d(context3d.Pass()); |
| 97 } | 99 } |
| 98 | 100 |
| 99 virtual DrawResult PrepareToDrawOnThread( | 101 virtual DrawResult PrepareToDrawOnThread( |
| 100 LayerTreeHostImpl* host_impl, | 102 LayerTreeHostImpl* host_impl, |
| 101 LayerTreeHostImpl::FrameData* frame, | 103 LayerTreeHostImpl::FrameData* frame, |
| 102 DrawResult draw_result) OVERRIDE { | 104 DrawResult draw_result) OVERRIDE { |
| 103 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 105 EXPECT_TRUE((DRAW_SUCCESS == draw_result) || |
| 106 (DRAW_ABORTED_CONTEXT_LOST == draw_result)); | |
| 104 if (!times_to_lose_during_draw_) | 107 if (!times_to_lose_during_draw_) |
| 105 return draw_result; | 108 return draw_result; |
| 106 | 109 |
| 107 --times_to_lose_during_draw_; | 110 --times_to_lose_during_draw_; |
| 108 LoseContext(); | 111 LoseContext(); |
| 109 | 112 |
| 110 times_to_fail_create_ = times_to_fail_recreate_; | 113 times_to_fail_create_ = times_to_fail_recreate_; |
| 111 times_to_fail_recreate_ = 0; | 114 times_to_fail_recreate_ = 0; |
| 112 | 115 |
| 113 return draw_result; | 116 return draw_result; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 // Lose the context and struggle to recreate it. | 653 // Lose the context and struggle to recreate it. |
| 651 LoseContext(); | 654 LoseContext(); |
| 652 times_to_fail_create_ = 1; | 655 times_to_fail_create_ = 1; |
| 653 break; | 656 break; |
| 654 case 2: | 657 case 2: |
| 655 EXPECT_GE(1u, root->lost_output_surface_count()); | 658 EXPECT_GE(1u, root->lost_output_surface_count()); |
| 656 EXPECT_GE(1u, child->lost_output_surface_count()); | 659 EXPECT_GE(1u, child->lost_output_surface_count()); |
| 657 EXPECT_GE(1u, grandchild->lost_output_surface_count()); | 660 EXPECT_GE(1u, grandchild->lost_output_surface_count()); |
| 658 EndTest(); | 661 EndTest(); |
| 659 break; | 662 break; |
| 663 case 3: | |
|
dneto
2014/08/15 17:44:31
The remaining changes to this file are a result of
| |
| 664 // The single thread proxy issues extra commits after context lost. | |
| 665 // http://crbug.com/287250 | |
|
danakj
2014/08/15 17:45:15
FYI enne this will go away with your Scheduler CL
| |
| 666 if (HasImplThread()) | |
| 667 NOTREACHED(); | |
| 668 break; | |
| 660 default: | 669 default: |
| 661 NOTREACHED(); | 670 NOTREACHED(); |
| 662 } | 671 } |
| 663 } | 672 } |
| 664 | 673 |
| 665 virtual void AfterTest() OVERRIDE {} | 674 virtual void AfterTest() OVERRIDE {} |
| 666 | 675 |
| 667 private: | 676 private: |
| 668 int num_commits_; | 677 int num_commits_; |
| 669 | 678 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 977 EXPECT_EQ(1, scrollbar_layer_->update_count()); | 986 EXPECT_EQ(1, scrollbar_layer_->update_count()); |
| 978 LoseContext(); | 987 LoseContext(); |
| 979 break; | 988 break; |
| 980 case 2: | 989 case 2: |
| 981 // Second update, after the lost context, we should still upload 2 | 990 // Second update, after the lost context, we should still upload 2 |
| 982 // resources even if the contents haven't changed. | 991 // resources even if the contents haven't changed. |
| 983 EXPECT_EQ(2, scrollbar_layer_->update_count()); | 992 EXPECT_EQ(2, scrollbar_layer_->update_count()); |
| 984 EndTest(); | 993 EndTest(); |
| 985 break; | 994 break; |
| 986 case 3: | 995 case 3: |
| 996 case 4: | |
| 987 // Single thread proxy issues extra commits after context lost. | 997 // Single thread proxy issues extra commits after context lost. |
| 988 // http://crbug.com/287250 | 998 // http://crbug.com/287250 |
| 989 if (HasImplThread()) | 999 if (HasImplThread()) |
| 990 NOTREACHED(); | 1000 NOTREACHED(); |
| 991 break; | 1001 break; |
| 992 default: | 1002 default: |
| 993 NOTREACHED(); | 1003 NOTREACHED(); |
| 994 } | 1004 } |
| 995 } | 1005 } |
| 996 | 1006 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 // Release resource before ending the test. | 1100 // Release resource before ending the test. |
| 1091 ui_resource_.reset(); | 1101 ui_resource_.reset(); |
| 1092 EndTest(); | 1102 EndTest(); |
| 1093 break; | 1103 break; |
| 1094 case 5: | 1104 case 5: |
| 1095 // Single thread proxy issues extra commits after context lost. | 1105 // Single thread proxy issues extra commits after context lost. |
| 1096 // http://crbug.com/287250 | 1106 // http://crbug.com/287250 |
| 1097 if (HasImplThread()) | 1107 if (HasImplThread()) |
| 1098 NOTREACHED(); | 1108 NOTREACHED(); |
| 1099 break; | 1109 break; |
| 1100 case 6: | 1110 case 7: |
|
danakj
2014/08/15 17:45:15
where's 6? should it be the same as case 5?
| |
| 1101 NOTREACHED(); | 1111 NOTREACHED(); |
| 1102 } | 1112 } |
| 1103 } | 1113 } |
| 1104 | 1114 |
| 1105 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { | 1115 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1106 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1116 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1107 switch (time_step_) { | 1117 switch (time_step_) { |
| 1108 case 1: | 1118 case 1: |
| 1109 // The resource should have been created on LTHI after the commit. | 1119 // The resource should have been created on LTHI after the commit. |
| 1110 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1120 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1111 PostSetNeedsCommitToMainThread(); | 1121 PostSetNeedsCommitToMainThread(); |
| 1112 break; | 1122 break; |
| 1113 case 2: | 1123 case 2: |
| 1114 LoseContext(); | 1124 LoseContext(); |
| 1115 break; | 1125 break; |
| 1116 case 3: | 1126 case 3: |
| 1117 // The resources should have been recreated. The bitmap callback should | 1127 if (HasImplThread()) |
| 1118 // have been called once with the resource_lost flag set to true. | 1128 CheckForLossRecoveryThenContinue(impl); |
| 1119 EXPECT_EQ(1, ui_resource_->lost_resource_count); | 1129 break; |
| 1120 // Resource Id on the impl-side have been recreated as well. Note | 1130 case 4: |
| 1121 // that the same UIResourceId persists after the context lost. | 1131 // In the single-threaded case, the layer tree host sees the |
| 1122 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1132 // loss one step later. |
| 1123 PostSetNeedsCommitToMainThread(); | 1133 if (!HasImplThread()) |
| 1134 CheckForLossRecoveryThenContinue(impl); | |
| 1124 break; | 1135 break; |
| 1125 } | 1136 } |
| 1126 } | 1137 } |
| 1138 | |
| 1139 void CheckForLossRecoveryThenContinue(LayerTreeHostImpl* impl) { | |
| 1140 // The resources should have been recreated. The bitmap callback should | |
| 1141 // have been called once with the resource_lost flag set to true. | |
| 1142 EXPECT_EQ(1, ui_resource_->lost_resource_count); | |
| 1143 // The resource id on the impl-side should have been recreated as well. | |
| 1144 // Note that the same UIResourceId persists after the context is lost. | |
| 1145 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
| 1146 PostSetNeedsCommitToMainThread(); | |
| 1147 } | |
| 1127 }; | 1148 }; |
| 1128 | 1149 |
| 1129 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostAfterCommit); | 1150 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostAfterCommit); |
| 1130 | 1151 |
| 1131 // Losing context before UI resource requests can be commited. Three sequences | 1152 // Losing context before UI resource requests can be commited. Three sequences |
| 1132 // of creation/deletion are considered: | 1153 // of creation/deletion are considered: |
| 1133 // 1. Create one resource -> Context Lost => Expect the resource to have been | 1154 // 1. Create one resource -> Context Lost => Expect the resource to have been |
| 1134 // created. | 1155 // created. |
| 1135 // 2. Delete an exisiting resource (test_id0_) -> create a second resource | 1156 // 2. Delete an exisiting resource (test_id0_) -> create a second resource |
| 1136 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and | 1157 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 layer_tree_host()->SetNeedsCommit(); | 1464 layer_tree_host()->SetNeedsCommit(); |
| 1444 break; | 1465 break; |
| 1445 case 2: | 1466 case 2: |
| 1446 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1467 EXPECT_EQ(1u, layer_->output_surface_created_count()); |
| 1447 layer_tree_host()->SetNeedsCommit(); | 1468 layer_tree_host()->SetNeedsCommit(); |
| 1448 break; | 1469 break; |
| 1449 case 3: | 1470 case 3: |
| 1450 EXPECT_EQ(1u, layer_->output_surface_created_count()); | 1471 EXPECT_EQ(1u, layer_->output_surface_created_count()); |
| 1451 break; | 1472 break; |
| 1452 case 4: | 1473 case 4: |
| 1453 EXPECT_EQ(2u, layer_->output_surface_created_count()); | 1474 // In the single threaded case, the layer tree host finishes committing |
| 1475 // before it is notified of surface loss. | |
| 1476 if (HasImplThread()) { | |
| 1477 EXPECT_EQ(2u, layer_->output_surface_created_count()); | |
| 1478 } else { | |
| 1479 EXPECT_EQ(1u, layer_->output_surface_created_count()); | |
| 1480 } | |
| 1454 layer_tree_host()->SetNeedsCommit(); | 1481 layer_tree_host()->SetNeedsCommit(); |
| 1455 break; | 1482 break; |
| 1483 case 5: | |
| 1484 if (!HasImplThread()) { | |
| 1485 EXPECT_EQ(2u, layer_->output_surface_created_count()); | |
| 1486 layer_tree_host()->SetNeedsCommit(); | |
| 1487 } | |
| 1488 break; | |
| 1489 case 6: | |
| 1490 if (HasImplThread()) | |
| 1491 NOTREACHED(); | |
| 1492 break; | |
| 1493 case 7: | |
| 1494 NOTREACHED(); | |
| 1495 break; | |
| 1456 } | 1496 } |
| 1457 } | 1497 } |
| 1458 | 1498 |
| 1459 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1499 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1460 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1500 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1461 switch (LastCommittedSourceFrameNumber(impl)) { | 1501 switch (LastCommittedSourceFrameNumber(impl)) { |
| 1462 case 0: | 1502 case 0: |
| 1463 break; | 1503 break; |
| 1464 case 1: | 1504 case 1: |
| 1465 break; | 1505 break; |
| 1466 case 2: | 1506 case 2: |
| 1467 LoseContext(); | 1507 LoseContext(); |
| 1468 break; | 1508 break; |
| 1469 case 3: | 1509 case 3: |
| 1470 EndTest(); | 1510 if (HasImplThread()) |
| 1511 EndTest(); | |
| 1512 case 4: | |
| 1513 break; | |
| 1514 case 5: | |
| 1515 if (!HasImplThread()) | |
| 1516 EndTest(); | |
| 1471 break; | 1517 break; |
| 1472 } | 1518 } |
| 1473 } | 1519 } |
| 1474 | 1520 |
| 1475 virtual void AfterTest() OVERRIDE {} | 1521 virtual void AfterTest() OVERRIDE {} |
| 1476 | 1522 |
| 1477 protected: | 1523 protected: |
| 1478 FakeContentLayerClient client_; | 1524 FakeContentLayerClient client_; |
| 1479 scoped_refptr<FakeContentLayer> layer_; | 1525 scoped_refptr<FakeContentLayer> layer_; |
| 1480 }; | 1526 }; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1535 virtual void AfterTest() OVERRIDE {} | 1581 virtual void AfterTest() OVERRIDE {} |
| 1536 | 1582 |
| 1537 bool deferred_; | 1583 bool deferred_; |
| 1538 }; | 1584 }; |
| 1539 | 1585 |
| 1540 // TODO(danakj): We don't use scheduler with SingleThreadProxy yet. | 1586 // TODO(danakj): We don't use scheduler with SingleThreadProxy yet. |
| 1541 MULTI_THREAD_TEST_F(LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1587 MULTI_THREAD_TEST_F(LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
| 1542 | 1588 |
| 1543 } // namespace | 1589 } // namespace |
| 1544 } // namespace cc | 1590 } // namespace cc |
| OLD | NEW |