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 5287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5298 // Since we are manually marking the source as unsuitable, | 5298 // Since we are manually marking the source as unsuitable, |
5299 // make sure that the layer gets a chance to update. | 5299 // make sure that the layer gets a chance to update. |
5300 layer_->SetNeedsDisplay(); | 5300 layer_->SetNeedsDisplay(); |
5301 PostSetNeedsCommitToMainThread(); | 5301 PostSetNeedsCommitToMainThread(); |
5302 } | 5302 } |
5303 | 5303 |
5304 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5304 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
5305 // Ensure the suitability bit sticks. | 5305 // Ensure the suitability bit sticks. |
5306 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5306 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
5307 | 5307 |
5308 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 5308 EXPECT_TRUE(host_impl->pending_tree()->use_gpu_rasterization()); |
5309 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5309 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
5310 } | 5310 } |
5311 | 5311 |
5312 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5312 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
5313 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | 5313 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); |
5314 | 5314 |
5315 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 5315 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); |
5316 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5316 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
5317 EndTest(); | 5317 EndTest(); |
5318 } | 5318 } |
5319 | 5319 |
5320 void AfterTest() override {} | 5320 void AfterTest() override {} |
5321 | 5321 |
5322 FakeContentLayerClient layer_client_; | 5322 FakeContentLayerClient layer_client_; |
5323 FakePictureLayer* layer_; | 5323 FakePictureLayer* layer_; |
5324 FakeRecordingSource* recording_source_; | 5324 FakeRecordingSource* recording_source_; |
5325 }; | 5325 }; |
5326 | 5326 |
5327 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); | 5327 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); |
5328 | 5328 |
5329 class LayerTreeHostTestGpuRasterizationReenabled | 5329 class LayerTreeHostTestGpuRasterizationReenabled |
5330 : public LayerTreeHostWithGpuRasterizationTest { | 5330 : public LayerTreeHostWithGpuRasterizationTest { |
5331 protected: | 5331 protected: |
| 5332 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5333 settings->gpu_rasterization_msaa_sample_count = 4; |
| 5334 } |
| 5335 |
| 5336 std::unique_ptr<TestCompositorFrameSink> CreateCompositorFrameSink( |
| 5337 scoped_refptr<ContextProvider> compositor_context_provider, |
| 5338 scoped_refptr<ContextProvider> worker_context_provider) override { |
| 5339 std::unique_ptr<TestWebGraphicsContext3D> context = |
| 5340 TestWebGraphicsContext3D::Create(); |
| 5341 context->SetMaxSamples(4); |
| 5342 context->set_gpu_rasterization(true); |
| 5343 compositor_context_provider = |
| 5344 TestContextProvider::Create(std::move(context)); |
| 5345 return LayerTreeTest::CreateCompositorFrameSink(compositor_context_provider, |
| 5346 worker_context_provider); |
| 5347 } |
| 5348 |
5332 void SetupTree() override { | 5349 void SetupTree() override { |
5333 LayerTreeHostTest::SetupTree(); | 5350 LayerTreeHostTest::SetupTree(); |
5334 | 5351 |
5335 std::unique_ptr<FakeRecordingSource> recording_source( | 5352 std::unique_ptr<FakeRecordingSource> recording_source( |
5336 new FakeRecordingSource); | 5353 new FakeRecordingSource); |
5337 recording_source_ = recording_source.get(); | 5354 recording_source_ = recording_source.get(); |
5338 | 5355 |
5339 scoped_refptr<FakePictureLayer> layer = | 5356 scoped_refptr<FakePictureLayer> layer = |
5340 FakePictureLayer::CreateWithRecordingSource( | 5357 FakePictureLayer::CreateWithRecordingSource( |
5341 &layer_client_, std::move(recording_source)); | 5358 &layer_client_, std::move(recording_source)); |
(...skipping 18 matching lines...) Expand all Loading... |
5360 // Veto will take effect when layers are updated. | 5377 // Veto will take effect when layers are updated. |
5361 // The results will be verified after commit is completed below. | 5378 // The results will be verified after commit is completed below. |
5362 // Since we are manually marking the source as unsuitable, | 5379 // Since we are manually marking the source as unsuitable, |
5363 // make sure that the layer gets a chance to update. | 5380 // make sure that the layer gets a chance to update. |
5364 layer_->SetNeedsDisplay(); | 5381 layer_->SetNeedsDisplay(); |
5365 PostSetNeedsCommitToMainThread(); | 5382 PostSetNeedsCommitToMainThread(); |
5366 } | 5383 } |
5367 | 5384 |
5368 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5385 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
5369 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); | 5386 SCOPED_TRACE(base::StringPrintf("commit %d", num_commits_)); |
5370 if (expected_gpu_enabled_) { | 5387 if (expected_use_msaa_) { |
5371 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 5388 EXPECT_TRUE(host_impl->use_msaa()); |
5372 } else { | 5389 } else { |
5373 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 5390 EXPECT_FALSE(host_impl->use_msaa()); |
5374 } | 5391 } |
5375 | 5392 |
5376 ++num_commits_; | 5393 ++num_commits_; |
5377 switch (num_commits_) { | 5394 switch (num_commits_) { |
5378 case 1: | 5395 case 1: |
5379 layer_->set_force_unsuitable_for_gpu_rasterization(false); | 5396 layer_->set_force_unsuitable_for_gpu_rasterization(false); |
5380 break; | 5397 break; |
5381 case 30: | 5398 case 30: |
5382 layer_->set_force_unsuitable_for_gpu_rasterization(true); | 5399 layer_->set_force_unsuitable_for_gpu_rasterization(true); |
5383 break; | 5400 break; |
5384 case 31: | 5401 case 31: |
5385 layer_->set_force_unsuitable_for_gpu_rasterization(false); | 5402 layer_->set_force_unsuitable_for_gpu_rasterization(false); |
5386 break; | 5403 break; |
5387 case 90: | 5404 case 90: |
5388 expected_gpu_enabled_ = true; | 5405 expected_use_msaa_ = false; |
5389 break; | 5406 break; |
5390 } | 5407 } |
5391 PostSetNeedsCommitToMainThread(); | 5408 PostSetNeedsCommitToMainThread(); |
5392 if (num_commits_ > 100) | 5409 if (num_commits_ > 100) |
5393 EndTest(); | 5410 EndTest(); |
5394 } | 5411 } |
5395 | 5412 |
5396 void AfterTest() override {} | 5413 void AfterTest() override {} |
5397 | 5414 |
5398 FakeContentLayerClient layer_client_; | 5415 FakeContentLayerClient layer_client_; |
5399 FakePictureLayer* layer_; | 5416 FakePictureLayer* layer_; |
5400 FakeRecordingSource* recording_source_; | 5417 FakeRecordingSource* recording_source_; |
5401 int num_commits_ = 0; | 5418 int num_commits_ = 0; |
5402 bool expected_gpu_enabled_ = false; | 5419 bool expected_use_msaa_ = true; |
5403 }; | 5420 }; |
5404 | 5421 |
5405 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationReenabled); | 5422 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationReenabled); |
5406 | 5423 |
5407 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { | 5424 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { |
5408 protected: | 5425 protected: |
5409 void InitializeSettings(LayerTreeSettings* settings) override { | 5426 void InitializeSettings(LayerTreeSettings* settings) override { |
5410 EXPECT_FALSE(settings->gpu_rasterization_forced); | 5427 EXPECT_FALSE(settings->gpu_rasterization_forced); |
5411 settings->gpu_rasterization_forced = true; | 5428 settings->gpu_rasterization_forced = true; |
5412 } | 5429 } |
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7331 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); | 7348 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); |
7332 } | 7349 } |
7333 | 7350 |
7334 void AfterTest() override {} | 7351 void AfterTest() override {} |
7335 }; | 7352 }; |
7336 | 7353 |
7337 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); | 7354 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); |
7338 | 7355 |
7339 } // namespace | 7356 } // namespace |
7340 } // namespace cc | 7357 } // namespace cc |
OLD | NEW |