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 8715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8726 | 8726 |
8727 // RequiresHighResToDraw is set when new output surface is used. | 8727 // RequiresHighResToDraw is set when new output surface is used. |
8728 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 8728 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
8729 | 8729 |
8730 host_impl_->ResetRequiresHighResToDraw(); | 8730 host_impl_->ResetRequiresHighResToDraw(); |
8731 | 8731 |
8732 host_impl_->SetContentIsSuitableForGpuRasterization(true); | 8732 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
8733 host_impl_->SetHasGpuRasterizationTrigger(false); | 8733 host_impl_->SetHasGpuRasterizationTrigger(false); |
8734 host_impl_->CommitComplete(); | 8734 host_impl_->CommitComplete(); |
8735 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 8735 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
| 8736 host_impl_->NotifyReadyToActivate(); |
8736 host_impl_->SetHasGpuRasterizationTrigger(true); | 8737 host_impl_->SetHasGpuRasterizationTrigger(true); |
8737 host_impl_->CommitComplete(); | 8738 host_impl_->CommitComplete(); |
8738 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 8739 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
| 8740 host_impl_->NotifyReadyToActivate(); |
8739 host_impl_->SetHasGpuRasterizationTrigger(false); | 8741 host_impl_->SetHasGpuRasterizationTrigger(false); |
8740 host_impl_->CommitComplete(); | 8742 host_impl_->CommitComplete(); |
8741 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 8743 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
| 8744 host_impl_->NotifyReadyToActivate(); |
8742 | 8745 |
8743 host_impl_->ResetRequiresHighResToDraw(); | 8746 host_impl_->ResetRequiresHighResToDraw(); |
8744 | 8747 |
8745 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 8748 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
8746 host_impl_->SetHasGpuRasterizationTrigger(true); | 8749 host_impl_->SetHasGpuRasterizationTrigger(true); |
8747 host_impl_->CommitComplete(); | 8750 host_impl_->CommitComplete(); |
8748 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 8751 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
| 8752 host_impl_->NotifyReadyToActivate(); |
8749 } | 8753 } |
8750 | 8754 |
8751 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { | 8755 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
8752 public: | 8756 public: |
8753 void SetUp() override { | 8757 void SetUp() override { |
8754 fake_host_impl_ = new FakeLayerTreeHostImpl( | 8758 fake_host_impl_ = new FakeLayerTreeHostImpl( |
8755 LayerTreeSettings(), &task_runner_provider_, &task_graph_runner_); | 8759 LayerTreeSettings(), &task_runner_provider_, &task_graph_runner_); |
8756 host_impl_.reset(fake_host_impl_); | 8760 host_impl_.reset(fake_host_impl_); |
8757 layer_tree_frame_sink_ = CreateLayerTreeFrameSink(); | 8761 layer_tree_frame_sink_ = CreateLayerTreeFrameSink(); |
8758 host_impl_->SetVisible(true); | 8762 host_impl_->SetVisible(true); |
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11835 | 11839 |
11836 // Tests that SetHasGpuRasterizationTrigger behaves as expected. | 11840 // Tests that SetHasGpuRasterizationTrigger behaves as expected. |
11837 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusTrigger) { | 11841 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusTrigger) { |
11838 // Set initial state, before varying GPU rasterization trigger. | 11842 // Set initial state, before varying GPU rasterization trigger. |
11839 host_impl_->SetHasGpuRasterizationTrigger(false); | 11843 host_impl_->SetHasGpuRasterizationTrigger(false); |
11840 host_impl_->SetContentIsSuitableForGpuRasterization(true); | 11844 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
11841 host_impl_->CommitComplete(); | 11845 host_impl_->CommitComplete(); |
11842 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, | 11846 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, |
11843 host_impl_->gpu_rasterization_status()); | 11847 host_impl_->gpu_rasterization_status()); |
11844 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11848 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11849 host_impl_->NotifyReadyToActivate(); |
11845 | 11850 |
11846 // Toggle the trigger on. | 11851 // Toggle the trigger on. |
11847 host_impl_->SetHasGpuRasterizationTrigger(true); | 11852 host_impl_->SetHasGpuRasterizationTrigger(true); |
11848 host_impl_->CommitComplete(); | 11853 host_impl_->CommitComplete(); |
11849 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 11854 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
11850 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11855 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11856 host_impl_->NotifyReadyToActivate(); |
11851 | 11857 |
11852 // And off. | 11858 // And off. |
11853 host_impl_->SetHasGpuRasterizationTrigger(false); | 11859 host_impl_->SetHasGpuRasterizationTrigger(false); |
11854 host_impl_->CommitComplete(); | 11860 host_impl_->CommitComplete(); |
11855 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, | 11861 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, |
11856 host_impl_->gpu_rasterization_status()); | 11862 host_impl_->gpu_rasterization_status()); |
11857 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11863 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11864 host_impl_->NotifyReadyToActivate(); |
11858 } | 11865 } |
11859 | 11866 |
11860 // Tests that SetContentIsSuitableForGpuRasterization behaves as expected. | 11867 // Tests that SetContentIsSuitableForGpuRasterization behaves as expected. |
11861 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusSuitability) { | 11868 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusSuitability) { |
11862 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 11869 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
11863 TestWebGraphicsContext3D::Create(); | 11870 TestWebGraphicsContext3D::Create(); |
11864 context_with_msaa->SetMaxSamples(4); | 11871 context_with_msaa->SetMaxSamples(4); |
11865 context_with_msaa->set_gpu_rasterization(true); | 11872 context_with_msaa->set_gpu_rasterization(true); |
11866 LayerTreeSettings msaaSettings = DefaultSettings(); | 11873 LayerTreeSettings msaaSettings = DefaultSettings(); |
11867 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 11874 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
11868 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeLayerTreeFrameSink::Create3d( | 11875 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeLayerTreeFrameSink::Create3d( |
11869 std::move(context_with_msaa)))); | 11876 std::move(context_with_msaa)))); |
11870 | 11877 |
11871 // Set initial state, before varying GPU rasterization suitability. | 11878 // Set initial state, before varying GPU rasterization suitability. |
11872 host_impl_->SetHasGpuRasterizationTrigger(true); | 11879 host_impl_->SetHasGpuRasterizationTrigger(true); |
11873 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11880 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11874 host_impl_->CommitComplete(); | 11881 host_impl_->CommitComplete(); |
11875 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 11882 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
11876 host_impl_->gpu_rasterization_status()); | 11883 host_impl_->gpu_rasterization_status()); |
11877 EXPECT_TRUE(host_impl_->use_msaa()); | 11884 EXPECT_TRUE(host_impl_->use_msaa()); |
| 11885 host_impl_->NotifyReadyToActivate(); |
11878 | 11886 |
11879 // Toggle suitability on. | 11887 // Toggle suitability on. |
11880 host_impl_->SetContentIsSuitableForGpuRasterization(true); | 11888 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
11881 host_impl_->CommitComplete(); | 11889 host_impl_->CommitComplete(); |
11882 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 11890 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
11883 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11891 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11884 EXPECT_FALSE(host_impl_->use_msaa()); | 11892 EXPECT_FALSE(host_impl_->use_msaa()); |
| 11893 host_impl_->NotifyReadyToActivate(); |
11885 | 11894 |
11886 // And off. | 11895 // And off. |
11887 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11896 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11888 host_impl_->CommitComplete(); | 11897 host_impl_->CommitComplete(); |
11889 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 11898 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
11890 host_impl_->gpu_rasterization_status()); | 11899 host_impl_->gpu_rasterization_status()); |
11891 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11900 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11892 EXPECT_TRUE(host_impl_->use_msaa()); | 11901 EXPECT_TRUE(host_impl_->use_msaa()); |
| 11902 host_impl_->NotifyReadyToActivate(); |
11893 } | 11903 } |
11894 | 11904 |
11895 // Tests that SetDeviceScaleFactor correctly impacts GPU rasterization. | 11905 // Tests that SetDeviceScaleFactor correctly impacts GPU rasterization. |
11896 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusDeviceScaleFactor) { | 11906 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusDeviceScaleFactor) { |
11897 // Create a host impl with MSAA support. | 11907 // Create a host impl with MSAA support. |
11898 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 11908 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
11899 TestWebGraphicsContext3D::Create(); | 11909 TestWebGraphicsContext3D::Create(); |
11900 context_with_msaa->SetMaxSamples(4); | 11910 context_with_msaa->SetMaxSamples(4); |
11901 context_with_msaa->set_gpu_rasterization(true); | 11911 context_with_msaa->set_gpu_rasterization(true); |
11902 LayerTreeSettings msaaSettings = DefaultSettings(); | 11912 LayerTreeSettings msaaSettings = DefaultSettings(); |
11903 msaaSettings.gpu_rasterization_msaa_sample_count = -1; | 11913 msaaSettings.gpu_rasterization_msaa_sample_count = -1; |
11904 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeLayerTreeFrameSink::Create3d( | 11914 EXPECT_TRUE(CreateHostImpl(msaaSettings, FakeLayerTreeFrameSink::Create3d( |
11905 std::move(context_with_msaa)))); | 11915 std::move(context_with_msaa)))); |
11906 | 11916 |
11907 // Set initial state, before varying scale factor. | 11917 // Set initial state, before varying scale factor. |
11908 host_impl_->SetHasGpuRasterizationTrigger(true); | 11918 host_impl_->SetHasGpuRasterizationTrigger(true); |
11909 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 11919 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
11910 host_impl_->CommitComplete(); | 11920 host_impl_->CommitComplete(); |
11911 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 11921 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
11912 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11922 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11923 host_impl_->NotifyReadyToActivate(); |
11913 | 11924 |
11914 // Set device scale factor to 2, which lowers the required MSAA samples from | 11925 // Set device scale factor to 2, which lowers the required MSAA samples from |
11915 // 8 to 4. | 11926 // 8 to 4. |
11916 host_impl_->active_tree()->SetDeviceScaleFactor(2.0f); | 11927 host_impl_->active_tree()->SetDeviceScaleFactor(2.0f); |
11917 host_impl_->CommitComplete(); | 11928 host_impl_->CommitComplete(); |
11918 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 11929 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
11919 host_impl_->gpu_rasterization_status()); | 11930 host_impl_->gpu_rasterization_status()); |
11920 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11931 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11921 EXPECT_TRUE(host_impl_->use_msaa()); | 11932 EXPECT_TRUE(host_impl_->use_msaa()); |
| 11933 host_impl_->NotifyReadyToActivate(); |
11922 | 11934 |
11923 // Set device scale factor back to 1. | 11935 // Set device scale factor back to 1. |
11924 host_impl_->active_tree()->SetDeviceScaleFactor(1.0f); | 11936 host_impl_->active_tree()->SetDeviceScaleFactor(1.0f); |
11925 host_impl_->CommitComplete(); | 11937 host_impl_->CommitComplete(); |
11926 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 11938 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
11927 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11939 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11928 EXPECT_FALSE(host_impl_->use_msaa()); | 11940 EXPECT_FALSE(host_impl_->use_msaa()); |
| 11941 host_impl_->NotifyReadyToActivate(); |
11929 } | 11942 } |
11930 | 11943 |
11931 // Tests that explicit MSAA sample count correctly impacts GPU rasterization. | 11944 // Tests that explicit MSAA sample count correctly impacts GPU rasterization. |
11932 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusExplicitMSAACount) { | 11945 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusExplicitMSAACount) { |
11933 // Create a host impl with MSAA support and a forced sample count of 4. | 11946 // Create a host impl with MSAA support and a forced sample count of 4. |
11934 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 11947 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
11935 TestWebGraphicsContext3D::Create(); | 11948 TestWebGraphicsContext3D::Create(); |
11936 context_with_msaa->SetMaxSamples(4); | 11949 context_with_msaa->SetMaxSamples(4); |
11937 context_with_msaa->set_gpu_rasterization(true); | 11950 context_with_msaa->set_gpu_rasterization(true); |
11938 LayerTreeSettings msaaSettings = DefaultSettings(); | 11951 LayerTreeSettings msaaSettings = DefaultSettings(); |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12662 // layer should be prioritized over the hidden layer. | 12675 // layer should be prioritized over the hidden layer. |
12663 hidden_layer->set_contributes_to_drawn_render_surface(false); | 12676 hidden_layer->set_contributes_to_drawn_render_surface(false); |
12664 hidden_layer->set_raster_even_if_not_drawn(true); | 12677 hidden_layer->set_raster_even_if_not_drawn(true); |
12665 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, | 12678 queue = host_impl_->BuildRasterQueue(TreePriority::SMOOTHNESS_TAKES_PRIORITY, |
12666 RasterTilePriorityQueue::Type::ALL); | 12679 RasterTilePriorityQueue::Type::ALL); |
12667 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); | 12680 EXPECT_EQ(queue->Top().tile()->layer_id(), 3); |
12668 } | 12681 } |
12669 | 12682 |
12670 } // namespace | 12683 } // namespace |
12671 } // namespace cc | 12684 } // namespace cc |
OLD | NEW |