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

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

Issue 2784683002: cc: remove the veto-to-software for complex content. (Closed)
Patch Set: Remove GpuRasterizationStatus::OFF_CONTENT entirely. 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 11457 matching lines...) Expand 10 before | Expand all | Expand 10 after
11468 // And off. 11468 // And off.
11469 host_impl_->SetHasGpuRasterizationTrigger(false); 11469 host_impl_->SetHasGpuRasterizationTrigger(false);
11470 host_impl_->CommitComplete(); 11470 host_impl_->CommitComplete();
11471 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, 11471 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT,
11472 host_impl_->gpu_rasterization_status()); 11472 host_impl_->gpu_rasterization_status());
11473 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11473 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11474 } 11474 }
11475 11475
11476 // Tests that SetContentIsSuitableForGpuRasterization behaves as expected. 11476 // Tests that SetContentIsSuitableForGpuRasterization behaves as expected.
11477 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusSuitability) { 11477 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusSuitability) {
11478 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa =
11479 TestWebGraphicsContext3D::Create();
11480 context_with_msaa->SetMaxSamples(4);
11481 context_with_msaa->set_gpu_rasterization(true);
11482 LayerTreeSettings msaaSettings = DefaultSettings();
11483 msaaSettings.gpu_rasterization_msaa_sample_count = 4;
11484 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d(
11485 std::move(context_with_msaa))));
11486
11478 // Set initial state, before varying GPU rasterization suitability. 11487 // Set initial state, before varying GPU rasterization suitability.
11479 host_impl_->SetHasGpuRasterizationTrigger(true); 11488 host_impl_->SetHasGpuRasterizationTrigger(true);
11480 host_impl_->SetContentIsSuitableForGpuRasterization(false); 11489 host_impl_->SetContentIsSuitableForGpuRasterization(false);
11481 host_impl_->CommitComplete(); 11490 host_impl_->CommitComplete();
11482 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 11491 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
11483 host_impl_->gpu_rasterization_status()); 11492 host_impl_->gpu_rasterization_status());
11484 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11493 EXPECT_TRUE(host_impl_->use_msaa());
11485 11494
11486 // Toggle suitability on. 11495 // Toggle suitability on.
11487 host_impl_->SetContentIsSuitableForGpuRasterization(true); 11496 host_impl_->SetContentIsSuitableForGpuRasterization(true);
11488 host_impl_->CommitComplete(); 11497 host_impl_->CommitComplete();
11489 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); 11498 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status());
11490 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11499 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11491 EXPECT_FALSE(host_impl_->use_msaa()); 11500 EXPECT_FALSE(host_impl_->use_msaa());
11492 11501
11493 // And off. 11502 // And off.
11494 host_impl_->SetContentIsSuitableForGpuRasterization(false); 11503 host_impl_->SetContentIsSuitableForGpuRasterization(false);
11495 host_impl_->CommitComplete(); 11504 host_impl_->CommitComplete();
11496 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 11505 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
11497 host_impl_->gpu_rasterization_status()); 11506 host_impl_->gpu_rasterization_status());
11498 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11507 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11499 EXPECT_FALSE(host_impl_->use_msaa()); 11508 EXPECT_TRUE(host_impl_->use_msaa());
11500 } 11509 }
11501 11510
11502 // Tests that SetDeviceScaleFactor correctly impacts GPU rasterization. 11511 // Tests that SetDeviceScaleFactor correctly impacts GPU rasterization.
11503 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusDeviceScaleFactor) { 11512 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusDeviceScaleFactor) {
11504 // Create a host impl with MSAA support. 11513 // Create a host impl with MSAA support.
11505 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = 11514 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa =
11506 TestWebGraphicsContext3D::Create(); 11515 TestWebGraphicsContext3D::Create();
11507 context_with_msaa->SetMaxSamples(4); 11516 context_with_msaa->SetMaxSamples(4);
11508 context_with_msaa->set_gpu_rasterization(true); 11517 context_with_msaa->set_gpu_rasterization(true);
11509 LayerTreeSettings msaaSettings = DefaultSettings(); 11518 LayerTreeSettings msaaSettings = DefaultSettings();
11510 msaaSettings.gpu_rasterization_msaa_sample_count = -1; 11519 msaaSettings.gpu_rasterization_msaa_sample_count = -1;
11511 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d( 11520 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeCompositorFrameSink::Create3d(
11512 std::move(context_with_msaa)))); 11521 std::move(context_with_msaa))));
11513 11522
11514 // Set initial state, before varying scale factor. 11523 // Set initial state, before varying scale factor.
11515 host_impl_->SetHasGpuRasterizationTrigger(true); 11524 host_impl_->SetHasGpuRasterizationTrigger(true);
11516 host_impl_->SetContentIsSuitableForGpuRasterization(false); 11525 host_impl_->SetContentIsSuitableForGpuRasterization(false);
11517 host_impl_->CommitComplete(); 11526 host_impl_->CommitComplete();
11518 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 11527 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status());
11519 host_impl_->gpu_rasterization_status()); 11528 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11520 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11521 11529
11522 // Set device scale factor to 2, which lowers the required MSAA samples from 11530 // Set device scale factor to 2, which lowers the required MSAA samples from
11523 // 8 to 4. 11531 // 8 to 4.
11524 host_impl_->active_tree()->SetDeviceScaleFactor(2.0f); 11532 host_impl_->active_tree()->SetDeviceScaleFactor(2.0f);
11525 host_impl_->CommitComplete(); 11533 host_impl_->CommitComplete();
11526 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, 11534 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
11527 host_impl_->gpu_rasterization_status()); 11535 host_impl_->gpu_rasterization_status());
11528 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11536 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11529 EXPECT_TRUE(host_impl_->use_msaa()); 11537 EXPECT_TRUE(host_impl_->use_msaa());
11530 11538
11531 // Set device scale factor back to 1. 11539 // Set device scale factor back to 1.
11532 host_impl_->active_tree()->SetDeviceScaleFactor(1.0f); 11540 host_impl_->active_tree()->SetDeviceScaleFactor(1.0f);
11533 host_impl_->CommitComplete(); 11541 host_impl_->CommitComplete();
11534 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 11542 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status());
11535 host_impl_->gpu_rasterization_status()); 11543 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11536 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11537 EXPECT_FALSE(host_impl_->use_msaa()); 11544 EXPECT_FALSE(host_impl_->use_msaa());
11538 } 11545 }
11539 11546
11540 // Tests that explicit MSAA sample count correctly impacts GPU rasterization. 11547 // Tests that explicit MSAA sample count correctly impacts GPU rasterization.
11541 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusExplicitMSAACount) { 11548 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusExplicitMSAACount) {
11542 // Create a host impl with MSAA support and a forced sample count of 4. 11549 // Create a host impl with MSAA support and a forced sample count of 4.
11543 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = 11550 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa =
11544 TestWebGraphicsContext3D::Create(); 11551 TestWebGraphicsContext3D::Create();
11545 context_with_msaa->SetMaxSamples(4); 11552 context_with_msaa->SetMaxSamples(4);
11546 context_with_msaa->set_gpu_rasterization(true); 11553 context_with_msaa->set_gpu_rasterization(true);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
11612 // msaa. 11619 // msaa.
11613 CreateHostImplWithMsaaIsSlow(false); 11620 CreateHostImplWithMsaaIsSlow(false);
11614 host_impl_->SetHasGpuRasterizationTrigger(true); 11621 host_impl_->SetHasGpuRasterizationTrigger(true);
11615 host_impl_->SetContentIsSuitableForGpuRasterization(false); 11622 host_impl_->SetContentIsSuitableForGpuRasterization(false);
11616 host_impl_->CommitComplete(); 11623 host_impl_->CommitComplete();
11617 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, 11624 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT,
11618 host_impl_->gpu_rasterization_status()); 11625 host_impl_->gpu_rasterization_status());
11619 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 11626 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11620 11627
11621 // Ensure that with the msaa_is_slow cap we don't raster unsuitable content 11628 // Ensure that with the msaa_is_slow cap we don't raster unsuitable content
11622 // with msaa. 11629 // with msaa (we'll still use GPU raster, though).
11623 CreateHostImplWithMsaaIsSlow(true); 11630 CreateHostImplWithMsaaIsSlow(true);
11624 host_impl_->SetHasGpuRasterizationTrigger(true); 11631 host_impl_->SetHasGpuRasterizationTrigger(true);
11625 host_impl_->SetContentIsSuitableForGpuRasterization(false); 11632 host_impl_->SetContentIsSuitableForGpuRasterization(false);
11626 host_impl_->CommitComplete(); 11633 host_impl_->CommitComplete();
11627 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 11634 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status());
11628 host_impl_->gpu_rasterization_status()); 11635 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
11629 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11636 EXPECT_FALSE(host_impl_->use_msaa());
11630 } 11637 }
11631 11638
11632 // A mock output surface which lets us detect calls to ForceReclaimResources. 11639 // A mock output surface which lets us detect calls to ForceReclaimResources.
11633 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink { 11640 class MockReclaimResourcesCompositorFrameSink : public FakeCompositorFrameSink {
11634 public: 11641 public:
11635 MockReclaimResourcesCompositorFrameSink() 11642 MockReclaimResourcesCompositorFrameSink()
11636 : FakeCompositorFrameSink(TestContextProvider::Create(), 11643 : FakeCompositorFrameSink(TestContextProvider::Create(),
11637 TestContextProvider::CreateWorker()) {} 11644 TestContextProvider::CreateWorker()) {}
11638 11645
11639 MOCK_METHOD0(ForceReclaimResources, void()); 11646 MOCK_METHOD0(ForceReclaimResources, void());
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
12094 else 12101 else
12095 EXPECT_FALSE(tile->HasRasterTask()); 12102 EXPECT_FALSE(tile->HasRasterTask());
12096 } 12103 }
12097 Region expected_invalidation( 12104 Region expected_invalidation(
12098 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12105 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12099 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12106 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12100 } 12107 }
12101 12108
12102 } // namespace 12109 } // namespace
12103 } // namespace cc 12110 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698