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

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

Issue 218633010: cc: Handle retroactive BeginFrames in the Scheduler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@compositorVsyncDisable
Patch Set: fix comment typo Created 6 years, 8 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/single_thread_proxy.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/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1039 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1040 EXPECT_EQ(frame_count_with_pending_tree_, 0); 1040 EXPECT_EQ(frame_count_with_pending_tree_, 0);
1041 impl->BlockNotifyReadyToActivateForTesting(true); 1041 impl->BlockNotifyReadyToActivateForTesting(true);
1042 } 1042 }
1043 1043
1044 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, 1044 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
1045 const BeginFrameArgs& args) OVERRIDE { 1045 const BeginFrameArgs& args) OVERRIDE {
1046 if (impl->pending_tree()) 1046 if (impl->pending_tree())
1047 frame_count_with_pending_tree_++; 1047 frame_count_with_pending_tree_++;
1048 1048
1049 if (frame_count_with_pending_tree_ == 2)
1050 impl->BlockNotifyReadyToActivateForTesting(false);
1051 }
1052
1053 virtual void DidBeginImplFrameOnThread(LayerTreeHostImpl* impl,
1054 const BeginFrameArgs& args) OVERRIDE {
1055 if (frame_count_with_pending_tree_ == 1) { 1049 if (frame_count_with_pending_tree_ == 1) {
1056 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); 1050 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0);
1057 first_frame_time_ = impl->CurrentFrameTimeTicks(); 1051 first_frame_time_ = impl->CurrentFrameTimeTicks();
1052 } else if (frame_count_with_pending_tree_ == 2) {
1053 impl->BlockNotifyReadyToActivateForTesting(false);
1058 } 1054 }
1059 } 1055 }
1060 1056
1061 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1057 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1062 if (frame_count_with_pending_tree_ > 1) { 1058 if (frame_count_with_pending_tree_ > 1) {
1063 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); 1059 EXPECT_NE(first_frame_time_.ToInternalValue(), 0);
1064 EXPECT_NE(first_frame_time_.ToInternalValue(), 1060 EXPECT_NE(first_frame_time_.ToInternalValue(),
1065 impl->CurrentFrameTimeTicks().ToInternalValue()); 1061 impl->CurrentFrameTimeTicks().ToInternalValue());
1066 EndTest(); 1062 EndTest();
1067 return; 1063 return;
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 break; 2593 break;
2598 } 2594 }
2599 } 2595 }
2600 2596
2601 private: 2597 private:
2602 NotificationClient client_; 2598 NotificationClient client_;
2603 }; 2599 };
2604 2600
2605 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); 2601 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification);
2606 2602
2607 // Verify that the BeginImplFrame notification is used to initiate rendering. 2603 // Verify that the BeginFrame notification is used to initiate rendering.
2608 class LayerTreeHostTestBeginImplFrameNotification : public LayerTreeHostTest { 2604 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest {
2609 public: 2605 public:
2610 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2606 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2611 settings->begin_impl_frame_scheduling_enabled = true; 2607 settings->begin_impl_frame_scheduling_enabled = true;
2612 } 2608 }
2613 2609
2614 virtual void BeginTest() OVERRIDE { 2610 virtual void BeginTest() OVERRIDE {
2615 // This will trigger a SetNeedsBeginImplFrame which will trigger a 2611 // This will trigger a SetNeedsBeginFrame which will trigger a
2616 // BeginImplFrame. 2612 // BeginFrame.
2617 PostSetNeedsCommitToMainThread(); 2613 PostSetNeedsCommitToMainThread();
2618 } 2614 }
2619 2615
2620 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( 2616 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
2621 LayerTreeHostImpl* host_impl, 2617 LayerTreeHostImpl* host_impl,
2622 LayerTreeHostImpl::FrameData* frame, 2618 LayerTreeHostImpl::FrameData* frame,
2623 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { 2619 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
2624 EndTest(); 2620 EndTest();
2625 return DrawSwapReadbackResult::DRAW_SUCCESS; 2621 return DrawSwapReadbackResult::DRAW_SUCCESS;
2626 } 2622 }
2627 2623
2628 virtual void AfterTest() OVERRIDE {} 2624 virtual void AfterTest() OVERRIDE {}
2629 2625
2630 private: 2626 private:
2631 base::TimeTicks frame_time_; 2627 base::TimeTicks frame_time_;
2632 }; 2628 };
2633 2629
2634 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginImplFrameNotification); 2630 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification);
2635 2631
2636 class LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled 2632 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
2637 : public LayerTreeHostTest { 2633 : public LayerTreeHostTest {
2638 public: 2634 public:
2639 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2635 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2640 settings->begin_impl_frame_scheduling_enabled = true; 2636 settings->begin_impl_frame_scheduling_enabled = true;
2641 settings->using_synchronous_renderer_compositor = true; 2637 settings->using_synchronous_renderer_compositor = true;
2642 } 2638 }
2643 2639
2644 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2640 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2645 2641
2646 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2642 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2647 // The BeginImplFrame notification is turned off now but will get enabled 2643 // The BeginFrame notification is turned off now but will get enabled
2648 // once we return. End test while it's enabled. 2644 // once we return. End test while it's enabled.
2649 ImplThreadTaskRunner()->PostTask( 2645 ImplThreadTaskRunner()->PostTask(
2650 FROM_HERE, 2646 FROM_HERE,
2651 base::Bind(&LayerTreeHostTestBeginImplFrameNotification::EndTest, 2647 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest,
2652 base::Unretained(this))); 2648 base::Unretained(this)));
2653 } 2649 }
2654 2650
2655 virtual void AfterTest() OVERRIDE {} 2651 virtual void AfterTest() OVERRIDE {}
2656 }; 2652 };
2657 2653
2658 MULTI_THREAD_TEST_F( 2654 MULTI_THREAD_TEST_F(
2659 LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled); 2655 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled);
2660 2656
2661 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { 2657 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest {
2662 protected: 2658 protected:
2663 LayerTreeHostTestAbortedCommitDoesntStall() 2659 LayerTreeHostTestAbortedCommitDoesntStall()
2664 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} 2660 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {}
2665 2661
2666 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 2662 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
2667 settings->begin_impl_frame_scheduling_enabled = true; 2663 settings->begin_impl_frame_scheduling_enabled = true;
2668 } 2664 }
2669 2665
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after
5222 const gfx::Size bounds_; 5218 const gfx::Size bounds_;
5223 FakeContentLayerClient client_; 5219 FakeContentLayerClient client_;
5224 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5220 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5225 scoped_refptr<FakePictureLayer> picture_layer_; 5221 scoped_refptr<FakePictureLayer> picture_layer_;
5226 Layer* child_layer_; 5222 Layer* child_layer_;
5227 }; 5223 };
5228 5224
5229 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5225 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5230 5226
5231 } // namespace cc 5227 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698