Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2270573002: cc: Get rid of LayerTreeHost::output_surface_lost_ state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-caps
Patch Set: lth-outputsurface-lost: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4851 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); 4862 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4863 EXPECT_TRUE(swap_promise_result_.dtor_called); 4863 EXPECT_TRUE(swap_promise_result_.dtor_called);
4864 } 4864 }
4865 } 4865 }
4866 4866
4867 TestSwapPromiseResult swap_promise_result_; 4867 TestSwapPromiseResult swap_promise_result_;
4868 }; 4868 };
4869 4869
4870 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForVisibility); 4870 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForVisibility);
4871 4871
4872 class LayerTreeHostTestBreakSwapPromiseForContext : public LayerTreeHostTest {
4873 protected:
4874 LayerTreeHostTestBreakSwapPromiseForContext()
4875 : output_surface_lost_triggered_(false) {}
4876
4877 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4878
4879 void LoseOutputSurfaceAndQueueSwapPromise() {
4880 layer_tree_host()->DidLoseOutputSurface();
4881 std::unique_ptr<SwapPromise> swap_promise(
4882 new TestSwapPromise(&swap_promise_result_));
4883 layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
4884 }
4885
4886 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
4887 const BeginFrameArgs& args) override {
4888 if (output_surface_lost_triggered_)
4889 return;
4890 output_surface_lost_triggered_ = true;
4891
4892 MainThreadTaskRunner()->PostTask(
4893 FROM_HERE, base::Bind(&LayerTreeHostTestBreakSwapPromiseForContext::
4894 LoseOutputSurfaceAndQueueSwapPromise,
4895 base::Unretained(this)));
4896 }
4897
4898 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4899 CommitEarlyOutReason reason) override {
4900 // This is needed so that the impl-thread state matches main-thread state.
4901 host_impl->DidLoseOutputSurface();
4902 EndTest();
4903 }
4904
4905 void AfterTest() override {
4906 {
4907 base::AutoLock lock(swap_promise_result_.lock);
4908 EXPECT_FALSE(swap_promise_result_.did_activate_called);
4909 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4910 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4911 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4912 EXPECT_TRUE(swap_promise_result_.dtor_called);
4913 }
4914 }
4915
4916 bool output_surface_lost_triggered_;
4917 TestSwapPromiseResult swap_promise_result_;
4918 };
4919
4920 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForContext);
4921
4922 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 4872 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
4923 public: 4873 public:
4924 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, 4874 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
4925 LayerTreeHostImpl* layer_tree_host_impl, 4875 LayerTreeHostImpl* layer_tree_host_impl,
4926 int* set_needs_commit_count, 4876 int* set_needs_commit_count,
4927 int* set_needs_redraw_count) 4877 int* set_needs_redraw_count)
4928 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 4878 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
4929 set_needs_commit_count_(set_needs_commit_count) {} 4879 set_needs_commit_count_(set_needs_commit_count) {}
4930 4880
4931 ~SimpleSwapPromiseMonitor() override {} 4881 ~SimpleSwapPromiseMonitor() override {}
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
7031 private: 6981 private:
7032 FakeContentLayerClient client_; 6982 FakeContentLayerClient client_;
7033 const gfx::Size viewport_size_; 6983 const gfx::Size viewport_size_;
7034 const gfx::Size large_image_size_; 6984 const gfx::Size large_image_size_;
7035 }; 6985 };
7036 6986
7037 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); 6987 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage);
7038 6988
7039 } // namespace 6989 } // namespace
7040 } // namespace cc 6990 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698