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

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: Address review comments 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
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 return false;
660 }
661
662 return true;
663 }
664
665 virtual void AfterTest() OVERRIDE {}
666
667 private:
668 int frame_;
669 base::TimeTicks first_frame_time_;
670 };
671
672 SINGLE_AND_MULTI_THREAD_TEST_F(
673 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
674
675 // This test verifies that LayerTreeHostImpl's current frame time gets
676 // updated in consecutive frames when it draws in each frame.
677 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
678 public:
679 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {}
680
681 virtual void BeginTest() OVERRIDE {
682 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
683 layer_tree_host()->set_background_color(SK_ColorGRAY);
684
685 PostSetNeedsCommitToMainThread();
686 }
687
688 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
689 frame_++;
690 if (frame_ == 1) {
691 first_frame_time_ = impl->CurrentFrameTimeTicks();
692 impl->SetNeedsRedraw();
danakj 2013/05/16 17:42:38 Can you add a CommitCompleteOnThread override and
ajuma 2013/05/16 19:50:01 Done.
693 return;
694 }
695
696 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
697 EndTest();
698 }
699
700 virtual void AfterTest() OVERRIDE {}
701
702 private:
703 int frame_;
704 base::TimeTicks first_frame_time_;
705 };
706
707 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFrameTimeUpdatesAfterDraw);
708
629 // Verifies that StartPageScaleAnimation events propagate correctly 709 // Verifies that StartPageScaleAnimation events propagate correctly
630 // from LayerTreeHost to LayerTreeHostImpl in the MT compositor. 710 // from LayerTreeHost to LayerTreeHostImpl in the MT compositor.
631 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { 711 class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
632 public: 712 public:
633 LayerTreeHostTestStartPageScaleAnimation() {} 713 LayerTreeHostTestStartPageScaleAnimation() {}
634 714
635 virtual void SetupTree() OVERRIDE { 715 virtual void SetupTree() OVERRIDE {
636 LayerTreeHostTest::SetupTree(); 716 LayerTreeHostTest::SetupTree();
637 717
638 scroll_layer_ = FakeContentLayer::Create(&client_); 718 scroll_layer_ = FakeContentLayer::Create(&client_);
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 3027 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2948 RunTest(true, true, true); 3028 RunTest(true, true, true);
2949 } 3029 }
2950 3030
2951 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 3031 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2952 RunTest(true, false, true); 3032 RunTest(true, false, true);
2953 } 3033 }
2954 3034
2955 } // namespace 3035 } // namespace
2956 } // namespace cc 3036 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698