Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2822143003: Remove ForceReclaimResources (Closed)
Patch Set: Rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 8725 matching lines...) Expand 10 before | Expand all | Expand 10 after
8736 }; 8736 };
8737 8737
8738 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { 8738 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
8739 scoped_refptr<TestContextProvider> context_provider = 8739 scoped_refptr<TestContextProvider> context_provider =
8740 TestContextProvider::Create(); 8740 TestContextProvider::Create();
8741 FrameSinkClient test_client_(context_provider); 8741 FrameSinkClient test_client_(context_provider);
8742 8742
8743 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( 8743 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>(
8744 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, 8744 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr,
8745 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), 8745 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(),
8746 true /* synchronous_composite */, 8746 true /* synchronous_composite */);
8747 false /* force_disable_reclaim_resources */);
8748 compositor_frame_sink->SetClient(&test_client_); 8747 compositor_frame_sink->SetClient(&test_client_);
8749 8748
8750 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); 8749 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink));
8751 8750
8752 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 8751 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
8753 8752
8754 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 8753 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
8755 root->test_properties()->copy_requests.push_back( 8754 root->test_properties()->copy_requests.push_back(
8756 CopyOutputRequest::CreateRequest( 8755 CopyOutputRequest::CreateRequest(
8757 base::Bind(&ShutdownReleasesContext_Callback))); 8756 base::Bind(&ShutdownReleasesContext_Callback)));
(...skipping 3085 matching lines...) Expand 10 before | Expand all | Expand 10 after
11843 // with msaa (we'll still use GPU raster, though). 11842 // with msaa (we'll still use GPU raster, though).
11844 CreateHostImplWithMsaaIsSlow(true); 11843 CreateHostImplWithMsaaIsSlow(true);
11845 host_impl_->SetHasGpuRasterizationTrigger(true); 11844 host_impl_->SetHasGpuRasterizationTrigger(true);
11846 host_impl_->SetContentIsSuitableForGpuRasterization(false); 11845 host_impl_->SetContentIsSuitableForGpuRasterization(false);
11847 host_impl_->CommitComplete(); 11846 host_impl_->CommitComplete();
11848 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); 11847 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status());
11849 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11848 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11850 EXPECT_FALSE(host_impl_->use_msaa()); 11849 EXPECT_FALSE(host_impl_->use_msaa());
11851 } 11850 }
11852 11851
11853 // A mock output surface which lets us detect calls to ForceReclaimResources.
11854 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink {
11855 public:
11856 MockReclaimResourcesCompositorFrameSink()
11857 : FakeCompositorFrameSink(TestContextProvider::Create(),
11858 TestContextProvider::CreateWorker()) {}
11859
11860 MOCK_METHOD0(ForceReclaimResources, void());
11861 };
11862
11863 // Display::Draw (and the planned Display Scheduler) currently rely on resources
11864 // being reclaimed to block drawing between BeginCommit / Swap. This test
11865 // ensures that BeginCommit triggers ForceReclaimResources. See
11866 // crbug.com/489515.
11867 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) {
11868 auto compositor_frame_sink =
11869 base::MakeUnique<MockReclaimResourcesCompositorFrameSink>();
11870 // Hold an unowned pointer to the output surface to use for mock expectations.
11871 MockReclaimResourcesCompositorFrameSink* mock_compositor_frame_sink =
11872 compositor_frame_sink.get();
11873
11874 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink));
11875 EXPECT_CALL(*mock_compositor_frame_sink, ForceReclaimResources()).Times(1);
11876 host_impl_->BeginCommit();
11877 }
11878
11879 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) { 11852 TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) {
11880 // Check page scale factor update in property trees when an update is made 11853 // Check page scale factor update in property trees when an update is made
11881 // on the active tree. 11854 // on the active tree.
11882 host_impl_->CreatePendingTree(); 11855 host_impl_->CreatePendingTree();
11883 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f); 11856 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 3.f);
11884 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 11857 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
11885 gfx::Size(100, 100)); 11858 gfx::Size(100, 100));
11886 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 11859 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
11887 host_impl_->ActivateSyncTree(); 11860 host_impl_->ActivateSyncTree();
11888 DrawFrame(); 11861 DrawFrame();
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
12317 else 12290 else
12318 EXPECT_FALSE(tile->HasRasterTask()); 12291 EXPECT_FALSE(tile->HasRasterTask());
12319 } 12292 }
12320 Region expected_invalidation( 12293 Region expected_invalidation(
12321 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12294 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12322 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12295 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12323 } 12296 }
12324 12297
12325 } // namespace 12298 } // namespace
12326 } // namespace cc 12299 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698