| 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 8346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8357 }; | 8357 }; |
| 8358 | 8358 |
| 8359 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 8359 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
| 8360 scoped_refptr<TestContextProvider> context_provider = | 8360 scoped_refptr<TestContextProvider> context_provider = |
| 8361 TestContextProvider::Create(); | 8361 TestContextProvider::Create(); |
| 8362 FrameSinkClient test_client_(context_provider); | 8362 FrameSinkClient test_client_(context_provider); |
| 8363 | 8363 |
| 8364 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( | 8364 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( |
| 8365 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, | 8365 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, |
| 8366 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | 8366 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), |
| 8367 true /* synchronous_composite */, | 8367 true /* synchronous_composite */); |
| 8368 false /* force_disable_reclaim_resources */); | |
| 8369 compositor_frame_sink->SetClient(&test_client_); | 8368 compositor_frame_sink->SetClient(&test_client_); |
| 8370 | 8369 |
| 8371 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 8370 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 8372 | 8371 |
| 8373 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8372 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 8374 | 8373 |
| 8375 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8374 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 8376 root->test_properties()->copy_requests.push_back( | 8375 root->test_properties()->copy_requests.push_back( |
| 8377 CopyOutputRequest::CreateRequest( | 8376 CopyOutputRequest::CreateRequest( |
| 8378 base::Bind(&ShutdownReleasesContext_Callback))); | 8377 base::Bind(&ShutdownReleasesContext_Callback))); |
| (...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11397 // with msaa. | 11396 // with msaa. |
| 11398 CreateHostImplWithMsaaIsSlow(true); | 11397 CreateHostImplWithMsaaIsSlow(true); |
| 11399 host_impl_->SetHasGpuRasterizationTrigger(true); | 11398 host_impl_->SetHasGpuRasterizationTrigger(true); |
| 11400 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11399 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
| 11401 host_impl_->CommitComplete(); | 11400 host_impl_->CommitComplete(); |
| 11402 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11401 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
| 11403 host_impl_->gpu_rasterization_status()); | 11402 host_impl_->gpu_rasterization_status()); |
| 11404 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11403 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11405 } | 11404 } |
| 11406 | 11405 |
| 11407 // A mock output surface which lets us detect calls to ForceReclaimResources. | |
| 11408 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { | |
| 11409 public: | |
| 11410 MockReclaimResourcesCompositorFrameSink() | |
| 11411 : FakeCompositorFrameSink(TestContextProvider::Create(), | |
| 11412 TestContextProvider::CreateWorker()) {} | |
| 11413 | |
| 11414 MOCK_METHOD0(ForceReclaimResources, void()); | |
| 11415 }; | |
| 11416 | |
| 11417 // Display::Draw (and the planned Display Scheduler) currently rely on resources | |
| 11418 // being reclaimed to block drawing between BeginCommit / Swap. This test | |
| 11419 // ensures that BeginCommit triggers ForceReclaimResources. See | |
| 11420 // crbug.com/489515. | |
| 11421 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | |
| 11422 auto compositor_frame_sink = | |
| 11423 base::MakeUnique<MockReclaimResourcesCompositorFrameSink>(); | |
| 11424 // Hold an unowned pointer to the output surface to use for mock expectations. | |
| 11425 MockReclaimResourcesCompositorFrameSink* mock_compositor_frame_sink = | |
| 11426 compositor_frame_sink.get(); | |
| 11427 | |
| 11428 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | |
| 11429 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1); | |
| 11430 host_impl_->BeginCommit(); | |
| 11431 } | |
| 11432 | |
| 11433 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 11406 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
| 11434 // Check page scale factor update in property trees when an update is made | 11407 // Check page scale factor update in property trees when an update is made |
| 11435 // on the active tree. | 11408 // on the active tree. |
| 11436 host_impl_->CreatePendingTree(); | 11409 host_impl_->CreatePendingTree(); |
| 11437 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 11410 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 11438 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 11411 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 11439 gfx::Size(100, 100)); | 11412 gfx::Size(100, 100)); |
| 11440 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 11413 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 11441 host_impl_->ActivateSyncTree(); | 11414 host_impl_->ActivateSyncTree(); |
| 11442 DrawFrame(); | 11415 DrawFrame(); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11743 SetupMouseMoveAtTestScrollbarStates(true); | 11716 SetupMouseMoveAtTestScrollbarStates(true); |
| 11744 } | 11717 } |
| 11745 | 11718 |
| 11746 TEST_F(LayerTreeHostImplTest, | 11719 TEST_F(LayerTreeHostImplTest, |
| 11747 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { | 11720 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { |
| 11748 SetupMouseMoveAtTestScrollbarStates(false); | 11721 SetupMouseMoveAtTestScrollbarStates(false); |
| 11749 } | 11722 } |
| 11750 | 11723 |
| 11751 } // namespace | 11724 } // namespace |
| 11752 } // namespace cc | 11725 } // namespace cc |
| OLD | NEW |