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

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

Issue 15139007: Ensure LayerTreeHostImpl's current frame time is updated every frame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.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/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 EXPECT_EQ(5.f, impl->active_tree()->page_scale_factor()); 619 EXPECT_EQ(5.f, impl->active_tree()->page_scale_factor());
620 620
621 EndTest(); 621 EndTest();
622 } 622 }
623 623
624 virtual void AfterTest() OVERRIDE {} 624 virtual void AfterTest() OVERRIDE {}
625 }; 625 };
626 626
627 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); 627 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
628 628
629 // This test verifies that LayerTreeHostImpl's current frame time gets
630 // updated in consecutive frames when it doesn't draw due to tree
631 // activation failure.
632 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
633 : public LayerTreeHostTest {
634 public:
635 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {}
636
637 virtual void BeginTest() OVERRIDE {
638 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
639 layer_tree_host()->set_background_color(SK_ColorGRAY);
640
641 PostSetNeedsCommitToMainThread();
642 }
643
644 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
645 if (frame_ >= 1) {
646 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
647 EndTest();
648 return;
649 }
650
651 EXPECT_FALSE(impl->settings().impl_side_painting);
652 EndTest();
653 }
654
655 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
656 frame_++;
657 if (frame_ == 1) {
658 first_frame_time_ = impl->CurrentFrameTimeTicks();
659
660 // Since base::TimeTicks::Now() uses a low-resolution clock on
661 // Windows, we need to make sure that the clock has incremented past
662 // first_frame_time_.
663 while (first_frame_time_ == base::TimeTicks::Now());
danakj 2013/05/17 13:39:36 nit: use {} instead of ; to end the line
ajuma 2013/05/17 13:46:50 Done.
664
665 return false;
666 }
667
668 return true;
669 }
670
671 virtual void AfterTest() OVERRIDE {}
672
673 private:
674 int frame_;
675 base::TimeTicks first_frame_time_;
676 };
677
678 SINGLE_AND_MULTI_THREAD_TEST_F(
679 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
680
681 // This test verifies that LayerTreeHostImpl's current frame time gets
682 // updated in consecutive frames when it draws in each frame.
683 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
684 public:
685 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {}
686
687 virtual void BeginTest() OVERRIDE {
688 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
689 layer_tree_host()->set_background_color(SK_ColorGRAY);
690
691 PostSetNeedsCommitToMainThread();
692 }
693
694 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
695 frame_++;
696 if (frame_ == 1) {
697 first_frame_time_ = impl->CurrentFrameTimeTicks();
698 impl->SetNeedsRedraw();
699
700 // Since base::TimeTicks::Now() uses a low-resolution clock on
701 // Windows, we need to make sure that the clock has incremented past
702 // first_frame_time_.
703 while (first_frame_time_ == base::TimeTicks::Now());
ajuma 2013/05/17 13:36:45 This test (and the next one) was flaking on Window
danakj 2013/05/17 13:39:36 and here
ajuma 2013/05/17 13:46:50 Done.
704
705 return;
706 }
707
708 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
709 EndTest();
710 }
711
712 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
713 // Ensure there isn't a commit between the two draws, to ensure that a
714 // commit isn't required for updating the current frame time. We can
715 // only check for this in the multi-threaded case, since in the single-
716 // threaded case there will always be a commit between consecutive draws.
717 if (ImplThread())
718 EXPECT_EQ(0, frame_);
719 }
720
721 virtual void AfterTest() OVERRIDE {}
722
723 private:
724 int frame_;
725 base::TimeTicks first_frame_time_;
726 };
727
728 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFrameTimeUpdatesAfterDraw);
729
629 // Verifies that StartPageScaleAnimation events propagate correctly 730 // Verifies that StartPageScaleAnimation events propagate correctly
630 // from LayerTreeHost to LayerTreeHostImpl in the MT compositor. 731 // from LayerTreeHost to LayerTreeHostImpl in the MT compositor.
631 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { 732 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
632 public: 733 public:
633 LayerTreeHostTestStartPageScaleAnimation() {} 734 LayerTreeHostTestStartPageScaleAnimation() {}
634 735
635 virtual void SetupTree() OVERRIDE { 736 virtual void SetupTree() OVERRIDE {
636 LayerTreeHostTest::SetupTree(); 737 LayerTreeHostTest::SetupTree();
637 738
638 scroll_layer_ = FakeContentLayer::Create(&client_); 739 scroll_layer_ = FakeContentLayer::Create(&client_);
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 3048 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2948 RunTest(true, true, true); 3049 RunTest(true, true, true);
2949 } 3050 }
2950 3051
2951 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 3052 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2952 RunTest(true, false, true); 3053 RunTest(true, false, true);
2953 } 3054 }
2954 3055
2955 } // namespace 3056 } // namespace
2956 } // namespace cc 3057 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.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