Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 #include "cc/test/fake_recording_source.h" | 43 #include "cc/test/fake_recording_source.h" |
| 44 #include "cc/test/fake_scoped_ui_resource.h" | 44 #include "cc/test/fake_scoped_ui_resource.h" |
| 45 #include "cc/test/fake_video_frame_provider.h" | 45 #include "cc/test/fake_video_frame_provider.h" |
| 46 #include "cc/test/geometry_test_utils.h" | 46 #include "cc/test/geometry_test_utils.h" |
| 47 #include "cc/test/layer_internals_for_test.h" | 47 #include "cc/test/layer_internals_for_test.h" |
| 48 #include "cc/test/layer_tree_test.h" | 48 #include "cc/test/layer_tree_test.h" |
| 49 #include "cc/test/skia_common.h" | 49 #include "cc/test/skia_common.h" |
| 50 #include "cc/test/test_shared_bitmap_manager.h" | 50 #include "cc/test/test_shared_bitmap_manager.h" |
| 51 #include "cc/test/test_web_graphics_context_3d.h" | 51 #include "cc/test/test_web_graphics_context_3d.h" |
| 52 #include "cc/trees/effect_node.h" | 52 #include "cc/trees/effect_node.h" |
| 53 #include "cc/trees/layer_tree_host_common.h" | |
| 53 #include "cc/trees/layer_tree_host_impl.h" | 54 #include "cc/trees/layer_tree_host_impl.h" |
| 54 #include "cc/trees/layer_tree_impl.h" | 55 #include "cc/trees/layer_tree_impl.h" |
| 55 #include "cc/trees/single_thread_proxy.h" | 56 #include "cc/trees/single_thread_proxy.h" |
| 56 #include "cc/trees/transform_node.h" | 57 #include "cc/trees/transform_node.h" |
| 57 #include "gpu/GLES2/gl2extchromium.h" | 58 #include "gpu/GLES2/gl2extchromium.h" |
| 58 #include "testing/gmock/include/gmock/gmock.h" | 59 #include "testing/gmock/include/gmock/gmock.h" |
| 59 #include "third_party/khronos/GLES2/gl2.h" | 60 #include "third_party/khronos/GLES2/gl2.h" |
| 60 #include "third_party/khronos/GLES2/gl2ext.h" | 61 #include "third_party/khronos/GLES2/gl2ext.h" |
| 61 #include "third_party/skia/include/core/SkPicture.h" | 62 #include "third_party/skia/include/core/SkPicture.h" |
| 62 #include "third_party/skia/include/gpu/GrContext.h" | 63 #include "third_party/skia/include/gpu/GrContext.h" |
| (...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2322 case 5: | 2323 case 5: |
| 2323 PostSetDeferCommitsToMainThread(false); | 2324 PostSetDeferCommitsToMainThread(false); |
| 2324 break; | 2325 break; |
| 2325 default: | 2326 default: |
| 2326 // Sometimes |num_will_begin_impl_frame_| will be greater than 5 if the | 2327 // Sometimes |num_will_begin_impl_frame_| will be greater than 5 if the |
| 2327 // main thread is slow to respond. | 2328 // main thread is slow to respond. |
| 2328 break; | 2329 break; |
| 2329 } | 2330 } |
| 2330 } | 2331 } |
| 2331 | 2332 |
| 2332 void ScheduledActionSendBeginMainFrame() override { | 2333 void WillBeginMainFrame() override { |
| 2333 num_send_begin_main_frame_++; | 2334 num_send_begin_main_frame_++; |
| 2334 switch (num_send_begin_main_frame_) { | 2335 switch (num_send_begin_main_frame_) { |
| 2335 case 1: | 2336 case 1: |
| 2336 PostSetDeferCommitsToMainThread(true); | 2337 layer_tree_host()->SetDeferCommits(true); |
| 2337 break; | 2338 break; |
| 2338 case 2: | 2339 case 2: |
| 2339 EndTest(); | 2340 EndTest(); |
| 2340 break; | 2341 break; |
| 2341 default: | 2342 default: |
| 2342 NOTREACHED(); | 2343 NOTREACHED(); |
| 2343 break; | 2344 break; |
| 2344 } | 2345 } |
| 2345 } | 2346 } |
| 2346 | 2347 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2610 EXPECT_EQ(commit_count_, 5); | 2611 EXPECT_EQ(commit_count_, 5); |
| 2611 EXPECT_EQ(commit_abort_count_, 3); | 2612 EXPECT_EQ(commit_abort_count_, 3); |
| 2612 EXPECT_EQ(commit_complete_count_, 2); | 2613 EXPECT_EQ(commit_complete_count_, 2); |
| 2613 } | 2614 } |
| 2614 | 2615 |
| 2615 int commit_count_; | 2616 int commit_count_; |
| 2616 int commit_abort_count_; | 2617 int commit_abort_count_; |
| 2617 int commit_complete_count_; | 2618 int commit_complete_count_; |
| 2618 }; | 2619 }; |
| 2619 | 2620 |
| 2621 class OnDrawOutputSurface : public OutputSurface { | |
|
danakj
2016/07/18 21:12:52
+boliu FYI: i made these LTH tests more like real
| |
| 2622 public: | |
| 2623 explicit OnDrawOutputSurface(base::Closure invalidate_callback) | |
| 2624 : OutputSurface(TestContextProvider::Create(), | |
| 2625 TestContextProvider::CreateWorker(), | |
| 2626 nullptr), | |
| 2627 invalidate_callback_(std::move(invalidate_callback)) { | |
| 2628 capabilities_.delegated_rendering = true; | |
| 2629 } | |
| 2630 | |
| 2631 // OutputSurface implementation. | |
| 2632 void SwapBuffers(CompositorFrame frame) override { did_swap_ = true; } | |
| 2633 uint32_t GetFramebufferCopyTextureFormat() override { return 0; } | |
| 2634 void Invalidate() override { invalidate_callback_.Run(); } | |
| 2635 | |
| 2636 void OnDraw(bool resourceless_software_draw) { | |
| 2637 gfx::Transform identity; | |
| 2638 gfx::Rect empty_rect; | |
| 2639 // SwapBuffers happens inside of OnDraw. | |
| 2640 client_->OnDraw(identity, empty_rect, empty_rect, | |
| 2641 resourceless_software_draw); | |
| 2642 if (did_swap_) { | |
| 2643 did_swap_ = false; | |
| 2644 client_->DidSwapBuffersComplete(); | |
| 2645 } | |
| 2646 } | |
| 2647 | |
| 2648 private: | |
| 2649 bool did_swap_ = false; | |
| 2650 base::Closure invalidate_callback_; | |
| 2651 }; | |
| 2652 | |
| 2620 class LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor | 2653 class LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor |
| 2621 : public LayerTreeHostTestAbortedCommitDoesntStall { | 2654 : public LayerTreeHostTestAbortedCommitDoesntStall { |
| 2622 protected: | 2655 protected: |
| 2623 void InitializeSettings(LayerTreeSettings* settings) override { | 2656 void InitializeSettings(LayerTreeSettings* settings) override { |
| 2624 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); | 2657 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); |
| 2625 settings->using_synchronous_renderer_compositor = true; | 2658 settings->using_synchronous_renderer_compositor = true; |
| 2626 } | 2659 } |
| 2627 | 2660 |
| 2628 void ScheduledActionInvalidateOutputSurface() override { | 2661 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 2629 // Do not call ImplThreadTaskRunner after the test ended because of the | 2662 auto output_surface = base::MakeUnique<OnDrawOutputSurface>(base::Bind( |
| 2630 // possibility of use-after-free due to a race. | 2663 &LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor:: |
| 2631 if (TestEnded()) | 2664 CallOnDraw, |
| 2632 return; | 2665 base::Unretained(this))); |
| 2633 ImplThreadTaskRunner()->PostTask( | 2666 output_surface_ = output_surface.get(); |
| 2634 FROM_HERE, | 2667 return output_surface; |
| 2635 base::Bind( | |
| 2636 &LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor:: | |
| 2637 CallOnDraw, | |
| 2638 base::Unretained(this))); | |
| 2639 } | 2668 } |
| 2640 | 2669 |
| 2641 void CallOnDraw() { | 2670 void CallOnDraw() { |
| 2642 // Synchronous compositor does not draw unless told to do so by the output | 2671 if (!TestEnded()) { |
| 2643 // surface. | 2672 // Synchronous compositor does not draw unless told to do so by the output |
| 2644 gfx::Transform identity; | 2673 // surface. But it needs to be done on a new stack frame. |
| 2645 gfx::Rect empty_rect; | 2674 bool resourceless_software_draw = false; |
| 2646 bool resourceless_software_draw = false; | 2675 ImplThreadTaskRunner()->PostTask( |
| 2647 fake_output_surface()->client()->OnDraw(identity, empty_rect, empty_rect, | 2676 FROM_HERE, base::Bind(&OnDrawOutputSurface::OnDraw, |
| 2648 resourceless_software_draw); | 2677 base::Unretained(output_surface_), |
| 2678 resourceless_software_draw)); | |
| 2679 } | |
| 2649 } | 2680 } |
| 2681 | |
| 2682 OnDrawOutputSurface* output_surface_ = nullptr; | |
| 2650 }; | 2683 }; |
| 2651 | 2684 |
| 2652 MULTI_THREAD_TEST_F( | 2685 MULTI_THREAD_TEST_F( |
| 2653 LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor); | 2686 LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor); |
| 2654 | 2687 |
| 2655 class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync | 2688 class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync |
| 2656 : public LayerTreeHostTestAbortedCommitDoesntStall { | 2689 : public LayerTreeHostTestAbortedCommitDoesntStall { |
| 2657 void InitializeSettings(LayerTreeSettings* settings) override { | 2690 void InitializeSettings(LayerTreeSettings* settings) override { |
| 2658 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); | 2691 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); |
| 2659 settings->wait_for_beginframe_interval = false; | 2692 settings->wait_for_beginframe_interval = false; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2731 | 2764 |
| 2732 void AfterTest() override {} | 2765 void AfterTest() override {} |
| 2733 | 2766 |
| 2734 protected: | 2767 protected: |
| 2735 int frame_; | 2768 int frame_; |
| 2736 }; | 2769 }; |
| 2737 | 2770 |
| 2738 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNumFramesPending); | 2771 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNumFramesPending); |
| 2739 | 2772 |
| 2740 class LayerTreeHostTestResourcelessSoftwareDraw : public LayerTreeHostTest { | 2773 class LayerTreeHostTestResourcelessSoftwareDraw : public LayerTreeHostTest { |
| 2741 public: | 2774 protected: |
| 2742 void InitializeSettings(LayerTreeSettings* settings) override { | 2775 void InitializeSettings(LayerTreeSettings* settings) override { |
| 2743 settings->using_synchronous_renderer_compositor = true; | 2776 settings->using_synchronous_renderer_compositor = true; |
| 2744 } | 2777 } |
| 2745 | 2778 |
| 2746 void SetupTree() override { | 2779 void SetupTree() override { |
| 2747 root_layer_ = FakePictureLayer::Create(&client_); | 2780 root_layer_ = FakePictureLayer::Create(&client_); |
| 2748 root_layer_->SetIsDrawable(true); | 2781 root_layer_->SetIsDrawable(true); |
| 2749 root_layer_->SetBounds(gfx::Size(50, 50)); | 2782 root_layer_->SetBounds(gfx::Size(50, 50)); |
| 2750 | 2783 |
| 2751 parent_layer_ = FakePictureLayer::Create(&client_); | 2784 parent_layer_ = FakePictureLayer::Create(&client_); |
| 2752 parent_layer_->SetIsDrawable(true); | 2785 parent_layer_->SetIsDrawable(true); |
| 2753 parent_layer_->SetBounds(gfx::Size(50, 50)); | 2786 parent_layer_->SetBounds(gfx::Size(50, 50)); |
| 2754 parent_layer_->SetForceRenderSurfaceForTesting(true); | 2787 parent_layer_->SetForceRenderSurfaceForTesting(true); |
| 2755 | 2788 |
| 2756 child_layer_ = FakePictureLayer::Create(&client_); | 2789 child_layer_ = FakePictureLayer::Create(&client_); |
| 2757 child_layer_->SetIsDrawable(true); | 2790 child_layer_->SetIsDrawable(true); |
| 2758 child_layer_->SetBounds(gfx::Size(50, 50)); | 2791 child_layer_->SetBounds(gfx::Size(50, 50)); |
| 2759 | 2792 |
| 2760 root_layer_->AddChild(parent_layer_); | 2793 root_layer_->AddChild(parent_layer_); |
| 2761 parent_layer_->AddChild(child_layer_); | 2794 parent_layer_->AddChild(child_layer_); |
| 2762 layer_tree_host()->SetRootLayer(root_layer_); | 2795 layer_tree_host()->SetRootLayer(root_layer_); |
| 2763 | 2796 |
| 2764 LayerTreeHostTest::SetupTree(); | 2797 LayerTreeHostTest::SetupTree(); |
| 2765 client_.set_bounds(root_layer_->bounds()); | 2798 client_.set_bounds(root_layer_->bounds()); |
| 2766 } | 2799 } |
| 2767 | 2800 |
| 2768 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 2801 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 2769 auto output_surface = delegating_renderer() | 2802 auto output_surface = base::MakeUnique<OnDrawOutputSurface>( |
| 2770 ? FakeOutputSurface::CreateDelegatingSoftware( | 2803 base::Bind(&LayerTreeHostTestResourcelessSoftwareDraw::CallOnDraw, |
| 2771 base::WrapUnique(new SoftwareOutputDevice)) | 2804 base::Unretained(this))); |
| 2772 : FakeOutputSurface::CreateSoftware( | 2805 output_surface_ = output_surface.get(); |
| 2773 base::WrapUnique(new SoftwareOutputDevice)); | 2806 return output_surface; |
| 2774 software_output_surface_ = output_surface.get(); | |
| 2775 return std::move(output_surface); | |
| 2776 } | 2807 } |
| 2777 | 2808 |
| 2778 void BeginTest() override { | 2809 void BeginTest() override { |
| 2779 PostSetNeedsCommitToMainThread(); | 2810 PostSetNeedsCommitToMainThread(); |
| 2780 swap_count_ = 0; | |
| 2781 } | |
| 2782 | |
| 2783 void ScheduledActionInvalidateOutputSurface() override { | |
| 2784 if (TestEnded()) | |
| 2785 return; | |
| 2786 | |
| 2787 ImplThreadTaskRunner()->PostTask( | |
| 2788 FROM_HERE, | |
| 2789 base::Bind(&LayerTreeHostTestResourcelessSoftwareDraw::CallOnDraw, | |
| 2790 base::Unretained(this))); | |
| 2791 } | 2811 } |
| 2792 | 2812 |
| 2793 void CallOnDraw() { | 2813 void CallOnDraw() { |
| 2794 gfx::Transform identity; | 2814 if (!TestEnded()) { |
| 2795 gfx::Rect empty_rect; | 2815 // Synchronous compositor does not draw unless told to do so by the output |
| 2796 bool resourceless_software_draw = true; | 2816 // surface. But it needs to be done on a new stack frame. |
| 2797 software_output_surface_->client()->OnDraw(identity, empty_rect, empty_rect, | 2817 bool resourceless_software_draw = true; |
| 2798 resourceless_software_draw); | 2818 ImplThreadTaskRunner()->PostTask( |
| 2819 FROM_HERE, base::Bind(&OnDrawOutputSurface::OnDraw, | |
| 2820 base::Unretained(output_surface_), | |
| 2821 resourceless_software_draw)); | |
| 2822 } | |
| 2799 } | 2823 } |
| 2800 | 2824 |
| 2801 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 2825 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 2802 LayerTreeHostImpl::FrameData* frame_data, | 2826 LayerTreeHostImpl::FrameData* frame_data, |
| 2803 DrawResult draw_result) override { | 2827 DrawResult draw_result) override { |
| 2804 if (host_impl->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 2828 if (host_impl->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 2805 EXPECT_EQ(1u, frame_data->render_passes.size()); | 2829 EXPECT_EQ(1u, frame_data->render_passes.size()); |
| 2806 // Has at least 3 quads for each layer. | 2830 // Has at least 3 quads for each layer. |
| 2807 RenderPass* render_pass = frame_data->render_passes[0].get(); | 2831 RenderPass* render_pass = frame_data->render_passes[0].get(); |
| 2808 EXPECT_GE(render_pass->quad_list.size(), 3u); | 2832 EXPECT_GE(render_pass->quad_list.size(), 3u); |
| 2809 } else { | 2833 } else { |
| 2810 EXPECT_EQ(2u, frame_data->render_passes.size()); | 2834 EXPECT_EQ(2u, frame_data->render_passes.size()); |
| 2811 | 2835 |
| 2812 // At least root layer quad in root render pass. | 2836 // At least root layer quad in root render pass. |
| 2813 EXPECT_GE(frame_data->render_passes[0]->quad_list.size(), 1u); | 2837 EXPECT_GE(frame_data->render_passes[0]->quad_list.size(), 1u); |
| 2814 // At least parent and child layer quads in parent render pass. | 2838 // At least parent and child layer quads in parent render pass. |
| 2815 EXPECT_GE(frame_data->render_passes[1]->quad_list.size(), 2u); | 2839 EXPECT_GE(frame_data->render_passes[1]->quad_list.size(), 2u); |
| 2816 } | 2840 } |
| 2817 return draw_result; | 2841 return draw_result; |
| 2818 } | 2842 } |
| 2819 | 2843 |
| 2820 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 2844 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 2821 swap_count_++; | 2845 draw_count_++; |
| 2822 switch (swap_count_) { | 2846 switch (draw_count_) { |
| 2823 case 1: | 2847 case 1: |
| 2824 host_impl->SetNeedsRedraw(); | 2848 host_impl->SetNeedsRedraw(); |
| 2825 break; | 2849 break; |
| 2826 case 2: | 2850 case 2: |
| 2827 EndTest(); | 2851 EndTest(); |
| 2828 break; | 2852 break; |
| 2829 default: | 2853 default: |
| 2830 NOTREACHED(); | 2854 NOTREACHED(); |
| 2831 } | 2855 } |
| 2832 } | 2856 } |
| 2833 | 2857 |
| 2834 void AfterTest() override {} | 2858 void AfterTest() override {} |
| 2835 | 2859 |
| 2836 private: | 2860 private: |
| 2837 FakeOutputSurface* software_output_surface_ = nullptr; | 2861 OnDrawOutputSurface* output_surface_ = nullptr; |
| 2838 FakeContentLayerClient client_; | 2862 FakeContentLayerClient client_; |
| 2839 scoped_refptr<Layer> root_layer_; | 2863 scoped_refptr<Layer> root_layer_; |
| 2840 scoped_refptr<Layer> parent_layer_; | 2864 scoped_refptr<Layer> parent_layer_; |
| 2841 scoped_refptr<Layer> child_layer_; | 2865 scoped_refptr<Layer> child_layer_; |
| 2842 int swap_count_; | 2866 int draw_count_ = 0; |
| 2843 }; | 2867 }; |
| 2844 | 2868 |
| 2845 // Resourceless is not used for SingleThreadProxy, so it is unimplemented. | 2869 // Resourceless is not used for SingleThreadProxy, so it is unimplemented. |
| 2846 MULTI_THREAD_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw); | 2870 MULTI_THREAD_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw); |
| 2847 | 2871 |
| 2848 // Test for UI Resource management. | 2872 // Test for UI Resource management. |
| 2849 class LayerTreeHostTestUIResource : public LayerTreeHostTest { | 2873 class LayerTreeHostTestUIResource : public LayerTreeHostTest { |
| 2850 public: | 2874 public: |
| 2851 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} | 2875 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} |
| 2852 | 2876 |
| (...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4625 protected: | 4649 protected: |
| 4626 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4650 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 4627 | 4651 |
| 4628 void SetVisibleFalseAndQueueSwapPromise() { | 4652 void SetVisibleFalseAndQueueSwapPromise() { |
| 4629 layer_tree_host()->SetVisible(false); | 4653 layer_tree_host()->SetVisible(false); |
| 4630 std::unique_ptr<SwapPromise> swap_promise( | 4654 std::unique_ptr<SwapPromise> swap_promise( |
| 4631 new TestSwapPromise(&swap_promise_result_)); | 4655 new TestSwapPromise(&swap_promise_result_)); |
| 4632 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); | 4656 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); |
| 4633 } | 4657 } |
| 4634 | 4658 |
| 4635 void ScheduledActionWillSendBeginMainFrame() override { | 4659 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
| 4660 const BeginFrameArgs& args) override { | |
| 4636 MainThreadTaskRunner()->PostTask( | 4661 MainThreadTaskRunner()->PostTask( |
| 4637 FROM_HERE, | 4662 FROM_HERE, |
| 4638 base::Bind(&LayerTreeHostTestBreakSwapPromiseForVisibility | 4663 base::Bind(&LayerTreeHostTestBreakSwapPromiseForVisibility |
| 4639 ::SetVisibleFalseAndQueueSwapPromise, | 4664 ::SetVisibleFalseAndQueueSwapPromise, |
| 4640 base::Unretained(this))); | 4665 base::Unretained(this))); |
| 4641 } | 4666 } |
| 4642 | 4667 |
| 4643 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | 4668 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
| 4644 CommitEarlyOutReason reason) override { | 4669 CommitEarlyOutReason reason) override { |
| 4645 EndTest(); | 4670 EndTest(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 4669 | 4694 |
| 4670 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4695 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 4671 | 4696 |
| 4672 void LoseOutputSurfaceAndQueueSwapPromise() { | 4697 void LoseOutputSurfaceAndQueueSwapPromise() { |
| 4673 layer_tree_host()->DidLoseOutputSurface(); | 4698 layer_tree_host()->DidLoseOutputSurface(); |
| 4674 std::unique_ptr<SwapPromise> swap_promise( | 4699 std::unique_ptr<SwapPromise> swap_promise( |
| 4675 new TestSwapPromise(&swap_promise_result_)); | 4700 new TestSwapPromise(&swap_promise_result_)); |
| 4676 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); | 4701 layer_tree_host()->QueueSwapPromise(std::move(swap_promise)); |
| 4677 } | 4702 } |
| 4678 | 4703 |
| 4679 void ScheduledActionWillSendBeginMainFrame() override { | 4704 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
| 4705 const BeginFrameArgs& args) override { | |
| 4680 if (output_surface_lost_triggered_) | 4706 if (output_surface_lost_triggered_) |
| 4681 return; | 4707 return; |
| 4682 output_surface_lost_triggered_ = true; | 4708 output_surface_lost_triggered_ = true; |
| 4683 | 4709 |
| 4684 MainThreadTaskRunner()->PostTask( | 4710 MainThreadTaskRunner()->PostTask( |
| 4685 FROM_HERE, | 4711 FROM_HERE, |
| 4686 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContext | 4712 base::Bind(&LayerTreeHostTestBreakSwapPromiseForContext |
| 4687 ::LoseOutputSurfaceAndQueueSwapPromise, | 4713 ::LoseOutputSurfaceAndQueueSwapPromise, |
| 4688 base::Unretained(this))); | 4714 base::Unretained(this))); |
| 4689 } | 4715 } |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5197 did_finish_impl_frame_count_++; | 5223 did_finish_impl_frame_count_++; |
| 5198 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); | 5224 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); |
| 5199 | 5225 |
| 5200 // Request a number of commits to cause multiple impl frames. We expect to | 5226 // Request a number of commits to cause multiple impl frames. We expect to |
| 5201 // get one more impl frames than the number of commits requested because | 5227 // get one more impl frames than the number of commits requested because |
| 5202 // after a commit it takes one frame to become idle. | 5228 // after a commit it takes one frame to become idle. |
| 5203 if (did_finish_impl_frame_count_ < kExpectedNumImplFrames - 1) | 5229 if (did_finish_impl_frame_count_ < kExpectedNumImplFrames - 1) |
| 5204 PostSetNeedsCommitToMainThread(); | 5230 PostSetNeedsCommitToMainThread(); |
| 5205 } | 5231 } |
| 5206 | 5232 |
| 5207 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } | 5233 void BeginMainFrameNotExpectedSoon() override { EndTest(); } |
| 5208 | 5234 |
| 5209 void AfterTest() override { | 5235 void AfterTest() override { |
| 5210 EXPECT_GT(will_begin_impl_frame_count_, 0); | 5236 EXPECT_GT(will_begin_impl_frame_count_, 0); |
| 5211 EXPECT_GT(did_finish_impl_frame_count_, 0); | 5237 EXPECT_GT(did_finish_impl_frame_count_, 0); |
| 5212 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); | 5238 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); |
| 5213 | 5239 |
| 5214 // TODO(mithro): Figure out why the multithread version of this test | 5240 // TODO(mithro): Figure out why the multithread version of this test |
| 5215 // sometimes has one more frame then expected. Possibly related to | 5241 // sometimes has one more frame then expected. Possibly related to |
| 5216 // http://crbug.com/443185 | 5242 // http://crbug.com/443185 |
| 5217 if (!HasImplThread()) { | 5243 if (!HasImplThread()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5270 if (will_begin_impl_frame_count_ < 10) | 5296 if (will_begin_impl_frame_count_ < 10) |
| 5271 PostSetNeedsCommitToMainThread(); | 5297 PostSetNeedsCommitToMainThread(); |
| 5272 } | 5298 } |
| 5273 | 5299 |
| 5274 void BeginMainFrame(const BeginFrameArgs& args) override { | 5300 void BeginMainFrame(const BeginFrameArgs& args) override { |
| 5275 ASSERT_GT(impl_frame_args_.size(), 0U) | 5301 ASSERT_GT(impl_frame_args_.size(), 0U) |
| 5276 << "BeginMainFrame called before BeginImplFrame called!"; | 5302 << "BeginMainFrame called before BeginImplFrame called!"; |
| 5277 EXPECT_PRED_FORMAT2(AssertFrameTimeContained, impl_frame_args_, args); | 5303 EXPECT_PRED_FORMAT2(AssertFrameTimeContained, impl_frame_args_, args); |
| 5278 } | 5304 } |
| 5279 | 5305 |
| 5280 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } | 5306 void BeginMainFrameNotExpectedSoon() override { EndTest(); } |
| 5281 | 5307 |
| 5282 void AfterTest() override { | 5308 void AfterTest() override { |
| 5283 EXPECT_GT(impl_frame_args_.size(), 0U); | 5309 EXPECT_GT(impl_frame_args_.size(), 0U); |
| 5284 EXPECT_GE(will_begin_impl_frame_count_, 10); | 5310 EXPECT_GE(will_begin_impl_frame_count_, 10); |
| 5285 } | 5311 } |
| 5286 | 5312 |
| 5287 private: | 5313 private: |
| 5288 std::vector<BeginFrameArgs> impl_frame_args_; | 5314 std::vector<BeginFrameArgs> impl_frame_args_; |
| 5289 int will_begin_impl_frame_count_; | 5315 int will_begin_impl_frame_count_; |
| 5290 }; | 5316 }; |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5975 bool success) override { | 6001 bool success) override { |
| 5976 ASSERT_TRUE(success); | 6002 ASSERT_TRUE(success); |
| 5977 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); | 6003 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); |
| 5978 } | 6004 } |
| 5979 | 6005 |
| 5980 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { | 6006 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { |
| 5981 ++notify_ready_to_activate_count_; | 6007 ++notify_ready_to_activate_count_; |
| 5982 EndTestAfterDelayMs(100); | 6008 EndTestAfterDelayMs(100); |
| 5983 } | 6009 } |
| 5984 | 6010 |
| 5985 void ScheduledActionPrepareTiles() override { | 6011 void WillPrepareTilesOnThread(LayerTreeHostImpl* impl) override { |
| 5986 ++scheduled_prepare_tiles_count_; | 6012 ++scheduled_prepare_tiles_count_; |
| 5987 } | 6013 } |
| 5988 | 6014 |
| 5989 void AfterTest() override { | 6015 void AfterTest() override { |
| 5990 // Expect at most a notification for each scheduled prepare tiles, plus one | 6016 // Expect at most a notification for each scheduled prepare tiles, plus one |
| 5991 // for the initial commit (which doesn't go through scheduled actions). | 6017 // for the initial commit (which doesn't go through scheduled actions). |
| 5992 // The reason this is not an equality is because depending on timing, we | 6018 // The reason this is not an equality is because depending on timing, we |
| 5993 // might get a prepare tiles but not yet get a notification that we're | 6019 // might get a prepare tiles but not yet get a notification that we're |
| 5994 // ready to activate. The intent of a test is to ensure that we don't | 6020 // ready to activate. The intent of a test is to ensure that we don't |
| 5995 // get more than one notification per prepare tiles, so this is OK. | 6021 // get more than one notification per prepare tiles, so this is OK. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6030 | 6056 |
| 6031 // After activating, we either need to prepare tiles, or we've already | 6057 // After activating, we either need to prepare tiles, or we've already |
| 6032 // called a scheduled prepare tiles. This is done because activation might | 6058 // called a scheduled prepare tiles. This is done because activation might |
| 6033 // cause us to have to memory available (old active tree is gone), so we | 6059 // cause us to have to memory available (old active tree is gone), so we |
| 6034 // need to ensure we will get a PrepareTiles call. | 6060 // need to ensure we will get a PrepareTiles call. |
| 6035 if (!impl->prepare_tiles_needed()) | 6061 if (!impl->prepare_tiles_needed()) |
| 6036 EXPECT_GE(scheduled_prepare_tiles_count_, 1); | 6062 EXPECT_GE(scheduled_prepare_tiles_count_, 1); |
| 6037 EndTest(); | 6063 EndTest(); |
| 6038 } | 6064 } |
| 6039 | 6065 |
| 6040 void ScheduledActionPrepareTiles() override { | 6066 void WillPrepareTilesOnThread(LayerTreeHostImpl* impl) override { |
| 6041 ++scheduled_prepare_tiles_count_; | 6067 ++scheduled_prepare_tiles_count_; |
| 6042 } | 6068 } |
| 6043 | 6069 |
| 6044 void AfterTest() override {} | 6070 void AfterTest() override {} |
| 6045 | 6071 |
| 6046 protected: | 6072 protected: |
| 6047 FakeContentLayerClient client_; | 6073 FakeContentLayerClient client_; |
| 6048 int scheduled_prepare_tiles_count_; | 6074 int scheduled_prepare_tiles_count_; |
| 6049 }; | 6075 }; |
| 6050 | 6076 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6873 private: | 6899 private: |
| 6874 FakeContentLayerClient client_; | 6900 FakeContentLayerClient client_; |
| 6875 const gfx::Size viewport_size_; | 6901 const gfx::Size viewport_size_; |
| 6876 const gfx::Size large_image_size_; | 6902 const gfx::Size large_image_size_; |
| 6877 }; | 6903 }; |
| 6878 | 6904 |
| 6879 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); | 6905 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 6880 | 6906 |
| 6881 } // namespace | 6907 } // namespace |
| 6882 } // namespace cc | 6908 } // namespace cc |
| OLD | NEW |