| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 4947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4958 | 4958 |
| 4959 void BeginTest() override { | 4959 void BeginTest() override { |
| 4960 // Verify default value. | 4960 // Verify default value. |
| 4961 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4961 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4962 | 4962 |
| 4963 // Gpu rasterization trigger is relevant. | 4963 // Gpu rasterization trigger is relevant. |
| 4964 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4964 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 4965 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4965 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4966 | 4966 |
| 4967 // Content-based veto is relevant as well. | 4967 // Content-based veto is relevant as well. |
| 4968 recording_source_->SetUnsuitableForGpuRasterization(); | 4968 recording_source_->SetForceUnsuitableForGpuRasterization(true); |
| 4969 | 4969 |
| 4970 // Veto will take effect when layers are updated. | 4970 // Veto will take effect when layers are updated. |
| 4971 // The results will be verified after commit is completed below. | 4971 // The results will be verified after commit is completed below. |
| 4972 // Since we are manually marking the source as unsuitable, | 4972 // Since we are manually marking the source as unsuitable, |
| 4973 // make sure that the layer gets a chance to update. | 4973 // make sure that the layer gets a chance to update. |
| 4974 layer_->SetNeedsDisplay(); | 4974 layer_->SetNeedsDisplay(); |
| 4975 PostSetNeedsCommitToMainThread(); | 4975 PostSetNeedsCommitToMainThread(); |
| 4976 } | 4976 } |
| 4977 | 4977 |
| 4978 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4978 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4995 | 4995 |
| 4996 void AfterTest() override {} | 4996 void AfterTest() override {} |
| 4997 | 4997 |
| 4998 FakeContentLayerClient layer_client_; | 4998 FakeContentLayerClient layer_client_; |
| 4999 FakePictureLayer* layer_; | 4999 FakePictureLayer* layer_; |
| 5000 FakeRecordingSource* recording_source_; | 5000 FakeRecordingSource* recording_source_; |
| 5001 }; | 5001 }; |
| 5002 | 5002 |
| 5003 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); | 5003 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); |
| 5004 | 5004 |
| 5005 class LayerTreeHostTestGpuRasterizationReenabled : public LayerTreeHostTest { |
| 5006 protected: |
| 5007 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5008 EXPECT_FALSE(settings->gpu_rasterization_enabled); |
| 5009 settings->gpu_rasterization_enabled = true; |
| 5010 settings->wait_for_beginframe_interval = false; |
| 5011 settings->renderer_settings.disable_display_vsync = true; |
| 5012 } |
| 5013 |
| 5014 void SetupTree() override { |
| 5015 LayerTreeHostTest::SetupTree(); |
| 5016 |
| 5017 std::unique_ptr<FakeRecordingSource> recording_source( |
| 5018 new FakeRecordingSource); |
| 5019 recording_source_ = recording_source.get(); |
| 5020 |
| 5021 scoped_refptr<FakePictureLayer> layer = |
| 5022 FakePictureLayer::CreateWithRecordingSource( |
| 5023 &layer_client_, std::move(recording_source)); |
| 5024 layer_ = layer.get(); |
| 5025 layer->SetBounds(gfx::Size(10, 10)); |
| 5026 layer->SetIsDrawable(true); |
| 5027 layer_tree_host()->root_layer()->AddChild(layer); |
| 5028 layer_client_.set_bounds(layer_->bounds()); |
| 5029 } |
| 5030 |
| 5031 void BeginTest() override { |
| 5032 // Verify default value. |
| 5033 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5034 |
| 5035 // Gpu rasterization trigger is relevant. |
| 5036 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5037 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5038 |
| 5039 // Content-based veto is relevant as well. |
| 5040 recording_source_->SetForceUnsuitableForGpuRasterization(true); |
| 5041 |
| 5042 // Veto will take effect when layers are updated. |
| 5043 // The results will be verified after commit is completed below. |
| 5044 // Since we are manually marking the source as unsuitable, |
| 5045 // make sure that the layer gets a chance to update. |
| 5046 layer_->SetNeedsDisplay(); |
| 5047 PostSetNeedsCommitToMainThread(); |
| 5048 } |
| 5049 |
| 5050 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5051 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); |
| 5052 if (expected_gpu_enabled_) { |
| 5053 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5054 } else { |
| 5055 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5056 } |
| 5057 |
| 5058 ++num_commits_; |
| 5059 switch (num_commits_) { |
| 5060 case 1: |
| 5061 recording_source_->SetForceUnsuitableForGpuRasterization(false); |
| 5062 break; |
| 5063 case 30: |
| 5064 recording_source_->SetForceUnsuitableForGpuRasterization(true); |
| 5065 break; |
| 5066 case 31: |
| 5067 recording_source_->SetForceUnsuitableForGpuRasterization(false); |
| 5068 break; |
| 5069 case 90: |
| 5070 expected_gpu_enabled_ = true; |
| 5071 break; |
| 5072 } |
| 5073 PostSetNeedsCommitToMainThread(); |
| 5074 if (num_commits_ > 100) |
| 5075 EndTest(); |
| 5076 } |
| 5077 |
| 5078 void AfterTest() override {} |
| 5079 |
| 5080 FakeContentLayerClient layer_client_; |
| 5081 FakePictureLayer* layer_; |
| 5082 FakeRecordingSource* recording_source_; |
| 5083 int num_commits_ = 0; |
| 5084 bool expected_gpu_enabled_ = false; |
| 5085 }; |
| 5086 |
| 5087 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationReenabled); |
| 5088 |
| 5005 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { | 5089 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { |
| 5006 protected: | 5090 protected: |
| 5007 void InitializeSettings(LayerTreeSettings* settings) override { | 5091 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5008 EXPECT_FALSE(settings->gpu_rasterization_forced); | 5092 EXPECT_FALSE(settings->gpu_rasterization_forced); |
| 5009 settings->gpu_rasterization_forced = true; | 5093 settings->gpu_rasterization_forced = true; |
| 5010 } | 5094 } |
| 5011 | 5095 |
| 5012 void SetupTree() override { | 5096 void SetupTree() override { |
| 5013 LayerTreeHostTest::SetupTree(); | 5097 LayerTreeHostTest::SetupTree(); |
| 5014 | 5098 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5029 | 5113 |
| 5030 void BeginTest() override { | 5114 void BeginTest() override { |
| 5031 // Verify default value. | 5115 // Verify default value. |
| 5032 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5116 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5033 | 5117 |
| 5034 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. | 5118 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. |
| 5035 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5119 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5036 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5120 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5037 | 5121 |
| 5038 // Content-based veto is irrelevant as well. | 5122 // Content-based veto is irrelevant as well. |
| 5039 recording_source_->SetUnsuitableForGpuRasterization(); | 5123 recording_source_->SetForceUnsuitableForGpuRasterization(true); |
| 5040 | 5124 |
| 5041 // Veto will take effect when layers are updated. | 5125 // Veto will take effect when layers are updated. |
| 5042 // The results will be verified after commit is completed below. | 5126 // The results will be verified after commit is completed below. |
| 5043 // Since we are manually marking the source as unsuitable, | 5127 // Since we are manually marking the source as unsuitable, |
| 5044 // make sure that the layer gets a chance to update. | 5128 // make sure that the layer gets a chance to update. |
| 5045 layer_->SetNeedsDisplay(); | 5129 layer_->SetNeedsDisplay(); |
| 5046 PostSetNeedsCommitToMainThread(); | 5130 PostSetNeedsCommitToMainThread(); |
| 5047 } | 5131 } |
| 5048 | 5132 |
| 5049 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5133 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6691 EndTest(); | 6775 EndTest(); |
| 6692 } | 6776 } |
| 6693 | 6777 |
| 6694 void AfterTest() override {} | 6778 void AfterTest() override {} |
| 6695 }; | 6779 }; |
| 6696 | 6780 |
| 6697 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6781 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6698 | 6782 |
| 6699 } // namespace | 6783 } // namespace |
| 6700 } // namespace cc | 6784 } // namespace cc |
| OLD | NEW |