OLD | NEW |
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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1100 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1101 EXPECT_EQ(frame_count_with_pending_tree_, 0); | 1101 EXPECT_EQ(frame_count_with_pending_tree_, 0); |
1102 impl->BlockNotifyReadyToActivateForTesting(true); | 1102 impl->BlockNotifyReadyToActivateForTesting(true); |
1103 } | 1103 } |
1104 | 1104 |
1105 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | 1105 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
1106 const BeginFrameArgs& args) OVERRIDE { | 1106 const BeginFrameArgs& args) OVERRIDE { |
1107 if (impl->pending_tree()) | 1107 if (impl->pending_tree()) |
1108 frame_count_with_pending_tree_++; | 1108 frame_count_with_pending_tree_++; |
1109 | 1109 |
1110 if (frame_count_with_pending_tree_ == 2) | |
1111 impl->BlockNotifyReadyToActivateForTesting(false); | |
1112 } | |
1113 | |
1114 virtual void DidBeginImplFrameOnThread(LayerTreeHostImpl* impl, | |
1115 const BeginFrameArgs& args) OVERRIDE { | |
1116 if (frame_count_with_pending_tree_ == 1) { | 1110 if (frame_count_with_pending_tree_ == 1) { |
1117 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); | 1111 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); |
1118 first_frame_time_ = impl->CurrentFrameTimeTicks(); | 1112 first_frame_time_ = impl->CurrentFrameTimeTicks(); |
| 1113 } else if (frame_count_with_pending_tree_ == 2) { |
| 1114 impl->BlockNotifyReadyToActivateForTesting(false); |
1119 } | 1115 } |
1120 } | 1116 } |
1121 | 1117 |
1122 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1118 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1123 if (frame_count_with_pending_tree_ > 1) { | 1119 if (frame_count_with_pending_tree_ > 1) { |
1124 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); | 1120 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); |
1125 EXPECT_NE(first_frame_time_.ToInternalValue(), | 1121 EXPECT_NE(first_frame_time_.ToInternalValue(), |
1126 impl->CurrentFrameTimeTicks().ToInternalValue()); | 1122 impl->CurrentFrameTimeTicks().ToInternalValue()); |
1127 EndTest(); | 1123 EndTest(); |
1128 return; | 1124 return; |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 break; | 2653 break; |
2658 } | 2654 } |
2659 } | 2655 } |
2660 | 2656 |
2661 private: | 2657 private: |
2662 NotificationClient client_; | 2658 NotificationClient client_; |
2663 }; | 2659 }; |
2664 | 2660 |
2665 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2661 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2666 | 2662 |
2667 // Verify that the BeginImplFrame notification is used to initiate rendering. | 2663 // Verify that the BeginFrame notification is used to initiate rendering. |
2668 class LayerTreeHostTestBeginImplFrameNotification : public LayerTreeHostTest { | 2664 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2669 public: | 2665 public: |
2670 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2666 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2671 settings->begin_impl_frame_scheduling_enabled = true; | 2667 settings->begin_impl_frame_scheduling_enabled = true; |
2672 } | 2668 } |
2673 | 2669 |
2674 virtual void BeginTest() OVERRIDE { | 2670 virtual void BeginTest() OVERRIDE { |
2675 // This will trigger a SetNeedsBeginImplFrame which will trigger a | 2671 // This will trigger a SetNeedsBeginFrame which will trigger a |
2676 // BeginImplFrame. | 2672 // BeginFrame. |
2677 PostSetNeedsCommitToMainThread(); | 2673 PostSetNeedsCommitToMainThread(); |
2678 } | 2674 } |
2679 | 2675 |
2680 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 2676 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( |
2681 LayerTreeHostImpl* host_impl, | 2677 LayerTreeHostImpl* host_impl, |
2682 LayerTreeHostImpl::FrameData* frame, | 2678 LayerTreeHostImpl::FrameData* frame, |
2683 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 2679 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { |
2684 EndTest(); | 2680 EndTest(); |
2685 return DrawSwapReadbackResult::DRAW_SUCCESS; | 2681 return DrawSwapReadbackResult::DRAW_SUCCESS; |
2686 } | 2682 } |
2687 | 2683 |
2688 virtual void AfterTest() OVERRIDE {} | 2684 virtual void AfterTest() OVERRIDE {} |
2689 | 2685 |
2690 private: | 2686 private: |
2691 base::TimeTicks frame_time_; | 2687 base::TimeTicks frame_time_; |
2692 }; | 2688 }; |
2693 | 2689 |
2694 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginImplFrameNotification); | 2690 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); |
2695 | 2691 |
2696 class LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled | 2692 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
2697 : public LayerTreeHostTest { | 2693 : public LayerTreeHostTest { |
2698 public: | 2694 public: |
2699 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2695 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2700 settings->begin_impl_frame_scheduling_enabled = true; | 2696 settings->begin_impl_frame_scheduling_enabled = true; |
2701 settings->using_synchronous_renderer_compositor = true; | 2697 settings->using_synchronous_renderer_compositor = true; |
2702 } | 2698 } |
2703 | 2699 |
2704 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2700 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2705 | 2701 |
2706 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2702 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2707 // The BeginImplFrame notification is turned off now but will get enabled | 2703 // The BeginFrame notification is turned off now but will get enabled |
2708 // once we return. End test while it's enabled. | 2704 // once we return. End test while it's enabled. |
2709 ImplThreadTaskRunner()->PostTask( | 2705 ImplThreadTaskRunner()->PostTask( |
2710 FROM_HERE, | 2706 FROM_HERE, |
2711 base::Bind(&LayerTreeHostTestBeginImplFrameNotification::EndTest, | 2707 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
2712 base::Unretained(this))); | 2708 base::Unretained(this))); |
2713 } | 2709 } |
2714 | 2710 |
2715 virtual void AfterTest() OVERRIDE {} | 2711 virtual void AfterTest() OVERRIDE {} |
2716 }; | 2712 }; |
2717 | 2713 |
2718 MULTI_THREAD_TEST_F( | 2714 MULTI_THREAD_TEST_F( |
2719 LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled); | 2715 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
2720 | 2716 |
2721 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { | 2717 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { |
2722 protected: | 2718 protected: |
2723 LayerTreeHostTestAbortedCommitDoesntStall() | 2719 LayerTreeHostTestAbortedCommitDoesntStall() |
2724 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} | 2720 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} |
2725 | 2721 |
2726 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2722 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2727 settings->begin_impl_frame_scheduling_enabled = true; | 2723 settings->begin_impl_frame_scheduling_enabled = true; |
2728 } | 2724 } |
2729 | 2725 |
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5282 const gfx::Size bounds_; | 5278 const gfx::Size bounds_; |
5283 FakeContentLayerClient client_; | 5279 FakeContentLayerClient client_; |
5284 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5280 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
5285 scoped_refptr<FakePictureLayer> picture_layer_; | 5281 scoped_refptr<FakePictureLayer> picture_layer_; |
5286 Layer* child_layer_; | 5282 Layer* child_layer_; |
5287 }; | 5283 }; |
5288 | 5284 |
5289 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5285 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
5290 | 5286 |
5291 } // namespace cc | 5287 } // namespace cc |
OLD | NEW |