| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 4853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4864 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); | 4864 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); |
| 4865 EXPECT_TRUE(swap_promise_result_.dtor_called); | 4865 EXPECT_TRUE(swap_promise_result_.dtor_called); |
| 4866 } | 4866 } |
| 4867 } | 4867 } |
| 4868 | 4868 |
| 4869 TestSwapPromiseResult swap_promise_result_; | 4869 TestSwapPromiseResult swap_promise_result_; |
| 4870 }; | 4870 }; |
| 4871 | 4871 |
| 4872 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForVisibility); | 4872 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForVisibility); |
| 4873 | 4873 |
| 4874 class LayerTreeHostTestBreakSwapPromiseForContext : public LayerTreeHostTest { | |
| 4875 protected: | |
| 4876 LayerTreeHostTestBreakSwapPromiseForContext() | |
| 4877 : output_surface_lost_triggered_(false) {} | |
| 4878 | |
| 4879 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 4880 | |
| 4881 void LoseOutputSurfaceAndQueueSwapPromise() { | |
| 4882 layer_tree_host()->DidLoseOutputSurface(); | |
| 4883 std::unique_ptr<SwapPromise> swap_promise( | |
| 4884 new TestSwapPromise(&swap_promise_result_)); | |
| 4885 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); | |
| 4886 } | |
| 4887 | |
| 4888 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | |
| 4889 const BeginFrameArgs& args) override { | |
| 4890 if (output_surface_lost_triggered_) | |
| 4891 return; | |
| 4892 output_surface_lost_triggered_ = true; | |
| 4893 | |
| 4894 MainThreadTaskRunner()->PostTask( | |
| 4895 FROM_HERE, base::Bind(&LayerTreeHostTestBreakSwapPromiseForContext:: | |
| 4896 LoseOutputSurfaceAndQueueSwapPromise, | |
| 4897 base::Unretained(this))); | |
| 4898 } | |
| 4899 | |
| 4900 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | |
| 4901 CommitEarlyOutReason reason) override { | |
| 4902 // This is needed so that the impl-thread state matches main-thread state. | |
| 4903 host_impl->DidLoseOutputSurface(); | |
| 4904 EndTest(); | |
| 4905 } | |
| 4906 | |
| 4907 void AfterTest() override { | |
| 4908 { | |
| 4909 base::AutoLock lock(swap_promise_result_.lock); | |
| 4910 EXPECT_FALSE(swap_promise_result_.did_activate_called); | |
| 4911 EXPECT_FALSE(swap_promise_result_.did_swap_called); | |
| 4912 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); | |
| 4913 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); | |
| 4914 EXPECT_TRUE(swap_promise_result_.dtor_called); | |
| 4915 } | |
| 4916 } | |
| 4917 | |
| 4918 bool output_surface_lost_triggered_; | |
| 4919 TestSwapPromiseResult swap_promise_result_; | |
| 4920 }; | |
| 4921 | |
| 4922 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForContext); | |
| 4923 | |
| 4924 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 4874 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
| 4925 public: | 4875 public: |
| 4926 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, | 4876 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, |
| 4927 LayerTreeHostImpl* layer_tree_host_impl, | 4877 LayerTreeHostImpl* layer_tree_host_impl, |
| 4928 int* set_needs_commit_count, | 4878 int* set_needs_commit_count, |
| 4929 int* set_needs_redraw_count) | 4879 int* set_needs_redraw_count) |
| 4930 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 4880 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
| 4931 set_needs_commit_count_(set_needs_commit_count) {} | 4881 set_needs_commit_count_(set_needs_commit_count) {} |
| 4932 | 4882 |
| 4933 ~SimpleSwapPromiseMonitor() override {} | 4883 ~SimpleSwapPromiseMonitor() override {} |
| (...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7033 private: | 6983 private: |
| 7034 FakeContentLayerClient client_; | 6984 FakeContentLayerClient client_; |
| 7035 const gfx::Size viewport_size_; | 6985 const gfx::Size viewport_size_; |
| 7036 const gfx::Size large_image_size_; | 6986 const gfx::Size large_image_size_; |
| 7037 }; | 6987 }; |
| 7038 | 6988 |
| 7039 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); | 6989 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 7040 | 6990 |
| 7041 } // namespace | 6991 } // namespace |
| 7042 } // namespace cc | 6992 } // namespace cc |
| OLD | NEW |