Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2141233002: cc: Clean up RecordingSource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix failed compositor_unittests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after
4986 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 4986 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4987 4987
4988 // Setting gpu rasterization trigger does not enable gpu rasterization. 4988 // Setting gpu rasterization trigger does not enable gpu rasterization.
4989 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4989 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4990 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4990 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4991 4991
4992 PostSetNeedsCommitToMainThread(); 4992 PostSetNeedsCommitToMainThread();
4993 } 4993 }
4994 4994
4995 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4995 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4996 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization());
4997 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); 4996 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization());
4998 4997
4999 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); 4998 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization());
5000 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4999 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5001 } 5000 }
5002 5001
5003 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 5002 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5004 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization());
5005 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); 5003 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization());
5006 5004
5007 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); 5005 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization());
5008 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 5006 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5009 EndTest(); 5007 EndTest();
5010 } 5008 }
5011 5009
5012 void AfterTest() override {} 5010 void AfterTest() override {}
5013 5011
5014 FakeContentLayerClient layer_client_; 5012 FakeContentLayerClient layer_client_;
(...skipping 24 matching lines...) Expand all
5039 5037
5040 void BeginTest() override { 5038 void BeginTest() override {
5041 // Setting gpu rasterization trigger does not enable gpu rasterization. 5039 // Setting gpu rasterization trigger does not enable gpu rasterization.
5042 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 5040 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
5043 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 5041 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
5044 5042
5045 PostSetNeedsCommitToMainThread(); 5043 PostSetNeedsCommitToMainThread();
5046 } 5044 }
5047 5045
5048 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 5046 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
5049 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization());
5050 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); 5047 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization());
5051 5048
5052 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); 5049 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization());
5053 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 5050 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5054 } 5051 }
5055 5052
5056 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 5053 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5057 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization());
5058 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); 5054 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization());
5059 5055
5060 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); 5056 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization());
5061 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 5057 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5062 EndTest(); 5058 EndTest();
5063 } 5059 }
5064 5060
5065 void AfterTest() override {} 5061 void AfterTest() override {}
5066 5062
5067 FakeContentLayerClient layer_client_; 5063 FakeContentLayerClient layer_client_;
(...skipping 29 matching lines...) Expand all
5097 5093
5098 void BeginTest() override { 5094 void BeginTest() override {
5099 // Verify default value. 5095 // Verify default value.
5100 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 5096 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
5101 5097
5102 // Gpu rasterization trigger is relevant. 5098 // Gpu rasterization trigger is relevant.
5103 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 5099 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
5104 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 5100 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
5105 5101
5106 // Content-based veto is relevant as well. 5102 // Content-based veto is relevant as well.
5107 recording_source_->SetForceUnsuitableForGpuRasterization(true); 5103 layer_->set_force_unsuitable_for_gpu_rasterization(true);
5108 5104
5109 // Veto will take effect when layers are updated. 5105 // Veto will take effect when layers are updated.
5110 // The results will be verified after commit is completed below. 5106 // The results will be verified after commit is completed below.
5111 // Since we are manually marking the source as unsuitable, 5107 // Since we are manually marking the source as unsuitable,
5112 // make sure that the layer gets a chance to update. 5108 // make sure that the layer gets a chance to update.
5113 layer_->SetNeedsDisplay(); 5109 layer_->SetNeedsDisplay();
5114 PostSetNeedsCommitToMainThread(); 5110 PostSetNeedsCommitToMainThread();
5115 } 5111 }
5116 5112
5117 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 5113 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
5118 // Ensure the suitability bit sticks. 5114 // Ensure the suitability bit sticks.
5119 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization());
5120 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); 5115 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization());
5121 5116
5122 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); 5117 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization());
5123 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 5118 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5124 } 5119 }
5125 5120
5126 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 5121 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5127 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization());
5128 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); 5122 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization());
5129 5123
5130 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); 5124 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization());
5131 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 5125 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5132 EndTest(); 5126 EndTest();
5133 } 5127 }
5134 5128
5135 void AfterTest() override {} 5129 void AfterTest() override {}
5136 5130
5137 FakeContentLayerClient layer_client_; 5131 FakeContentLayerClient layer_client_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5169 5163
5170 void BeginTest() override { 5164 void BeginTest() override {
5171 // Verify default value. 5165 // Verify default value.
5172 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 5166 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
5173 5167
5174 // Gpu rasterization trigger is relevant. 5168 // Gpu rasterization trigger is relevant.
5175 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 5169 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
5176 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 5170 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
5177 5171
5178 // Content-based veto is relevant as well. 5172 // Content-based veto is relevant as well.
5179 recording_source_->SetForceUnsuitableForGpuRasterization(true); 5173 layer_->set_force_unsuitable_for_gpu_rasterization(true);
5180 5174
5181 // Veto will take effect when layers are updated. 5175 // Veto will take effect when layers are updated.
5182 // The results will be verified after commit is completed below. 5176 // The results will be verified after commit is completed below.
5183 // Since we are manually marking the source as unsuitable, 5177 // Since we are manually marking the source as unsuitable,
5184 // make sure that the layer gets a chance to update. 5178 // make sure that the layer gets a chance to update.
5185 layer_->SetNeedsDisplay(); 5179 layer_->SetNeedsDisplay();
5186 PostSetNeedsCommitToMainThread(); 5180 PostSetNeedsCommitToMainThread();
5187 } 5181 }
5188 5182
5189 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 5183 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
5190 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); 5184 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_));
5191 if (expected_gpu_enabled_) { 5185 if (expected_gpu_enabled_) {
5192 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 5186 EXPECT_TRUE(host_impl->use_gpu_rasterization());
5193 } else { 5187 } else {
5194 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 5188 EXPECT_FALSE(host_impl->use_gpu_rasterization());
5195 } 5189 }
5196 5190
5197 ++num_commits_; 5191 ++num_commits_;
5198 switch (num_commits_) { 5192 switch (num_commits_) {
5199 case 1: 5193 case 1:
5200 recording_source_->SetForceUnsuitableForGpuRasterization(false); 5194 layer_->set_force_unsuitable_for_gpu_rasterization(false);
5201 break; 5195 break;
5202 case 30: 5196 case 30:
5203 recording_source_->SetForceUnsuitableForGpuRasterization(true); 5197 layer_->set_force_unsuitable_for_gpu_rasterization(true);
5204 break; 5198 break;
5205 case 31: 5199 case 31:
5206 recording_source_->SetForceUnsuitableForGpuRasterization(false); 5200 layer_->set_force_unsuitable_for_gpu_rasterization(false);
5207 break; 5201 break;
5208 case 90: 5202 case 90:
5209 expected_gpu_enabled_ = true; 5203 expected_gpu_enabled_ = true;
5210 break; 5204 break;
5211 } 5205 }
5212 PostSetNeedsCommitToMainThread(); 5206 PostSetNeedsCommitToMainThread();
5213 if (num_commits_ > 100) 5207 if (num_commits_ > 100)
5214 EndTest(); 5208 EndTest();
5215 } 5209 }
5216 5210
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5252 5246
5253 void BeginTest() override { 5247 void BeginTest() override {
5254 // Verify default value. 5248 // Verify default value.
5255 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); 5249 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
5256 5250
5257 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. 5251 // With gpu rasterization forced, gpu rasterization trigger is irrelevant.
5258 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 5252 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
5259 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 5253 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
5260 5254
5261 // Content-based veto is irrelevant as well. 5255 // Content-based veto is irrelevant as well.
5262 recording_source_->SetForceUnsuitableForGpuRasterization(true); 5256 layer_->set_force_unsuitable_for_gpu_rasterization(true);
5263 5257
5264 // Veto will take effect when layers are updated. 5258 // Veto will take effect when layers are updated.
5265 // The results will be verified after commit is completed below. 5259 // The results will be verified after commit is completed below.
5266 // Since we are manually marking the source as unsuitable, 5260 // Since we are manually marking the source as unsuitable,
5267 // make sure that the layer gets a chance to update. 5261 // make sure that the layer gets a chance to update.
5268 layer_->SetNeedsDisplay(); 5262 layer_->SetNeedsDisplay();
5269 PostSetNeedsCommitToMainThread(); 5263 PostSetNeedsCommitToMainThread();
5270 } 5264 }
5271 5265
5272 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 5266 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
5273 // Ensure the suitability bit sticks. 5267 // Ensure the suitability bit sticks.
5274 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization());
5275 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); 5268 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization());
5276 5269
5277 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); 5270 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization());
5278 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 5271 EXPECT_TRUE(host_impl->use_gpu_rasterization());
5279 } 5272 }
5280 5273
5281 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 5274 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
5282 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization());
5283 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); 5275 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization());
5284 5276
5285 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); 5277 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization());
5286 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 5278 EXPECT_TRUE(host_impl->use_gpu_rasterization());
5287 EndTest(); 5279 EndTest();
5288 } 5280 }
5289 5281
5290 void AfterTest() override {} 5282 void AfterTest() override {}
5291 5283
5292 FakeContentLayerClient layer_client_; 5284 FakeContentLayerClient layer_client_;
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
6940 private: 6932 private:
6941 FakeContentLayerClient client_; 6933 FakeContentLayerClient client_;
6942 const gfx::Size viewport_size_; 6934 const gfx::Size viewport_size_;
6943 const gfx::Size large_image_size_; 6935 const gfx::Size large_image_size_;
6944 }; 6936 };
6945 6937
6946 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage); 6938 SINGLE_AND_MULTI_THREAD_TEST_F(GpuRasterizationSucceedsWithLargeImage);
6947 6939
6948 } // namespace 6940 } // namespace
6949 } // namespace cc 6941 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698