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

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

Issue 2822303003: cc : Compute subtree has copy requests before property tree building (Closed)
Patch Set: . Created 3 years, 8 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_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 5520 matching lines...) Expand 10 before | Expand all | Expand 10 after
5531 5531
5532 copy_layer->test_properties()->copy_requests.push_back( 5532 copy_layer->test_properties()->copy_requests.push_back(
5533 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 5533 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5534 5534
5535 LayerImplList render_surface_layer_list; 5535 LayerImplList render_surface_layer_list;
5536 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 5536 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
5537 root_layer, root_layer->bounds(), &render_surface_layer_list); 5537 root_layer, root_layer->bounds(), &render_surface_layer_list);
5538 inputs.can_adjust_raster_scales = true; 5538 inputs.can_adjust_raster_scales = true;
5539 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 5539 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
5540 5540
5541 EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0); 5541 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree());
5542 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); 5542 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree());
5543 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); 5543 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree());
5544 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); 5544 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree());
5545 5545
5546 // We should have four render surfaces, one for the root, one for the grand 5546 // We should have four render surfaces, one for the root, one for the grand
5547 // parent since it has opacity and two drawing descendants, one for the parent 5547 // parent since it has opacity and two drawing descendants, one for the parent
5548 // since it owns a surface, and one for the copy_layer. 5548 // since it owns a surface, and one for the copy_layer.
5549 ASSERT_EQ(4u, render_surface_layer_list.size()); 5549 ASSERT_EQ(4u, render_surface_layer_list.size());
5550 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); 5550 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
5551 EXPECT_EQ(copy_grand_parent_layer->id(), 5551 EXPECT_EQ(copy_grand_parent_layer->id(),
5552 render_surface_layer_list.at(1)->id()); 5552 render_surface_layer_list.at(1)->id());
5553 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); 5553 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
5554 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); 5554 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
(...skipping 3782 matching lines...) Expand 10 before | Expand all | Expand 10 after
9337 9337
9338 scroll_child->SetPosition(gfx::PointF(0, -10.f)); 9338 scroll_child->SetPosition(gfx::PointF(0, -10.f));
9339 scroll_parent->SetCurrentScrollOffset(gfx::ScrollOffset(0.f, 10.f)); 9339 scroll_parent->SetCurrentScrollOffset(gfx::ScrollOffset(0.f, 10.f));
9340 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9340 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9341 ExecuteCalculateDrawProperties(root); 9341 ExecuteCalculateDrawProperties(root);
9342 EXPECT_EQ(gfx::Rect(0, 5, 25, 25), scroll_child->visible_layer_rect()); 9342 EXPECT_EQ(gfx::Rect(0, 5, 25, 25), scroll_child->visible_layer_rect());
9343 } 9343 }
9344 9344
9345 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 9345 static void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
9346 9346
9347 TEST_F(LayerTreeHostCommonTest, NumCopyRequestsInTargetSubtree) { 9347 TEST_F(LayerTreeHostCommonTest, HasCopyRequestsInTargetSubtree) {
9348 // If the layer has a node in effect_tree, the return value of
9349 // num_copy_requests_in_target_subtree() must be equal to the actual number
9350 // of copy requests in the sub-layer_tree; Otherwise, the number is expected
9351 // to be the value of its nearest ancestor that owns an effect node and
9352 // greater than or equal to the actual number of copy requests in the
9353 // sub-layer_tree.
9354
9355 scoped_refptr<Layer> root = Layer::Create(); 9348 scoped_refptr<Layer> root = Layer::Create();
9356 scoped_refptr<Layer> child1 = Layer::Create(); 9349 scoped_refptr<Layer> child1 = Layer::Create();
9357 scoped_refptr<Layer> child2 = Layer::Create(); 9350 scoped_refptr<Layer> child2 = Layer::Create();
9358 scoped_refptr<Layer> grandchild = Layer::Create(); 9351 scoped_refptr<Layer> grandchild = Layer::Create();
9359 scoped_refptr<Layer> greatgrandchild = Layer::Create(); 9352 scoped_refptr<Layer> greatgrandchild = Layer::Create();
9360 9353
9361 root->AddChild(child1); 9354 root->AddChild(child1);
9362 root->AddChild(child2); 9355 root->AddChild(child2);
9363 child1->AddChild(grandchild); 9356 child1->AddChild(grandchild);
9364 grandchild->AddChild(greatgrandchild); 9357 grandchild->AddChild(greatgrandchild);
9365 host()->SetRootLayer(root); 9358 host()->SetRootLayer(root);
9366 9359
9367 child1->RequestCopyOfOutput( 9360 child1->RequestCopyOfOutput(
9368 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 9361 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
9369 greatgrandchild->RequestCopyOfOutput( 9362 greatgrandchild->RequestCopyOfOutput(
9370 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); 9363 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback)));
9371 child2->SetOpacity(0.f); 9364 child2->SetOpacity(0.f);
9372 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 9365 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9373 9366
9374 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2); 9367 EXPECT_TRUE(root->has_copy_requests_in_target_subtree());
9375 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2); 9368 EXPECT_TRUE(child1->has_copy_requests_in_target_subtree());
9376 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0); 9369 EXPECT_FALSE(child2->has_copy_requests_in_target_subtree());
9377 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2); 9370 EXPECT_TRUE(grandchild->has_copy_requests_in_target_subtree());
9378 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1); 9371 EXPECT_TRUE(greatgrandchild->has_copy_requests_in_target_subtree());
9379 } 9372 }
9380 9373
9381 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { 9374 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) {
9382 scoped_refptr<Layer> root = Layer::Create(); 9375 scoped_refptr<Layer> root = Layer::Create();
9383 FakeContentLayerClient client; 9376 FakeContentLayerClient client;
9384 client.set_bounds(root->bounds()); 9377 client.set_bounds(root->bounds());
9385 scoped_refptr<LayerWithForcedDrawsContent> child = 9378 scoped_refptr<LayerWithForcedDrawsContent> child =
9386 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9379 make_scoped_refptr(new LayerWithForcedDrawsContent());
9387 scoped_refptr<LayerWithForcedDrawsContent> grandchild = 9380 scoped_refptr<LayerWithForcedDrawsContent> grandchild =
9388 make_scoped_refptr(new LayerWithForcedDrawsContent()); 9381 make_scoped_refptr(new LayerWithForcedDrawsContent());
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
9774 child->SetClipParent(root.get()); 9767 child->SetClipParent(root.get());
9775 9768
9776 root->AddChild(parent); 9769 root->AddChild(parent);
9777 parent->AddChild(child); 9770 parent->AddChild(child);
9778 host()->SetRootLayer(root); 9771 host()->SetRootLayer(root);
9779 9772
9780 child->RequestCopyOfOutput( 9773 child->RequestCopyOfOutput(
9781 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 9774 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
9782 9775
9783 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 9776 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9784 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); 9777 EXPECT_TRUE(root->has_copy_requests_in_target_subtree());
9785 9778
9786 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 9779 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9787 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); 9780 EXPECT_TRUE(root->has_copy_requests_in_target_subtree());
9788 } 9781 }
9789 9782
9790 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { 9783 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) {
9791 scoped_refptr<Layer> root = Layer::Create(); 9784 scoped_refptr<Layer> root = Layer::Create();
9792 root->SetBounds(gfx::Size(800, 800)); 9785 root->SetBounds(gfx::Size(800, 800));
9793 9786
9794 gfx::Transform translate_z; 9787 gfx::Transform translate_z;
9795 translate_z.Translate3d(0, 0, 10); 9788 translate_z.Translate3d(0, 0, 10);
9796 9789
9797 scoped_refptr<Layer> child = Layer::Create(); 9790 scoped_refptr<Layer> child = Layer::Create();
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
10867 10860
10868 // Check child layer draw properties. 10861 // Check child layer draw properties.
10869 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10862 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10870 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10863 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10871 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10864 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10872 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10865 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10873 } 10866 }
10874 10867
10875 } // namespace 10868 } // namespace
10876 } // namespace cc 10869 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698