| 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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); | 1562 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostEviction); |
| 1563 | 1563 |
| 1564 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame | 1564 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame |
| 1565 : public LayerTreeHostContextTest { | 1565 : public LayerTreeHostContextTest { |
| 1566 protected: | 1566 protected: |
| 1567 void BeginTest() override { | 1567 void BeginTest() override { |
| 1568 deferred_ = false; | 1568 deferred_ = false; |
| 1569 PostSetNeedsCommitToMainThread(); | 1569 PostSetNeedsCommitToMainThread(); |
| 1570 } | 1570 } |
| 1571 | 1571 |
| 1572 void ScheduledActionWillSendBeginMainFrame() override { | 1572 void WillBeginMainFrame() override { |
| 1573 // Don't begin a frame with a lost surface. |
| 1574 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); |
| 1575 |
| 1573 if (deferred_) | 1576 if (deferred_) |
| 1574 return; | 1577 return; |
| 1575 deferred_ = true; | 1578 deferred_ = true; |
| 1576 | 1579 |
| 1577 // Defer commits before the BeginFrame arrives, causing it to be delayed. | 1580 // Defer commits before the BeginFrame completes, causing it to be delayed. |
| 1578 PostSetDeferCommitsToMainThread(true); | 1581 layer_tree_host()->SetDeferCommits(true); |
| 1579 // Meanwhile, lose the context while we are in defer commits. | 1582 // Meanwhile, lose the context while we are in defer commits. |
| 1580 ImplThreadTaskRunner()->PostTask( | 1583 ImplThreadTaskRunner()->PostTask( |
| 1581 FROM_HERE, | 1584 FROM_HERE, |
| 1582 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | 1585 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
| 1583 LoseContextOnImplThread, | 1586 LoseContextOnImplThread, |
| 1584 base::Unretained(this))); | 1587 base::Unretained(this))); |
| 1585 } | 1588 } |
| 1586 | 1589 |
| 1587 void LoseContextOnImplThread() { | 1590 void LoseContextOnImplThread() { |
| 1588 LoseContext(); | 1591 LoseContext(); |
| 1589 | 1592 |
| 1590 // After losing the context, stop deferring commits. | 1593 // After losing the context, stop deferring commits. |
| 1591 PostSetDeferCommitsToMainThread(false); | 1594 PostSetDeferCommitsToMainThread(false); |
| 1592 } | 1595 } |
| 1593 | 1596 |
| 1594 void WillBeginMainFrame() override { | |
| 1595 // Don't begin a frame with a lost surface. | |
| 1596 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); | |
| 1597 } | |
| 1598 | |
| 1599 void DidCommitAndDrawFrame() override { EndTest(); } | 1597 void DidCommitAndDrawFrame() override { EndTest(); } |
| 1600 | 1598 |
| 1601 void AfterTest() override {} | 1599 void AfterTest() override {} |
| 1602 | 1600 |
| 1603 bool deferred_; | 1601 bool deferred_; |
| 1604 }; | 1602 }; |
| 1605 | 1603 |
| 1606 SINGLE_AND_MULTI_THREAD_TEST_F( | 1604 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1607 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1605 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
| 1608 | 1606 |
| 1609 } // namespace | 1607 } // namespace |
| 1610 } // namespace cc | 1608 } // namespace cc |
| OLD | NEW |