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

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

Issue 1588093004: Compute if a layer is drawn without LayerTree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "cc/layers/layer_iterator.h" 7 #include "cc/layers/layer_iterator.h"
8 #include "cc/output/copy_output_request.h" 8 #include "cc/output/copy_output_request.h"
9 #include "cc/output/copy_output_result.h" 9 #include "cc/output/copy_output_result.h"
10 #include "cc/test/fake_content_layer_client.h" 10 #include "cc/test/fake_content_layer_client.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 372
373 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { 373 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {
374 ++callback_count_; 374 ++callback_count_;
375 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); 375 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread());
376 EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString()) 376 EXPECT_EQ(copy_layer_->bounds().ToString(), result->size().ToString())
377 << callback_count_; 377 << callback_count_;
378 switch (callback_count_) { 378 switch (callback_count_) {
379 case 1: 379 case 1:
380 // Hide the copy request layer. 380 // Hide the copy request layer.
381 grand_parent_layer_->SetHideLayerAndSubtree(false); 381 grand_parent_layer_->SetOpacity(1.f);
382 parent_layer_->SetHideLayerAndSubtree(false); 382 parent_layer_->SetOpacity(1.f);
383 copy_layer_->SetHideLayerAndSubtree(true); 383 copy_layer_->SetOpacity(0.f);
384 AddCopyRequest(copy_layer_.get()); 384 AddCopyRequest(copy_layer_.get());
385 break; 385 break;
386 case 2: 386 case 2:
387 // Hide the copy request layer's parent only. 387 // Hide the copy request layer's parent only.
388 grand_parent_layer_->SetHideLayerAndSubtree(false); 388 grand_parent_layer_->SetOpacity(1.f);
389 parent_layer_->SetHideLayerAndSubtree(true); 389 parent_layer_->SetOpacity(0.f);
390 copy_layer_->SetHideLayerAndSubtree(false); 390 copy_layer_->SetOpacity(1.f);
391 AddCopyRequest(copy_layer_.get()); 391 AddCopyRequest(copy_layer_.get());
392 break; 392 break;
393 case 3: 393 case 3:
394 // Hide the copy request layer's grand parent only. 394 // Hide the copy request layer's grand parent only.
395 grand_parent_layer_->SetHideLayerAndSubtree(true); 395 grand_parent_layer_->SetOpacity(0.f);
396 parent_layer_->SetHideLayerAndSubtree(false); 396 parent_layer_->SetOpacity(1.f);
397 copy_layer_->SetHideLayerAndSubtree(false); 397 copy_layer_->SetOpacity(1.f);
398 AddCopyRequest(copy_layer_.get()); 398 AddCopyRequest(copy_layer_.get());
399 break; 399 break;
400 case 4: 400 case 4:
401 // Hide the copy request layer's parent and grandparent. 401 // Hide the copy request layer's parent and grandparent.
402 grand_parent_layer_->SetHideLayerAndSubtree(true); 402 grand_parent_layer_->SetOpacity(0.f);
403 parent_layer_->SetHideLayerAndSubtree(true); 403 parent_layer_->SetOpacity(0.f);
404 copy_layer_->SetHideLayerAndSubtree(false); 404 copy_layer_->SetOpacity(1.f);
405 AddCopyRequest(copy_layer_.get()); 405 AddCopyRequest(copy_layer_.get());
406 break; 406 break;
407 case 5: 407 case 5:
408 // Hide the copy request layer as well as its parent and grandparent. 408 // Hide the copy request layer as well as its parent and grandparent.
409 grand_parent_layer_->SetHideLayerAndSubtree(true); 409 grand_parent_layer_->SetOpacity(0.f);
410 parent_layer_->SetHideLayerAndSubtree(true); 410 parent_layer_->SetOpacity(0.f);
411 copy_layer_->SetHideLayerAndSubtree(true); 411 copy_layer_->SetOpacity(0.f);
412 AddCopyRequest(copy_layer_.get()); 412 AddCopyRequest(copy_layer_.get());
413 break; 413 break;
414 case 6: 414 case 6:
415 EndTest(); 415 EndTest();
416 break; 416 break;
417 } 417 }
418 } 418 }
419 419
420 void AfterTest() override {} 420 void AfterTest() override {}
421 421
(...skipping 10 matching lines...) Expand all
432 432
433 class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest 433 class LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest
434 : public LayerTreeHostCopyRequestTest { 434 : public LayerTreeHostCopyRequestTest {
435 protected: 435 protected:
436 void SetupTree() override { 436 void SetupTree() override {
437 root_ = FakePictureLayer::Create(layer_settings(), &client_); 437 root_ = FakePictureLayer::Create(layer_settings(), &client_);
438 root_->SetBounds(gfx::Size(20, 20)); 438 root_->SetBounds(gfx::Size(20, 20));
439 439
440 grand_parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_); 440 grand_parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
441 grand_parent_layer_->SetBounds(gfx::Size(15, 15)); 441 grand_parent_layer_->SetBounds(gfx::Size(15, 15));
442 grand_parent_layer_->SetHideLayerAndSubtree(true); 442 grand_parent_layer_->SetOpacity(0.f);
443 root_->AddChild(grand_parent_layer_); 443 root_->AddChild(grand_parent_layer_);
444 444
445 // parent_layer_ owns a render surface. 445 // parent_layer_ owns a render surface.
446 parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_); 446 parent_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
447 parent_layer_->SetBounds(gfx::Size(15, 15)); 447 parent_layer_->SetBounds(gfx::Size(15, 15));
448 parent_layer_->SetForceRenderSurface(true); 448 parent_layer_->SetForceRenderSurface(true);
449 grand_parent_layer_->AddChild(parent_layer_); 449 grand_parent_layer_->AddChild(parent_layer_);
450 450
451 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_); 451 copy_layer_ = FakePictureLayer::Create(layer_settings(), &client_);
452 copy_layer_->SetBounds(gfx::Size(10, 10)); 452 copy_layer_->SetBounds(gfx::Size(10, 10));
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest 1155 class LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest
1156 : public LayerTreeHostCopyRequestTest { 1156 : public LayerTreeHostCopyRequestTest {
1157 protected: 1157 protected:
1158 void SetupTree() override { 1158 void SetupTree() override {
1159 scoped_refptr<FakePictureLayer> root = 1159 scoped_refptr<FakePictureLayer> root =
1160 FakePictureLayer::Create(layer_settings(), &client_); 1160 FakePictureLayer::Create(layer_settings(), &client_);
1161 root->SetBounds(gfx::Size(20, 20)); 1161 root->SetBounds(gfx::Size(20, 20));
1162 1162
1163 child_ = FakePictureLayer::Create(layer_settings(), &client_); 1163 child_ = FakePictureLayer::Create(layer_settings(), &client_);
1164 child_->SetBounds(gfx::Size(10, 10)); 1164 child_->SetBounds(gfx::Size(10, 10));
1165 child_->SetOpacity(0.f);
1165 root->AddChild(child_); 1166 root->AddChild(child_);
1166 child_->SetHideLayerAndSubtree(true);
1167 1167
1168 layer_tree_host()->SetRootLayer(root); 1168 layer_tree_host()->SetRootLayer(root);
1169 LayerTreeHostCopyRequestTest::SetupTree(); 1169 LayerTreeHostCopyRequestTest::SetupTree();
1170 client_.set_bounds(root->bounds()); 1170 client_.set_bounds(root->bounds());
1171 } 1171 }
1172 1172
1173 void BeginTest() override { 1173 void BeginTest() override {
1174 num_draws_ = 0; 1174 num_draws_ = 0;
1175 copy_happened_ = false; 1175 copy_happened_ = false;
1176 draw_happened_ = false; 1176 draw_happened_ = false;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 int num_draws_; 1264 int num_draws_;
1265 bool copy_happened_; 1265 bool copy_happened_;
1266 bool draw_happened_; 1266 bool draw_happened_;
1267 }; 1267 };
1268 1268
1269 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1269 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1270 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); 1270 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest);
1271 1271
1272 } // namespace 1272 } // namespace
1273 } // namespace cc 1273 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698