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