| 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 4976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4987 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4987 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4988 | 4988 |
| 4989 // Setting gpu rasterization trigger does not enable gpu rasterization. | 4989 // Setting gpu rasterization trigger does not enable gpu rasterization. |
| 4990 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4990 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 4991 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4991 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4992 | 4992 |
| 4993 PostSetNeedsCommitToMainThread(); | 4993 PostSetNeedsCommitToMainThread(); |
| 4994 } | 4994 } |
| 4995 | 4995 |
| 4996 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4996 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 4997 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 4998 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 4997 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 4999 | 4998 |
| 5000 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 4999 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
| 5001 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5000 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5002 } | 5001 } |
| 5003 | 5002 |
| 5004 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5003 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5005 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5006 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 5004 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 5007 | 5005 |
| 5008 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 5006 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5009 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5007 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5010 EndTest(); | 5008 EndTest(); |
| 5011 } | 5009 } |
| 5012 | 5010 |
| 5013 void AfterTest() override {} | 5011 void AfterTest() override {} |
| 5014 | 5012 |
| 5015 FakeContentLayerClient layer_client_; | 5013 FakeContentLayerClient layer_client_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5040 | 5038 |
| 5041 void BeginTest() override { | 5039 void BeginTest() override { |
| 5042 // Setting gpu rasterization trigger does not enable gpu rasterization. | 5040 // Setting gpu rasterization trigger does not enable gpu rasterization. |
| 5043 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5041 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5044 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5042 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5045 | 5043 |
| 5046 PostSetNeedsCommitToMainThread(); | 5044 PostSetNeedsCommitToMainThread(); |
| 5047 } | 5045 } |
| 5048 | 5046 |
| 5049 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5047 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5050 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5051 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 5048 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 5052 | 5049 |
| 5053 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 5050 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
| 5054 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5051 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5055 } | 5052 } |
| 5056 | 5053 |
| 5057 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5054 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5058 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5059 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 5055 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 5060 | 5056 |
| 5061 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 5057 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5062 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5058 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5063 EndTest(); | 5059 EndTest(); |
| 5064 } | 5060 } |
| 5065 | 5061 |
| 5066 void AfterTest() override {} | 5062 void AfterTest() override {} |
| 5067 | 5063 |
| 5068 FakeContentLayerClient layer_client_; | 5064 FakeContentLayerClient layer_client_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5098 | 5094 |
| 5099 void BeginTest() override { | 5095 void BeginTest() override { |
| 5100 // Verify default value. | 5096 // Verify default value. |
| 5101 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5097 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5102 | 5098 |
| 5103 // Gpu rasterization trigger is relevant. | 5099 // Gpu rasterization trigger is relevant. |
| 5104 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5100 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5105 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5101 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5106 | 5102 |
| 5107 // Content-based veto is relevant as well. | 5103 // Content-based veto is relevant as well. |
| 5108 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5104 layer_->set_force_unsuitable_for_gpu_rasterization(true); |
| 5109 | 5105 |
| 5110 // Veto will take effect when layers are updated. | 5106 // Veto will take effect when layers are updated. |
| 5111 // The results will be verified after commit is completed below. | 5107 // The results will be verified after commit is completed below. |
| 5112 // Since we are manually marking the source as unsuitable, | 5108 // Since we are manually marking the source as unsuitable, |
| 5113 // make sure that the layer gets a chance to update. | 5109 // make sure that the layer gets a chance to update. |
| 5114 layer_->SetNeedsDisplay(); | 5110 layer_->SetNeedsDisplay(); |
| 5115 PostSetNeedsCommitToMainThread(); | 5111 PostSetNeedsCommitToMainThread(); |
| 5116 } | 5112 } |
| 5117 | 5113 |
| 5118 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5114 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5119 // Ensure the suitability bit sticks. | 5115 // Ensure the suitability bit sticks. |
| 5120 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5121 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5116 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5122 | 5117 |
| 5123 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 5118 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
| 5124 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5119 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5125 } | 5120 } |
| 5126 | 5121 |
| 5127 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5122 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5128 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5129 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5123 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5130 | 5124 |
| 5131 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 5125 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5132 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5126 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5133 EndTest(); | 5127 EndTest(); |
| 5134 } | 5128 } |
| 5135 | 5129 |
| 5136 void AfterTest() override {} | 5130 void AfterTest() override {} |
| 5137 | 5131 |
| 5138 FakeContentLayerClient layer_client_; | 5132 FakeContentLayerClient layer_client_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5170 | 5164 |
| 5171 void BeginTest() override { | 5165 void BeginTest() override { |
| 5172 // Verify default value. | 5166 // Verify default value. |
| 5173 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5167 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5174 | 5168 |
| 5175 // Gpu rasterization trigger is relevant. | 5169 // Gpu rasterization trigger is relevant. |
| 5176 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5170 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5177 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5171 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5178 | 5172 |
| 5179 // Content-based veto is relevant as well. | 5173 // Content-based veto is relevant as well. |
| 5180 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5174 layer_->set_force_unsuitable_for_gpu_rasterization(true); |
| 5181 | 5175 |
| 5182 // Veto will take effect when layers are updated. | 5176 // Veto will take effect when layers are updated. |
| 5183 // The results will be verified after commit is completed below. | 5177 // The results will be verified after commit is completed below. |
| 5184 // Since we are manually marking the source as unsuitable, | 5178 // Since we are manually marking the source as unsuitable, |
| 5185 // make sure that the layer gets a chance to update. | 5179 // make sure that the layer gets a chance to update. |
| 5186 layer_->SetNeedsDisplay(); | 5180 layer_->SetNeedsDisplay(); |
| 5187 PostSetNeedsCommitToMainThread(); | 5181 PostSetNeedsCommitToMainThread(); |
| 5188 } | 5182 } |
| 5189 | 5183 |
| 5190 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5184 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5191 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); | 5185 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); |
| 5192 if (expected_gpu_enabled_) { | 5186 if (expected_gpu_enabled_) { |
| 5193 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5187 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5194 } else { | 5188 } else { |
| 5195 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5189 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5196 } | 5190 } |
| 5197 | 5191 |
| 5198 ++num_commits_; | 5192 ++num_commits_; |
| 5199 switch (num_commits_) { | 5193 switch (num_commits_) { |
| 5200 case 1: | 5194 case 1: |
| 5201 recording_source_->SetForceUnsuitableForGpuRasterization(false); | 5195 layer_->set_force_unsuitable_for_gpu_rasterization(false); |
| 5202 break; | 5196 break; |
| 5203 case 30: | 5197 case 30: |
| 5204 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5198 layer_->set_force_unsuitable_for_gpu_rasterization(true); |
| 5205 break; | 5199 break; |
| 5206 case 31: | 5200 case 31: |
| 5207 recording_source_->SetForceUnsuitableForGpuRasterization(false); | 5201 layer_->set_force_unsuitable_for_gpu_rasterization(false); |
| 5208 break; | 5202 break; |
| 5209 case 90: | 5203 case 90: |
| 5210 expected_gpu_enabled_ = true; | 5204 expected_gpu_enabled_ = true; |
| 5211 break; | 5205 break; |
| 5212 } | 5206 } |
| 5213 PostSetNeedsCommitToMainThread(); | 5207 PostSetNeedsCommitToMainThread(); |
| 5214 if (num_commits_ > 100) | 5208 if (num_commits_ > 100) |
| 5215 EndTest(); | 5209 EndTest(); |
| 5216 } | 5210 } |
| 5217 | 5211 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5253 | 5247 |
| 5254 void BeginTest() override { | 5248 void BeginTest() override { |
| 5255 // Verify default value. | 5249 // Verify default value. |
| 5256 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5250 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5257 | 5251 |
| 5258 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. | 5252 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. |
| 5259 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5253 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5260 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5254 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5261 | 5255 |
| 5262 // Content-based veto is irrelevant as well. | 5256 // Content-based veto is irrelevant as well. |
| 5263 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5257 layer_->set_force_unsuitable_for_gpu_rasterization(true); |
| 5264 | 5258 |
| 5265 // Veto will take effect when layers are updated. | 5259 // Veto will take effect when layers are updated. |
| 5266 // The results will be verified after commit is completed below. | 5260 // The results will be verified after commit is completed below. |
| 5267 // Since we are manually marking the source as unsuitable, | 5261 // Since we are manually marking the source as unsuitable, |
| 5268 // make sure that the layer gets a chance to update. | 5262 // make sure that the layer gets a chance to update. |
| 5269 layer_->SetNeedsDisplay(); | 5263 layer_->SetNeedsDisplay(); |
| 5270 PostSetNeedsCommitToMainThread(); | 5264 PostSetNeedsCommitToMainThread(); |
| 5271 } | 5265 } |
| 5272 | 5266 |
| 5273 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5267 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5274 // Ensure the suitability bit sticks. | 5268 // Ensure the suitability bit sticks. |
| 5275 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5276 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5269 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5277 | 5270 |
| 5278 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); | 5271 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); |
| 5279 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5272 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5280 } | 5273 } |
| 5281 | 5274 |
| 5282 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5275 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5283 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5284 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5276 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5285 | 5277 |
| 5286 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); | 5278 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5287 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5279 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5288 EndTest(); | 5280 EndTest(); |
| 5289 } | 5281 } |
| 5290 | 5282 |
| 5291 void AfterTest() override {} | 5283 void AfterTest() override {} |
| 5292 | 5284 |
| 5293 FakeContentLayerClient layer_client_; | 5285 FakeContentLayerClient layer_client_; |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6960 private: | 6952 private: |
| 6961 FakeContentLayerClient client_; | 6953 FakeContentLayerClient client_; |
| 6962 const gfx::Size viewport_size_; | 6954 const gfx::Size viewport_size_; |
| 6963 const gfx::Size large_image_size_; | 6955 const gfx::Size large_image_size_; |
| 6964 }; | 6956 }; |
| 6965 | 6957 |
| 6966 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); | 6958 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 6967 | 6959 |
| 6968 } // namespace | 6960 } // namespace |
| 6969 } // namespace cc | 6961 } // namespace cc |
| OLD | NEW |