| 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 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 private: | 2596 private: |
| 2598 NotificationClient client_; | 2597 NotificationClient client_; |
| 2599 }; | 2598 }; |
| 2600 | 2599 |
| 2601 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); | 2600 SINGLE_THREAD_TEST_F(LayerTreeHostTestLCDNotification); |
| 2602 | 2601 |
| 2603 // Verify that the BeginFrame notification is used to initiate rendering. | 2602 // Verify that the BeginFrame notification is used to initiate rendering. |
| 2604 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | 2603 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { |
| 2605 public: | 2604 public: |
| 2606 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2605 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2607 settings->begin_impl_frame_scheduling_enabled = true; | 2606 settings->begin_frame_scheduling_enabled = true; |
| 2608 } | 2607 } |
| 2609 | 2608 |
| 2610 virtual void BeginTest() OVERRIDE { | 2609 virtual void BeginTest() OVERRIDE { |
| 2611 // This will trigger a SetNeedsBeginFrame which will trigger a | 2610 // This will trigger a SetNeedsBeginFrame which will trigger a |
| 2612 // BeginFrame. | 2611 // BeginFrame. |
| 2613 PostSetNeedsCommitToMainThread(); | 2612 PostSetNeedsCommitToMainThread(); |
| 2614 } | 2613 } |
| 2615 | 2614 |
| 2616 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( | 2615 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread( |
| 2617 LayerTreeHostImpl* host_impl, | 2616 LayerTreeHostImpl* host_impl, |
| 2618 LayerTreeHostImpl::FrameData* frame, | 2617 LayerTreeHostImpl::FrameData* frame, |
| 2619 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { | 2618 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE { |
| 2620 EndTest(); | 2619 EndTest(); |
| 2621 return DrawSwapReadbackResult::DRAW_SUCCESS; | 2620 return DrawSwapReadbackResult::DRAW_SUCCESS; |
| 2622 } | 2621 } |
| 2623 | 2622 |
| 2624 virtual void AfterTest() OVERRIDE {} | 2623 virtual void AfterTest() OVERRIDE {} |
| 2625 | 2624 |
| 2626 private: | 2625 private: |
| 2627 base::TimeTicks frame_time_; | 2626 base::TimeTicks frame_time_; |
| 2628 }; | 2627 }; |
| 2629 | 2628 |
| 2630 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); | 2629 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); |
| 2631 | 2630 |
| 2632 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled | 2631 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
| 2633 : public LayerTreeHostTest { | 2632 : public LayerTreeHostTest { |
| 2634 public: | 2633 public: |
| 2635 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2634 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2636 settings->begin_impl_frame_scheduling_enabled = true; | 2635 settings->begin_frame_scheduling_enabled = true; |
| 2637 settings->using_synchronous_renderer_compositor = true; | 2636 settings->using_synchronous_renderer_compositor = true; |
| 2638 } | 2637 } |
| 2639 | 2638 |
| 2640 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2639 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 2641 | 2640 |
| 2642 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2641 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2643 // The BeginFrame notification is turned off now but will get enabled | 2642 // The BeginFrame notification is turned off now but will get enabled |
| 2644 // once we return. End test while it's enabled. | 2643 // once we return. End test while it's enabled. |
| 2645 ImplThreadTaskRunner()->PostTask( | 2644 ImplThreadTaskRunner()->PostTask( |
| 2646 FROM_HERE, | 2645 FROM_HERE, |
| 2647 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, | 2646 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
| 2648 base::Unretained(this))); | 2647 base::Unretained(this))); |
| 2649 } | 2648 } |
| 2650 | 2649 |
| 2651 virtual void AfterTest() OVERRIDE {} | 2650 virtual void AfterTest() OVERRIDE {} |
| 2652 }; | 2651 }; |
| 2653 | 2652 |
| 2654 MULTI_THREAD_TEST_F( | 2653 MULTI_THREAD_TEST_F( |
| 2655 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); | 2654 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
| 2656 | 2655 |
| 2657 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { | 2656 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { |
| 2658 protected: | 2657 protected: |
| 2659 LayerTreeHostTestAbortedCommitDoesntStall() | 2658 LayerTreeHostTestAbortedCommitDoesntStall() |
| 2660 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} | 2659 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} |
| 2661 | 2660 |
| 2662 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2661 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2663 settings->begin_impl_frame_scheduling_enabled = true; | 2662 settings->begin_frame_scheduling_enabled = true; |
| 2664 } | 2663 } |
| 2665 | 2664 |
| 2666 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2665 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 2667 | 2666 |
| 2668 virtual void DidCommit() OVERRIDE { | 2667 virtual void DidCommit() OVERRIDE { |
| 2669 commit_count_++; | 2668 commit_count_++; |
| 2670 if (commit_count_ == 4) { | 2669 if (commit_count_ == 4) { |
| 2671 // After two aborted commits, request a real commit now to make sure a | 2670 // After two aborted commits, request a real commit now to make sure a |
| 2672 // real commit following an aborted commit will still complete and | 2671 // real commit following an aborted commit will still complete and |
| 2673 // end the test even when the Impl thread is idle. | 2672 // end the test even when the Impl thread is idle. |
| (...skipping 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5218 const gfx::Size bounds_; | 5217 const gfx::Size bounds_; |
| 5219 FakeContentLayerClient client_; | 5218 FakeContentLayerClient client_; |
| 5220 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5219 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 5221 scoped_refptr<FakePictureLayer> picture_layer_; | 5220 scoped_refptr<FakePictureLayer> picture_layer_; |
| 5222 Layer* child_layer_; | 5221 Layer* child_layer_; |
| 5223 }; | 5222 }; |
| 5224 | 5223 |
| 5225 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5224 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 5226 | 5225 |
| 5227 } // namespace cc | 5226 } // namespace cc |
| OLD | NEW |