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 5914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5925 | 5925 |
5926 host_impl_->SetVisible(true); | 5926 host_impl_->SetVisible(true); |
5927 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 5927 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
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 CreateHostImpl(settings, CreateOutputSurface()); | 5934 CreateHostImpl(settings, CreateOutputSurface()); |
5935 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 5935 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
5936 host_impl_->set_has_gpu_rasterization_trigger(true); | 5936 host_impl_->SetHasGpuRasterizationTrigger(true); |
5937 host_impl_->UpdateGpuRasterizationStatus(); | |
5938 host_impl_->SetVisible(true); | 5937 host_impl_->SetVisible(true); |
5939 host_impl_->SetMemoryPolicy(policy1); | 5938 host_impl_->SetMemoryPolicy(policy1); |
5940 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 5939 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
5941 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); | 5940 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); |
5942 | 5941 |
5943 host_impl_->SetVisible(false); | 5942 host_impl_->SetVisible(false); |
5944 EXPECT_EQ(0u, current_limit_bytes_); | 5943 EXPECT_EQ(0u, current_limit_bytes_); |
5945 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 5944 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
5946 } | 5945 } |
5947 | 5946 |
(...skipping 21 matching lines...) Expand all Loading... |
5969 | 5968 |
5970 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { | 5969 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { |
5971 ASSERT_TRUE(host_impl_->active_tree()); | 5970 ASSERT_TRUE(host_impl_->active_tree()); |
5972 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 5971 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
5973 | 5972 |
5974 // RequiresHighResToDraw is set when new output surface is used. | 5973 // RequiresHighResToDraw is set when new output surface is used. |
5975 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5974 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5976 | 5975 |
5977 host_impl_->ResetRequiresHighResToDraw(); | 5976 host_impl_->ResetRequiresHighResToDraw(); |
5978 | 5977 |
5979 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 5978 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
5980 host_impl_->set_has_gpu_rasterization_trigger(false); | 5979 host_impl_->SetHasGpuRasterizationTrigger(false); |
5981 host_impl_->UpdateGpuRasterizationStatus(); | 5980 host_impl_->UpdateTreeResourcesForGpuRasterizationIfNeeded(); |
5982 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 5981 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
5983 host_impl_->set_has_gpu_rasterization_trigger(true); | 5982 host_impl_->SetHasGpuRasterizationTrigger(true); |
5984 host_impl_->UpdateGpuRasterizationStatus(); | 5983 host_impl_->UpdateTreeResourcesForGpuRasterizationIfNeeded(); |
5985 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5984 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5986 host_impl_->set_has_gpu_rasterization_trigger(false); | 5985 host_impl_->SetHasGpuRasterizationTrigger(false); |
5987 host_impl_->UpdateGpuRasterizationStatus(); | 5986 host_impl_->UpdateTreeResourcesForGpuRasterizationIfNeeded(); |
5988 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5987 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5989 | 5988 |
5990 host_impl_->ResetRequiresHighResToDraw(); | 5989 host_impl_->ResetRequiresHighResToDraw(); |
5991 | 5990 |
5992 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); | 5991 EXPECT_FALSE(host_impl_->RequiresHighResToDraw()); |
5993 host_impl_->set_has_gpu_rasterization_trigger(true); | 5992 host_impl_->SetHasGpuRasterizationTrigger(true); |
5994 host_impl_->UpdateGpuRasterizationStatus(); | 5993 host_impl_->UpdateTreeResourcesForGpuRasterizationIfNeeded(); |
5995 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 5994 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
5996 } | 5995 } |
5997 | 5996 |
5998 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { | 5997 class LayerTreeHostImplTestPrepareTiles : public LayerTreeHostImplTest { |
5999 public: | 5998 public: |
6000 void SetUp() override { | 5999 void SetUp() override { |
6001 LayerTreeSettings settings; | 6000 LayerTreeSettings settings; |
6002 settings.impl_side_painting = true; | 6001 settings.impl_side_painting = true; |
6003 | 6002 |
6004 fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_, | 6003 fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_, |
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7719 | 7718 |
7720 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 7719 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
7721 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 7720 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
7722 host_impl_->WillBeginImplFrame(begin_frame_args); | 7721 host_impl_->WillBeginImplFrame(begin_frame_args); |
7723 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 7722 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
7724 } | 7723 } |
7725 | 7724 |
7726 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) { | 7725 TEST_F(LayerTreeHostImplTest, GpuRasterizationStatusModes) { |
7727 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7726 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7728 | 7727 |
7729 host_impl_->set_has_gpu_rasterization_trigger(true); | 7728 host_impl_->SetHasGpuRasterizationTrigger(true); |
7730 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 7729 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
7731 host_impl_->UpdateGpuRasterizationStatus(); | |
7732 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); | 7730 EXPECT_EQ(GpuRasterizationStatus::ON, host_impl_->gpu_rasterization_status()); |
7733 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7731 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7734 | 7732 |
7735 host_impl_->set_has_gpu_rasterization_trigger(false); | 7733 host_impl_->SetHasGpuRasterizationTrigger(false); |
7736 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 7734 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
7737 host_impl_->UpdateGpuRasterizationStatus(); | |
7738 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, | 7735 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, |
7739 host_impl_->gpu_rasterization_status()); | 7736 host_impl_->gpu_rasterization_status()); |
7740 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7737 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7741 | 7738 |
7742 host_impl_->set_has_gpu_rasterization_trigger(true); | 7739 host_impl_->SetHasGpuRasterizationTrigger(true); |
7743 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7740 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
7744 host_impl_->UpdateGpuRasterizationStatus(); | |
7745 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, | 7741 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, |
7746 host_impl_->gpu_rasterization_status()); | 7742 host_impl_->gpu_rasterization_status()); |
7747 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7743 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7748 EXPECT_FALSE(host_impl_->use_msaa()); | 7744 EXPECT_FALSE(host_impl_->use_msaa()); |
7749 | 7745 |
7750 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = | 7746 scoped_ptr<TestWebGraphicsContext3D> context_with_msaa = |
7751 TestWebGraphicsContext3D::Create(); | 7747 TestWebGraphicsContext3D::Create(); |
7752 context_with_msaa->SetMaxSamples(8); | 7748 context_with_msaa->SetMaxSamples(8); |
7753 | 7749 |
7754 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 7750 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); |
7755 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 7751 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
7756 EXPECT_TRUE(CreateHostImpl( | 7752 EXPECT_TRUE(CreateHostImpl( |
7757 msaaSettings, FakeOutputSurface::Create3d(context_with_msaa.Pass()))); | 7753 msaaSettings, FakeOutputSurface::Create3d(context_with_msaa.Pass()))); |
7758 host_impl_->set_has_gpu_rasterization_trigger(true); | 7754 host_impl_->SetHasGpuRasterizationTrigger(true); |
7759 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7755 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
7760 host_impl_->UpdateGpuRasterizationStatus(); | |
7761 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 7756 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
7762 host_impl_->gpu_rasterization_status()); | 7757 host_impl_->gpu_rasterization_status()); |
7763 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7758 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7764 EXPECT_TRUE(host_impl_->use_msaa()); | 7759 EXPECT_TRUE(host_impl_->use_msaa()); |
7765 | 7760 |
7766 LayerTreeSettings settings = DefaultSettings(); | 7761 LayerTreeSettings settings = DefaultSettings(); |
7767 settings.gpu_rasterization_enabled = false; | 7762 settings.gpu_rasterization_enabled = false; |
7768 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 7763 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); |
7769 host_impl_->set_has_gpu_rasterization_trigger(true); | 7764 host_impl_->SetHasGpuRasterizationTrigger(true); |
7770 host_impl_->set_content_is_suitable_for_gpu_rasterization(true); | 7765 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
7771 host_impl_->UpdateGpuRasterizationStatus(); | |
7772 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, | 7766 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, |
7773 host_impl_->gpu_rasterization_status()); | 7767 host_impl_->gpu_rasterization_status()); |
7774 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 7768 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
7775 | 7769 |
7776 settings.gpu_rasterization_forced = true; | 7770 settings.gpu_rasterization_forced = true; |
7777 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 7771 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); |
7778 | 7772 |
7779 host_impl_->set_has_gpu_rasterization_trigger(false); | 7773 host_impl_->SetHasGpuRasterizationTrigger(false); |
7780 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); | 7774 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
7781 host_impl_->UpdateGpuRasterizationStatus(); | |
7782 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 7775 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
7783 host_impl_->gpu_rasterization_status()); | 7776 host_impl_->gpu_rasterization_status()); |
7784 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7777 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7785 } | 7778 } |
7786 | 7779 |
7787 } // namespace | 7780 } // namespace |
7788 } // namespace cc | 7781 } // namespace cc |
OLD | NEW |