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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 5917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5928 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); | 5928 EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_); |
5929 | 5929 |
5930 // Now enable GPU rasterization and test if we get nice to have cutoff, | 5930 // Now enable GPU rasterization and test if we get nice to have cutoff, |
5931 // when visible. | 5931 // when visible. |
5932 LayerTreeSettings settings; | 5932 LayerTreeSettings settings; |
5933 settings.gpu_rasterization_enabled = true; | 5933 settings.gpu_rasterization_enabled = true; |
5934 host_impl_ = LayerTreeHostImpl::Create( | 5934 host_impl_ = LayerTreeHostImpl::Create( |
5935 settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, NULL, 0); | 5935 settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, NULL, 0); |
5936 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 5936 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); |
5937 host_impl_->set_has_gpu_rasterization_trigger(true); | 5937 host_impl_->set_has_gpu_rasterization_trigger(true); |
5938 host_impl_->UpdateGpuRasterizationStatus(); | |
5939 host_impl_->SetVisible(true); | 5938 host_impl_->SetVisible(true); |
5940 host_impl_->SetMemoryPolicy(policy1); | 5939 host_impl_->SetMemoryPolicy(policy1); |
5941 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 5940 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
5942 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); | 5941 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); |
5943 | 5942 |
5944 host_impl_->SetVisible(false); | 5943 host_impl_->SetVisible(false); |
5945 EXPECT_EQ(0u, current_limit_bytes_); | 5944 EXPECT_EQ(0u, current_limit_bytes_); |
5946 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 5945 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
5947 } | 5946 } |
5948 | 5947 |
(...skipping 23 matching lines...) Expand all Loading... |
5972 ASSERT_TRUE(host_impl_->active_tree()); | 5971 ASSERT_TRUE(host_impl_->active_tree()); |
5973 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 5972 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
5974 | 5973 |
5975 // RequiresHighResToDraw is set when new output surface is used. | 5974 // RequiresHighResToDraw is set when new output surface is used. |
5976 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5975 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5977 | 5976 |
5978 host_impl_->ResetRequiresHighResToDraw(); | 5977 host_impl_->ResetRequiresHighResToDraw(); |
5979 | 5978 |
5980 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 5979 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); |
5981 host_impl_->set_has_gpu_rasterization_trigger(false); | 5980 host_impl_->set_has_gpu_rasterization_trigger(false); |
5982 host_impl_->UpdateGpuRasterizationStatus(); | 5981 host_impl_->UpdateTreeResourcesIfNeeded(); |
5983 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 5982 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
5984 host_impl_->set_has_gpu_rasterization_trigger(true); | 5983 host_impl_->set_has_gpu_rasterization_trigger(true); |
5985 host_impl_->UpdateGpuRasterizationStatus(); | 5984 host_impl_->UpdateTreeResourcesIfNeeded(); |
5986 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5985 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5987 host_impl_->set_has_gpu_rasterization_trigger(false); | 5986 host_impl_->set_has_gpu_rasterization_trigger(false); |
5988 host_impl_->UpdateGpuRasterizationStatus(); | 5987 host_impl_->UpdateTreeResourcesIfNeeded(); |
5989 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5988 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5990 | 5989 |
5991 host_impl_->ResetRequiresHighResToDraw(); | 5990 host_impl_->ResetRequiresHighResToDraw(); |
5992 | 5991 |
5993 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 5992 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
5994 host_impl_->set_has_gpu_rasterization_trigger(true); | 5993 host_impl_->set_has_gpu_rasterization_trigger(true); |
5995 host_impl_->UpdateGpuRasterizationStatus(); | 5994 host_impl_->UpdateTreeResourcesIfNeeded(); |
5996 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5995 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5997 } | 5996 } |
5998 | 5997 |
5999 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { | 5998 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
6000 public: | 5999 public: |
6001 void SetUp() override { | 6000 void SetUp() override { |
6002 LayerTreeSettings settings; | 6001 LayerTreeSettings settings; |
6003 settings.impl_side_painting = true; | 6002 settings.impl_side_painting = true; |
6004 | 6003 |
6005 fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_, | 6004 fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_, |
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7722 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 7721 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
7723 host_impl_->WillBeginImplFrame(begin_frame_args); | 7722 host_impl_->WillBeginImplFrame(begin_frame_args); |
7724 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 7723 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
7725 } | 7724 } |
7726 | 7725 |
7727 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) { | 7726 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) { |
7728 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7727 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7729 | 7728 |
7730 host_impl_->set_has_gpu_rasterization_trigger(true); | 7729 host_impl_->set_has_gpu_rasterization_trigger(true); |
7731 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 7730 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); |
7732 host_impl_->UpdateGpuRasterizationStatus(); | |
7733 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 7731 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
7734 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7732 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7735 | 7733 |
7736 host_impl_->set_has_gpu_rasterization_trigger(false); | 7734 host_impl_->set_has_gpu_rasterization_trigger(false); |
7737 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 7735 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); |
7738 host_impl_->UpdateGpuRasterizationStatus(); | |
7739 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, | 7736 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, |
7740 host_impl_->gpu_rasterization_status()); | 7737 host_impl_->gpu_rasterization_status()); |
7741 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7738 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7742 | 7739 |
7743 host_impl_->set_has_gpu_rasterization_trigger(true); | 7740 host_impl_->set_has_gpu_rasterization_trigger(true); |
7744 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7741 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); |
7745 host_impl_->UpdateGpuRasterizationStatus(); | |
7746 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 7742 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
7747 host_impl_->gpu_rasterization_status()); | 7743 host_impl_->gpu_rasterization_status()); |
7748 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7744 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7749 EXPECT_FALSE(host_impl_->use_msaa()); | 7745 EXPECT_FALSE(host_impl_->use_msaa()); |
7750 | 7746 |
7751 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = | 7747 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = |
7752 TestWebGraphicsContext3D::Create(); | 7748 TestWebGraphicsContext3D::Create(); |
7753 context_with_msaa->SetMaxSamples(8); | 7749 context_with_msaa->SetMaxSamples(8); |
7754 | 7750 |
7755 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 7751 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); |
7756 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 7752 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
7757 EXPECT_TRUE(CreateHostImpl( | 7753 EXPECT_TRUE(CreateHostImpl( |
7758 msaaSettings, FakeOutputSurface::Create3d(context_with_msaa.Pass()))); | 7754 msaaSettings, FakeOutputSurface::Create3d(context_with_msaa.Pass()))); |
7759 host_impl_->set_has_gpu_rasterization_trigger(true); | 7755 host_impl_->set_has_gpu_rasterization_trigger(true); |
7760 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7756 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); |
7761 host_impl_->UpdateGpuRasterizationStatus(); | |
7762 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 7757 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
7763 host_impl_->gpu_rasterization_status()); | 7758 host_impl_->gpu_rasterization_status()); |
7764 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7759 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7765 EXPECT_TRUE(host_impl_->use_msaa()); | 7760 EXPECT_TRUE(host_impl_->use_msaa()); |
7766 | 7761 |
7767 LayerTreeSettings settings = DefaultSettings(); | 7762 LayerTreeSettings settings = DefaultSettings(); |
7768 settings.gpu_rasterization_enabled = false; | 7763 settings.gpu_rasterization_enabled = false; |
7769 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 7764 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); |
7770 host_impl_->set_has_gpu_rasterization_trigger(true); | 7765 host_impl_->set_has_gpu_rasterization_trigger(true); |
7771 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 7766 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); |
7772 host_impl_->UpdateGpuRasterizationStatus(); | |
7773 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, | 7767 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, |
7774 host_impl_->gpu_rasterization_status()); | 7768 host_impl_->gpu_rasterization_status()); |
7775 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7769 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7776 | 7770 |
7777 settings.gpu_rasterization_forced = true; | 7771 settings.gpu_rasterization_forced = true; |
7778 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 7772 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); |
7779 | 7773 |
7780 host_impl_->set_has_gpu_rasterization_trigger(false); | 7774 host_impl_->set_has_gpu_rasterization_trigger(false); |
7781 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7775 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); |
7782 host_impl_->UpdateGpuRasterizationStatus(); | |
7783 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 7776 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
7784 host_impl_->gpu_rasterization_status()); | 7777 host_impl_->gpu_rasterization_status()); |
7785 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7778 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7786 } | 7779 } |
7787 | 7780 |
7788 } // namespace | 7781 } // namespace |
7789 } // namespace cc | 7782 } // namespace cc |
OLD | NEW |