| 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 8394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8405 }; | 8405 }; |
| 8406 | 8406 |
| 8407 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 8407 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
| 8408 scoped_refptr<TestContextProvider> context_provider = | 8408 scoped_refptr<TestContextProvider> context_provider = |
| 8409 TestContextProvider::Create(); | 8409 TestContextProvider::Create(); |
| 8410 FrameSinkClient test_client_(context_provider); | 8410 FrameSinkClient test_client_(context_provider); |
| 8411 | 8411 |
| 8412 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( | 8412 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( |
| 8413 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, | 8413 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, |
| 8414 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | 8414 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), |
| 8415 true /* synchronous_composite */, | 8415 true /* synchronous_composite */); |
| 8416 false /* force_disable_reclaim_resources */); | |
| 8417 compositor_frame_sink->SetClient(&test_client_); | 8416 compositor_frame_sink->SetClient(&test_client_); |
| 8418 | 8417 |
| 8419 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 8418 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 8420 | 8419 |
| 8421 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8420 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 8422 | 8421 |
| 8423 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8422 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
| 8424 root->test_properties()->copy_requests.push_back( | 8423 root->test_properties()->copy_requests.push_back( |
| 8425 CopyOutputRequest::CreateRequest( | 8424 CopyOutputRequest::CreateRequest( |
| 8426 base::Bind(&ShutdownReleasesContext_Callback))); | 8425 base::Bind(&ShutdownReleasesContext_Callback))); |
| (...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11406 // with msaa. | 11405 // with msaa. |
| 11407 CreateHostImplWithMsaaIsSlow(true); | 11406 CreateHostImplWithMsaaIsSlow(true); |
| 11408 host_impl_->SetHasGpuRasterizationTrigger(true); | 11407 host_impl_->SetHasGpuRasterizationTrigger(true); |
| 11409 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11408 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
| 11410 host_impl_->CommitComplete(); | 11409 host_impl_->CommitComplete(); |
| 11411 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 11410 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
| 11412 host_impl_->gpu_rasterization_status()); | 11411 host_impl_->gpu_rasterization_status()); |
| 11413 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11412 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11414 } | 11413 } |
| 11415 | 11414 |
| 11416 // A mock output surface which lets us detect calls to ForceReclaimResources. | |
| 11417 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { | |
| 11418 public: | |
| 11419 MockReclaimResourcesCompositorFrameSink() | |
| 11420 : FakeCompositorFrameSink(TestContextProvider::Create(), | |
| 11421 TestContextProvider::CreateWorker()) {} | |
| 11422 | |
| 11423 MOCK_METHOD0(ForceReclaimResources, void()); | |
| 11424 }; | |
| 11425 | |
| 11426 // Display::Draw (and the planned Display Scheduler) currently rely on resources | |
| 11427 // being reclaimed to block drawing between BeginCommit / Swap. This test | |
| 11428 // ensures that BeginCommit triggers ForceReclaimResources. See | |
| 11429 // crbug.com/489515. | |
| 11430 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | |
| 11431 auto compositor_frame_sink = | |
| 11432 base::MakeUnique<MockReclaimResourcesCompositorFrameSink>(); | |
| 11433 // Hold an unowned pointer to the output surface to use for mock expectations. | |
| 11434 MockReclaimResourcesCompositorFrameSink* mock_compositor_frame_sink = | |
| 11435 compositor_frame_sink.get(); | |
| 11436 | |
| 11437 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | |
| 11438 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1); | |
| 11439 host_impl_->BeginCommit(); | |
| 11440 } | |
| 11441 | |
| 11442 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 11415 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
| 11443 // Check page scale factor update in property trees when an update is made | 11416 // Check page scale factor update in property trees when an update is made |
| 11444 // on the active tree. | 11417 // on the active tree. |
| 11445 host_impl_->CreatePendingTree(); | 11418 host_impl_->CreatePendingTree(); |
| 11446 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 11419 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
| 11447 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 11420 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 11448 gfx::Size(100, 100)); | 11421 gfx::Size(100, 100)); |
| 11449 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 11422 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 11450 host_impl_->ActivateSyncTree(); | 11423 host_impl_->ActivateSyncTree(); |
| 11451 DrawFrame(); | 11424 DrawFrame(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11731 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11704 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11732 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11705 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11733 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11706 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
| 11734 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11707 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
| 11735 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11708 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
| 11736 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11709 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11737 } | 11710 } |
| 11738 | 11711 |
| 11739 } // namespace | 11712 } // namespace |
| 11740 } // namespace cc | 11713 } // namespace cc |
| OLD | NEW |