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 29 matching lines...) Expand all Loading... | |
| 40 #include "cc/test/fake_picture_layer.h" | 40 #include "cc/test/fake_picture_layer.h" |
| 41 #include "cc/test/fake_picture_layer_impl.h" | 41 #include "cc/test/fake_picture_layer_impl.h" |
| 42 #include "cc/test/fake_proxy.h" | 42 #include "cc/test/fake_proxy.h" |
| 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_delegating_output_surface.h" | |
| 50 #include "cc/test/test_shared_bitmap_manager.h" | 51 #include "cc/test/test_shared_bitmap_manager.h" |
| 51 #include "cc/test/test_web_graphics_context_3d.h" | 52 #include "cc/test/test_web_graphics_context_3d.h" |
| 52 #include "cc/trees/effect_node.h" | 53 #include "cc/trees/effect_node.h" |
| 53 #include "cc/trees/layer_tree_host_common.h" | 54 #include "cc/trees/layer_tree_host_common.h" |
| 54 #include "cc/trees/layer_tree_host_impl.h" | 55 #include "cc/trees/layer_tree_host_impl.h" |
| 55 #include "cc/trees/layer_tree_impl.h" | 56 #include "cc/trees/layer_tree_impl.h" |
| 56 #include "cc/trees/single_thread_proxy.h" | 57 #include "cc/trees/single_thread_proxy.h" |
| 57 #include "cc/trees/transform_node.h" | 58 #include "cc/trees/transform_node.h" |
| 58 #include "gpu/GLES2/gl2extchromium.h" | 59 #include "gpu/GLES2/gl2extchromium.h" |
| 59 #include "testing/gmock/include/gmock/gmock.h" | 60 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 bool did_notify_ready_to_draw_; | 426 bool did_notify_ready_to_draw_; |
| 426 bool did_draw_; | 427 bool did_draw_; |
| 427 }; | 428 }; |
| 428 | 429 |
| 429 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in | 430 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in |
| 430 // single threaded mode. | 431 // single threaded mode. |
| 431 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); | 432 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); |
| 432 | 433 |
| 433 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { | 434 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { |
| 434 public: | 435 public: |
| 435 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 436 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( |
| 436 auto output_surface = base::WrapUnique( | 437 scoped_refptr<ContextProvider> compositor_context_provider, |
| 437 new testing::StrictMock< | 438 scoped_refptr<ContextProvider> worker_context_provider) override { |
| 438 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( | 439 auto mock_worker_context_support_owned = |
| 439 delegating_renderer())); | 440 base::MakeUnique<MockContextSupport>(); |
| 441 auto* mock_worker_context_support = mock_worker_context_support_owned.get(); | |
| 442 | |
| 443 auto mock_worker_context_provider = make_scoped_refptr( | |
| 444 new MockContextProvider(std::move(mock_worker_context_support_owned))); | |
| 445 | |
| 446 // Workers are bound on the main thread. | |
| 447 mock_worker_context_provider->BindToCurrentThread(); | |
| 440 | 448 |
| 441 // At init, we expect one call to set visibility to true. | 449 // At init, we expect one call to set visibility to true. |
| 442 testing::Expectation visibility_true = | 450 testing::Expectation visibility_true = |
| 443 EXPECT_CALL(*output_surface, | 451 EXPECT_CALL(*mock_worker_context_support, |
| 444 SetWorkerContextShouldAggressivelyFreeResources(false)) | 452 SetAggressivelyFreeResources(false)) |
| 445 .Times(1); | 453 .Times(1); |
| 446 | 454 |
| 447 // After running, we should get exactly one call to | 455 // After running, we should get exactly one call to |
| 448 // FreeWorkerContextGpuResources. | 456 // DeleteCachedResources, along with SetAggressivelyFreeResources. |
| 449 EXPECT_CALL(*output_surface, | 457 EXPECT_CALL(*mock_worker_context_provider, DeleteCachedResources()) |
| 450 SetWorkerContextShouldAggressivelyFreeResources(true)) | 458 .After(visibility_true); |
| 459 EXPECT_CALL(*mock_worker_context_support, | |
| 460 SetAggressivelyFreeResources(true)) | |
| 451 .After(visibility_true) | 461 .After(visibility_true) |
| 452 .WillOnce(testing::Invoke([this](bool is_visible) { EndTest(); })); | 462 .WillOnce(testing::Invoke([this](bool is_visible) { EndTest(); })); |
| 453 return std::move(output_surface); | 463 |
| 464 return LayerTreeHostTest::CreateDelegatingOutputSurface( | |
| 465 std::move(compositor_context_provider), | |
| 466 std::move(mock_worker_context_provider)); | |
| 454 } | 467 } |
| 455 | 468 |
| 456 void InitializeSettings(LayerTreeSettings* settings) override { | 469 void InitializeSettings(LayerTreeSettings* settings) override { |
| 457 settings->gpu_rasterization_enabled = true; | 470 settings->gpu_rasterization_enabled = true; |
| 458 settings->gpu_rasterization_forced = true; | 471 settings->gpu_rasterization_forced = true; |
| 459 } | 472 } |
| 460 | 473 |
| 461 void BeginTest() override { | 474 void BeginTest() override {} |
| 462 // Logic is handled in InitializedRendererOnThread to ensure that our | 475 void AfterTest() override {} |
| 463 // LTHI is fully set up. | |
| 464 } | |
| 465 | |
| 466 void AfterTest() override { | |
| 467 // Expectations handled via mock. | |
| 468 } | |
| 469 | 476 |
| 470 private: | 477 private: |
| 471 class MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface | 478 class MockContextProvider : public TestContextProvider { |
| 472 : public FakeOutputSurface { | |
| 473 public: | 479 public: |
| 474 ~MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface() {} | 480 explicit MockContextProvider(std::unique_ptr<TestContextSupport> support) |
| 475 explicit MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface( | 481 : TestContextProvider(std::move(support), |
| 476 bool delegated_rendering) | 482 base::MakeUnique<TestGLES2Interface>(), |
| 477 : FakeOutputSurface(TestContextProvider::Create(), | 483 TestWebGraphicsContext3D::Create()) {} |
| 478 TestContextProvider::CreateWorker(), | 484 |
| 479 delegated_rendering) {} | 485 MOCK_METHOD0(DeleteCachedResources, void()); |
| 480 MOCK_METHOD1(SetWorkerContextShouldAggressivelyFreeResources, | 486 |
| 481 void(bool is_visible)); | 487 private: |
| 488 ~MockContextProvider() = default; | |
| 489 }; | |
| 490 | |
| 491 class MockContextSupport : public TestContextSupport { | |
| 492 public: | |
| 493 MOCK_METHOD1(SetAggressivelyFreeResources, | |
| 494 void(bool aggressively_free_resources)); | |
| 482 }; | 495 }; |
| 483 }; | 496 }; |
| 484 | 497 |
| 485 // Test if the LTH successfully frees resources on the worker context when | 498 // Test if the LTH successfully frees resources on the worker context when |
| 486 // visibility is set to false. | 499 // visibility is set to false. |
| 487 class LayerTreeHostFreeWorkerContextResourcesOnInvisible | 500 class LayerTreeHostFreeWorkerContextResourcesOnInvisible |
| 488 : public LayerTreeHostFreeWorkerContextResourcesTest { | 501 : public LayerTreeHostFreeWorkerContextResourcesTest { |
| 489 public: | 502 public: |
| 490 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, | 503 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
| 491 bool success) override { | 504 bool success) override { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 513 LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit); | 526 LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit); |
| 514 | 527 |
| 515 // Test if the LTH successfully frees resources on the worker context when | 528 // Test if the LTH successfully frees resources on the worker context when |
| 516 // hard memory limit is set to zero while using a synchronous compositor (like | 529 // hard memory limit is set to zero while using a synchronous compositor (like |
| 517 // Android WebView). | 530 // Android WebView). |
| 518 class LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimitSynchronous | 531 class LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimitSynchronous |
| 519 : public LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit { | 532 : public LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimit { |
| 520 public: | 533 public: |
| 521 void InitializeSettings(LayerTreeSettings* settings) override { | 534 void InitializeSettings(LayerTreeSettings* settings) override { |
| 522 LayerTreeHostFreeWorkerContextResourcesTest::InitializeSettings(settings); | 535 LayerTreeHostFreeWorkerContextResourcesTest::InitializeSettings(settings); |
| 523 settings->use_external_begin_frame_source = true; | |
| 524 settings->using_synchronous_renderer_compositor = true; | 536 settings->using_synchronous_renderer_compositor = true; |
| 525 } | 537 } |
| 526 }; | 538 }; |
| 527 | 539 |
| 528 SINGLE_AND_MULTI_THREAD_TEST_F( | 540 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 529 LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimitSynchronous); | 541 LayerTreeHostFreeWorkerContextResourcesOnZeroMemoryLimitSynchronous); |
| 530 | 542 |
| 531 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 | 543 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 |
| 532 // draw with frame 0. | 544 // draw with frame 0. |
| 533 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { | 545 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { |
| (...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2555 | 2567 |
| 2556 void AfterTest() override {} | 2568 void AfterTest() override {} |
| 2557 | 2569 |
| 2558 private: | 2570 private: |
| 2559 FakeContentLayerClient client_; | 2571 FakeContentLayerClient client_; |
| 2560 int num_tiles_rastered_; | 2572 int num_tiles_rastered_; |
| 2561 }; | 2573 }; |
| 2562 | 2574 |
| 2563 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDChange); | 2575 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLCDChange); |
| 2564 | 2576 |
| 2565 // Verify that the BeginFrame notification is used to initiate rendering. | |
| 2566 class LayerTreeHostTestBeginFrameNotification : public LayerTreeHostTest { | |
| 2567 public: | |
| 2568 void InitializeSettings(LayerTreeSettings* settings) override { | |
| 2569 settings->use_external_begin_frame_source = true; | |
| 2570 } | |
| 2571 | |
| 2572 void BeginTest() override { | |
| 2573 // This will trigger a SetNeedsBeginFrame which will trigger a | |
| 2574 // BeginFrame. | |
| 2575 PostSetNeedsCommitToMainThread(); | |
| 2576 } | |
| 2577 | |
| 2578 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | |
| 2579 LayerTreeHostImpl::FrameData* frame, | |
| 2580 DrawResult draw_result) override { | |
| 2581 EndTest(); | |
| 2582 return DRAW_SUCCESS; | |
| 2583 } | |
| 2584 | |
| 2585 void AfterTest() override {} | |
| 2586 | |
| 2587 private: | |
| 2588 base::TimeTicks frame_time_; | |
| 2589 }; | |
| 2590 | |
| 2591 MULTI_THREAD_TEST_F(LayerTreeHostTestBeginFrameNotification); | |
| 2592 | |
| 2593 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled | 2577 class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled |
| 2594 : public LayerTreeHostTest { | 2578 : public LayerTreeHostTest { |
| 2595 public: | 2579 public: |
| 2596 void InitializeSettings(LayerTreeSettings* settings) override { | 2580 void InitializeSettings(LayerTreeSettings* settings) override { |
| 2597 settings->use_external_begin_frame_source = true; | |
| 2598 settings->using_synchronous_renderer_compositor = true; | 2581 settings->using_synchronous_renderer_compositor = true; |
| 2599 } | 2582 } |
| 2600 | 2583 |
| 2601 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 2584 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 2602 | 2585 |
| 2603 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 2586 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 2604 // The BeginFrame notification is turned off now but will get enabled | 2587 // The BeginFrame notification is turned off now but will get enabled |
| 2605 // once we return. End test while it's enabled. | 2588 // once we return. End test while it's enabled. |
| 2606 ImplThreadTaskRunner()->PostTask( | 2589 ImplThreadTaskRunner()->PostTask( |
| 2607 FROM_HERE, | 2590 FROM_HERE, |
| 2608 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, | 2591 base::Bind(&LayerTreeHostTest::EndTest, base::Unretained(this))); |
| 2609 base::Unretained(this))); | |
| 2610 } | 2592 } |
| 2611 | 2593 |
| 2612 void AfterTest() override {} | 2594 void AfterTest() override {} |
| 2613 }; | 2595 }; |
| 2614 | 2596 |
| 2615 MULTI_THREAD_TEST_F( | 2597 MULTI_THREAD_TEST_F( |
| 2616 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); | 2598 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
| 2617 | 2599 |
| 2618 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { | 2600 class LayerTreeHostTestAbortedCommitDoesntStall : public LayerTreeHostTest { |
| 2619 protected: | 2601 protected: |
| 2620 LayerTreeHostTestAbortedCommitDoesntStall() | 2602 LayerTreeHostTestAbortedCommitDoesntStall() |
| 2621 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} | 2603 : commit_count_(0), commit_abort_count_(0), commit_complete_count_(0) {} |
| 2622 | 2604 |
| 2623 void InitializeSettings(LayerTreeSettings* settings) override { | |
| 2624 settings->use_external_begin_frame_source = true; | |
| 2625 } | |
| 2626 | |
| 2627 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 2605 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 2628 | 2606 |
| 2629 void DidCommit() override { | 2607 void DidCommit() override { |
| 2630 commit_count_++; | 2608 commit_count_++; |
| 2631 if (commit_count_ == 4) { | 2609 if (commit_count_ == 4) { |
| 2632 // After two aborted commits, request a real commit now to make sure a | 2610 // After two aborted commits, request a real commit now to make sure a |
| 2633 // real commit following an aborted commit will still complete and | 2611 // real commit following an aborted commit will still complete and |
| 2634 // end the test even when the Impl thread is idle. | 2612 // end the test even when the Impl thread is idle. |
| 2635 layer_tree_host()->SetNeedsCommit(); | 2613 layer_tree_host()->SetNeedsCommit(); |
| 2636 } | 2614 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2657 EXPECT_EQ(commit_count_, 5); | 2635 EXPECT_EQ(commit_count_, 5); |
| 2658 EXPECT_EQ(commit_abort_count_, 3); | 2636 EXPECT_EQ(commit_abort_count_, 3); |
| 2659 EXPECT_EQ(commit_complete_count_, 2); | 2637 EXPECT_EQ(commit_complete_count_, 2); |
| 2660 } | 2638 } |
| 2661 | 2639 |
| 2662 int commit_count_; | 2640 int commit_count_; |
| 2663 int commit_abort_count_; | 2641 int commit_abort_count_; |
| 2664 int commit_complete_count_; | 2642 int commit_complete_count_; |
| 2665 }; | 2643 }; |
| 2666 | 2644 |
| 2667 class OnDrawOutputSurface : public OutputSurface { | 2645 class OnDrawOutputSurface : public TestDelegatingOutputSurface { |
|
danakj
2016/07/30 00:54:24
This is the singular time we override CreateDelega
| |
| 2668 public: | 2646 public: |
| 2669 explicit OnDrawOutputSurface(base::Closure invalidate_callback) | 2647 explicit OnDrawOutputSurface( |
| 2670 : OutputSurface(TestContextProvider::Create(), | 2648 scoped_refptr<ContextProvider> compositor_context_provider, |
| 2671 TestContextProvider::CreateWorker(), | 2649 scoped_refptr<ContextProvider> worker_context_provider, |
| 2672 nullptr), | 2650 std::unique_ptr<OutputSurface> display_output_surface, |
| 2673 invalidate_callback_(std::move(invalidate_callback)) { | 2651 SharedBitmapManager* shared_bitmap_manager, |
| 2674 capabilities_.delegated_rendering = true; | 2652 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 2675 } | 2653 const RendererSettings& renderer_settings, |
| 2654 base::SingleThreadTaskRunner* task_runner, | |
| 2655 bool synchronous_composite, | |
| 2656 bool force_disable_reclaim_resources, | |
| 2657 base::Closure invalidate_callback) | |
| 2658 : TestDelegatingOutputSurface(std::move(compositor_context_provider), | |
| 2659 std::move(worker_context_provider), | |
| 2660 std::move(display_output_surface), | |
| 2661 shared_bitmap_manager, | |
| 2662 gpu_memory_buffer_manager, | |
| 2663 renderer_settings, | |
| 2664 task_runner, | |
| 2665 synchronous_composite, | |
| 2666 force_disable_reclaim_resources), | |
| 2667 invalidate_callback_(std::move(invalidate_callback)) {} | |
| 2676 | 2668 |
| 2677 // OutputSurface implementation. | 2669 // TestDelegatingOutputSurface overrides. |
| 2678 void SwapBuffers(CompositorFrame frame) override { did_swap_ = true; } | |
| 2679 uint32_t GetFramebufferCopyTextureFormat() override { return 0; } | |
| 2680 void Invalidate() override { invalidate_callback_.Run(); } | 2670 void Invalidate() override { invalidate_callback_.Run(); } |
| 2681 | 2671 |
| 2682 void OnDraw(bool resourceless_software_draw) { | 2672 void OnDraw(bool resourceless_software_draw) { |
| 2683 gfx::Transform identity; | 2673 gfx::Transform identity; |
| 2684 gfx::Rect empty_rect; | 2674 gfx::Rect empty_rect; |
| 2685 // SwapBuffers happens inside of OnDraw. | |
| 2686 client_->OnDraw(identity, empty_rect, resourceless_software_draw); | 2675 client_->OnDraw(identity, empty_rect, resourceless_software_draw); |
| 2687 if (did_swap_) { | |
| 2688 did_swap_ = false; | |
| 2689 client_->DidSwapBuffersComplete(); | |
| 2690 } | |
| 2691 } | 2676 } |
| 2692 | 2677 |
| 2693 private: | 2678 private: |
| 2694 bool did_swap_ = false; | 2679 const base::Closure invalidate_callback_; |
| 2695 base::Closure invalidate_callback_; | |
| 2696 }; | 2680 }; |
| 2697 | 2681 |
| 2698 class LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor | 2682 class LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor |
| 2699 : public LayerTreeHostTestAbortedCommitDoesntStall { | 2683 : public LayerTreeHostTestAbortedCommitDoesntStall { |
| 2700 protected: | 2684 protected: |
| 2701 void InitializeSettings(LayerTreeSettings* settings) override { | 2685 void InitializeSettings(LayerTreeSettings* settings) override { |
| 2702 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); | 2686 LayerTreeHostTestAbortedCommitDoesntStall::InitializeSettings(settings); |
| 2703 settings->using_synchronous_renderer_compositor = true; | 2687 settings->using_synchronous_renderer_compositor = true; |
| 2704 } | 2688 } |
| 2705 | 2689 |
| 2706 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 2690 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( |
| 2707 auto output_surface = base::MakeUnique<OnDrawOutputSurface>(base::Bind( | 2691 scoped_refptr<ContextProvider> compositor_context_provider, |
| 2692 scoped_refptr<ContextProvider> worker_context_provider) override { | |
| 2693 auto on_draw_callback = base::Bind( | |
| 2708 &LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor:: | 2694 &LayerTreeHostTestAbortedCommitDoesntStallSynchronousCompositor:: |
| 2709 CallOnDraw, | 2695 CallOnDraw, |
| 2710 base::Unretained(this))); | 2696 base::Unretained(this)); |
| 2697 auto output_surface = base::MakeUnique<OnDrawOutputSurface>( | |
| 2698 compositor_context_provider, std::move(worker_context_provider), | |
| 2699 CreateDisplayOutputSurface(compositor_context_provider), | |
| 2700 shared_bitmap_manager(), gpu_memory_buffer_manager(), | |
| 2701 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(), | |
| 2702 false /* synchronous_composite */, | |
| 2703 false /* force_disable_reclaim_resources */, | |
| 2704 std::move(on_draw_callback)); | |
| 2711 output_surface_ = output_surface.get(); | 2705 output_surface_ = output_surface.get(); |
| 2712 return std::move(output_surface); | 2706 return std::move(output_surface); |
| 2713 } | 2707 } |
| 2714 | 2708 |
| 2715 void CallOnDraw() { | 2709 void CallOnDraw() { |
| 2716 if (!TestEnded()) { | 2710 if (!TestEnded()) { |
| 2717 // Synchronous compositor does not draw unless told to do so by the output | 2711 // Synchronous compositor does not draw unless told to do so by the output |
| 2718 // surface. But it needs to be done on a new stack frame. | 2712 // surface. But it needs to be done on a new stack frame. |
| 2719 bool resourceless_software_draw = false; | 2713 bool resourceless_software_draw = false; |
| 2720 ImplThreadTaskRunner()->PostTask( | 2714 ImplThreadTaskRunner()->PostTask( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2836 child_layer_->SetBounds(gfx::Size(50, 50)); | 2830 child_layer_->SetBounds(gfx::Size(50, 50)); |
| 2837 | 2831 |
| 2838 root_layer_->AddChild(parent_layer_); | 2832 root_layer_->AddChild(parent_layer_); |
| 2839 parent_layer_->AddChild(child_layer_); | 2833 parent_layer_->AddChild(child_layer_); |
| 2840 layer_tree_host()->SetRootLayer(root_layer_); | 2834 layer_tree_host()->SetRootLayer(root_layer_); |
| 2841 | 2835 |
| 2842 LayerTreeHostTest::SetupTree(); | 2836 LayerTreeHostTest::SetupTree(); |
| 2843 client_.set_bounds(root_layer_->bounds()); | 2837 client_.set_bounds(root_layer_->bounds()); |
| 2844 } | 2838 } |
| 2845 | 2839 |
| 2846 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 2840 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( |
| 2841 scoped_refptr<ContextProvider> compositor_context_provider, | |
| 2842 scoped_refptr<ContextProvider> worker_context_provider) override { | |
| 2843 auto on_draw_callback = | |
| 2844 base::Bind(&LayerTreeHostTestResourcelessSoftwareDraw::CallOnDraw, | |
| 2845 base::Unretained(this)); | |
| 2847 auto output_surface = base::MakeUnique<OnDrawOutputSurface>( | 2846 auto output_surface = base::MakeUnique<OnDrawOutputSurface>( |
| 2848 base::Bind(&LayerTreeHostTestResourcelessSoftwareDraw::CallOnDraw, | 2847 compositor_context_provider, std::move(worker_context_provider), |
| 2849 base::Unretained(this))); | 2848 CreateDisplayOutputSurface(compositor_context_provider), |
| 2849 shared_bitmap_manager(), gpu_memory_buffer_manager(), | |
| 2850 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(), | |
| 2851 false /* synchronous_composite */, | |
| 2852 false /* force_disable_reclaim_resources */, | |
| 2853 std::move(on_draw_callback)); | |
| 2850 output_surface_ = output_surface.get(); | 2854 output_surface_ = output_surface.get(); |
| 2851 return std::move(output_surface); | 2855 return std::move(output_surface); |
| 2852 } | 2856 } |
| 2853 | 2857 |
| 2854 void BeginTest() override { | 2858 void BeginTest() override { |
| 2855 PostSetNeedsCommitToMainThread(); | 2859 PostSetNeedsCommitToMainThread(); |
| 2856 } | 2860 } |
| 2857 | 2861 |
| 2858 void CallOnDraw() { | 2862 void CallOnDraw() { |
| 2859 if (!TestEnded()) { | 2863 if (!TestEnded()) { |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4369 | 4373 |
| 4370 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); | 4374 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); |
| 4371 | 4375 |
| 4372 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4376 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4373 : public LayerTreeHostTest { | 4377 : public LayerTreeHostTest { |
| 4374 protected: | 4378 protected: |
| 4375 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 4379 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() |
| 4376 : first_output_surface_memory_limit_(4321234), | 4380 : first_output_surface_memory_limit_(4321234), |
| 4377 second_output_surface_memory_limit_(1234321) {} | 4381 second_output_surface_memory_limit_(1234321) {} |
| 4378 | 4382 |
| 4379 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 4383 std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( |
| 4380 if (!first_context_provider_.get()) { | 4384 scoped_refptr<ContextProvider> compositor_context_provider) override { |
| 4385 if (!first_context_provider_) { | |
| 4381 first_context_provider_ = TestContextProvider::Create(); | 4386 first_context_provider_ = TestContextProvider::Create(); |
| 4387 compositor_context_provider = first_context_provider_; | |
| 4382 } else { | 4388 } else { |
| 4383 EXPECT_FALSE(second_context_provider_.get()); | 4389 EXPECT_FALSE(second_context_provider_); |
| 4384 second_context_provider_ = TestContextProvider::Create(); | 4390 second_context_provider_ = TestContextProvider::Create(); |
| 4391 compositor_context_provider = second_context_provider_; | |
| 4385 } | 4392 } |
| 4386 | 4393 |
| 4387 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() | 4394 auto output_surface = |
| 4388 ? second_context_provider_ | 4395 FakeOutputSurface::Create3d(std::move(compositor_context_provider)); |
| 4389 : first_context_provider_); | |
| 4390 std::unique_ptr<FakeOutputSurface> output_surface; | |
| 4391 if (delegating_renderer()) | |
| 4392 output_surface = FakeOutputSurface::CreateDelegating3d(provider); | |
| 4393 else | |
| 4394 output_surface = FakeOutputSurface::Create3d(provider); | |
| 4395 output_surface->SetMemoryPolicyToSetAtBind( | 4396 output_surface->SetMemoryPolicyToSetAtBind( |
| 4396 base::WrapUnique(new ManagedMemoryPolicy( | 4397 base::WrapUnique(new ManagedMemoryPolicy( |
| 4397 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4398 second_context_provider_.get() ? second_output_surface_memory_limit_ |
| 4398 : first_output_surface_memory_limit_, | 4399 : first_output_surface_memory_limit_, |
| 4399 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4400 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 4400 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4401 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
| 4401 return std::move(output_surface); | 4402 return std::move(output_surface); |
| 4402 } | 4403 } |
| 4403 | 4404 |
| 4404 void SetupTree() override { | 4405 void SetupTree() override { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4520 if (frame == -1) { | 4521 if (frame == -1) { |
| 4521 host_impl->active_tree()->QueuePinnedSwapPromise(base::WrapUnique( | 4522 host_impl->active_tree()->QueuePinnedSwapPromise(base::WrapUnique( |
| 4522 new TestSwapPromise(&pinned_active_swap_promise_result_))); | 4523 new TestSwapPromise(&pinned_active_swap_promise_result_))); |
| 4523 host_impl->pending_tree()->QueueSwapPromise( | 4524 host_impl->pending_tree()->QueueSwapPromise( |
| 4524 base::WrapUnique(new TestSwapPromise(&pending_swap_promise_result_))); | 4525 base::WrapUnique(new TestSwapPromise(&pending_swap_promise_result_))); |
| 4525 host_impl->active_tree()->QueueSwapPromise( | 4526 host_impl->active_tree()->QueueSwapPromise( |
| 4526 base::WrapUnique(new TestSwapPromise(&active_swap_promise_result_))); | 4527 base::WrapUnique(new TestSwapPromise(&active_swap_promise_result_))); |
| 4527 } | 4528 } |
| 4528 } | 4529 } |
| 4529 | 4530 |
| 4530 void SwapBuffersCompleteOnThread() override { EndTest(); } | 4531 void DisplayDidDrawAndSwapOnThread() override { EndTest(); } |
| 4531 | 4532 |
| 4532 void AfterTest() override { | 4533 void AfterTest() override { |
| 4533 // The pending swap promise should activate and swap. | 4534 // The pending swap promise should activate and swap. |
| 4534 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called); | 4535 EXPECT_TRUE(pending_swap_promise_result_.did_activate_called); |
| 4535 EXPECT_TRUE(pending_swap_promise_result_.did_swap_called); | 4536 EXPECT_TRUE(pending_swap_promise_result_.did_swap_called); |
| 4536 | 4537 |
| 4537 // The active swap promise should fail to swap (it is cancelled by | 4538 // The active swap promise should fail to swap (it is cancelled by |
| 4538 // the activation of a new frame). | 4539 // the activation of a new frame). |
| 4539 EXPECT_FALSE(active_swap_promise_result_.did_activate_called); | 4540 EXPECT_FALSE(active_swap_promise_result_.did_activate_called); |
| 4540 EXPECT_FALSE(active_swap_promise_result_.did_swap_called); | 4541 EXPECT_FALSE(active_swap_promise_result_.did_swap_called); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4712 } | 4713 } |
| 4713 | 4714 |
| 4714 void SetCallback(LayerTreeHostImpl* host_impl, bool enable) { | 4715 void SetCallback(LayerTreeHostImpl* host_impl, bool enable) { |
| 4715 host_impl->SetTreeActivationCallback( | 4716 host_impl->SetTreeActivationCallback( |
| 4716 enable | 4717 enable |
| 4717 ? base::Bind(&LayerTreeHostTestKeepSwapPromise::ActivationCallback, | 4718 ? base::Bind(&LayerTreeHostTestKeepSwapPromise::ActivationCallback, |
| 4718 base::Unretained(this)) | 4719 base::Unretained(this)) |
| 4719 : base::Closure()); | 4720 : base::Closure()); |
| 4720 } | 4721 } |
| 4721 | 4722 |
| 4722 void SwapBuffersCompleteOnThread() override { | 4723 void DisplayDidDrawAndSwapOnThread() override { |
| 4723 if (num_swaps_++ >= 1) { | 4724 if (num_swaps_++ >= 1) { |
| 4724 // The commit changes layers so it should cause a swap. | 4725 // The commit changes layers so it should cause a swap. |
| 4725 base::AutoLock lock(swap_promise_result_.lock); | 4726 base::AutoLock lock(swap_promise_result_.lock); |
| 4726 EXPECT_TRUE(swap_promise_result_.did_swap_called); | 4727 EXPECT_TRUE(swap_promise_result_.did_swap_called); |
| 4727 EXPECT_FALSE(swap_promise_result_.did_not_swap_called); | 4728 EXPECT_FALSE(swap_promise_result_.did_not_swap_called); |
| 4728 EXPECT_TRUE(swap_promise_result_.dtor_called); | 4729 EXPECT_TRUE(swap_promise_result_.dtor_called); |
| 4729 EndTest(); | 4730 EndTest(); |
| 4730 } | 4731 } |
| 4731 } | 4732 } |
| 4732 | 4733 |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5464 }; | 5465 }; |
| 5465 | 5466 |
| 5466 // TODO(vmpstr): Enable with single thread impl-side painting. | 5467 // TODO(vmpstr): Enable with single thread impl-side painting. |
| 5467 // This test blocks activation which is not supported for single thread mode. | 5468 // This test blocks activation which is not supported for single thread mode. |
| 5468 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestActivateOnInvisible); | 5469 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestActivateOnInvisible); |
| 5469 | 5470 |
| 5470 // Do a synchronous composite and assert that the swap promise succeeds. | 5471 // Do a synchronous composite and assert that the swap promise succeeds. |
| 5471 class LayerTreeHostTestSynchronousCompositeSwapPromise | 5472 class LayerTreeHostTestSynchronousCompositeSwapPromise |
| 5472 : public LayerTreeHostTest { | 5473 : public LayerTreeHostTest { |
| 5473 public: | 5474 public: |
| 5474 LayerTreeHostTestSynchronousCompositeSwapPromise() : commit_count_(0) {} | 5475 LayerTreeHostTestSynchronousCompositeSwapPromise() = default; |
| 5475 | 5476 |
| 5476 void InitializeSettings(LayerTreeSettings* settings) override { | 5477 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5477 settings->single_thread_proxy_scheduler = false; | 5478 settings->single_thread_proxy_scheduler = false; |
| 5478 settings->use_zero_copy = true; | 5479 settings->use_zero_copy = true; |
| 5479 } | 5480 } |
| 5480 | 5481 |
| 5482 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( | |
| 5483 scoped_refptr<ContextProvider> compositor_context_provider, | |
| 5484 scoped_refptr<ContextProvider> worker_context_provider) override { | |
| 5485 bool synchronous_composite = | |
| 5486 !HasImplThread() && | |
| 5487 !layer_tree_host()->settings().single_thread_proxy_scheduler; | |
| 5488 // Relaiming resources is parameterized for this test. | |
| 5489 bool force_disable_reclaim_resources = !reclaim_resources_; | |
| 5490 return base::MakeUnique<TestDelegatingOutputSurface>( | |
| 5491 compositor_context_provider, std::move(worker_context_provider), | |
| 5492 CreateDisplayOutputSurface(compositor_context_provider), | |
| 5493 shared_bitmap_manager(), gpu_memory_buffer_manager(), | |
| 5494 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(), | |
| 5495 synchronous_composite, force_disable_reclaim_resources); | |
| 5496 } | |
| 5497 | |
| 5481 void BeginTest() override { | 5498 void BeginTest() override { |
| 5482 // Successful composite. | 5499 // Successful composite. |
| 5483 std::unique_ptr<SwapPromise> swap_promise0( | 5500 std::unique_ptr<SwapPromise> swap_promise0( |
| 5484 new TestSwapPromise(&swap_promise_result_[0])); | 5501 new TestSwapPromise(&swap_promise_result_[0])); |
| 5485 layer_tree_host()->QueueSwapPromise(std::move(swap_promise0)); | 5502 layer_tree_host()->QueueSwapPromise(std::move(swap_promise0)); |
| 5486 layer_tree_host()->Composite(base::TimeTicks::Now()); | 5503 layer_tree_host()->Composite(base::TimeTicks::Now()); |
| 5487 | 5504 |
| 5488 // Fail to swap (no damage). | 5505 // Fail to swap (no damage) if not reclaiming resources from the Display. |
| 5489 std::unique_ptr<SwapPromise> swap_promise1( | 5506 std::unique_ptr<SwapPromise> swap_promise1( |
| 5490 new TestSwapPromise(&swap_promise_result_[1])); | 5507 new TestSwapPromise(&swap_promise_result_[1])); |
| 5491 layer_tree_host()->QueueSwapPromise(std::move(swap_promise1)); | 5508 layer_tree_host()->QueueSwapPromise(std::move(swap_promise1)); |
| 5492 layer_tree_host()->SetNeedsCommit(); | 5509 layer_tree_host()->SetNeedsCommit(); |
| 5493 layer_tree_host()->Composite(base::TimeTicks::Now()); | 5510 layer_tree_host()->Composite(base::TimeTicks::Now()); |
| 5494 | 5511 |
| 5495 // Fail to draw (not visible). | 5512 // Fail to draw (not visible). |
| 5496 std::unique_ptr<SwapPromise> swap_promise2( | 5513 std::unique_ptr<SwapPromise> swap_promise2( |
| 5497 new TestSwapPromise(&swap_promise_result_[2])); | 5514 new TestSwapPromise(&swap_promise_result_[2])); |
| 5498 layer_tree_host()->QueueSwapPromise(std::move(swap_promise2)); | 5515 layer_tree_host()->QueueSwapPromise(std::move(swap_promise2)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 5512 EXPECT_EQ(3, commit_count_); | 5529 EXPECT_EQ(3, commit_count_); |
| 5513 | 5530 |
| 5514 // Initial swap promise should have succeded. | 5531 // Initial swap promise should have succeded. |
| 5515 { | 5532 { |
| 5516 base::AutoLock lock(swap_promise_result_[0].lock); | 5533 base::AutoLock lock(swap_promise_result_[0].lock); |
| 5517 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); | 5534 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); |
| 5518 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); | 5535 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); |
| 5519 EXPECT_TRUE(swap_promise_result_[0].dtor_called); | 5536 EXPECT_TRUE(swap_promise_result_[0].dtor_called); |
| 5520 } | 5537 } |
| 5521 | 5538 |
| 5522 // Second swap promise fails to swap. | 5539 // Second swap promise fails to swap if not reclaiming resources from the |
| 5540 // Display. | |
| 5523 { | 5541 { |
| 5524 base::AutoLock lock(swap_promise_result_[1].lock); | 5542 base::AutoLock lock(swap_promise_result_[1].lock); |
| 5525 EXPECT_TRUE(swap_promise_result_[1].did_activate_called); | 5543 EXPECT_TRUE(swap_promise_result_[1].did_activate_called); |
| 5526 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); | 5544 if (!reclaim_resources_) { |
| 5527 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); | 5545 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); |
| 5528 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[1].reason); | 5546 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); |
| 5547 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[1].reason); | |
| 5548 } else { | |
| 5549 EXPECT_TRUE(swap_promise_result_[1].did_swap_called); | |
| 5550 EXPECT_FALSE(swap_promise_result_[1].did_not_swap_called); | |
| 5551 } | |
| 5529 EXPECT_TRUE(swap_promise_result_[1].dtor_called); | 5552 EXPECT_TRUE(swap_promise_result_[1].dtor_called); |
| 5530 } | 5553 } |
| 5531 | 5554 |
| 5532 // Third swap promises also fails to swap (and draw). | 5555 // Third swap promises also fails to swap (and draw). |
| 5533 { | 5556 { |
| 5534 base::AutoLock lock(swap_promise_result_[2].lock); | 5557 base::AutoLock lock(swap_promise_result_[2].lock); |
| 5535 EXPECT_TRUE(swap_promise_result_[2].did_activate_called); | 5558 EXPECT_TRUE(swap_promise_result_[2].did_activate_called); |
| 5536 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); | 5559 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); |
| 5537 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); | 5560 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); |
| 5538 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); | 5561 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); |
| 5539 EXPECT_TRUE(swap_promise_result_[2].dtor_called); | 5562 EXPECT_TRUE(swap_promise_result_[2].dtor_called); |
| 5540 } | 5563 } |
| 5541 } | 5564 } |
| 5542 | 5565 |
| 5543 int commit_count_; | 5566 bool reclaim_resources_; |
| 5567 int commit_count_ = 0; | |
| 5544 TestSwapPromiseResult swap_promise_result_[3]; | 5568 TestSwapPromiseResult swap_promise_result_[3]; |
| 5545 }; | 5569 }; |
| 5546 | 5570 |
| 5547 SINGLE_THREAD_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); | 5571 TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise, NoReclaim) { |
| 5572 reclaim_resources_ = false; | |
| 5573 RunTest(CompositorMode::SINGLE_THREADED, true); | |
| 5574 } | |
| 5575 | |
| 5576 TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise, Reclaim) { | |
| 5577 reclaim_resources_ = true; | |
| 5578 RunTest(CompositorMode::SINGLE_THREADED, true); | |
| 5579 } | |
| 5548 | 5580 |
| 5549 // Make sure page scale and top control deltas are applied to the client even | 5581 // Make sure page scale and top control deltas are applied to the client even |
| 5550 // when the LayerTreeHost doesn't have a root layer. | 5582 // when the LayerTreeHost doesn't have a root layer. |
| 5551 class LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer | 5583 class LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer |
| 5552 : public LayerTreeHostTest { | 5584 : public LayerTreeHostTest { |
| 5553 public: | 5585 public: |
| 5554 LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer() | 5586 LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer() |
| 5555 : deltas_sent_to_client_(false) {} | 5587 : deltas_sent_to_client_(false) {} |
| 5556 | 5588 |
| 5557 void BeginTest() override { | 5589 void BeginTest() override { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5775 base::WaitableEvent playback_allowed_event_; | 5807 base::WaitableEvent playback_allowed_event_; |
| 5776 }; | 5808 }; |
| 5777 | 5809 |
| 5778 // This test does pinching on the impl side which is not supported in single | 5810 // This test does pinching on the impl side which is not supported in single |
| 5779 // thread. | 5811 // thread. |
| 5780 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5812 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5781 | 5813 |
| 5782 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5814 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5783 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5815 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5784 protected: | 5816 protected: |
| 5785 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 5817 std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( |
| 5786 std::unique_ptr<TestWebGraphicsContext3D> context3d = | 5818 scoped_refptr<ContextProvider> compositor_context_provider) override { |
| 5787 TestWebGraphicsContext3D::Create(); | 5819 scoped_refptr<TestContextProvider> display_context_provider = |
| 5788 context3d->set_support_image(true); | 5820 TestContextProvider::Create(); |
| 5821 TestWebGraphicsContext3D* context3d = | |
| 5822 display_context_provider->UnboundTestContext3d(); | |
| 5789 context3d->set_support_sync_query(true); | 5823 context3d->set_support_sync_query(true); |
| 5790 #if defined(OS_MACOSX) | 5824 #if defined(OS_MACOSX) |
| 5791 context3d->set_support_texture_rectangle(true); | 5825 context3d->set_support_texture_rectangle(true); |
| 5792 #endif | 5826 #endif |
| 5793 | 5827 return LayerTreeTest::CreateDisplayOutputSurface( |
| 5794 if (delegating_renderer()) | 5828 std::move(display_context_provider)); |
| 5795 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); | |
| 5796 else | |
| 5797 return FakeOutputSurface::Create3d(std::move(context3d)); | |
| 5798 } | 5829 } |
| 5799 }; | 5830 }; |
| 5800 | 5831 |
| 5801 // This test does pinching on the impl side which is not supported in single | 5832 // This test does pinching on the impl side which is not supported in single |
| 5802 // thread. | 5833 // thread. |
| 5803 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); | 5834 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); |
| 5804 | 5835 |
| 5805 class RasterizeWithGpuRasterizationCreatesResources : public LayerTreeHostTest { | 5836 class RasterizeWithGpuRasterizationCreatesResources : public LayerTreeHostTest { |
| 5806 protected: | 5837 protected: |
| 5807 RasterizeWithGpuRasterizationCreatesResources() {} | 5838 RasterizeWithGpuRasterizationCreatesResources() {} |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6827 | 6858 |
| 6828 void AfterTest() override {} | 6859 void AfterTest() override {} |
| 6829 }; | 6860 }; |
| 6830 | 6861 |
| 6831 MULTI_THREAD_TEST_F(LayerTreeHostTestDestroyWhileInitializingOutputSurface); | 6862 MULTI_THREAD_TEST_F(LayerTreeHostTestDestroyWhileInitializingOutputSurface); |
| 6832 | 6863 |
| 6833 // Makes sure that painted_device_scale_factor is propagated to the | 6864 // Makes sure that painted_device_scale_factor is propagated to the |
| 6834 // frame's metadata. | 6865 // frame's metadata. |
| 6835 class LayerTreeHostTestPaintedDeviceScaleFactor : public LayerTreeHostTest { | 6866 class LayerTreeHostTestPaintedDeviceScaleFactor : public LayerTreeHostTest { |
| 6836 protected: | 6867 protected: |
| 6837 LayerTreeHostTestPaintedDeviceScaleFactor() = default; | |
| 6838 | |
| 6839 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | |
| 6840 auto ret = FakeOutputSurface::CreateDelegating3d(); | |
| 6841 fake_output_surface_ = ret.get(); | |
| 6842 return std::move(ret); | |
| 6843 } | |
| 6844 | |
| 6845 void BeginTest() override { | 6868 void BeginTest() override { |
| 6846 layer_tree_host()->SetPaintedDeviceScaleFactor(2.0f); | 6869 layer_tree_host()->SetPaintedDeviceScaleFactor(2.0f); |
| 6847 EXPECT_EQ(1.0f, layer_tree_host()->device_scale_factor()); | 6870 EXPECT_EQ(1.0f, layer_tree_host()->device_scale_factor()); |
| 6848 PostSetNeedsCommitToMainThread(); | 6871 PostSetNeedsCommitToMainThread(); |
| 6849 } | 6872 } |
| 6850 | 6873 |
| 6851 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 6874 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 6852 EXPECT_EQ(2.0f, host_impl->active_tree()->painted_device_scale_factor()); | 6875 EXPECT_EQ(2.0f, host_impl->active_tree()->painted_device_scale_factor()); |
| 6853 EXPECT_EQ(1.0f, host_impl->active_tree()->device_scale_factor()); | 6876 EXPECT_EQ(1.0f, host_impl->active_tree()->device_scale_factor()); |
| 6854 } | 6877 } |
| 6855 | 6878 |
| 6856 void SwapBuffersCompleteOnThread() override { | 6879 void DisplayReceivedCompositorFrameOnThread( |
| 6857 EXPECT_EQ( | 6880 const CompositorFrame& frame) override { |
| 6858 2.0f, | 6881 EXPECT_EQ(2.0f, frame.metadata.device_scale_factor); |
| 6859 fake_output_surface_->last_sent_frame()->metadata.device_scale_factor); | |
| 6860 EndTest(); | 6882 EndTest(); |
| 6861 } | 6883 } |
| 6862 | 6884 |
| 6863 void AfterTest() override {} | 6885 void AfterTest() override {} |
| 6864 | |
| 6865 FakeOutputSurface* fake_output_surface_ = nullptr; | |
| 6866 }; | 6886 }; |
| 6867 | 6887 |
| 6868 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6888 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6869 | 6889 |
| 6870 // The GPU image decode controller hands images off to Skia for rasterization. | 6890 // The GPU image decode controller hands images off to Skia for rasterization. |
| 6871 // When used with large images, the images in question could be deleted before | 6891 // When used with large images, the images in question could be deleted before |
| 6872 // Skia was done with them, causing a crash. This test performs an end-to-end | 6892 // Skia was done with them, causing a crash. This test performs an end-to-end |
| 6873 // check of large image rasterization to ensure we do not hit this crash. | 6893 // check of large image rasterization to ensure we do not hit this crash. |
| 6874 // Note that this code path won't always hit the crash, even when incorrect | 6894 // Note that this code path won't always hit the crash, even when incorrect |
| 6875 // behavior occurs, so this is more of a sanity check. | 6895 // behavior occurs, so this is more of a sanity check. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6940 private: | 6960 private: |
| 6941 FakeContentLayerClient client_; | 6961 FakeContentLayerClient client_; |
| 6942 const gfx::Size viewport_size_; | 6962 const gfx::Size viewport_size_; |
| 6943 const gfx::Size large_image_size_; | 6963 const gfx::Size large_image_size_; |
| 6944 }; | 6964 }; |
| 6945 | 6965 |
| 6946 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); | 6966 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 6947 | 6967 |
| 6948 } // namespace | 6968 } // namespace |
| 6949 } // namespace cc | 6969 } // namespace cc |
| OLD | NEW |