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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 layer_tree_host()->set_background_color(SK_ColorGRAY); | 1095 layer_tree_host()->set_background_color(SK_ColorGRAY); |
1096 | 1096 |
1097 PostSetNeedsCommitToMainThread(); | 1097 PostSetNeedsCommitToMainThread(); |
1098 } | 1098 } |
1099 | 1099 |
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 WillBeginFrameOnThread(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) | 1110 if (frame_count_with_pending_tree_ == 2) |
1111 impl->BlockNotifyReadyToActivateForTesting(false); | 1111 impl->BlockNotifyReadyToActivateForTesting(false); |
1112 } | 1112 } |
1113 | 1113 |
1114 virtual void DidBeginImplFrameOnThread(LayerTreeHostImpl* impl, | 1114 virtual void DidBeginFrameOnThread(LayerTreeHostImpl* impl, |
1115 const BeginFrameArgs& args) OVERRIDE { | 1115 const BeginFrameArgs& args) OVERRIDE { |
1116 if (frame_count_with_pending_tree_ == 1) { | 1116 if (frame_count_with_pending_tree_ == 1) { |
1117 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); | 1117 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); |
1118 first_frame_time_ = impl->CurrentFrameTimeTicks(); | 1118 first_frame_time_ = impl->CurrentFrameTimeTicks(); |
1119 } | 1119 } |
1120 } | 1120 } |
1121 | 1121 |
1122 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1122 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1123 if (frame_count_with_pending_tree_ > 1) { | 1123 if (frame_count_with_pending_tree_ > 1) { |
1124 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); | 1124 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); |
1125 EXPECT_NE(first_frame_time_.ToInternalValue(), | 1125 EXPECT_NE(first_frame_time_.ToInternalValue(), |
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 break; | 2657 break; |
2658 } | 2658 } |
2659 } | 2659 } |
2660 | 2660 |
2661 private: | 2661 private: |
2662 NotificationClient client_; | 2662 NotificationClient client_; |
2663 }; | 2663 }; |
2664 | 2664 |
2665 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2665 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2666 | 2666 |
2667 // Verify that the BeginImplFrame notification is used to initiate rendering. | 2667 // Verify that the BeginFrame notification is used to initiate rendering. |
2668 class LayerTreeHostTestBeginImplFrameNotification : public LayerTreeHostTest { | 2668 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2669 public: | 2669 public: |
2670 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2670 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2671 settings->begin_impl_frame_scheduling_enabled = true; | 2671 settings->begin_impl_frame_scheduling_enabled = true; |
2672 } | 2672 } |
2673 | 2673 |
2674 virtual void BeginTest() OVERRIDE { | 2674 virtual void BeginTest() OVERRIDE { |
2675 // This will trigger a SetNeedsBeginImplFrame which will trigger a | 2675 // This will trigger a SetNeedsBeginFrame which will trigger a |
2676 // BeginImplFrame. | 2676 // BeginFrame. |
2677 PostSetNeedsCommitToMainThread(); | 2677 PostSetNeedsCommitToMainThread(); |
2678 } | 2678 } |
2679 | 2679 |
2680 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 2680 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( |
2681 LayerTreeHostImpl* host_impl, | 2681 LayerTreeHostImpl* host_impl, |
2682 LayerTreeHostImpl::FrameData* frame, | 2682 LayerTreeHostImpl::FrameData* frame, |
2683 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 2683 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { |
2684 EndTest(); | 2684 EndTest(); |
2685 return DrawSwapReadbackResult::DRAW_SUCCESS; | 2685 return DrawSwapReadbackResult::DRAW_SUCCESS; |
2686 } | 2686 } |
2687 | 2687 |
2688 virtual void AfterTest() OVERRIDE {} | 2688 virtual void AfterTest() OVERRIDE {} |
2689 | 2689 |
2690 private: | 2690 private: |
2691 base::TimeTicks frame_time_; | 2691 base::TimeTicks frame_time_; |
2692 }; | 2692 }; |
2693 | 2693 |
2694 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginImplFrameNotification); | 2694 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); |
2695 | 2695 |
2696 class LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled | 2696 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
2697 : public LayerTreeHostTest { | 2697 : public LayerTreeHostTest { |
2698 public: | 2698 public: |
2699 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2699 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2700 settings->begin_impl_frame_scheduling_enabled = true; | 2700 settings->begin_impl_frame_scheduling_enabled = true; |
2701 settings->using_synchronous_renderer_compositor = true; | 2701 settings->using_synchronous_renderer_compositor = true; |
2702 } | 2702 } |
2703 | 2703 |
2704 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2704 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2705 | 2705 |
2706 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2706 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2707 // The BeginImplFrame notification is turned off now but will get enabled | 2707 // The BeginFrame notification is turned off now but will get enabled |
2708 // once we return. End test while it's enabled. | 2708 // once we return. End test while it's enabled. |
2709 ImplThreadTaskRunner()->PostTask( | 2709 ImplThreadTaskRunner()->PostTask( |
2710 FROM_HERE, | 2710 FROM_HERE, |
2711 base::Bind(&LayerTreeHostTestBeginImplFrameNotification::EndTest, | 2711 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
2712 base::Unretained(this))); | 2712 base::Unretained(this))); |
2713 } | 2713 } |
2714 | 2714 |
2715 virtual void AfterTest() OVERRIDE {} | 2715 virtual void AfterTest() OVERRIDE {} |
2716 }; | 2716 }; |
2717 | 2717 |
2718 MULTI_THREAD_TEST_F( | 2718 MULTI_THREAD_TEST_F( |
2719 LayerTreeHostTestBeginImplFrameNotificationShutdownWhileEnabled); | 2719 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
2720 | 2720 |
2721 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { | 2721 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { |
2722 protected: | 2722 protected: |
2723 LayerTreeHostTestAbortedCommitDoesntStall() | 2723 LayerTreeHostTestAbortedCommitDoesntStall() |
2724 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} | 2724 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} |
2725 | 2725 |
2726 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2726 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2727 settings->begin_impl_frame_scheduling_enabled = true; | 2727 settings->begin_impl_frame_scheduling_enabled = true; |
2728 } | 2728 } |
2729 | 2729 |
(...skipping 2473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5203 } | 5203 } |
5204 | 5204 |
5205 virtual void AfterTest() OVERRIDE {} | 5205 virtual void AfterTest() OVERRIDE {} |
5206 | 5206 |
5207 FakeContentLayerClient client_; | 5207 FakeContentLayerClient client_; |
5208 }; | 5208 }; |
5209 | 5209 |
5210 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationSetting); | 5210 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationSetting); |
5211 | 5211 |
5212 } // namespace cc | 5212 } // namespace cc |
OLD | NEW |