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 */); | |
8414 compositor_frame_sink->SetClient(&test_client_); | 8413 compositor_frame_sink->SetClient(&test_client_); |
8415 | 8414 |
8416 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 8415 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
8417 | 8416 |
8418 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8417 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
8419 | 8418 |
8420 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8419 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
8421 root->test_properties()->copy_requests.push_back( | 8420 root->test_properties()->copy_requests.push_back( |
8422 CopyOutputRequest::CreateRequest( | 8421 CopyOutputRequest::CreateRequest( |
8423 base::Bind(&ShutdownReleasesContext_Callback))); | 8422 base::Bind(&ShutdownReleasesContext_Callback))); |
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11442 // with msaa. | 11441 // with msaa. |
11443 CreateHostImplWithMsaaIsSlow(true); | 11442 CreateHostImplWithMsaaIsSlow(true); |
11444 host_impl_->SetHasGpuRasterizationTrigger(true); | 11443 host_impl_->SetHasGpuRasterizationTrigger(true); |
11445 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11444 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11446 host_impl_->CommitComplete(); | 11445 host_impl_->CommitComplete(); |
11447 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11446 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
11448 host_impl_->gpu_rasterization_status()); | 11447 host_impl_->gpu_rasterization_status()); |
11449 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11448 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11450 } | 11449 } |
11451 | 11450 |
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 | |
11478 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 11451 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
11479 // Check page scale factor update in property trees when an update is made | 11452 // Check page scale factor update in property trees when an update is made |
11480 // on the active tree. | 11453 // on the active tree. |
11481 host_impl_->CreatePendingTree(); | 11454 host_impl_->CreatePendingTree(); |
11482 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 11455 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
11483 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 11456 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
11484 gfx::Size(100, 100)); | 11457 gfx::Size(100, 100)); |
11485 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 11458 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
11486 host_impl_->ActivateSyncTree(); | 11459 host_impl_->ActivateSyncTree(); |
11487 DrawFrame(); | 11460 DrawFrame(); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11740 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11768 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11741 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
11769 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11742 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11743 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
11771 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11744 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11745 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
11773 } | 11746 } |
11774 | 11747 |
11775 } // namespace | 11748 } // namespace |
11776 } // namespace cc | 11749 } // namespace cc |
OLD | NEW |