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

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

Issue 1349913002: Cache gpu suitability in DisplayItemList, remove SetUnsuitable...ForTesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Needs more nullptr Created 5 years, 3 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 <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 4362 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 LayerTreeHostTest::SetupTree(); 4373 LayerTreeHostTest::SetupTree();
4374 4374
4375 scoped_refptr<PictureLayer> layer = 4375 scoped_refptr<PictureLayer> layer =
4376 PictureLayer::Create(layer_settings(), &layer_client_); 4376 PictureLayer::Create(layer_settings(), &layer_client_);
4377 layer->SetBounds(gfx::Size(10, 10)); 4377 layer->SetBounds(gfx::Size(10, 10));
4378 layer->SetIsDrawable(true); 4378 layer->SetIsDrawable(true);
4379 layer_tree_host()->root_layer()->AddChild(layer); 4379 layer_tree_host()->root_layer()->AddChild(layer);
4380 } 4380 }
4381 4381
4382 void BeginTest() override { 4382 void BeginTest() override {
4383 Layer* root = layer_tree_host()->root_layer(); 4383 // 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()); 4384 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4392 4385
4393 // Setting gpu rasterization trigger does not enable gpu rasterization. 4386 // Setting gpu rasterization trigger does not enable gpu rasterization.
4394 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4387 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4395 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4388 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4396 4389
4397 PostSetNeedsCommitToMainThread(); 4390 PostSetNeedsCommitToMainThread();
4398 } 4391 }
4399 4392
4400 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4393 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
(...skipping 19 matching lines...) Expand all
4420 void InitializeSettings(LayerTreeSettings* settings) override { 4413 void InitializeSettings(LayerTreeSettings* settings) override {
4421 EXPECT_FALSE(settings->gpu_rasterization_enabled); 4414 EXPECT_FALSE(settings->gpu_rasterization_enabled);
4422 settings->gpu_rasterization_enabled = true; 4415 settings->gpu_rasterization_enabled = true;
4423 } 4416 }
4424 4417
4425 void SetupTree() override { 4418 void SetupTree() override {
4426 LayerTreeHostTest::SetupTree(); 4419 LayerTreeHostTest::SetupTree();
4427 4420
4428 scoped_ptr<FakeDisplayListRecordingSource> recording_source( 4421 scoped_ptr<FakeDisplayListRecordingSource> recording_source(
4429 new FakeDisplayListRecordingSource(gfx::Size(10, 10))); 4422 new FakeDisplayListRecordingSource(gfx::Size(10, 10)));
4423 recording_source_ = recording_source.get();
4430 4424
4431 scoped_refptr<FakePictureLayer> layer = 4425 scoped_refptr<FakePictureLayer> layer =
4432 FakePictureLayer::CreateWithRecordingSource( 4426 FakePictureLayer::CreateWithRecordingSource(
4433 layer_settings(), &layer_client_, recording_source.Pass()); 4427 layer_settings(), &layer_client_, recording_source.Pass());
4428 layer_ = layer.get();
4434 layer->SetBounds(gfx::Size(10, 10)); 4429 layer->SetBounds(gfx::Size(10, 10));
4435 layer->SetIsDrawable(true); 4430 layer->SetIsDrawable(true);
4436 layer_tree_host()->root_layer()->AddChild(layer); 4431 layer_tree_host()->root_layer()->AddChild(layer);
4437 } 4432 }
4438 4433
4439 void BeginTest() override { 4434 void BeginTest() override {
4440 Layer* root = layer_tree_host()->root_layer(); 4435 // 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()); 4436 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4451 4437
4452 // Gpu rasterization trigger is relevant. 4438 // Gpu rasterization trigger is relevant.
4453 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4439 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4454 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4440 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4455 4441
4456 // Content-based veto is relevant as well. 4442 // Content-based veto is relevant as well.
4457 recording_source->SetUnsuitableForGpuRasterizationForTesting(); 4443 recording_source_->SetUnsuitableForGpuRasterization();
4458 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); 4444
4459 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
4460 // Veto will take effect when layers are updated. 4445 // Veto will take effect when layers are updated.
4461 // The results will be verified after commit is completed below. 4446 // The results will be verified after commit is completed below.
4462 // Since we are manually marking picture pile as unsuitable, 4447 // Since we are manually marking the source as unsuitable,
4463 // make sure that the layer gets a chance to update. 4448 // make sure that the layer gets a chance to update.
4464 layer->SetNeedsDisplay(); 4449 layer_->SetNeedsDisplay();
4465 PostSetNeedsCommitToMainThread(); 4450 PostSetNeedsCommitToMainThread();
4466 } 4451 }
4467 4452
4468 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4453 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4454 // Ensure the suitability bit sticks.
4455 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization());
4456 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization());
4457
4469 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization()); 4458 EXPECT_FALSE(host_impl->pending_tree()->use_gpu_rasterization());
4470 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4459 EXPECT_FALSE(host_impl->use_gpu_rasterization());
4471 } 4460 }
4472 4461
4473 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 4462 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4474 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization()); 4463 EXPECT_FALSE(host_impl->active_tree()->use_gpu_rasterization());
4475 EXPECT_FALSE(host_impl->use_gpu_rasterization()); 4464 EXPECT_FALSE(host_impl->use_gpu_rasterization());
4476 EndTest(); 4465 EndTest();
4477 } 4466 }
4478 4467
4479 void AfterTest() override {} 4468 void AfterTest() override {}
4480 4469
4481 FakeContentLayerClient layer_client_; 4470 FakeContentLayerClient layer_client_;
4471 FakePictureLayer* layer_;
4472 FakeDisplayListRecordingSource* recording_source_;
4482 }; 4473 };
4483 4474
4484 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled); 4475 MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationEnabled);
4485 4476
4486 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest { 4477 class LayerTreeHostTestGpuRasterizationForced : public LayerTreeHostTest {
4487 protected: 4478 protected:
4488 void InitializeSettings(LayerTreeSettings* settings) override { 4479 void InitializeSettings(LayerTreeSettings* settings) override {
4489 EXPECT_FALSE(settings->gpu_rasterization_forced); 4480 EXPECT_FALSE(settings->gpu_rasterization_forced);
4490 settings->gpu_rasterization_forced = true; 4481 settings->gpu_rasterization_forced = true;
4491 } 4482 }
4492 4483
4493 void SetupTree() override { 4484 void SetupTree() override {
4494 LayerTreeHostTest::SetupTree(); 4485 LayerTreeHostTest::SetupTree();
4495 4486
4487 scoped_ptr<FakeDisplayListRecordingSource> recording_source(
4488 new FakeDisplayListRecordingSource(gfx::Size(100, 100)));
4489 recording_source_ = recording_source.get();
4490
4496 scoped_refptr<FakePictureLayer> layer = 4491 scoped_refptr<FakePictureLayer> layer =
4497 FakePictureLayer::Create(layer_settings(), &layer_client_); 4492 FakePictureLayer::CreateWithRecordingSource(
4493 layer_settings(), &layer_client_, recording_source.Pass());
4494 layer_ = layer.get();
4495
4498 layer->SetBounds(gfx::Size(10, 10)); 4496 layer->SetBounds(gfx::Size(10, 10));
4499 layer->SetIsDrawable(true); 4497 layer->SetIsDrawable(true);
4500 layer_tree_host()->root_layer()->AddChild(layer); 4498 layer_tree_host()->root_layer()->AddChild(layer);
4501 } 4499 }
4502 4500
4503 void BeginTest() override { 4501 void BeginTest() override {
4504 Layer* root = layer_tree_host()->root_layer(); 4502 // 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()); 4503 EXPECT_FALSE(layer_tree_host()->has_gpu_rasterization_trigger());
4513 4504
4514 // With gpu rasterization forced, gpu rasterization trigger is irrelevant. 4505 // With gpu rasterization forced, gpu rasterization trigger is irrelevant.
4515 layer_tree_host()->SetHasGpuRasterizationTrigger(true); 4506 layer_tree_host()->SetHasGpuRasterizationTrigger(true);
4516 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger()); 4507 EXPECT_TRUE(layer_tree_host()->has_gpu_rasterization_trigger());
4517 4508
4518 // Content-based veto is irrelevant as well. 4509 // Content-based veto is irrelevant as well.
4519 recording_source->SetUnsuitableForGpuRasterizationForTesting(); 4510 recording_source_->SetUnsuitableForGpuRasterization();
4520 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); 4511
4521 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
4522 // Veto will take effect when layers are updated. 4512 // Veto will take effect when layers are updated.
4523 // The results will be verified after commit is completed below. 4513 // The results will be verified after commit is completed below.
4524 // Since we are manually marking picture pile as unsuitable, 4514 // Since we are manually marking the source as unsuitable,
4525 // make sure that the layer gets a chance to update. 4515 // make sure that the layer gets a chance to update.
4526 layer->SetNeedsDisplay(); 4516 layer_->SetNeedsDisplay();
4527 PostSetNeedsCommitToMainThread(); 4517 PostSetNeedsCommitToMainThread();
4528 } 4518 }
4529 4519
4530 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 4520 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
4521 // Ensure the suitability bit sticks.
4522 EXPECT_FALSE(recording_source_->IsSuitableForGpuRasterization());
4523 EXPECT_FALSE(layer_->IsSuitableForGpuRasterization());
4524
4531 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization()); 4525 EXPECT_TRUE(host_impl->sync_tree()->use_gpu_rasterization());
4532 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 4526 EXPECT_TRUE(host_impl->use_gpu_rasterization());
4533 } 4527 }
4534 4528
4535 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { 4529 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
4536 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization()); 4530 EXPECT_TRUE(host_impl->active_tree()->use_gpu_rasterization());
4537 EXPECT_TRUE(host_impl->use_gpu_rasterization()); 4531 EXPECT_TRUE(host_impl->use_gpu_rasterization());
4538 EndTest(); 4532 EndTest();
4539 } 4533 }
4540 4534
4541 void AfterTest() override {} 4535 void AfterTest() override {}
4542 4536
4543 FakeContentLayerClient layer_client_; 4537 FakeContentLayerClient layer_client_;
4538 FakePictureLayer* layer_;
4539 FakeDisplayListRecordingSource* recording_source_;
4544 }; 4540 };
4545 4541
4546 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced); 4542 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestGpuRasterizationForced);
4547 4543
4548 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame 4544 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame
4549 : public LayerTreeHostTest { 4545 : public LayerTreeHostTest {
4550 public: 4546 public:
4551 enum { kExpectedNumImplFrames = 10 }; 4547 enum { kExpectedNumImplFrames = 10 };
4552 4548
4553 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() 4549 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame()
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
6185 ScrollAndScaleSet scale_info_; 6181 ScrollAndScaleSet scale_info_;
6186 ScrollAndScaleSet no_op_info_; 6182 ScrollAndScaleSet no_op_info_;
6187 bool requested_update_layers_; 6183 bool requested_update_layers_;
6188 int commit_count_; 6184 int commit_count_;
6189 }; 6185 };
6190 6186
6191 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers); 6187 MULTI_THREAD_TEST_F(LayerTreeHostScrollingAndScalingUpdatesLayers);
6192 6188
6193 } // namespace 6189 } // namespace
6194 } // namespace cc 6190 } // namespace cc
OLDNEW
« cc/playback/display_list_recording_source.cc ('K') | « cc/test/fake_display_list_recording_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698