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" |
11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
12 #include "cc/base/swap_promise.h" | 12 #include "cc/base/swap_promise.h" |
13 #include "cc/debug/frame_rate_counter.h" | 13 #include "cc/debug/frame_rate_counter.h" |
14 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
15 #include "cc/layers/content_layer_client.h" | 15 #include "cc/layers/content_layer_client.h" |
16 #include "cc/layers/io_surface_layer.h" | 16 #include "cc/layers/io_surface_layer.h" |
17 #include "cc/layers/layer_impl.h" | 17 #include "cc/layers/layer_impl.h" |
18 #include "cc/layers/painted_scrollbar_layer.h" | 18 #include "cc/layers/painted_scrollbar_layer.h" |
19 #include "cc/layers/picture_layer.h" | 19 #include "cc/layers/picture_layer.h" |
20 #include "cc/layers/solid_color_layer.h" | 20 #include "cc/layers/solid_color_layer.h" |
21 #include "cc/layers/video_layer.h" | 21 #include "cc/layers/video_layer.h" |
22 #include "cc/output/begin_frame_args.h" | 22 #include "cc/output/begin_frame_args.h" |
23 #include "cc/output/copy_output_request.h" | 23 #include "cc/output/copy_output_request.h" |
24 #include "cc/output/copy_output_result.h" | 24 #include "cc/output/copy_output_result.h" |
25 #include "cc/output/output_surface.h" | 25 #include "cc/output/output_surface.h" |
26 #include "cc/resources/prioritized_resource.h" | 26 #include "cc/resources/prioritized_resource.h" |
27 #include "cc/resources/prioritized_resource_manager.h" | 27 #include "cc/resources/prioritized_resource_manager.h" |
28 #include "cc/resources/resource_update_queue.h" | 28 #include "cc/resources/resource_update_queue.h" |
29 #include "cc/scheduler/frame_rate_controller.h" | |
30 #include "cc/test/fake_content_layer.h" | 29 #include "cc/test/fake_content_layer.h" |
31 #include "cc/test/fake_content_layer_client.h" | 30 #include "cc/test/fake_content_layer_client.h" |
32 #include "cc/test/fake_content_layer_impl.h" | 31 #include "cc/test/fake_content_layer_impl.h" |
33 #include "cc/test/fake_layer_tree_host_client.h" | 32 #include "cc/test/fake_layer_tree_host_client.h" |
34 #include "cc/test/fake_output_surface.h" | 33 #include "cc/test/fake_output_surface.h" |
35 #include "cc/test/fake_painted_scrollbar_layer.h" | 34 #include "cc/test/fake_painted_scrollbar_layer.h" |
36 #include "cc/test/fake_picture_layer.h" | 35 #include "cc/test/fake_picture_layer.h" |
37 #include "cc/test/fake_picture_layer_impl.h" | 36 #include "cc/test/fake_picture_layer_impl.h" |
38 #include "cc/test/fake_proxy.h" | 37 #include "cc/test/fake_proxy.h" |
39 #include "cc/test/fake_scoped_ui_resource.h" | 38 #include "cc/test/fake_scoped_ui_resource.h" |
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 private: | 2656 private: |
2658 NotificationClient client_; | 2657 NotificationClient client_; |
2659 }; | 2658 }; |
2660 | 2659 |
2661 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2660 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
2662 | 2661 |
2663 // Verify that the BeginFrame notification is used to initiate rendering. | 2662 // Verify that the BeginFrame notification is used to initiate rendering. |
2664 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | 2663 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
2665 public: | 2664 public: |
2666 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2665 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2667 settings->begin_impl_frame_scheduling_enabled = true; | 2666 settings->begin_frame_scheduling_enabled = true; |
2668 } | 2667 } |
2669 | 2668 |
2670 virtual void BeginTest() OVERRIDE { | 2669 virtual void BeginTest() OVERRIDE { |
2671 // This will trigger a SetNeedsBeginFrame which will trigger a | 2670 // This will trigger a SetNeedsBeginFrame which will trigger a |
2672 // BeginFrame. | 2671 // BeginFrame. |
2673 PostSetNeedsCommitToMainThread(); | 2672 PostSetNeedsCommitToMainThread(); |
2674 } | 2673 } |
2675 | 2674 |
2676 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 2675 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( |
2677 LayerTreeHostImpl* host_impl, | 2676 LayerTreeHostImpl* host_impl, |
2678 LayerTreeHostImpl::FrameData* frame, | 2677 LayerTreeHostImpl::FrameData* frame, |
2679 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 2678 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { |
2680 EndTest(); | 2679 EndTest(); |
2681 return DrawSwapReadbackResult::DRAW_SUCCESS; | 2680 return DrawSwapReadbackResult::DRAW_SUCCESS; |
2682 } | 2681 } |
2683 | 2682 |
2684 virtual void AfterTest() OVERRIDE {} | 2683 virtual void AfterTest() OVERRIDE {} |
2685 | 2684 |
2686 private: | 2685 private: |
2687 base::TimeTicks frame_time_; | 2686 base::TimeTicks frame_time_; |
2688 }; | 2687 }; |
2689 | 2688 |
2690 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); | 2689 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); |
2691 | 2690 |
2692 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled | 2691 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
2693 : public LayerTreeHostTest { | 2692 : public LayerTreeHostTest { |
2694 public: | 2693 public: |
2695 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2694 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2696 settings->begin_impl_frame_scheduling_enabled = true; | 2695 settings->begin_frame_scheduling_enabled = true; |
2697 settings->using_synchronous_renderer_compositor = true; | 2696 settings->using_synchronous_renderer_compositor = true; |
2698 } | 2697 } |
2699 | 2698 |
2700 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2699 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2701 | 2700 |
2702 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2701 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2703 // The BeginFrame notification is turned off now but will get enabled | 2702 // The BeginFrame notification is turned off now but will get enabled |
2704 // once we return. End test while it's enabled. | 2703 // once we return. End test while it's enabled. |
2705 ImplThreadTaskRunner()->PostTask( | 2704 ImplThreadTaskRunner()->PostTask( |
2706 FROM_HERE, | 2705 FROM_HERE, |
2707 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, | 2706 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
2708 base::Unretained(this))); | 2707 base::Unretained(this))); |
2709 } | 2708 } |
2710 | 2709 |
2711 virtual void AfterTest() OVERRIDE {} | 2710 virtual void AfterTest() OVERRIDE {} |
2712 }; | 2711 }; |
2713 | 2712 |
2714 MULTI_THREAD_TEST_F( | 2713 MULTI_THREAD_TEST_F( |
2715 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); | 2714 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
2716 | 2715 |
2717 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { | 2716 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { |
2718 protected: | 2717 protected: |
2719 LayerTreeHostTestAbortedCommitDoesntStall() | 2718 LayerTreeHostTestAbortedCommitDoesntStall() |
2720 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} | 2719 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} |
2721 | 2720 |
2722 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2721 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
2723 settings->begin_impl_frame_scheduling_enabled = true; | 2722 settings->begin_frame_scheduling_enabled = true; |
2724 } | 2723 } |
2725 | 2724 |
2726 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2725 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2727 | 2726 |
2728 virtual void DidCommit() OVERRIDE { | 2727 virtual void DidCommit() OVERRIDE { |
2729 commit_count_++; | 2728 commit_count_++; |
2730 if (commit_count_ == 4) { | 2729 if (commit_count_ == 4) { |
2731 // After two aborted commits, request a real commit now to make sure a | 2730 // After two aborted commits, request a real commit now to make sure a |
2732 // real commit following an aborted commit will still complete and | 2731 // real commit following an aborted commit will still complete and |
2733 // end the test even when the Impl thread is idle. | 2732 // end the test even when the Impl thread is idle. |
(...skipping 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5278 const gfx::Size bounds_; | 5277 const gfx::Size bounds_; |
5279 FakeContentLayerClient client_; | 5278 FakeContentLayerClient client_; |
5280 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5279 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
5281 scoped_refptr<FakePictureLayer> picture_layer_; | 5280 scoped_refptr<FakePictureLayer> picture_layer_; |
5282 Layer* child_layer_; | 5281 Layer* child_layer_; |
5283 }; | 5282 }; |
5284 | 5283 |
5285 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5284 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
5286 | 5285 |
5287 } // namespace cc | 5286 } // namespace cc |
OLD | NEW |