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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 8391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8402 }; | 8402 }; |
8403 | 8403 |
8404 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 8404 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
8405 scoped_refptr<TestContextProvider> context_provider = | 8405 scoped_refptr<TestContextProvider> context_provider = |
8406 TestContextProvider::Create(); | 8406 TestContextProvider::Create(); |
8407 FrameSinkClient test_client_(context_provider); | 8407 FrameSinkClient test_client_(context_provider); |
8408 | 8408 |
8409 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( | 8409 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( |
8410 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, | 8410 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, |
8411 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | 8411 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), |
8412 true /* synchronous_composite */); | 8412 true /* synchronous_composite */, |
| 8413 false /* force_disable_reclaim_resources */); |
8413 compositor_frame_sink->SetClient(&test_client_); | 8414 compositor_frame_sink->SetClient(&test_client_); |
8414 | 8415 |
8415 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 8416 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
8416 | 8417 |
8417 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8418 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
8418 | 8419 |
8419 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8420 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
8420 root->test_properties()->copy_requests.push_back( | 8421 root->test_properties()->copy_requests.push_back( |
8421 CopyOutputRequest::CreateRequest( | 8422 CopyOutputRequest::CreateRequest( |
8422 base::Bind(&ShutdownReleasesContext_Callback))); | 8423 base::Bind(&ShutdownReleasesContext_Callback))); |
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11441 // with msaa. | 11442 // with msaa. |
11442 CreateHostImplWithMsaaIsSlow(true); | 11443 CreateHostImplWithMsaaIsSlow(true); |
11443 host_impl_->SetHasGpuRasterizationTrigger(true); | 11444 host_impl_->SetHasGpuRasterizationTrigger(true); |
11444 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11445 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11445 host_impl_->CommitComplete(); | 11446 host_impl_->CommitComplete(); |
11446 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11447 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
11447 host_impl_->gpu_rasterization_status()); | 11448 host_impl_->gpu_rasterization_status()); |
11448 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11449 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11449 } | 11450 } |
11450 | 11451 |
| 11452 // A mock output surface which lets us detect calls to ForceReclaimResources. |
| 11453 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { |
| 11454 public: |
| 11455 MockReclaimResourcesCompositorFrameSink() |
| 11456 : FakeCompositorFrameSink(TestContextProvider::Create(), |
| 11457 TestContextProvider::CreateWorker()) {} |
| 11458 |
| 11459 MOCK_METHOD0(ForceReclaimResources, void()); |
| 11460 }; |
| 11461 |
| 11462 // Display::Draw (and the planned Display Scheduler) currently rely on resources |
| 11463 // being reclaimed to block drawing between BeginCommit / Swap. This test |
| 11464 // ensures that BeginCommit triggers ForceReclaimResources. See |
| 11465 // crbug.com/489515. |
| 11466 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { |
| 11467 auto compositor_frame_sink = |
| 11468 base::MakeUnique<MockReclaimResourcesCompositorFrameSink>(); |
| 11469 // Hold an unowned pointer to the output surface to use for mock expectations. |
| 11470 MockReclaimResourcesCompositorFrameSink* mock_compositor_frame_sink = |
| 11471 compositor_frame_sink.get(); |
| 11472 |
| 11473 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 11474 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1); |
| 11475 host_impl_->BeginCommit(); |
| 11476 } |
| 11477 |
11451 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 11478 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
11452 // Check page scale factor update in property trees when an update is made | 11479 // Check page scale factor update in property trees when an update is made |
11453 // on the active tree. | 11480 // on the active tree. |
11454 host_impl_->CreatePendingTree(); | 11481 host_impl_->CreatePendingTree(); |
11455 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 11482 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
11456 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 11483 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
11457 gfx::Size(100, 100)); | 11484 gfx::Size(100, 100)); |
11458 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 11485 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
11459 host_impl_->ActivateSyncTree(); | 11486 host_impl_->ActivateSyncTree(); |
11460 DrawFrame(); | 11487 DrawFrame(); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11740 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11741 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11768 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11742 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11769 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11743 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11744 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11771 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11745 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11746 } | 11773 } |
11747 | 11774 |
11748 } // namespace | 11775 } // namespace |
11749 } // namespace cc | 11776 } // namespace cc |
OLD | NEW |