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

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

Issue 1292773003: Queue latency info swap promises in a separate already-active queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use different return value for failed draw in test, to avoid NOTREACHED() Created 5 years, 3 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_unittest.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 <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 3907 matching lines...) Expand 10 before | Expand all | Expand 10 after
3918 void DidActivate() override { 3918 void DidActivate() override {
3919 base::AutoLock lock(result_->lock); 3919 base::AutoLock lock(result_->lock);
3920 EXPECT_FALSE(result_->did_activate_called); 3920 EXPECT_FALSE(result_->did_activate_called);
3921 EXPECT_FALSE(result_->did_swap_called); 3921 EXPECT_FALSE(result_->did_swap_called);
3922 EXPECT_FALSE(result_->did_not_swap_called); 3922 EXPECT_FALSE(result_->did_not_swap_called);
3923 result_->did_activate_called = true; 3923 result_->did_activate_called = true;
3924 } 3924 }
3925 3925
3926 void DidSwap(CompositorFrameMetadata* metadata) override { 3926 void DidSwap(CompositorFrameMetadata* metadata) override {
3927 base::AutoLock lock(result_->lock); 3927 base::AutoLock lock(result_->lock);
3928 EXPECT_TRUE(result_->did_activate_called);
3929 EXPECT_FALSE(result_->did_swap_called); 3928 EXPECT_FALSE(result_->did_swap_called);
3930 EXPECT_FALSE(result_->did_not_swap_called); 3929 EXPECT_FALSE(result_->did_not_swap_called);
3931 result_->did_swap_called = true; 3930 result_->did_swap_called = true;
3932 } 3931 }
3933 3932
3934 void DidNotSwap(DidNotSwapReason reason) override { 3933 void DidNotSwap(DidNotSwapReason reason) override {
3935 base::AutoLock lock(result_->lock); 3934 base::AutoLock lock(result_->lock);
3936 EXPECT_FALSE(result_->did_swap_called); 3935 EXPECT_FALSE(result_->did_swap_called);
3937 EXPECT_FALSE(result_->did_not_swap_called); 3936 EXPECT_FALSE(result_->did_not_swap_called);
3938 EXPECT_FALSE(result_->did_activate_called && 3937 EXPECT_FALSE(result_->did_activate_called &&
3939 reason != DidNotSwapReason::SWAP_FAILS); 3938 reason != DidNotSwapReason::SWAP_FAILS);
3940 result_->did_not_swap_called = true; 3939 result_->did_not_swap_called = true;
3941 result_->reason = reason; 3940 result_->reason = reason;
3942 } 3941 }
3943 3942
3944 int64 TraceId() const override { return 0; } 3943 int64 TraceId() const override { return 0; }
3945 3944
3946 private: 3945 private:
3947 // Not owned. 3946 // Not owned.
3948 TestSwapPromiseResult* result_; 3947 TestSwapPromiseResult* result_;
3949 }; 3948 };
3950 3949
3950 class PinnedLayerTreeSwapPromise : public LayerTreeHostTest {
3951 protected:
3952 void BeginTest() override {
3953 PostSetNextCommitForcesRedrawToMainThread();
3954 PostSetNeedsCommitToMainThread();
3955 }
3956
3957 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
3958 int frame = host_impl->active_tree()->source_frame_number();
3959 if (frame == -1) {
3960 host_impl->active_tree()->QueuePinnedSwapPromise(make_scoped_ptr(
3961 new TestSwapPromise(&pinned_active_swap_promise_result_)));
3962 host_impl->pending_tree()->QueueSwapPromise(
3963 make_scoped_ptr(new TestSwapPromise(&pending_swap_promise_result_)));
3964 host_impl->active_tree()->QueueSwapPromise(
3965 make_scoped_ptr(new TestSwapPromise(&active_swap_promise_result_)));
3966 }
3967 }
3968
3969 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override {
3970 EndTest();
3971 }
3972
3973 void AfterTest() override {
3974 // The pending swap promise should activate and swap.
3975 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called);
3976 EXPECT_TRUE(pending_swap_promise_result_.did_swap_called);
3977
3978 // The active swap promise should fail to swap (it is cancelled by
3979 // the activation of a new frame).
3980 EXPECT_FALSE(active_swap_promise_result_.did_activate_called);
3981 EXPECT_FALSE(active_swap_promise_result_.did_swap_called);
3982 EXPECT_TRUE(active_swap_promise_result_.did_not_swap_called);
3983 EXPECT_EQ(active_swap_promise_result_.reason, SwapPromise::SWAP_FAILS);
3984
3985 // The pinned active swap promise should not activate, but should swap.
3986 EXPECT_FALSE(pinned_active_swap_promise_result_.did_activate_called);
3987 EXPECT_TRUE(pinned_active_swap_promise_result_.did_swap_called);
3988 }
3989
3990 TestSwapPromiseResult pending_swap_promise_result_;
3991 TestSwapPromiseResult active_swap_promise_result_;
3992 TestSwapPromiseResult pinned_active_swap_promise_result_;
3993 };
3994
3995 MULTI_THREAD_TEST_F(PinnedLayerTreeSwapPromise);
3996
3951 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest { 3997 class LayerTreeHostTestBreakSwapPromise : public LayerTreeHostTest {
3952 protected: 3998 protected:
3953 LayerTreeHostTestBreakSwapPromise() 3999 LayerTreeHostTestBreakSwapPromise()
3954 : commit_count_(0), commit_complete_count_(0) {} 4000 : commit_count_(0), commit_complete_count_(0) {}
3955 4001
3956 void WillBeginMainFrame() override { 4002 void WillBeginMainFrame() override {
3957 ASSERT_LE(commit_count_, 2); 4003 ASSERT_LE(commit_count_, 2);
3958 scoped_ptr<SwapPromise> swap_promise( 4004 scoped_ptr<SwapPromise> swap_promise(
3959 new TestSwapPromise(&swap_promise_result_[commit_count_])); 4005 new TestSwapPromise(&swap_promise_result_[commit_count_]));
3960 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); 4006 layer_tree_host()->QueueSwapPromise(swap_promise.Pass());
(...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after
6260 ScrollAndScaleSet scale_info_; 6306 ScrollAndScaleSet scale_info_;
6261 ScrollAndScaleSet no_op_info_; 6307 ScrollAndScaleSet no_op_info_;
6262 bool requested_update_layers_; 6308 bool requested_update_layers_;
6263 int commit_count_; 6309 int commit_count_;
6264 }; 6310 };
6265 6311
6266 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); 6312 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers);
6267 6313
6268 } // namespace 6314 } // namespace
6269 } // namespace cc 6315 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698