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 8784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8795 }; | 8795 }; |
8796 | 8796 |
8797 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 8797 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
8798 scoped_refptr<TestContextProvider> context_provider = | 8798 scoped_refptr<TestContextProvider> context_provider = |
8799 TestContextProvider::Create(); | 8799 TestContextProvider::Create(); |
8800 FrameSinkClient test_client_(context_provider); | 8800 FrameSinkClient test_client_(context_provider); |
8801 | 8801 |
8802 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( | 8802 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( |
8803 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, | 8803 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, |
8804 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | 8804 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), |
8805 true /* synchronous_composite */, | 8805 true /* synchronous_composite */); |
8806 false /* force_disable_reclaim_resources */); | |
8807 compositor_frame_sink->SetClient(&test_client_); | 8806 compositor_frame_sink->SetClient(&test_client_); |
8808 | 8807 |
8809 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 8808 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
8810 | 8809 |
8811 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8810 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
8812 | 8811 |
8813 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8812 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
8814 root->test_properties()->copy_requests.push_back( | 8813 root->test_properties()->copy_requests.push_back( |
8815 CopyOutputRequest::CreateRequest( | 8814 CopyOutputRequest::CreateRequest( |
8816 base::Bind(&ShutdownReleasesContext_Callback))); | 8815 base::Bind(&ShutdownReleasesContext_Callback))); |
(...skipping 3085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11902 // with msaa (we'll still use GPU raster, though). | 11901 // with msaa (we'll still use GPU raster, though). |
11903 CreateHostImplWithMsaaIsSlow(true); | 11902 CreateHostImplWithMsaaIsSlow(true); |
11904 host_impl_->SetHasGpuRasterizationTrigger(true); | 11903 host_impl_->SetHasGpuRasterizationTrigger(true); |
11905 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11904 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11906 host_impl_->CommitComplete(); | 11905 host_impl_->CommitComplete(); |
11907 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 11906 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
11908 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11907 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11909 EXPECT_FALSE(host_impl_->use_msaa()); | 11908 EXPECT_FALSE(host_impl_->use_msaa()); |
11910 } | 11909 } |
11911 | 11910 |
11912 // A mock output surface which lets us detect calls to ForceReclaimResources. | |
11913 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { | |
11914 public: | |
11915 MockReclaimResourcesCompositorFrameSink() | |
11916 : FakeCompositorFrameSink(TestContextProvider::Create(), | |
11917 TestContextProvider::CreateWorker()) {} | |
11918 | |
11919 MOCK_METHOD0(ForceReclaimResources, void()); | |
11920 }; | |
11921 | |
11922 // Display::Draw (and the planned Display Scheduler) currently rely on resources | |
11923 // being reclaimed to block drawing between BeginCommit / Swap. This test | |
11924 // ensures that BeginCommit triggers ForceReclaimResources. See | |
11925 // crbug.com/489515. | |
11926 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { | |
11927 auto compositor_frame_sink = | |
11928 base::MakeUnique<MockReclaimResourcesCompositorFrameSink>(); | |
11929 // Hold an unowned pointer to the output surface to use for mock expectations. | |
11930 MockReclaimResourcesCompositorFrameSink* mock_compositor_frame_sink = | |
11931 compositor_frame_sink.get(); | |
11932 | |
11933 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | |
11934 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1); | |
11935 host_impl_->BeginCommit(); | |
11936 } | |
11937 | |
11938 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { | 11911 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { |
11939 // Check page scale factor update in property trees when an update is made | 11912 // Check page scale factor update in property trees when an update is made |
11940 // on the active tree. | 11913 // on the active tree. |
11941 host_impl_->CreatePendingTree(); | 11914 host_impl_->CreatePendingTree(); |
11942 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); | 11915 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); |
11943 CreateScrollAndContentsLayers(host_impl_->pending_tree(), | 11916 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
11944 gfx::Size(100, 100)); | 11917 gfx::Size(100, 100)); |
11945 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 11918 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
11946 host_impl_->ActivateSyncTree(); | 11919 host_impl_->ActivateSyncTree(); |
11947 DrawFrame(); | 11920 DrawFrame(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12375 else | 12348 else |
12376 EXPECT_FALSE(tile->HasRasterTask()); | 12349 EXPECT_FALSE(tile->HasRasterTask()); |
12377 } | 12350 } |
12378 Region expected_invalidation( | 12351 Region expected_invalidation( |
12379 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12352 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
12380 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12353 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
12381 } | 12354 } |
12382 | 12355 |
12383 } // namespace | 12356 } // namespace |
12384 } // namespace cc | 12357 } // namespace cc |
OLD | NEW |