Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 3833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3844 void DidActivate() override { | 3844 void DidActivate() override { |
| 3845 base::AutoLock lock(result_->lock); | 3845 base::AutoLock lock(result_->lock); |
| 3846 EXPECT_FALSE(result_->did_activate_called); | 3846 EXPECT_FALSE(result_->did_activate_called); |
| 3847 EXPECT_FALSE(result_->did_swap_called); | 3847 EXPECT_FALSE(result_->did_swap_called); |
| 3848 EXPECT_FALSE(result_->did_not_swap_called); | 3848 EXPECT_FALSE(result_->did_not_swap_called); |
| 3849 result_->did_activate_called = true; | 3849 result_->did_activate_called = true; |
| 3850 } | 3850 } |
| 3851 | 3851 |
| 3852 void DidSwap(CompositorFrameMetadata* metadata) override { | 3852 void DidSwap(CompositorFrameMetadata* metadata) override { |
| 3853 base::AutoLock lock(result_->lock); | 3853 base::AutoLock lock(result_->lock); |
| 3854 EXPECT_TRUE(result_->did_activate_called); | |
| 3855 EXPECT_FALSE(result_->did_swap_called); | 3854 EXPECT_FALSE(result_->did_swap_called); |
| 3856 EXPECT_FALSE(result_->did_not_swap_called); | 3855 EXPECT_FALSE(result_->did_not_swap_called); |
| 3857 result_->did_swap_called = true; | 3856 result_->did_swap_called = true; |
| 3858 } | 3857 } |
| 3859 | 3858 |
| 3860 void DidNotSwap(DidNotSwapReason reason) override { | 3859 void DidNotSwap(DidNotSwapReason reason) override { |
| 3861 base::AutoLock lock(result_->lock); | 3860 base::AutoLock lock(result_->lock); |
| 3862 EXPECT_FALSE(result_->did_swap_called); | 3861 EXPECT_FALSE(result_->did_swap_called); |
| 3863 EXPECT_FALSE(result_->did_not_swap_called); | 3862 EXPECT_FALSE(result_->did_not_swap_called); |
| 3864 EXPECT_FALSE(result_->did_activate_called && | 3863 EXPECT_FALSE(result_->did_activate_called && |
| 3865 reason != DidNotSwapReason::SWAP_FAILS); | 3864 reason != DidNotSwapReason::SWAP_FAILS); |
| 3866 result_->did_not_swap_called = true; | 3865 result_->did_not_swap_called = true; |
| 3867 result_->reason = reason; | 3866 result_->reason = reason; |
| 3868 } | 3867 } |
| 3869 | 3868 |
| 3870 int64 TraceId() const override { return 0; } | 3869 int64 TraceId() const override { return 0; } |
| 3871 | 3870 |
| 3872 private: | 3871 private: |
| 3873 // Not owned. | 3872 // Not owned. |
| 3874 TestSwapPromiseResult* result_; | 3873 TestSwapPromiseResult* result_; |
| 3875 }; | 3874 }; |
| 3876 | 3875 |
| 3876 class PinnedLayerTreeSwapPromise : public LayerTreeHostTest { | |
| 3877 protected: | |
| 3878 PinnedLayerTreeSwapPromise() {} | |
|
danakj
2015/08/25 21:37:30
don't need this
Tobias Sargeant
2015/08/26 11:06:49
Done.
| |
| 3879 | |
| 3880 void BeginTest() override { | |
| 3881 PostSetNextCommitForcesRedrawToMainThread(); | |
| 3882 PostSetNeedsCommitToMainThread(); | |
| 3883 } | |
| 3884 | |
| 3885 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | |
| 3886 int frame = host_impl->active_tree()->source_frame_number(); | |
| 3887 if (frame == -1) { | |
| 3888 host_impl->pending_tree()->QueuePinnedSwapPromise( | |
| 3889 make_scoped_ptr( | |
| 3890 new TestSwapPromise(&pinned_pending_swap_promise_result_)) | |
| 3891 .Pass()); | |
|
danakj
2015/08/25 21:37:30
you don't need .Pass() here. make_scoped_ptr's ret
Tobias Sargeant
2015/08/26 11:06:49
Done.
| |
| 3892 host_impl->active_tree()->QueuePinnedSwapPromise( | |
| 3893 make_scoped_ptr( | |
| 3894 new TestSwapPromise(&pinned_active_swap_promise_result_)) | |
| 3895 .Pass()); | |
|
danakj
2015/08/25 21:37:30
and here, etc
Tobias Sargeant
2015/08/26 11:06:49
Done.
| |
| 3896 | |
| 3897 host_impl->pending_tree()->QueueSwapPromise( | |
| 3898 make_scoped_ptr(new TestSwapPromise(&pending_swap_promise_result_)) | |
| 3899 .Pass()); | |
| 3900 host_impl->active_tree()->QueueSwapPromise( | |
| 3901 make_scoped_ptr(new TestSwapPromise(&active_swap_promise_result_)) | |
| 3902 .Pass()); | |
| 3903 } | |
| 3904 } | |
| 3905 | |
| 3906 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { | |
| 3907 EndTest(); | |
| 3908 } | |
| 3909 | |
| 3910 void AfterTest() override { | |
| 3911 // The pending swap promise should activate and swap. | |
| 3912 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called); | |
| 3913 EXPECT_TRUE(pending_swap_promise_result_.did_swap_called); | |
| 3914 | |
| 3915 // The pinned pending swap promise should activate but neither swap nor fail | |
| 3916 // to swap. | |
| 3917 EXPECT_TRUE(pinned_pending_swap_promise_result_.did_activate_called); | |
| 3918 EXPECT_FALSE(pinned_pending_swap_promise_result_.did_swap_called); | |
| 3919 EXPECT_FALSE(pinned_pending_swap_promise_result_.did_not_swap_called); | |
| 3920 | |
| 3921 // The active swap promise should fail to swap (it is cancelled by | |
| 3922 // the activation of a new frame). | |
| 3923 EXPECT_FALSE(active_swap_promise_result_.did_activate_called); | |
| 3924 EXPECT_FALSE(active_swap_promise_result_.did_swap_called); | |
| 3925 EXPECT_TRUE(active_swap_promise_result_.did_not_swap_called); | |
| 3926 EXPECT_EQ(active_swap_promise_result_.reason, SwapPromise::SWAP_FAILS); | |
| 3927 | |
| 3928 // The pinned active swap promise should not activate, but should swap. | |
| 3929 EXPECT_FALSE(pinned_active_swap_promise_result_.did_activate_called); | |
| 3930 EXPECT_TRUE(pinned_active_swap_promise_result_.did_swap_called); | |
| 3931 } | |
| 3932 | |
| 3933 TestSwapPromiseResult pending_swap_promise_result_, | |
|
danakj
2015/08/25 21:37:30
please define one variable per statement.
Tobias Sargeant
2015/08/26 11:06:49
Done.
| |
| 3934 pinned_pending_swap_promise_result_, active_swap_promise_result_, | |
| 3935 pinned_active_swap_promise_result_; | |
| 3936 }; | |
| 3937 | |
| 3938 MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise); | |
| 3939 | |
| 3877 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { | 3940 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { |
| 3878 protected: | 3941 protected: |
| 3879 LayerTreeHostTestBreakSwapPromise() | 3942 LayerTreeHostTestBreakSwapPromise() |
| 3880 : commit_count_(0), commit_complete_count_(0) {} | 3943 : commit_count_(0), commit_complete_count_(0) {} |
| 3881 | 3944 |
| 3882 void WillBeginMainFrame() override { | 3945 void WillBeginMainFrame() override { |
| 3883 ASSERT_LE(commit_count_, 2); | 3946 ASSERT_LE(commit_count_, 2); |
| 3884 scoped_ptr<SwapPromise> swap_promise( | 3947 scoped_ptr<SwapPromise> swap_promise( |
| 3885 new TestSwapPromise(&swap_promise_result_[commit_count_])); | 3948 new TestSwapPromise(&swap_promise_result_[commit_count_])); |
| 3886 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); | 3949 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6186 ScrollAndScaleSet scale_info_; | 6249 ScrollAndScaleSet scale_info_; |
| 6187 ScrollAndScaleSet no_op_info_; | 6250 ScrollAndScaleSet no_op_info_; |
| 6188 bool requested_update_layers_; | 6251 bool requested_update_layers_; |
| 6189 int commit_count_; | 6252 int commit_count_; |
| 6190 }; | 6253 }; |
| 6191 | 6254 |
| 6192 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); | 6255 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); |
| 6193 | 6256 |
| 6194 } // namespace | 6257 } // namespace |
| 6195 } // namespace cc | 6258 } // namespace cc |
| OLD | NEW |