| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "ui/gfx/geometry/vector2d_conversions.h" | 64 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 65 | 65 |
| 66 using testing::_; | 66 using testing::_; |
| 67 using testing::AnyNumber; | 67 using testing::AnyNumber; |
| 68 using testing::AtLeast; | 68 using testing::AtLeast; |
| 69 using testing::Mock; | 69 using testing::Mock; |
| 70 | 70 |
| 71 namespace cc { | 71 namespace cc { |
| 72 namespace { | 72 namespace { |
| 73 | 73 |
| 74 class LayerTreeHostTest : public LayerTreeTest {}; | 74 class LayerTreeHostTest : public LayerTreeTest { |
| 75 protected: |
| 76 // These tests are not pixel tests, and they use a fake output surface, |
| 77 // while storing pointers to the test-types for tests to poke at. |
| 78 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 79 auto context = TestContextProvider::Create(); |
| 80 context_provider_ = context.get(); |
| 81 auto ret = delegating_renderer() |
| 82 ? FakeOutputSurface::CreateDelegating3d(std::move(context)) |
| 83 : FakeOutputSurface::Create3d(std::move(context)); |
| 84 output_surface_ = ret.get(); |
| 85 return std::move(ret); |
| 86 } |
| 87 |
| 88 FakeOutputSurface* fake_output_surface() { return output_surface_; } |
| 89 TestContextProvider* test_context_provider() { return context_provider_; } |
| 90 |
| 91 private: |
| 92 FakeOutputSurface* output_surface_ = nullptr; |
| 93 TestContextProvider* context_provider_ = nullptr; |
| 94 }; |
| 75 | 95 |
| 76 class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest { | 96 class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest { |
| 77 public: | 97 public: |
| 78 LayerTreeHostTestHasImplThreadTest() : threaded_(false) {} | 98 LayerTreeHostTestHasImplThreadTest() : threaded_(false) {} |
| 79 | 99 |
| 80 void RunTest(CompositorMode mode, bool delegating_renderer) override { | 100 void RunTest(CompositorMode mode, bool delegating_renderer) override { |
| 81 threaded_ = mode == CompositorMode::THREADED; | 101 threaded_ = mode == CompositorMode::THREADED; |
| 82 LayerTreeHostTest::RunTest(mode, delegating_renderer); | 102 LayerTreeHostTest::RunTest(mode, delegating_renderer); |
| 83 } | 103 } |
| 84 | 104 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 bool did_notify_ready_to_draw_; | 438 bool did_notify_ready_to_draw_; |
| 419 bool did_draw_; | 439 bool did_draw_; |
| 420 }; | 440 }; |
| 421 | 441 |
| 422 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in | 442 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in |
| 423 // single threaded mode. | 443 // single threaded mode. |
| 424 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); | 444 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); |
| 425 | 445 |
| 426 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { | 446 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { |
| 427 public: | 447 public: |
| 428 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 448 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 429 auto output_surface = base::WrapUnique( | 449 auto output_surface = base::WrapUnique( |
| 430 new testing::StrictMock< | 450 new testing::StrictMock< |
| 431 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( | 451 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( |
| 432 delegating_renderer())); | 452 delegating_renderer())); |
| 433 | 453 |
| 434 // At init, we expect one call to set visibility to true. | 454 // At init, we expect one call to set visibility to true. |
| 435 testing::Expectation visibility_true = | 455 testing::Expectation visibility_true = |
| 436 EXPECT_CALL(*output_surface, | 456 EXPECT_CALL(*output_surface, |
| 437 SetWorkerContextShouldAggressivelyFreeResources(false)) | 457 SetWorkerContextShouldAggressivelyFreeResources(false)) |
| 438 .Times(1); | 458 .Times(1); |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 CallOnDraw, | 2636 CallOnDraw, |
| 2617 base::Unretained(this))); | 2637 base::Unretained(this))); |
| 2618 } | 2638 } |
| 2619 | 2639 |
| 2620 void CallOnDraw() { | 2640 void CallOnDraw() { |
| 2621 // Synchronous compositor does not draw unless told to do so by the output | 2641 // Synchronous compositor does not draw unless told to do so by the output |
| 2622 // surface. | 2642 // surface. |
| 2623 gfx::Transform identity; | 2643 gfx::Transform identity; |
| 2624 gfx::Rect empty_rect; | 2644 gfx::Rect empty_rect; |
| 2625 bool resourceless_software_draw = false; | 2645 bool resourceless_software_draw = false; |
| 2626 output_surface()->client()->OnDraw(identity, empty_rect, empty_rect, | 2646 fake_output_surface()->client()->OnDraw(identity, empty_rect, empty_rect, |
| 2627 resourceless_software_draw); | 2647 resourceless_software_draw); |
| 2628 } | 2648 } |
| 2629 }; | 2649 }; |
| 2630 | 2650 |
| 2631 MULTI_THREAD_TEST_F( | 2651 MULTI_THREAD_TEST_F( |
| 2632 LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor); | 2652 LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor); |
| 2633 | 2653 |
| 2634 class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync | 2654 class LayerTreeHostTestAbortedCommitDoesntStallDisabledVsync |
| 2635 : public LayerTreeHostTestAbortedCommitDoesntStall { | 2655 : public LayerTreeHostTestAbortedCommitDoesntStall { |
| 2636 void InitializeSettings(LayerTreeSettings* settings) override { | 2656 void InitializeSettings(LayerTreeSettings* settings) override { |
| 2637 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); | 2657 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2737 child_layer_->SetBounds(gfx::Size(50, 50)); | 2757 child_layer_->SetBounds(gfx::Size(50, 50)); |
| 2738 | 2758 |
| 2739 root_layer_->AddChild(parent_layer_); | 2759 root_layer_->AddChild(parent_layer_); |
| 2740 parent_layer_->AddChild(child_layer_); | 2760 parent_layer_->AddChild(child_layer_); |
| 2741 layer_tree_host()->SetRootLayer(root_layer_); | 2761 layer_tree_host()->SetRootLayer(root_layer_); |
| 2742 | 2762 |
| 2743 LayerTreeHostTest::SetupTree(); | 2763 LayerTreeHostTest::SetupTree(); |
| 2744 client_.set_bounds(root_layer_->bounds()); | 2764 client_.set_bounds(root_layer_->bounds()); |
| 2745 } | 2765 } |
| 2746 | 2766 |
| 2747 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 2767 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 2748 if (delegating_renderer()) { | 2768 auto output_surface = delegating_renderer() |
| 2749 return FakeOutputSurface::CreateDelegatingSoftware( | 2769 ? FakeOutputSurface::CreateDelegatingSoftware( |
| 2750 base::WrapUnique(new SoftwareOutputDevice)); | 2770 base::WrapUnique(new SoftwareOutputDevice)) |
| 2751 } else { | 2771 : FakeOutputSurface::CreateSoftware( |
| 2752 return FakeOutputSurface::CreateSoftware( | 2772 base::WrapUnique(new SoftwareOutputDevice)); |
| 2753 base::WrapUnique(new SoftwareOutputDevice)); | 2773 software_output_surface_ = output_surface.get(); |
| 2754 } | 2774 return std::move(output_surface); |
| 2755 } | 2775 } |
| 2756 | 2776 |
| 2757 void BeginTest() override { | 2777 void BeginTest() override { |
| 2758 PostSetNeedsCommitToMainThread(); | 2778 PostSetNeedsCommitToMainThread(); |
| 2759 swap_count_ = 0; | 2779 swap_count_ = 0; |
| 2760 } | 2780 } |
| 2761 | 2781 |
| 2762 void ScheduledActionInvalidateOutputSurface() override { | 2782 void ScheduledActionInvalidateOutputSurface() override { |
| 2763 if (TestEnded()) | 2783 if (TestEnded()) |
| 2764 return; | 2784 return; |
| 2765 | 2785 |
| 2766 ImplThreadTaskRunner()->PostTask( | 2786 ImplThreadTaskRunner()->PostTask( |
| 2767 FROM_HERE, | 2787 FROM_HERE, |
| 2768 base::Bind(&LayerTreeHostTestResourcelessSoftwareDraw::CallOnDraw, | 2788 base::Bind(&LayerTreeHostTestResourcelessSoftwareDraw::CallOnDraw, |
| 2769 base::Unretained(this))); | 2789 base::Unretained(this))); |
| 2770 } | 2790 } |
| 2771 | 2791 |
| 2772 void CallOnDraw() { | 2792 void CallOnDraw() { |
| 2773 gfx::Transform identity; | 2793 gfx::Transform identity; |
| 2774 gfx::Rect empty_rect; | 2794 gfx::Rect empty_rect; |
| 2775 bool resourceless_software_draw = true; | 2795 bool resourceless_software_draw = true; |
| 2776 output_surface()->client()->OnDraw(identity, empty_rect, empty_rect, | 2796 software_output_surface_->client()->OnDraw(identity, empty_rect, empty_rect, |
| 2777 resourceless_software_draw); | 2797 resourceless_software_draw); |
| 2778 } | 2798 } |
| 2779 | 2799 |
| 2780 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 2800 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 2781 LayerTreeHostImpl::FrameData* frame_data, | 2801 LayerTreeHostImpl::FrameData* frame_data, |
| 2782 DrawResult draw_result) override { | 2802 DrawResult draw_result) override { |
| 2783 if (host_impl->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 2803 if (host_impl->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 2784 EXPECT_EQ(1u, frame_data->render_passes.size()); | 2804 EXPECT_EQ(1u, frame_data->render_passes.size()); |
| 2785 // Has at least 3 quads for each layer. | 2805 // Has at least 3 quads for each layer. |
| 2786 RenderPass* render_pass = frame_data->render_passes[0].get(); | 2806 RenderPass* render_pass = frame_data->render_passes[0].get(); |
| 2787 EXPECT_GE(render_pass->quad_list.size(), 3u); | 2807 EXPECT_GE(render_pass->quad_list.size(), 3u); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2806 EndTest(); | 2826 EndTest(); |
| 2807 break; | 2827 break; |
| 2808 default: | 2828 default: |
| 2809 NOTREACHED(); | 2829 NOTREACHED(); |
| 2810 } | 2830 } |
| 2811 } | 2831 } |
| 2812 | 2832 |
| 2813 void AfterTest() override {} | 2833 void AfterTest() override {} |
| 2814 | 2834 |
| 2815 private: | 2835 private: |
| 2836 FakeOutputSurface* software_output_surface_ = nullptr; |
| 2816 FakeContentLayerClient client_; | 2837 FakeContentLayerClient client_; |
| 2817 scoped_refptr<Layer> root_layer_; | 2838 scoped_refptr<Layer> root_layer_; |
| 2818 scoped_refptr<Layer> parent_layer_; | 2839 scoped_refptr<Layer> parent_layer_; |
| 2819 scoped_refptr<Layer> child_layer_; | 2840 scoped_refptr<Layer> child_layer_; |
| 2820 int swap_count_; | 2841 int swap_count_; |
| 2821 }; | 2842 }; |
| 2822 | 2843 |
| 2823 // Resourceless is not used for SingleThreadProxy, so it is unimplemented. | 2844 // Resourceless is not used for SingleThreadProxy, so it is unimplemented. |
| 2824 MULTI_THREAD_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw); | 2845 MULTI_THREAD_TEST_F(LayerTreeHostTestResourcelessSoftwareDraw); |
| 2825 | 2846 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2860 PostSetNeedsCommitToMainThread(); | 2881 PostSetNeedsCommitToMainThread(); |
| 2861 break; | 2882 break; |
| 2862 case 5: | 2883 case 5: |
| 2863 ClearResources(); | 2884 ClearResources(); |
| 2864 EndTest(); | 2885 EndTest(); |
| 2865 break; | 2886 break; |
| 2866 } | 2887 } |
| 2867 } | 2888 } |
| 2868 | 2889 |
| 2869 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 2890 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 2870 TestWebGraphicsContext3D* context = TestContext(); | 2891 auto* context = test_context_provider()->TestContext3d(); |
| 2871 | 2892 |
| 2872 int frame = impl->active_tree()->source_frame_number(); | 2893 int frame = impl->active_tree()->source_frame_number(); |
| 2873 switch (frame) { | 2894 switch (frame) { |
| 2874 case 0: | 2895 case 0: |
| 2875 ASSERT_EQ(0u, context->NumTextures()); | 2896 ASSERT_EQ(0u, context->NumTextures()); |
| 2876 break; | 2897 break; |
| 2877 case 1: | 2898 case 1: |
| 2878 // Created two textures. | 2899 // Created two textures. |
| 2879 ASSERT_EQ(2u, context->NumTextures()); | 2900 ASSERT_EQ(2u, context->NumTextures()); |
| 2880 break; | 2901 break; |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3947 EndTest(); | 3968 EndTest(); |
| 3948 break; | 3969 break; |
| 3949 } | 3970 } |
| 3950 return LayerTreeHostTest::PrepareToDrawOnThread( | 3971 return LayerTreeHostTest::PrepareToDrawOnThread( |
| 3951 host_impl, frame_data, draw_result); | 3972 host_impl, frame_data, draw_result); |
| 3952 } | 3973 } |
| 3953 | 3974 |
| 3954 void AfterTest() override { EXPECT_EQ(3, num_commits_); } | 3975 void AfterTest() override { EXPECT_EQ(3, num_commits_); } |
| 3955 | 3976 |
| 3956 void SetCallback(bool enable) { | 3977 void SetCallback(bool enable) { |
| 3957 output_surface()->SetTreeActivationCallback( | 3978 fake_output_surface()->SetTreeActivationCallback( |
| 3958 enable | 3979 enable |
| 3959 ? base::Bind( | 3980 ? base::Bind( |
| 3960 &LayerTreeHostTestTreeActivationCallback::ActivationCallback, | 3981 &LayerTreeHostTestTreeActivationCallback::ActivationCallback, |
| 3961 base::Unretained(this)) | 3982 base::Unretained(this)) |
| 3962 : base::Closure()); | 3983 : base::Closure()); |
| 3963 } | 3984 } |
| 3964 | 3985 |
| 3965 void ActivationCallback() { ++callback_count_; } | 3986 void ActivationCallback() { ++callback_count_; } |
| 3966 | 3987 |
| 3967 int num_commits_; | 3988 int num_commits_; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4227 | 4248 |
| 4228 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); | 4249 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); |
| 4229 | 4250 |
| 4230 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4251 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4231 : public LayerTreeHostTest { | 4252 : public LayerTreeHostTest { |
| 4232 protected: | 4253 protected: |
| 4233 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 4254 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
| 4234 : first_output_surface_memory_limit_(4321234), | 4255 : first_output_surface_memory_limit_(4321234), |
| 4235 second_output_surface_memory_limit_(1234321) {} | 4256 second_output_surface_memory_limit_(1234321) {} |
| 4236 | 4257 |
| 4237 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 4258 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 4238 if (!first_context_provider_.get()) { | 4259 if (!first_context_provider_.get()) { |
| 4239 first_context_provider_ = TestContextProvider::Create(); | 4260 first_context_provider_ = TestContextProvider::Create(); |
| 4240 } else { | 4261 } else { |
| 4241 EXPECT_FALSE(second_context_provider_.get()); | 4262 EXPECT_FALSE(second_context_provider_.get()); |
| 4242 second_context_provider_ = TestContextProvider::Create(); | 4263 second_context_provider_ = TestContextProvider::Create(); |
| 4243 } | 4264 } |
| 4244 | 4265 |
| 4245 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() | 4266 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() |
| 4246 ? second_context_provider_ | 4267 ? second_context_provider_ |
| 4247 : first_context_provider_); | 4268 : first_context_provider_); |
| 4248 std::unique_ptr<FakeOutputSurface> output_surface; | 4269 std::unique_ptr<FakeOutputSurface> output_surface; |
| 4249 if (delegating_renderer()) | 4270 if (delegating_renderer()) |
| 4250 output_surface = FakeOutputSurface::CreateDelegating3d(provider); | 4271 output_surface = FakeOutputSurface::CreateDelegating3d(provider); |
| 4251 else | 4272 else |
| 4252 output_surface = FakeOutputSurface::Create3d(provider); | 4273 output_surface = FakeOutputSurface::Create3d(provider); |
| 4253 output_surface->SetMemoryPolicyToSetAtBind( | 4274 output_surface->SetMemoryPolicyToSetAtBind( |
| 4254 base::WrapUnique(new ManagedMemoryPolicy( | 4275 base::WrapUnique(new ManagedMemoryPolicy( |
| 4255 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4276 second_context_provider_.get() ? second_output_surface_memory_limit_ |
| 4256 : first_output_surface_memory_limit_, | 4277 : first_output_surface_memory_limit_, |
| 4257 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4278 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 4258 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4279 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
| 4259 return output_surface; | 4280 return std::move(output_surface); |
| 4260 } | 4281 } |
| 4261 | 4282 |
| 4262 void SetupTree() override { | 4283 void SetupTree() override { |
| 4263 root_ = FakePictureLayer::Create(&client_); | 4284 root_ = FakePictureLayer::Create(&client_); |
| 4264 root_->SetBounds(gfx::Size(20, 20)); | 4285 root_->SetBounds(gfx::Size(20, 20)); |
| 4265 layer_tree_host()->SetRootLayer(root_); | 4286 layer_tree_host()->SetRootLayer(root_); |
| 4266 LayerTreeHostTest::SetupTree(); | 4287 LayerTreeHostTest::SetupTree(); |
| 4267 client_.set_bounds(root_->bounds()); | 4288 client_.set_bounds(root_->bounds()); |
| 4268 } | 4289 } |
| 4269 | 4290 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4500 } | 4521 } |
| 4501 } | 4522 } |
| 4502 | 4523 |
| 4503 int commit_count_; | 4524 int commit_count_; |
| 4504 int commit_complete_count_; | 4525 int commit_complete_count_; |
| 4505 TestSwapPromiseResult swap_promise_result_[3]; | 4526 TestSwapPromiseResult swap_promise_result_[3]; |
| 4506 }; | 4527 }; |
| 4507 | 4528 |
| 4508 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); | 4529 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); |
| 4509 | 4530 |
| 4510 class LayerTreeHostTestKeepSwapPromise : public LayerTreeTest { | 4531 class LayerTreeHostTestKeepSwapPromise : public LayerTreeHostTest { |
| 4511 public: | 4532 public: |
| 4512 LayerTreeHostTestKeepSwapPromise() {} | 4533 LayerTreeHostTestKeepSwapPromise() {} |
| 4513 | 4534 |
| 4514 void BeginTest() override { | 4535 void BeginTest() override { |
| 4515 layer_ = SolidColorLayer::Create(); | 4536 layer_ = SolidColorLayer::Create(); |
| 4516 layer_->SetIsDrawable(true); | 4537 layer_->SetIsDrawable(true); |
| 4517 layer_->SetBounds(gfx::Size(10, 10)); | 4538 layer_->SetBounds(gfx::Size(10, 10)); |
| 4518 layer_tree_host()->SetRootLayer(layer_); | 4539 layer_tree_host()->SetRootLayer(layer_); |
| 4519 gfx::Size bounds(100, 100); | 4540 gfx::Size bounds(100, 100); |
| 4520 layer_tree_host()->SetViewportSize(bounds); | 4541 layer_tree_host()->SetViewportSize(bounds); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4563 } | 4584 } |
| 4564 } | 4585 } |
| 4565 | 4586 |
| 4566 void ActivationCallback() { | 4587 void ActivationCallback() { |
| 4567 // DidActivate needs to happen before the tree activation callback. | 4588 // DidActivate needs to happen before the tree activation callback. |
| 4568 base::AutoLock lock(swap_promise_result_.lock); | 4589 base::AutoLock lock(swap_promise_result_.lock); |
| 4569 EXPECT_TRUE(swap_promise_result_.did_activate_called); | 4590 EXPECT_TRUE(swap_promise_result_.did_activate_called); |
| 4570 } | 4591 } |
| 4571 | 4592 |
| 4572 void SetCallback(bool enable) { | 4593 void SetCallback(bool enable) { |
| 4573 output_surface()->SetTreeActivationCallback( | 4594 fake_output_surface()->SetTreeActivationCallback( |
| 4574 enable | 4595 enable |
| 4575 ? base::Bind(&LayerTreeHostTestKeepSwapPromise::ActivationCallback, | 4596 ? base::Bind(&LayerTreeHostTestKeepSwapPromise::ActivationCallback, |
| 4576 base::Unretained(this)) | 4597 base::Unretained(this)) |
| 4577 : base::Closure()); | 4598 : base::Closure()); |
| 4578 } | 4599 } |
| 4579 | 4600 |
| 4580 void SwapBuffersCompleteOnThread() override { | 4601 void SwapBuffersCompleteOnThread() override { |
| 4581 if (num_swaps_++ >= 1) { | 4602 if (num_swaps_++ >= 1) { |
| 4582 // The commit changes layers so it should cause a swap. | 4603 // The commit changes layers so it should cause a swap. |
| 4583 base::AutoLock lock(swap_promise_result_.lock); | 4604 base::AutoLock lock(swap_promise_result_.lock); |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5631 base::WaitableEvent playback_allowed_event_; | 5652 base::WaitableEvent playback_allowed_event_; |
| 5632 }; | 5653 }; |
| 5633 | 5654 |
| 5634 // This test does pinching on the impl side which is not supported in single | 5655 // This test does pinching on the impl side which is not supported in single |
| 5635 // thread. | 5656 // thread. |
| 5636 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5657 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5637 | 5658 |
| 5638 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5659 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5639 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5660 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5640 protected: | 5661 protected: |
| 5641 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 5662 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
| 5642 std::unique_ptr<TestWebGraphicsContext3D> context3d = | 5663 std::unique_ptr<TestWebGraphicsContext3D> context3d = |
| 5643 TestWebGraphicsContext3D::Create(); | 5664 TestWebGraphicsContext3D::Create(); |
| 5644 context3d->set_support_image(true); | 5665 context3d->set_support_image(true); |
| 5645 context3d->set_support_sync_query(true); | 5666 context3d->set_support_sync_query(true); |
| 5646 #if defined(OS_MACOSX) | 5667 #if defined(OS_MACOSX) |
| 5647 context3d->set_support_texture_rectangle(true); | 5668 context3d->set_support_texture_rectangle(true); |
| 5648 #endif | 5669 #endif |
| 5649 | 5670 |
| 5650 if (delegating_renderer()) | 5671 if (delegating_renderer()) |
| 5651 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); | 5672 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6762 } | 6783 } |
| 6763 | 6784 |
| 6764 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 6785 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 6765 EXPECT_EQ(2.0f, host_impl->active_tree()->painted_device_scale_factor()); | 6786 EXPECT_EQ(2.0f, host_impl->active_tree()->painted_device_scale_factor()); |
| 6766 EXPECT_EQ(1.0f, host_impl->active_tree()->device_scale_factor()); | 6787 EXPECT_EQ(1.0f, host_impl->active_tree()->device_scale_factor()); |
| 6767 } | 6788 } |
| 6768 | 6789 |
| 6769 void SwapBuffersCompleteOnThread() override { | 6790 void SwapBuffersCompleteOnThread() override { |
| 6770 EXPECT_EQ( | 6791 EXPECT_EQ( |
| 6771 2.0f, | 6792 2.0f, |
| 6772 output_surface()->last_sent_frame()->metadata.device_scale_factor); | 6793 fake_output_surface()->last_sent_frame()->metadata.device_scale_factor); |
| 6773 EndTest(); | 6794 EndTest(); |
| 6774 } | 6795 } |
| 6775 | 6796 |
| 6776 void AfterTest() override {} | 6797 void AfterTest() override {} |
| 6777 }; | 6798 }; |
| 6778 | 6799 |
| 6779 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6800 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6780 | 6801 |
| 6781 } // namespace | 6802 } // namespace |
| 6782 } // namespace cc | 6803 } // namespace cc |
| OLD | NEW |