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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "cc/layers/heads_up_display_layer.h" | 9 #include "cc/layers/heads_up_display_layer.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 } | 1538 } |
1539 } | 1539 } |
1540 }; | 1540 }; |
1541 | 1541 |
1542 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); | 1542 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); |
1543 | 1543 |
1544 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame | 1544 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame |
1545 : public LayerTreeHostContextTest { | 1545 : public LayerTreeHostContextTest { |
1546 protected: | 1546 protected: |
1547 void BeginTest() override { | 1547 void BeginTest() override { |
1548 deferred_ = false; | |
1549 PostSetNeedsCommitToMainThread(); | 1548 PostSetNeedsCommitToMainThread(); |
1550 } | 1549 } |
1551 | 1550 |
1552 void WillBeginMainFrame() override { | 1551 void WillBeginMainFrame() override { |
1553 // Don't begin a frame with a lost surface. | 1552 // Don't begin a frame with a lost surface. |
1554 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); | 1553 EXPECT_FALSE(lost_); |
1555 | 1554 |
1556 if (deferred_) | 1555 if (deferred_) |
1557 return; | 1556 return; |
1558 deferred_ = true; | 1557 deferred_ = true; |
1559 | 1558 |
1560 // Defer commits before the BeginFrame completes, causing it to be delayed. | 1559 // Defer commits before the BeginFrame completes, causing it to be delayed. |
1561 layer_tree_host()->SetDeferCommits(true); | 1560 layer_tree_host()->SetDeferCommits(true); |
1562 // Meanwhile, lose the context while we are in defer commits. | 1561 // Meanwhile, lose the context while we are in defer commits. |
1563 ImplThreadTaskRunner()->PostTask( | 1562 ImplThreadTaskRunner()->PostTask( |
1564 FROM_HERE, | 1563 FROM_HERE, |
1565 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | 1564 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
1566 LoseContextOnImplThread, | 1565 LoseContextOnImplThread, |
1567 base::Unretained(this))); | 1566 base::Unretained(this))); |
| 1567 |
| 1568 // After the first frame, we will lose the context and then not start |
| 1569 // allowing commits until that happens. The 2nd frame should not happen |
| 1570 // before DidInitializeOutputSurface occurs. |
| 1571 lost_ = true; |
| 1572 } |
| 1573 |
| 1574 void DidInitializeOutputSurface() override { |
| 1575 EXPECT_TRUE(lost_); |
| 1576 lost_ = false; |
1568 } | 1577 } |
1569 | 1578 |
1570 void LoseContextOnImplThread() { | 1579 void LoseContextOnImplThread() { |
1571 LoseContext(); | 1580 LoseContext(); |
1572 | 1581 |
1573 // After losing the context, stop deferring commits. | 1582 // After losing the context, stop deferring commits. |
1574 PostSetDeferCommitsToMainThread(false); | 1583 PostSetDeferCommitsToMainThread(false); |
1575 } | 1584 } |
1576 | 1585 |
1577 void DidCommitAndDrawFrame() override { EndTest(); } | 1586 void DidCommitAndDrawFrame() override { EndTest(); } |
1578 | 1587 |
1579 void AfterTest() override {} | 1588 void AfterTest() override {} |
1580 | 1589 |
1581 bool deferred_; | 1590 bool deferred_ = false; |
| 1591 bool lost_ = true; |
1582 }; | 1592 }; |
1583 | 1593 |
1584 SINGLE_AND_MULTI_THREAD_TEST_F( | 1594 SINGLE_AND_MULTI_THREAD_TEST_F( |
1585 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1595 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
1586 | 1596 |
1587 } // namespace | 1597 } // namespace |
1588 } // namespace cc | 1598 } // namespace cc |
OLD | NEW |