| 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 4927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4938 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4938 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4939 | 4939 |
| 4940 // Setting gpu rasterization trigger does not enable gpu rasterization. | 4940 // Setting gpu rasterization trigger does not enable gpu rasterization. |
| 4941 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4941 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 4942 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4942 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4943 | 4943 |
| 4944 PostSetNeedsCommitToMainThread(); | 4944 PostSetNeedsCommitToMainThread(); |
| 4945 } | 4945 } |
| 4946 | 4946 |
| 4947 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4947 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 4948 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 4949 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 4948 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 4950 | 4949 |
| 4951 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 4950 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
| 4952 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 4951 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 4953 } | 4952 } |
| 4954 | 4953 |
| 4955 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 4954 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 4956 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 4957 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 4955 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 4958 | 4956 |
| 4959 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 4957 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
| 4960 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 4958 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 4961 EndTest(); | 4959 EndTest(); |
| 4962 } | 4960 } |
| 4963 | 4961 |
| 4964 void AfterTest() override {} | 4962 void AfterTest() override {} |
| 4965 | 4963 |
| 4966 FakeContentLayerClient layer_client_; | 4964 FakeContentLayerClient layer_client_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4991 | 4989 |
| 4992 void BeginTest() override { | 4990 void BeginTest() override { |
| 4993 // Setting gpu rasterization trigger does not enable gpu rasterization. | 4991 // Setting gpu rasterization trigger does not enable gpu rasterization. |
| 4994 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4992 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 4995 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4993 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 4996 | 4994 |
| 4997 PostSetNeedsCommitToMainThread(); | 4995 PostSetNeedsCommitToMainThread(); |
| 4998 } | 4996 } |
| 4999 | 4997 |
| 5000 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4998 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5001 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5002 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 4999 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 5003 | 5000 |
| 5004 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 5001 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
| 5005 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5002 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5006 } | 5003 } |
| 5007 | 5004 |
| 5008 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5005 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5009 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5010 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | 5006 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); |
| 5011 | 5007 |
| 5012 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 5008 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5013 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5009 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5014 EndTest(); | 5010 EndTest(); |
| 5015 } | 5011 } |
| 5016 | 5012 |
| 5017 void AfterTest() override {} | 5013 void AfterTest() override {} |
| 5018 | 5014 |
| 5019 FakeContentLayerClient layer_client_; | 5015 FakeContentLayerClient layer_client_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5049 | 5045 |
| 5050 void BeginTest() override { | 5046 void BeginTest() override { |
| 5051 // Verify default value. | 5047 // Verify default value. |
| 5052 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5048 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5053 | 5049 |
| 5054 // Gpu rasterization trigger is relevant. | 5050 // Gpu rasterization trigger is relevant. |
| 5055 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5051 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5056 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5052 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5057 | 5053 |
| 5058 // Content-based veto is relevant as well. | 5054 // Content-based veto is relevant as well. |
| 5059 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5055 layer_->SetForceUnsuitableForGpuRasterization(true); |
| 5060 | 5056 |
| 5061 // Veto will take effect when layers are updated. | 5057 // Veto will take effect when layers are updated. |
| 5062 // The results will be verified after commit is completed below. | 5058 // The results will be verified after commit is completed below. |
| 5063 // Since we are manually marking the source as unsuitable, | 5059 // Since we are manually marking the source as unsuitable, |
| 5064 // make sure that the layer gets a chance to update. | 5060 // make sure that the layer gets a chance to update. |
| 5065 layer_->SetNeedsDisplay(); | 5061 layer_->SetNeedsDisplay(); |
| 5066 PostSetNeedsCommitToMainThread(); | 5062 PostSetNeedsCommitToMainThread(); |
| 5067 } | 5063 } |
| 5068 | 5064 |
| 5069 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5065 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5070 // Ensure the suitability bit sticks. | 5066 // Ensure the suitability bit sticks. |
| 5071 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5072 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5067 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5073 | 5068 |
| 5074 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 5069 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
| 5075 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5070 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5076 } | 5071 } |
| 5077 | 5072 |
| 5078 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5073 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5079 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5080 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5074 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5081 | 5075 |
| 5082 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 5076 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5083 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5077 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5084 EndTest(); | 5078 EndTest(); |
| 5085 } | 5079 } |
| 5086 | 5080 |
| 5087 void AfterTest() override {} | 5081 void AfterTest() override {} |
| 5088 | 5082 |
| 5089 FakeContentLayerClient layer_client_; | 5083 FakeContentLayerClient layer_client_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5121 | 5115 |
| 5122 void BeginTest() override { | 5116 void BeginTest() override { |
| 5123 // Verify default value. | 5117 // Verify default value. |
| 5124 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5118 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5125 | 5119 |
| 5126 // Gpu rasterization trigger is relevant. | 5120 // Gpu rasterization trigger is relevant. |
| 5127 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5121 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5128 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5122 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5129 | 5123 |
| 5130 // Content-based veto is relevant as well. | 5124 // Content-based veto is relevant as well. |
| 5131 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5125 layer_->SetForceUnsuitableForGpuRasterization(true); |
| 5132 | 5126 |
| 5133 // Veto will take effect when layers are updated. | 5127 // Veto will take effect when layers are updated. |
| 5134 // The results will be verified after commit is completed below. | 5128 // The results will be verified after commit is completed below. |
| 5135 // Since we are manually marking the source as unsuitable, | 5129 // Since we are manually marking the source as unsuitable, |
| 5136 // make sure that the layer gets a chance to update. | 5130 // make sure that the layer gets a chance to update. |
| 5137 layer_->SetNeedsDisplay(); | 5131 layer_->SetNeedsDisplay(); |
| 5138 PostSetNeedsCommitToMainThread(); | 5132 PostSetNeedsCommitToMainThread(); |
| 5139 } | 5133 } |
| 5140 | 5134 |
| 5141 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5135 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5142 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); | 5136 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); |
| 5143 if (expected_gpu_enabled_) { | 5137 if (expected_gpu_enabled_) { |
| 5144 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5138 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5145 } else { | 5139 } else { |
| 5146 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5140 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
| 5147 } | 5141 } |
| 5148 | 5142 |
| 5149 ++num_commits_; | 5143 ++num_commits_; |
| 5150 switch (num_commits_) { | 5144 switch (num_commits_) { |
| 5151 case 1: | 5145 case 1: |
| 5152 recording_source_->SetForceUnsuitableForGpuRasterization(false); | 5146 layer_->SetForceUnsuitableForGpuRasterization(false); |
| 5153 break; | 5147 break; |
| 5154 case 30: | 5148 case 30: |
| 5155 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5149 layer_->SetForceUnsuitableForGpuRasterization(true); |
| 5156 break; | 5150 break; |
| 5157 case 31: | 5151 case 31: |
| 5158 recording_source_->SetForceUnsuitableForGpuRasterization(false); | 5152 layer_->SetForceUnsuitableForGpuRasterization(false); |
| 5159 break; | 5153 break; |
| 5160 case 90: | 5154 case 90: |
| 5161 expected_gpu_enabled_ = true; | 5155 expected_gpu_enabled_ = true; |
| 5162 break; | 5156 break; |
| 5163 } | 5157 } |
| 5164 PostSetNeedsCommitToMainThread(); | 5158 PostSetNeedsCommitToMainThread(); |
| 5165 if (num_commits_ > 100) | 5159 if (num_commits_ > 100) |
| 5166 EndTest(); | 5160 EndTest(); |
| 5167 } | 5161 } |
| 5168 | 5162 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5204 | 5198 |
| 5205 void BeginTest() override { | 5199 void BeginTest() override { |
| 5206 // Verify default value. | 5200 // Verify default value. |
| 5207 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5201 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5208 | 5202 |
| 5209 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. | 5203 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. |
| 5210 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 5204 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
| 5211 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 5205 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
| 5212 | 5206 |
| 5213 // Content-based veto is irrelevant as well. | 5207 // Content-based veto is irrelevant as well. |
| 5214 recording_source_->SetForceUnsuitableForGpuRasterization(true); | 5208 layer_->SetForceUnsuitableForGpuRasterization(true); |
| 5215 | 5209 |
| 5216 // Veto will take effect when layers are updated. | 5210 // Veto will take effect when layers are updated. |
| 5217 // The results will be verified after commit is completed below. | 5211 // The results will be verified after commit is completed below. |
| 5218 // Since we are manually marking the source as unsuitable, | 5212 // Since we are manually marking the source as unsuitable, |
| 5219 // make sure that the layer gets a chance to update. | 5213 // make sure that the layer gets a chance to update. |
| 5220 layer_->SetNeedsDisplay(); | 5214 layer_->SetNeedsDisplay(); |
| 5221 PostSetNeedsCommitToMainThread(); | 5215 PostSetNeedsCommitToMainThread(); |
| 5222 } | 5216 } |
| 5223 | 5217 |
| 5224 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5218 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5225 // Ensure the suitability bit sticks. | 5219 // Ensure the suitability bit sticks. |
| 5226 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5227 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5220 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5228 | 5221 |
| 5229 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); | 5222 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); |
| 5230 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5223 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5231 } | 5224 } |
| 5232 | 5225 |
| 5233 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5226 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 5234 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
| 5235 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5227 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
| 5236 | 5228 |
| 5237 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); | 5229 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); |
| 5238 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5230 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
| 5239 EndTest(); | 5231 EndTest(); |
| 5240 } | 5232 } |
| 5241 | 5233 |
| 5242 void AfterTest() override {} | 5234 void AfterTest() override {} |
| 5243 | 5235 |
| 5244 FakeContentLayerClient layer_client_; | 5236 FakeContentLayerClient layer_client_; |
| (...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6892 private: | 6884 private: |
| 6893 FakeContentLayerClient client_; | 6885 FakeContentLayerClient client_; |
| 6894 const gfx::Size viewport_size_; | 6886 const gfx::Size viewport_size_; |
| 6895 const gfx::Size large_image_size_; | 6887 const gfx::Size large_image_size_; |
| 6896 }; | 6888 }; |
| 6897 | 6889 |
| 6898 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); | 6890 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); |
| 6899 | 6891 |
| 6900 } // namespace | 6892 } // namespace |
| 6901 } // namespace cc | 6893 } // namespace cc |
| OLD | NEW |