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

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

Issue 2188093002: cc: Complete swap promise for aborted commit after pending activation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: post rebase fix 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 // a second commit as a result. 1574 // a second commit as a result.
1575 layer_tree_host()->SetDeviceScaleFactor(4.f); 1575 layer_tree_host()->SetDeviceScaleFactor(4.f);
1576 break; 1576 break;
1577 default: 1577 default:
1578 // No extra commits. 1578 // No extra commits.
1579 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); 1579 EXPECT_EQ(2, layer_tree_host()->source_frame_number());
1580 break; 1580 break;
1581 } 1581 }
1582 } 1582 }
1583 1583
1584 void AfterTest() override { 1584 void AfterTest() override {}
1585 }
1586 1585
1587 private: 1586 private:
1588 FakeContentLayerClient client_; 1587 FakeContentLayerClient client_;
1589 scoped_refptr<Layer> root_layer_; 1588 scoped_refptr<Layer> root_layer_;
1590 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_; 1589 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_;
1591 }; 1590 };
1592 1591
1593 SINGLE_AND_MULTI_THREAD_TEST_F( 1592 SINGLE_AND_MULTI_THREAD_TEST_F(
1594 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); 1593 LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate);
1595 1594
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 } 2124 }
2126 2125
2127 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 2126 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2128 2127
2129 void ApplyViewportDeltas(const gfx::Vector2dF& scroll_delta, 2128 void ApplyViewportDeltas(const gfx::Vector2dF& scroll_delta,
2130 const gfx::Vector2dF&, 2129 const gfx::Vector2dF&,
2131 const gfx::Vector2dF& elastic_overscroll_delta, 2130 const gfx::Vector2dF& elastic_overscroll_delta,
2132 float scale, 2131 float scale,
2133 float) override { 2132 float) override {
2134 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); 2133 gfx::ScrollOffset offset = scroll_layer_->scroll_offset();
2135 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, 2134 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, scroll_delta));
2136 scroll_delta));
2137 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); 2135 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
2138 } 2136 }
2139 2137
2140 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { 2138 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
2141 // We get one commit before the first draw, and the animation doesn't happen 2139 // We get one commit before the first draw, and the animation doesn't happen
2142 // until the second draw. 2140 // until the second draw.
2143 switch (impl->active_tree()->source_frame_number()) { 2141 switch (impl->active_tree()->source_frame_number()) {
2144 case 0: 2142 case 0:
2145 EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor()); 2143 EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor());
2146 // We'll start an animation when we get back to the main thread. 2144 // We'll start an animation when we get back to the main thread.
2147 break; 2145 break;
2148 case 1: 2146 case 1:
2149 EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor()); 2147 EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor());
2150 break; 2148 break;
2151 case 2: 2149 case 2:
2152 EXPECT_EQ(1.25f, impl->active_tree()->current_page_scale_factor()); 2150 EXPECT_EQ(1.25f, impl->active_tree()->current_page_scale_factor());
2153 EndTest(); 2151 EndTest();
2154 break; 2152 break;
2155 case 3: 2153 case 3:
2156 break; 2154 break;
2157 default: 2155 default:
2158 NOTREACHED(); 2156 NOTREACHED();
2159 } 2157 }
2160 } 2158 }
2161 2159
2162 void DidCommitAndDrawFrame() override { 2160 void DidCommitAndDrawFrame() override {
2163 switch (layer_tree_host()->source_frame_number()) { 2161 switch (layer_tree_host()->source_frame_number()) {
2164 case 1: 2162 case 1:
2165 layer_tree_host()->StartPageScaleAnimation( 2163 layer_tree_host()->StartPageScaleAnimation(gfx::Vector2d(), false,
2166 gfx::Vector2d(), false, 1.25f, base::TimeDelta()); 2164 1.25f, base::TimeDelta());
2167 break; 2165 break;
2168 } 2166 }
2169 } 2167 }
2170 2168
2171 void AfterTest() override {} 2169 void AfterTest() override {}
2172 2170
2173 FakeContentLayerClient client_; 2171 FakeContentLayerClient client_;
2174 scoped_refptr<Layer> scroll_layer_; 2172 scoped_refptr<Layer> scroll_layer_;
2175 }; 2173 };
2176 2174
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 scoped_refptr<Layer> layer_; 2350 scoped_refptr<Layer> layer_;
2353 int num_commit_complete_; 2351 int num_commit_complete_;
2354 int num_draw_layers_; 2352 int num_draw_layers_;
2355 }; 2353 };
2356 2354
2357 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); 2355 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate);
2358 2356
2359 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { 2357 class LayerTreeHostTestDeferCommits : public LayerTreeHostTest {
2360 public: 2358 public:
2361 LayerTreeHostTestDeferCommits() 2359 LayerTreeHostTestDeferCommits()
2362 : num_will_begin_impl_frame_(0), 2360 : num_will_begin_impl_frame_(0), num_send_begin_main_frame_(0) {}
2363 num_send_begin_main_frame_(0) {}
2364 2361
2365 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 2362 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2366 2363
2367 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, 2364 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
2368 const BeginFrameArgs& args) override { 2365 const BeginFrameArgs& args) override {
2369 num_will_begin_impl_frame_++; 2366 num_will_begin_impl_frame_++;
2370 switch (num_will_begin_impl_frame_) { 2367 switch (num_will_begin_impl_frame_) {
2371 case 1: 2368 case 1:
2372 break; 2369 break;
2373 case 2: 2370 case 2:
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 CreateDisplayOutputSurface(compositor_context_provider), 2845 CreateDisplayOutputSurface(compositor_context_provider),
2849 shared_bitmap_manager(), gpu_memory_buffer_manager(), 2846 shared_bitmap_manager(), gpu_memory_buffer_manager(),
2850 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(), 2847 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(),
2851 false /* synchronous_composite */, 2848 false /* synchronous_composite */,
2852 false /* force_disable_reclaim_resources */, 2849 false /* force_disable_reclaim_resources */,
2853 std::move(on_draw_callback)); 2850 std::move(on_draw_callback));
2854 output_surface_ = output_surface.get(); 2851 output_surface_ = output_surface.get();
2855 return std::move(output_surface); 2852 return std::move(output_surface);
2856 } 2853 }
2857 2854
2858 void BeginTest() override { 2855 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
2859 PostSetNeedsCommitToMainThread();
2860 }
2861 2856
2862 void CallOnDraw() { 2857 void CallOnDraw() {
2863 if (!TestEnded()) { 2858 if (!TestEnded()) {
2864 // Synchronous compositor does not draw unless told to do so by the output 2859 // Synchronous compositor does not draw unless told to do so by the output
2865 // surface. But it needs to be done on a new stack frame. 2860 // surface. But it needs to be done on a new stack frame.
2866 bool resourceless_software_draw = true; 2861 bool resourceless_software_draw = true;
2867 ImplThreadTaskRunner()->PostTask( 2862 ImplThreadTaskRunner()->PostTask(
2868 FROM_HERE, base::Bind(&OnDrawOutputSurface::OnDraw, 2863 FROM_HERE, base::Bind(&OnDrawOutputSurface::OnDraw,
2869 base::Unretained(output_surface_), 2864 base::Unretained(output_surface_),
2870 resourceless_software_draw)); 2865 resourceless_software_draw));
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3019 int id) { 3014 int id) {
3020 return base::WrapUnique(new PushPropertiesCountingLayerImpl(tree_impl, id)); 3015 return base::WrapUnique(new PushPropertiesCountingLayerImpl(tree_impl, id));
3021 } 3016 }
3022 3017
3023 ~PushPropertiesCountingLayerImpl() override {} 3018 ~PushPropertiesCountingLayerImpl() override {}
3024 3019
3025 void PushPropertiesTo(LayerImpl* layer) override { 3020 void PushPropertiesTo(LayerImpl* layer) override {
3026 LayerImpl::PushPropertiesTo(layer); 3021 LayerImpl::PushPropertiesTo(layer);
3027 push_properties_count_++; 3022 push_properties_count_++;
3028 // Push state to the active tree because we can only access it from there. 3023 // Push state to the active tree because we can only access it from there.
3029 static_cast<PushPropertiesCountingLayerImpl*>( 3024 static_cast<PushPropertiesCountingLayerImpl*>(layer)
3030 layer)->push_properties_count_ = push_properties_count_; 3025 ->push_properties_count_ = push_properties_count_;
3031 } 3026 }
3032 3027
3033 std::unique_ptr<LayerImpl> CreateLayerImpl( 3028 std::unique_ptr<LayerImpl> CreateLayerImpl(
3034 LayerTreeImpl* tree_impl) override { 3029 LayerTreeImpl* tree_impl) override {
3035 return PushPropertiesCountingLayerImpl::Create(tree_impl, id()); 3030 return PushPropertiesCountingLayerImpl::Create(tree_impl, id());
3036 } 3031 }
3037 3032
3038 size_t push_properties_count() const { return push_properties_count_; } 3033 size_t push_properties_count() const { return push_properties_count_; }
3039 void reset_push_properties_count() { push_properties_count_ = 0; } 3034 void reset_push_properties_count() { push_properties_count_ = 0; }
3040 3035
3041 private: 3036 private:
3042 size_t push_properties_count_; 3037 size_t push_properties_count_;
3043 3038
3044 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id) 3039 PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id)
3045 : LayerImpl(tree_impl, id), 3040 : LayerImpl(tree_impl, id), push_properties_count_(0) {
3046 push_properties_count_(0) {
3047 SetBounds(gfx::Size(1, 1)); 3041 SetBounds(gfx::Size(1, 1));
3048 } 3042 }
3049 }; 3043 };
3050 3044
3051 class PushPropertiesCountingLayer : public Layer { 3045 class PushPropertiesCountingLayer : public Layer {
3052 public: 3046 public:
3053 static scoped_refptr<PushPropertiesCountingLayer> Create() { 3047 static scoped_refptr<PushPropertiesCountingLayer> Create() {
3054 return new PushPropertiesCountingLayer(); 3048 return new PushPropertiesCountingLayer();
3055 } 3049 }
3056 3050
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 4048
4055 MULTI_THREAD_TEST_F( 4049 MULTI_THREAD_TEST_F(
4056 LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent); 4050 LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent);
4057 4051
4058 // This test verifies that the tree activation callback is invoked correctly. 4052 // This test verifies that the tree activation callback is invoked correctly.
4059 class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest { 4053 class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest {
4060 public: 4054 public:
4061 LayerTreeHostTestTreeActivationCallback() 4055 LayerTreeHostTestTreeActivationCallback()
4062 : num_commits_(0), callback_count_(0) {} 4056 : num_commits_(0), callback_count_(0) {}
4063 4057
4064 void BeginTest() override { 4058 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4065 PostSetNeedsCommitToMainThread();
4066 }
4067 4059
4068 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 4060 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
4069 LayerTreeHostImpl::FrameData* frame_data, 4061 LayerTreeHostImpl::FrameData* frame_data,
4070 DrawResult draw_result) override { 4062 DrawResult draw_result) override {
4071 ++num_commits_; 4063 ++num_commits_;
4072 switch (num_commits_) { 4064 switch (num_commits_) {
4073 case 1: 4065 case 1:
4074 EXPECT_EQ(0, callback_count_); 4066 EXPECT_EQ(0, callback_count_);
4075 callback_count_ = 0; 4067 callback_count_ = 0;
4076 SetCallback(host_impl, true); 4068 SetCallback(host_impl, true);
4077 PostSetNeedsCommitToMainThread(); 4069 PostSetNeedsCommitToMainThread();
4078 break; 4070 break;
4079 case 2: 4071 case 2:
4080 EXPECT_EQ(1, callback_count_); 4072 EXPECT_EQ(1, callback_count_);
4081 callback_count_ = 0; 4073 callback_count_ = 0;
4082 SetCallback(host_impl, false); 4074 SetCallback(host_impl, false);
4083 PostSetNeedsCommitToMainThread(); 4075 PostSetNeedsCommitToMainThread();
4084 break; 4076 break;
4085 case 3: 4077 case 3:
4086 EXPECT_EQ(0, callback_count_); 4078 EXPECT_EQ(0, callback_count_);
4087 callback_count_ = 0; 4079 callback_count_ = 0;
4088 EndTest(); 4080 EndTest();
4089 break; 4081 break;
4090 default: 4082 default:
4091 ADD_FAILURE() << num_commits_; 4083 ADD_FAILURE() << num_commits_;
4092 EndTest(); 4084 EndTest();
4093 break; 4085 break;
4094 } 4086 }
4095 return LayerTreeHostTest::PrepareToDrawOnThread( 4087 return LayerTreeHostTest::PrepareToDrawOnThread(host_impl, frame_data,
4096 host_impl, frame_data, draw_result); 4088 draw_result);
4097 } 4089 }
4098 4090
4099 void AfterTest() override { EXPECT_EQ(3, num_commits_); } 4091 void AfterTest() override { EXPECT_EQ(3, num_commits_); }
4100 4092
4101 void SetCallback(LayerTreeHostImpl* host_impl, bool enable) { 4093 void SetCallback(LayerTreeHostImpl* host_impl, bool enable) {
4102 host_impl->SetTreeActivationCallback( 4094 host_impl->SetTreeActivationCallback(
4103 enable 4095 enable
4104 ? base::Bind( 4096 ? base::Bind(
4105 &LayerTreeHostTestTreeActivationCallback::ActivationCallback, 4097 &LayerTreeHostTestTreeActivationCallback::ActivationCallback,
4106 base::Unretained(this)) 4098 base::Unretained(this))
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
4734 void AfterTest() override {} 4726 void AfterTest() override {}
4735 4727
4736 private: 4728 private:
4737 int num_swaps_ = 0; 4729 int num_swaps_ = 0;
4738 scoped_refptr<Layer> layer_; 4730 scoped_refptr<Layer> layer_;
4739 TestSwapPromiseResult swap_promise_result_; 4731 TestSwapPromiseResult swap_promise_result_;
4740 }; 4732 };
4741 4733
4742 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestKeepSwapPromise); 4734 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestKeepSwapPromise);
4743 4735
4736 class LayerTreeHostTestKeepSwapPromiseMFBA : public LayerTreeHostTest {
4737 public:
4738 LayerTreeHostTestKeepSwapPromiseMFBA() {}
4739
4740 void InitializeSettings(LayerTreeSettings* settings) override {
4741 settings->main_frame_before_activation_enabled = true;
4742 }
4743
4744 void BeginTest() override {
4745 layer_ = SolidColorLayer::Create();
4746 layer_->SetIsDrawable(true);
4747 layer_->SetBounds(gfx::Size(10, 10));
4748 layer_tree_host()->SetRootLayer(layer_);
4749 gfx::Size bounds(100, 100);
4750 layer_tree_host()->SetViewportSize(bounds);
4751 PostSetNeedsCommitToMainThread();
4752 }
4753
4754 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override {
4755 // Safe to check frame number here because main thread is blocked.
4756 if (layer_tree_host()->source_frame_number() == 0) {
4757 host_impl->BlockNotifyReadyToActivateForTesting(true);
4758 } else {
4759 NOTREACHED();
4760 }
4761 }
4762
4763 void DidCommit() override {
4764 MainThreadTaskRunner()->PostTask(
4765 FROM_HERE,
4766 base::Bind(&LayerTreeHostTestKeepSwapPromiseMFBA::ChangeFrame,
4767 base::Unretained(this)));
4768 }
4769
4770 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4771 CommitEarlyOutReason reason) override {
4772 base::AutoLock lock(swap_promise_result_.lock);
4773 EXPECT_FALSE(swap_promise_result_.did_not_swap_called);
4774 EXPECT_FALSE(swap_promise_result_.did_activate_called);
4775 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4776 host_impl->BlockNotifyReadyToActivateForTesting(false);
4777 }
4778
4779 void ChangeFrame() {
4780 switch (layer_tree_host()->source_frame_number()) {
4781 case 1:
4782 // Make no changes so that we abort the next commit caused by queuing
4783 // the swap promise.
4784 layer_tree_host()->QueueSwapPromise(
4785 base::WrapUnique(new TestSwapPromise(&swap_promise_result_)));
4786 layer_tree_host()->SetNeedsUpdateLayers();
4787 break;
4788 case 2:
4789 break;
4790 default:
4791 NOTREACHED();
4792 break;
4793 }
4794 }
4795
4796 void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4797 if (host_impl->pending_tree()) {
4798 if (host_impl->pending_tree()->source_frame_number() == 1) {
4799 base::AutoLock lock(swap_promise_result_.lock);
4800 EXPECT_FALSE(swap_promise_result_.did_activate_called);
4801 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4802 SetCallback(host_impl, true);
4803 } else {
4804 SetCallback(host_impl, false);
4805 }
4806 }
4807 }
4808
4809 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4810 if (host_impl->active_tree()->source_frame_number() == 1) {
4811 base::AutoLock lock(swap_promise_result_.lock);
4812 EXPECT_TRUE(swap_promise_result_.did_activate_called);
4813 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4814 }
4815 }
4816
4817 void ActivationCallback() {
4818 // DidActivate needs to happen before the tree activation callback.
4819 base::AutoLock lock(swap_promise_result_.lock);
4820 EXPECT_TRUE(swap_promise_result_.did_activate_called);
4821 }
4822
4823 void SetCallback(LayerTreeHostImpl* host_impl, bool enable) {
4824 host_impl->SetTreeActivationCallback(
4825 enable ? base::Bind(
4826 &LayerTreeHostTestKeepSwapPromiseMFBA::ActivationCallback,
4827 base::Unretained(this))
4828 : base::Closure());
4829 }
4830
4831 void DisplayDidDrawAndSwapOnThread() override {
4832 num_swaps_++;
4833 base::AutoLock lock(swap_promise_result_.lock);
4834 EXPECT_TRUE(swap_promise_result_.did_swap_called);
4835 EXPECT_FALSE(swap_promise_result_.did_not_swap_called);
4836 EXPECT_TRUE(swap_promise_result_.dtor_called);
4837 EndTest();
4838 }
4839
4840 void AfterTest() override { EXPECT_EQ(1, num_swaps_); }
4841
4842 private:
4843 int num_swaps_ = 0;
4844 scoped_refptr<Layer> layer_;
4845 TestSwapPromiseResult swap_promise_result_;
4846 };
4847
4848 MULTI_THREAD_TEST_F(LayerTreeHostTestKeepSwapPromiseMFBA);
4849
4744 class LayerTreeHostTestBreakSwapPromiseForVisibility 4850 class LayerTreeHostTestBreakSwapPromiseForVisibility
4745 : public LayerTreeHostTest { 4851 : public LayerTreeHostTest {
4746 protected: 4852 protected:
4747 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4853 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4748 4854
4749 void SetVisibleFalseAndQueueSwapPromise() { 4855 void SetVisibleFalseAndQueueSwapPromise() {
4750 layer_tree_host()->SetVisible(false); 4856 layer_tree_host()->SetVisible(false);
4751 std::unique_ptr<SwapPromise> swap_promise( 4857 std::unique_ptr<SwapPromise> swap_promise(
4752 new TestSwapPromise(&swap_promise_result_)); 4858 new TestSwapPromise(&swap_promise_result_));
4753 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); 4859 layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
4754 } 4860 }
4755 4861
4756 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, 4862 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
4757 const BeginFrameArgs& args) override { 4863 const BeginFrameArgs& args) override {
4758 MainThreadTaskRunner()->PostTask( 4864 MainThreadTaskRunner()->PostTask(
4759 FROM_HERE, 4865 FROM_HERE, base::Bind(&LayerTreeHostTestBreakSwapPromiseForVisibility::
4760 base::Bind(&LayerTreeHostTestBreakSwapPromiseForVisibility 4866 SetVisibleFalseAndQueueSwapPromise,
4761 ::SetVisibleFalseAndQueueSwapPromise, 4867 base::Unretained(this)));
4762 base::Unretained(this)));
4763 } 4868 }
4764 4869
4765 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, 4870 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4766 CommitEarlyOutReason reason) override { 4871 CommitEarlyOutReason reason) override {
4767 EndTest(); 4872 EndTest();
4768 } 4873 }
4769 4874
4770 void AfterTest() override { 4875 void AfterTest() override {
4771 { 4876 {
4772 base::AutoLock lock(swap_promise_result_.lock); 4877 base::AutoLock lock(swap_promise_result_.lock);
4773 EXPECT_FALSE(swap_promise_result_.did_activate_called); 4878 EXPECT_FALSE(swap_promise_result_.did_activate_called);
4774 EXPECT_FALSE(swap_promise_result_.did_swap_called); 4879 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4775 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); 4880 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4776 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); 4881 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4777 EXPECT_TRUE(swap_promise_result_.dtor_called); 4882 EXPECT_TRUE(swap_promise_result_.dtor_called);
4778 } 4883 }
4779 } 4884 }
4780 4885
4781 TestSwapPromiseResult swap_promise_result_; 4886 TestSwapPromiseResult swap_promise_result_;
4782 }; 4887 };
4783 4888
4784 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForVisibility); 4889 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForVisibility);
4785 4890
4786 class LayerTreeHostTestBreakSwapPromiseForContext : public LayerTreeHostTest { 4891 class LayerTreeHostTestBreakSwapPromiseForContext : public LayerTreeHostTest {
4787 protected: 4892 protected:
4788 LayerTreeHostTestBreakSwapPromiseForContext() 4893 LayerTreeHostTestBreakSwapPromiseForContext()
4789 : output_surface_lost_triggered_(false) { 4894 : output_surface_lost_triggered_(false) {}
4790 }
4791 4895
4792 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4896 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4793 4897
4794 void LoseOutputSurfaceAndQueueSwapPromise() { 4898 void LoseOutputSurfaceAndQueueSwapPromise() {
4795 layer_tree_host()->DidLoseOutputSurface(); 4899 layer_tree_host()->DidLoseOutputSurface();
4796 std::unique_ptr<SwapPromise> swap_promise( 4900 std::unique_ptr<SwapPromise> swap_promise(
4797 new TestSwapPromise(&swap_promise_result_)); 4901 new TestSwapPromise(&swap_promise_result_));
4798 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); 4902 layer_tree_host()->QueueSwapPromise(std::move(swap_promise));
4799 } 4903 }
4800 4904
4801 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, 4905 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
4802 const BeginFrameArgs& args) override { 4906 const BeginFrameArgs& args) override {
4803 if (output_surface_lost_triggered_) 4907 if (output_surface_lost_triggered_)
4804 return; 4908 return;
4805 output_surface_lost_triggered_ = true; 4909 output_surface_lost_triggered_ = true;
4806 4910
4807 MainThreadTaskRunner()->PostTask( 4911 MainThreadTaskRunner()->PostTask(
4808 FROM_HERE, 4912 FROM_HERE, base::Bind(&LayerTreeHostTestBreakSwapPromiseForContext::
4809 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContext 4913 LoseOutputSurfaceAndQueueSwapPromise,
4810 ::LoseOutputSurfaceAndQueueSwapPromise, 4914 base::Unretained(this)));
4811 base::Unretained(this)));
4812 } 4915 }
4813 4916
4814 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, 4917 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl,
4815 CommitEarlyOutReason reason) override { 4918 CommitEarlyOutReason reason) override {
4816 // This is needed so that the impl-thread state matches main-thread state. 4919 // This is needed so that the impl-thread state matches main-thread state.
4817 host_impl->DidLoseOutputSurface(); 4920 host_impl->DidLoseOutputSurface();
4818 EndTest(); 4921 EndTest();
4819 } 4922 }
4820 4923
4821 void AfterTest() override { 4924 void AfterTest() override {
4822 { 4925 {
4823 base::AutoLock lock(swap_promise_result_.lock); 4926 base::AutoLock lock(swap_promise_result_.lock);
4824 EXPECT_FALSE(swap_promise_result_.did_activate_called); 4927 EXPECT_FALSE(swap_promise_result_.did_activate_called);
4825 EXPECT_FALSE(swap_promise_result_.did_swap_called); 4928 EXPECT_FALSE(swap_promise_result_.did_swap_called);
4826 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); 4929 EXPECT_TRUE(swap_promise_result_.did_not_swap_called);
4827 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); 4930 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason);
4828 EXPECT_TRUE(swap_promise_result_.dtor_called); 4931 EXPECT_TRUE(swap_promise_result_.dtor_called);
4829 } 4932 }
4830 } 4933 }
4831 4934
4832 bool output_surface_lost_triggered_; 4935 bool output_surface_lost_triggered_;
4833 TestSwapPromiseResult swap_promise_result_; 4936 TestSwapPromiseResult swap_promise_result_;
4834 }; 4937 };
4835 4938
4836 SINGLE_AND_MULTI_THREAD_TEST_F( 4939 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForContext);
4837 LayerTreeHostTestBreakSwapPromiseForContext);
4838 4940
4839 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { 4941 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
4840 public: 4942 public:
4841 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, 4943 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
4842 LayerTreeHostImpl* layer_tree_host_impl, 4944 LayerTreeHostImpl* layer_tree_host_impl,
4843 int* set_needs_commit_count, 4945 int* set_needs_commit_count,
4844 int* set_needs_redraw_count) 4946 int* set_needs_redraw_count)
4845 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 4947 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
4846 set_needs_commit_count_(set_needs_commit_count) {} 4948 set_needs_commit_count_(set_needs_commit_count) {}
4847 4949
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
5290 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); 5392 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced);
5291 5393
5292 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame 5394 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame
5293 : public LayerTreeHostTest { 5395 : public LayerTreeHostTest {
5294 public: 5396 public:
5295 enum { kExpectedNumImplFrames = 10 }; 5397 enum { kExpectedNumImplFrames = 10 };
5296 5398
5297 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() 5399 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame()
5298 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} 5400 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {}
5299 5401
5300 void BeginTest() override { 5402 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
5301 PostSetNeedsCommitToMainThread();
5302 }
5303 5403
5304 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, 5404 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
5305 const BeginFrameArgs& args) override { 5405 const BeginFrameArgs& args) override {
5306 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); 5406 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_);
5307 EXPECT_FALSE(TestEnded()); 5407 EXPECT_FALSE(TestEnded());
5308 will_begin_impl_frame_count_++; 5408 will_begin_impl_frame_count_++;
5309 } 5409 }
5310 5410
5311 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override { 5411 void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) override {
5312 did_finish_impl_frame_count_++; 5412 did_finish_impl_frame_count_++;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
5596 void ApplyViewportDeltas(const gfx::Vector2dF& inner, 5696 void ApplyViewportDeltas(const gfx::Vector2dF& inner,
5597 const gfx::Vector2dF& outer, 5697 const gfx::Vector2dF& outer,
5598 const gfx::Vector2dF& elastic_overscroll_delta, 5698 const gfx::Vector2dF& elastic_overscroll_delta,
5599 float scale_delta, 5699 float scale_delta,
5600 float top_controls_delta) override { 5700 float top_controls_delta) override {
5601 EXPECT_EQ(info_.page_scale_delta, scale_delta); 5701 EXPECT_EQ(info_.page_scale_delta, scale_delta);
5602 EXPECT_EQ(info_.top_controls_delta, top_controls_delta); 5702 EXPECT_EQ(info_.top_controls_delta, top_controls_delta);
5603 deltas_sent_to_client_ = true; 5703 deltas_sent_to_client_ = true;
5604 } 5704 }
5605 5705
5606 void AfterTest() override { 5706 void AfterTest() override { EXPECT_TRUE(deltas_sent_to_client_); }
5607 EXPECT_TRUE(deltas_sent_to_client_);
5608 }
5609 5707
5610 ScrollAndScaleSet info_; 5708 ScrollAndScaleSet info_;
5611 bool deltas_sent_to_client_; 5709 bool deltas_sent_to_client_;
5612 }; 5710 };
5613 5711
5614 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); 5712 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer);
5615 5713
5616 class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest { 5714 class LayerTreeHostTestCrispUpAfterPinchEnds : public LayerTreeHostTest {
5617 protected: 5715 protected:
5618 LayerTreeHostTestCrispUpAfterPinchEnds() 5716 LayerTreeHostTestCrispUpAfterPinchEnds()
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
6952 private: 7050 private:
6953 FakeContentLayerClient client_; 7051 FakeContentLayerClient client_;
6954 const gfx::Size viewport_size_; 7052 const gfx::Size viewport_size_;
6955 const gfx::Size large_image_size_; 7053 const gfx::Size large_image_size_;
6956 }; 7054 };
6957 7055
6958 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); 7056 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage);
6959 7057
6960 } // namespace 7058 } // namespace
6961 } // namespace cc 7059 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698