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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 4354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4365 class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest { | 4365 class LayerTreeHostTestGpuRasterizationDefault : public LayerTreeHostTest { |
4366 protected: | 4366 protected: |
4367 void InitializeSettings(LayerTreeSettings* settings) override { | 4367 void InitializeSettings(LayerTreeSettings* settings) override { |
4368 EXPECT_FALSE(settings->gpu_rasterization_enabled); | 4368 EXPECT_FALSE(settings->gpu_rasterization_enabled); |
4369 EXPECT_FALSE(settings->gpu_rasterization_forced); | 4369 EXPECT_FALSE(settings->gpu_rasterization_forced); |
4370 } | 4370 } |
4371 | 4371 |
4372 void SetupTree() override { | 4372 void SetupTree() override { |
4373 LayerTreeHostTest::SetupTree(); | 4373 LayerTreeHostTest::SetupTree(); |
4374 | 4374 |
4375 scoped_refptr<PictureLayer> layer = | 4375 scoped_ptr<FakeDisplayListRecordingSource> recording_source( |
4376 PictureLayer::Create(layer_settings(), &layer_client_); | 4376 new FakeDisplayListRecordingSource(gfx::Size(10, 10))); |
4377 recording_source_ = recording_source.get(); | |
4378 | |
4379 scoped_refptr<FakePictureLayer> layer = | |
4380 FakePictureLayer::CreateWithRecordingSource( | |
4381 layer_settings(), &layer_client_, recording_source.Pass()); | |
4382 layer_ = layer.get(); | |
4377 layer->SetBounds(gfx::Size(10, 10)); | 4383 layer->SetBounds(gfx::Size(10, 10)); |
4378 layer->SetIsDrawable(true); | 4384 layer->SetIsDrawable(true); |
4379 layer_tree_host()->root_layer()->AddChild(layer); | 4385 layer_tree_host()->root_layer()->AddChild(layer); |
4380 } | 4386 } |
4381 | 4387 |
4382 void BeginTest() override { | 4388 void BeginTest() override { |
4383 Layer* root = layer_tree_host()->root_layer(); | 4389 // Verify default value. |
4384 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); | |
4385 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | |
4386 | |
4387 // Verify default values. | |
4388 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); | |
4389 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | |
4390 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | |
4391 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4390 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4392 | 4391 |
4393 // Setting gpu rasterization trigger does not enable gpu rasterization. | 4392 // Setting gpu rasterization trigger does not enable gpu rasterization. |
4394 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4393 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
4395 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4394 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4396 | 4395 |
4397 PostSetNeedsCommitToMainThread(); | 4396 PostSetNeedsCommitToMainThread(); |
4398 } | 4397 } |
4399 | 4398 |
4400 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4399 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
4400 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
4401 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | |
4402 | |
4401 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 4403 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
4402 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 4404 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
4403 } | 4405 } |
4404 | 4406 |
4405 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 4407 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
4408 EXPECT_TRUE(recording_source_->IsSuitableForGpuRasterization()); | |
4409 EXPECT_TRUE(layer_->IsSuitableForGpuRasterization()); | |
4410 | |
4406 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 4411 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
4407 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 4412 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
4408 EndTest(); | 4413 EndTest(); |
4409 } | 4414 } |
4410 | 4415 |
4411 void AfterTest() override {} | 4416 void AfterTest() override {} |
4412 | 4417 |
4413 FakeContentLayerClient layer_client_; | 4418 FakeContentLayerClient layer_client_; |
4419 FakePictureLayer* layer_; | |
4420 FakeDisplayListRecordingSource* recording_source_; | |
4414 }; | 4421 }; |
4415 | 4422 |
4416 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault); | 4423 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationDefault); |
4417 | 4424 |
4418 class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { | 4425 class LayerTreeHostTestGpuRasterizationEnabled : public LayerTreeHostTest { |
4419 protected: | 4426 protected: |
4420 void InitializeSettings(LayerTreeSettings* settings) override { | 4427 void InitializeSettings(LayerTreeSettings* settings) override { |
4421 EXPECT_FALSE(settings->gpu_rasterization_enabled); | 4428 EXPECT_FALSE(settings->gpu_rasterization_enabled); |
4422 settings->gpu_rasterization_enabled = true; | 4429 settings->gpu_rasterization_enabled = true; |
4423 } | 4430 } |
4424 | 4431 |
4425 void SetupTree() override { | 4432 void SetupTree() override { |
4426 LayerTreeHostTest::SetupTree(); | 4433 LayerTreeHostTest::SetupTree(); |
4427 | 4434 |
4428 scoped_ptr<FakeDisplayListRecordingSource> recording_source( | 4435 scoped_ptr<FakeDisplayListRecordingSource> recording_source( |
4429 new FakeDisplayListRecordingSource(gfx::Size(10, 10))); | 4436 new FakeDisplayListRecordingSource(gfx::Size(10, 10))); |
4437 recording_source_ = recording_source.get(); | |
4430 | 4438 |
4431 scoped_refptr<FakePictureLayer> layer = | 4439 scoped_refptr<FakePictureLayer> layer = |
4432 FakePictureLayer::CreateWithRecordingSource( | 4440 FakePictureLayer::CreateWithRecordingSource( |
4433 layer_settings(), &layer_client_, recording_source.Pass()); | 4441 layer_settings(), &layer_client_, recording_source.Pass()); |
4442 layer_ = layer.get(); | |
4434 layer->SetBounds(gfx::Size(10, 10)); | 4443 layer->SetBounds(gfx::Size(10, 10)); |
4435 layer->SetIsDrawable(true); | 4444 layer->SetIsDrawable(true); |
4436 layer_tree_host()->root_layer()->AddChild(layer); | 4445 layer_tree_host()->root_layer()->AddChild(layer); |
4437 } | 4446 } |
4438 | 4447 |
4439 void BeginTest() override { | 4448 void BeginTest() override { |
4440 Layer* root = layer_tree_host()->root_layer(); | 4449 // Verify default value. |
4441 FakePictureLayer* layer = static_cast<FakePictureLayer*>(root->child_at(0)); | |
4442 FakeDisplayListRecordingSource* recording_source = | |
4443 static_cast<FakeDisplayListRecordingSource*>( | |
4444 layer->GetRecordingSourceForTesting()); | |
4445 | |
4446 // Verify default values. | |
4447 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); | |
4448 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | |
4449 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | |
4450 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4450 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4451 | 4451 |
4452 // Gpu rasterization trigger is relevant. | 4452 // Gpu rasterization trigger is relevant. |
4453 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4453 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
4454 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4454 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4455 | 4455 |
4456 // Content-based veto is relevant as well. | 4456 // Content-based veto is relevant as well. |
4457 recording_source->SetUnsuitableForGpuRasterizationForTesting(); | 4457 recording_source_->SetUnsuitableForGpuRasterization(); |
4458 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 4458 |
4459 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | |
4460 // Veto will take effect when layers are updated. | 4459 // Veto will take effect when layers are updated. |
4461 // The results will be verified after commit is completed below. | 4460 // The results will be verified after commit is completed below. |
4462 // Since we are manually marking picture pile as unsuitable, | 4461 // Since we are manually marking the source as unsuitable, |
4463 // make sure that the layer gets a chance to update. | 4462 // make sure that the layer gets a chance to update. |
4464 layer->SetNeedsDisplay(); | 4463 layer_->SetNeedsDisplay(); |
4465 PostSetNeedsCommitToMainThread(); | 4464 PostSetNeedsCommitToMainThread(); |
4466 } | 4465 } |
4467 | 4466 |
4468 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4467 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
4468 // Ensure the suitability bit sticks. | |
4469 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
hendrikw
2015/09/21 18:36:46
Same thing here
danakj
2015/09/21 18:43:27
I think it's ok, it's testing the test which is a
| |
4470 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | |
4471 | |
4469 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); | 4472 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); |
4470 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 4473 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
4471 } | 4474 } |
4472 | 4475 |
4473 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 4476 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
4477 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
hendrikw
2015/09/21 18:36:46
and here.
| |
4478 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | |
4479 | |
4474 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); | 4480 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); |
4475 EXPECT_FALSE(host_impl->use_gpu_rasterization()); | 4481 EXPECT_FALSE(host_impl->use_gpu_rasterization()); |
4476 EndTest(); | 4482 EndTest(); |
4477 } | 4483 } |
4478 | 4484 |
4479 void AfterTest() override {} | 4485 void AfterTest() override {} |
4480 | 4486 |
4481 FakeContentLayerClient layer_client_; | 4487 FakeContentLayerClient layer_client_; |
4488 FakePictureLayer* layer_; | |
4489 FakeDisplayListRecordingSource* recording_source_; | |
4482 }; | 4490 }; |
4483 | 4491 |
4484 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); | 4492 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); |
4485 | 4493 |
4486 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { | 4494 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { |
4487 protected: | 4495 protected: |
4488 void InitializeSettings(LayerTreeSettings* settings) override { | 4496 void InitializeSettings(LayerTreeSettings* settings) override { |
4489 EXPECT_FALSE(settings->gpu_rasterization_forced); | 4497 EXPECT_FALSE(settings->gpu_rasterization_forced); |
4490 settings->gpu_rasterization_forced = true; | 4498 settings->gpu_rasterization_forced = true; |
4491 } | 4499 } |
4492 | 4500 |
4493 void SetupTree() override { | 4501 void SetupTree() override { |
4494 LayerTreeHostTest::SetupTree(); | 4502 LayerTreeHostTest::SetupTree(); |
4495 | 4503 |
4504 scoped_ptr<FakeDisplayListRecordingSource> recording_source( | |
4505 new FakeDisplayListRecordingSource(gfx::Size(100, 100))); | |
4506 recording_source_ = recording_source.get(); | |
4507 | |
4496 scoped_refptr<FakePictureLayer> layer = | 4508 scoped_refptr<FakePictureLayer> layer = |
4497 FakePictureLayer::Create(layer_settings(), &layer_client_); | 4509 FakePictureLayer::CreateWithRecordingSource( |
4510 layer_settings(), &layer_client_, recording_source.Pass()); | |
4511 layer_ = layer.get(); | |
4512 | |
4498 layer->SetBounds(gfx::Size(10, 10)); | 4513 layer->SetBounds(gfx::Size(10, 10)); |
4499 layer->SetIsDrawable(true); | 4514 layer->SetIsDrawable(true); |
4500 layer_tree_host()->root_layer()->AddChild(layer); | 4515 layer_tree_host()->root_layer()->AddChild(layer); |
4501 } | 4516 } |
4502 | 4517 |
4503 void BeginTest() override { | 4518 void BeginTest() override { |
4504 Layer* root = layer_tree_host()->root_layer(); | 4519 // Verify default value. |
4505 PictureLayer* layer = static_cast<PictureLayer*>(root->child_at(0)); | |
4506 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | |
4507 | |
4508 // Verify default values. | |
4509 EXPECT_TRUE(root->IsSuitableForGpuRasterization()); | |
4510 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); | |
4511 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); | |
4512 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4520 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4513 | 4521 |
4514 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. | 4522 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. |
4515 layer_tree_host()->SetHasGpuRasterizationTrigger(true); | 4523 layer_tree_host()->SetHasGpuRasterizationTrigger(true); |
4516 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); | 4524 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); |
4517 | 4525 |
4518 // Content-based veto is irrelevant as well. | 4526 // Content-based veto is irrelevant as well. |
4519 recording_source->SetUnsuitableForGpuRasterizationForTesting(); | 4527 recording_source_->SetUnsuitableForGpuRasterization(); |
4520 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); | 4528 |
4521 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); | |
4522 // Veto will take effect when layers are updated. | 4529 // Veto will take effect when layers are updated. |
4523 // The results will be verified after commit is completed below. | 4530 // The results will be verified after commit is completed below. |
4524 // Since we are manually marking picture pile as unsuitable, | 4531 // Since we are manually marking the source as unsuitable, |
4525 // make sure that the layer gets a chance to update. | 4532 // make sure that the layer gets a chance to update. |
4526 layer->SetNeedsDisplay(); | 4533 layer_->SetNeedsDisplay(); |
4527 PostSetNeedsCommitToMainThread(); | 4534 PostSetNeedsCommitToMainThread(); |
4528 } | 4535 } |
4529 | 4536 |
4530 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 4537 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
4538 // Ensure the suitability bit sticks. | |
4539 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
hendrikw
2015/09/21 18:36:46
and here
| |
4540 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | |
4541 | |
4531 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); | 4542 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); |
4532 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 4543 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
4533 } | 4544 } |
4534 | 4545 |
4535 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 4546 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
4547 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization()); | |
hendrikw
2015/09/21 18:36:46
and here
| |
4548 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization()); | |
4549 | |
4536 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); | 4550 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); |
4537 EXPECT_TRUE(host_impl->use_gpu_rasterization()); | 4551 EXPECT_TRUE(host_impl->use_gpu_rasterization()); |
4538 EndTest(); | 4552 EndTest(); |
4539 } | 4553 } |
4540 | 4554 |
4541 void AfterTest() override {} | 4555 void AfterTest() override {} |
4542 | 4556 |
4543 FakeContentLayerClient layer_client_; | 4557 FakeContentLayerClient layer_client_; |
4558 FakePictureLayer* layer_; | |
4559 FakeDisplayListRecordingSource* recording_source_; | |
4544 }; | 4560 }; |
4545 | 4561 |
4546 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); | 4562 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); |
4547 | 4563 |
4548 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame | 4564 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame |
4549 : public LayerTreeHostTest { | 4565 : public LayerTreeHostTest { |
4550 public: | 4566 public: |
4551 enum { kExpectedNumImplFrames = 10 }; | 4567 enum { kExpectedNumImplFrames = 10 }; |
4552 | 4568 |
4553 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() | 4569 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6185 ScrollAndScaleSet scale_info_; | 6201 ScrollAndScaleSet scale_info_; |
6186 ScrollAndScaleSet no_op_info_; | 6202 ScrollAndScaleSet no_op_info_; |
6187 bool requested_update_layers_; | 6203 bool requested_update_layers_; |
6188 int commit_count_; | 6204 int commit_count_; |
6189 }; | 6205 }; |
6190 | 6206 |
6191 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); | 6207 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); |
6192 | 6208 |
6193 } // namespace | 6209 } // namespace |
6194 } // namespace cc | 6210 } // namespace cc |
OLD | NEW |