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

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

Issue 22926024: cc: Control activation from the Scheduler (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedOutputSurface4
Patch Set: git cl format Created 7 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_host_unittest_scroll.cc » ('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/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 }; 694 };
695 695
696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); 696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
697 697
698 // This test verifies that LayerTreeHostImpl's current frame time gets 698 // This test verifies that LayerTreeHostImpl's current frame time gets
699 // updated in consecutive frames when it doesn't draw due to tree 699 // updated in consecutive frames when it doesn't draw due to tree
700 // activation failure. 700 // activation failure.
701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails 701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
702 : public LayerTreeHostTest { 702 : public LayerTreeHostTest {
703 public: 703 public:
704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {} 704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
705 : frame_count_with_pending_tree_(0) {}
705 706
706 virtual void BeginTest() OVERRIDE { 707 virtual void BeginTest() OVERRIDE {
707 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 708 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
708 layer_tree_host()->set_background_color(SK_ColorGRAY); 709 layer_tree_host()->set_background_color(SK_ColorGRAY);
709 710
710 PostSetNeedsCommitToMainThread(); 711 PostSetNeedsCommitToMainThread();
711 } 712 }
712 713
714 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
715 const BeginFrameArgs& args) OVERRIDE {
716 if (host_impl->pending_tree())
717 frame_count_with_pending_tree_++;
718 host_impl->BlockNotifyReadyToActivateForTesting(
719 frame_count_with_pending_tree_ <= 1);
720 }
721
713 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 722 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
714 if (frame_ >= 1) { 723 if (frame_count_with_pending_tree_ > 1) {
715 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); 724 EXPECT_NE(first_frame_time_.ToInternalValue(),
725 impl->CurrentFrameTimeTicks().ToInternalValue());
716 EndTest(); 726 EndTest();
717 return; 727 return;
718 } 728 }
719 729
720 EXPECT_FALSE(impl->settings().impl_side_painting); 730 EXPECT_FALSE(impl->settings().impl_side_painting);
721 EndTest(); 731 EndTest();
722 } 732 }
723 733 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
724 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { 734 if (impl->settings().impl_side_painting)
725 if (frame_ >= 1) 735 EXPECT_NE(frame_count_with_pending_tree_, 1);
726 return true;
727
728 return false;
729 }
730
731 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl)
732 OVERRIDE {
733 frame_++;
734 if (frame_ == 1) {
735 first_frame_time_ = impl->CurrentFrameTimeTicks();
736
737 // Since base::TimeTicks::Now() uses a low-resolution clock on
738 // Windows, we need to make sure that the clock has incremented past
739 // first_frame_time_.
740 while (first_frame_time_ == base::TimeTicks::Now()) {}
741
742 return false;
743 }
744
745 return true;
746 } 736 }
747 737
748 virtual void AfterTest() OVERRIDE {} 738 virtual void AfterTest() OVERRIDE {}
749 739
750 private: 740 private:
751 int frame_; 741 int frame_count_with_pending_tree_;
752 base::TimeTicks first_frame_time_; 742 base::TimeTicks first_frame_time_;
753 }; 743 };
754 744
755 SINGLE_AND_MULTI_THREAD_TEST_F( 745 SINGLE_AND_MULTI_THREAD_TEST_F(
756 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); 746 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
757 747
758 // This test verifies that LayerTreeHostImpl's current frame time gets 748 // This test verifies that LayerTreeHostImpl's current frame time gets
759 // updated in consecutive frames when it draws in each frame. 749 // updated in consecutive frames when it draws in each frame.
760 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { 750 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
761 public: 751 public:
(...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after
4465 int num_will_begin_frames_; 4455 int num_will_begin_frames_;
4466 int num_impl_commits_; 4456 int num_impl_commits_;
4467 }; 4457 };
4468 4458
4469 // Commits can only be aborted when using the thread proxy. 4459 // Commits can only be aborted when using the thread proxy.
4470 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4460 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4471 4461
4472 } // namespace 4462 } // namespace
4473 4463
4474 } // namespace cc 4464 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698