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

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

Issue 1912893002: cc : Stop pushing properties not used by LayerImpl to LayerImpl. (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 1586
1587 const gfx::Transform identity_matrix; 1587 const gfx::Transform identity_matrix;
1588 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), 1588 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
1589 gfx::PointF(), gfx::Size(10, 10), true, false); 1589 gfx::PointF(), gfx::Size(10, 10), true, false);
1590 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), 1590 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(),
1591 gfx::PointF(), gfx::Size(10, 10), true, false); 1591 gfx::PointF(), gfx::Size(10, 10), true, false);
1592 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 1592 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
1593 gfx::PointF(), gfx::Size(10, 10), true, false); 1593 gfx::PointF(), gfx::Size(10, 10), true, false);
1594 1594
1595 child->SetDrawsContent(true); 1595 child->SetDrawsContent(true);
1596 render_surface1->SetForceRenderSurface(true); 1596 render_surface1->test_properties()->force_render_surface = true;
1597 1597
1598 { 1598 {
1599 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent); 1599 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent);
1600 1600
1601 // The root layer always creates a render surface 1601 // The root layer always creates a render surface
1602 EXPECT_TRUE(parent->has_render_surface()); 1602 EXPECT_TRUE(parent->has_render_surface());
1603 EXPECT_TRUE(render_surface1->has_render_surface()); 1603 EXPECT_TRUE(render_surface1->has_render_surface());
1604 } 1604 }
1605 1605
1606 { 1606 {
1607 render_surface1->SetForceRenderSurface(false); 1607 render_surface1->test_properties()->force_render_surface = false;
1608 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true; 1608 render_surface1->layer_tree_impl()->property_trees()->needs_rebuild = true;
1609 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent); 1609 ExecuteCalculateDrawPropertiesWithPropertyTrees(parent);
1610 EXPECT_TRUE(parent->has_render_surface()); 1610 EXPECT_TRUE(parent->has_render_surface());
1611 EXPECT_FALSE(render_surface1->has_render_surface()); 1611 EXPECT_FALSE(render_surface1->has_render_surface());
1612 } 1612 }
1613 } 1613 }
1614 1614
1615 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) { 1615 TEST_F(LayerTreeHostCommonTest, RenderSurfacesFlattenScreenSpaceTransform) {
1616 // Render surfaces act as a flattening point for their subtree, so should 1616 // Render surfaces act as a flattening point for their subtree, so should
1617 // always flatten the target-to-screen space transform seen by descendants. 1617 // always flatten the target-to-screen space transform seen by descendants.
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(), 2305 SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(),
2306 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000), 2306 gfx::PointF(16.f, 16.f), gfx::Size(2000, 2000),
2307 true, false); 2307 true, false);
2308 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(), 2308 SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
2309 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000), 2309 gfx::PointF(9.f, 9.f), gfx::Size(2000, 2000),
2310 true, false); 2310 true, false);
2311 2311
2312 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its 2312 // Case 1: Nothing is clipped. In this case, each layer's clip rect is its
2313 // bounds in target space. The only thing that changes when surfaces are 2313 // bounds in target space. The only thing that changes when surfaces are
2314 // disabled is that target space is always screen space. 2314 // disabled is that target space is always screen space.
2315 root->SetForceRenderSurface(true); 2315 root->test_properties()->force_render_surface = true;
2316 child1->SetForceRenderSurface(true); 2316 child1->test_properties()->force_render_surface = true;
2317 grand_child->SetForceRenderSurface(true); 2317 grand_child->test_properties()->force_render_surface = true;
2318 ExecuteCalculateDrawProperties(root); 2318 ExecuteCalculateDrawProperties(root);
2319 EXPECT_TRUE(root->has_render_surface()); 2319 EXPECT_TRUE(root->has_render_surface());
2320 EXPECT_FALSE(parent->has_render_surface()); 2320 EXPECT_FALSE(parent->has_render_surface());
2321 EXPECT_TRUE(child1->has_render_surface()); 2321 EXPECT_TRUE(child1->has_render_surface());
2322 EXPECT_FALSE(child2->has_render_surface()); 2322 EXPECT_FALSE(child2->has_render_surface());
2323 EXPECT_TRUE(grand_child->has_render_surface()); 2323 EXPECT_TRUE(grand_child->has_render_surface());
2324 EXPECT_FALSE(leaf_node1->has_render_surface()); 2324 EXPECT_FALSE(leaf_node1->has_render_surface());
2325 EXPECT_FALSE(leaf_node2->has_render_surface()); 2325 EXPECT_FALSE(leaf_node2->has_render_surface());
2326 EXPECT_FALSE(root->is_clipped()); 2326 EXPECT_FALSE(root->is_clipped());
2327 EXPECT_FALSE(parent->is_clipped()); 2327 EXPECT_FALSE(parent->is_clipped());
(...skipping 15 matching lines...) Expand all
2343 EXPECT_FALSE(grand_child->is_clipped()); 2343 EXPECT_FALSE(grand_child->is_clipped());
2344 EXPECT_FALSE(leaf_node1->is_clipped()); 2344 EXPECT_FALSE(leaf_node1->is_clipped());
2345 EXPECT_FALSE(leaf_node2->is_clipped()); 2345 EXPECT_FALSE(leaf_node2->is_clipped());
2346 EXPECT_TRUE(root->render_surface()->is_clipped()); 2346 EXPECT_TRUE(root->render_surface()->is_clipped());
2347 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect()); 2347 EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
2348 2348
2349 // Case 2: The root is clipped. In this case, layers that draw into the root 2349 // Case 2: The root is clipped. In this case, layers that draw into the root
2350 // render surface are clipped by the root's bounds. 2350 // render surface are clipped by the root's bounds.
2351 root->SetMasksToBounds(true); 2351 root->SetMasksToBounds(true);
2352 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 2352 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
2353 root->SetForceRenderSurface(true); 2353 root->test_properties()->force_render_surface = true;
2354 child1->SetForceRenderSurface(true); 2354 child1->test_properties()->force_render_surface = true;
2355 grand_child->SetForceRenderSurface(true); 2355 grand_child->test_properties()->force_render_surface = true;
2356 ExecuteCalculateDrawProperties(root); 2356 ExecuteCalculateDrawProperties(root);
2357 EXPECT_TRUE(root->has_render_surface()); 2357 EXPECT_TRUE(root->has_render_surface());
2358 EXPECT_FALSE(parent->has_render_surface()); 2358 EXPECT_FALSE(parent->has_render_surface());
2359 EXPECT_TRUE(child1->has_render_surface()); 2359 EXPECT_TRUE(child1->has_render_surface());
2360 EXPECT_FALSE(child2->has_render_surface()); 2360 EXPECT_FALSE(child2->has_render_surface());
2361 EXPECT_TRUE(grand_child->has_render_surface()); 2361 EXPECT_TRUE(grand_child->has_render_surface());
2362 EXPECT_FALSE(leaf_node1->has_render_surface()); 2362 EXPECT_FALSE(leaf_node1->has_render_surface());
2363 EXPECT_FALSE(leaf_node2->has_render_surface()); 2363 EXPECT_FALSE(leaf_node2->has_render_surface());
2364 EXPECT_TRUE(root->is_clipped()); 2364 EXPECT_TRUE(root->is_clipped());
2365 EXPECT_TRUE(parent->is_clipped()); 2365 EXPECT_TRUE(parent->is_clipped());
(...skipping 30 matching lines...) Expand all
2396 2396
2397 // Case 3: The parent and child1 are clipped. When surfaces are enabled, the 2397 // Case 3: The parent and child1 are clipped. When surfaces are enabled, the
2398 // parent clip rect only contributes to the subtree rooted at child2, since 2398 // parent clip rect only contributes to the subtree rooted at child2, since
2399 // the subtree rooted at child1 renders into a separate surface. Similarly, 2399 // the subtree rooted at child1 renders into a separate surface. Similarly,
2400 // child1's clip rect doesn't contribute to its descendants, since its only 2400 // child1's clip rect doesn't contribute to its descendants, since its only
2401 // child is a render surface. However, without surfaces, these clip rects 2401 // child is a render surface. However, without surfaces, these clip rects
2402 // contribute to all descendants. 2402 // contribute to all descendants.
2403 parent->SetMasksToBounds(true); 2403 parent->SetMasksToBounds(true);
2404 child1->SetMasksToBounds(true); 2404 child1->SetMasksToBounds(true);
2405 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 2405 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
2406 root->SetForceRenderSurface(true); 2406 root->test_properties()->force_render_surface = true;
2407 child1->SetForceRenderSurface(true); 2407 child1->test_properties()->force_render_surface = true;
2408 grand_child->SetForceRenderSurface(true); 2408 grand_child->test_properties()->force_render_surface = true;
2409 ExecuteCalculateDrawProperties(root); 2409 ExecuteCalculateDrawProperties(root);
2410 EXPECT_TRUE(root->has_render_surface()); 2410 EXPECT_TRUE(root->has_render_surface());
2411 EXPECT_FALSE(parent->has_render_surface()); 2411 EXPECT_FALSE(parent->has_render_surface());
2412 EXPECT_TRUE(child1->has_render_surface()); 2412 EXPECT_TRUE(child1->has_render_surface());
2413 EXPECT_FALSE(child2->has_render_surface()); 2413 EXPECT_FALSE(child2->has_render_surface());
2414 EXPECT_TRUE(grand_child->has_render_surface()); 2414 EXPECT_TRUE(grand_child->has_render_surface());
2415 EXPECT_FALSE(leaf_node1->has_render_surface()); 2415 EXPECT_FALSE(leaf_node1->has_render_surface());
2416 EXPECT_FALSE(leaf_node2->has_render_surface()); 2416 EXPECT_FALSE(leaf_node2->has_render_surface());
2417 EXPECT_FALSE(root->is_clipped()); 2417 EXPECT_FALSE(root->is_clipped());
2418 EXPECT_TRUE(root->render_surface()->is_clipped()); 2418 EXPECT_TRUE(root->render_surface()->is_clipped());
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after
4389 AddChild<LayerImpl>(back_facing_surface); 4389 AddChild<LayerImpl>(back_facing_surface);
4390 // Opacity will not force creation of render surfaces in this case because of 4390 // Opacity will not force creation of render surfaces in this case because of
4391 // the preserve-3d transform style. Instead, an example of when a surface 4391 // the preserve-3d transform style. Instead, an example of when a surface
4392 // would be created with preserve-3d is when there is a replica layer. 4392 // would be created with preserve-3d is when there is a replica layer.
4393 LayerImpl* dummy_replica_layer1 = 4393 LayerImpl* dummy_replica_layer1 =
4394 AddReplicaLayer<LayerImpl>(front_facing_surface); 4394 AddReplicaLayer<LayerImpl>(front_facing_surface);
4395 LayerImpl* dummy_replica_layer2 = 4395 LayerImpl* dummy_replica_layer2 =
4396 AddReplicaLayer<LayerImpl>(back_facing_surface); 4396 AddReplicaLayer<LayerImpl>(back_facing_surface);
4397 4397
4398 // Nothing is double-sided 4398 // Nothing is double-sided
4399 front_facing_child->SetDoubleSided(false); 4399 front_facing_child->test_properties()->double_sided = false;
4400 back_facing_child->SetDoubleSided(false); 4400 back_facing_child->test_properties()->double_sided = false;
4401 front_facing_surface->SetDoubleSided(false); 4401 front_facing_surface->test_properties()->double_sided = false;
4402 back_facing_surface->SetDoubleSided(false); 4402 back_facing_surface->test_properties()->double_sided = false;
4403 front_facing_child_of_front_facing_surface->SetDoubleSided(false); 4403 front_facing_child_of_front_facing_surface->test_properties()->double_sided =
4404 back_facing_child_of_front_facing_surface->SetDoubleSided(false); 4404 false;
4405 front_facing_child_of_back_facing_surface->SetDoubleSided(false); 4405 back_facing_child_of_front_facing_surface->test_properties()->double_sided =
4406 back_facing_child_of_back_facing_surface->SetDoubleSided(false); 4406 false;
4407 front_facing_child_of_back_facing_surface->test_properties()->double_sided =
4408 false;
4409 back_facing_child_of_back_facing_surface->test_properties()->double_sided =
4410 false;
4407 4411
4408 // Everything draws content. 4412 // Everything draws content.
4409 front_facing_child->SetDrawsContent(true); 4413 front_facing_child->SetDrawsContent(true);
4410 back_facing_child->SetDrawsContent(true); 4414 back_facing_child->SetDrawsContent(true);
4411 front_facing_surface->SetDrawsContent(true); 4415 front_facing_surface->SetDrawsContent(true);
4412 back_facing_surface->SetDrawsContent(true); 4416 back_facing_surface->SetDrawsContent(true);
4413 front_facing_child_of_front_facing_surface->SetDrawsContent(true); 4417 front_facing_child_of_front_facing_surface->SetDrawsContent(true);
4414 back_facing_child_of_front_facing_surface->SetDrawsContent(true); 4418 back_facing_child_of_front_facing_surface->SetDrawsContent(true);
4415 front_facing_child_of_back_facing_surface->SetDrawsContent(true); 4419 front_facing_child_of_back_facing_surface->SetDrawsContent(true);
4416 back_facing_child_of_back_facing_surface->SetDrawsContent(true); 4420 back_facing_child_of_back_facing_surface->SetDrawsContent(true);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4513 animating_surface->SetDoubleSided(false); 4517 animating_surface->SetDoubleSided(false);
4514 child_of_animating_surface->SetDoubleSided(false); 4518 child_of_animating_surface->SetDoubleSided(false);
4515 animating_child->SetDoubleSided(false); 4519 animating_child->SetDoubleSided(false);
4516 4520
4517 gfx::Transform backface_matrix; 4521 gfx::Transform backface_matrix;
4518 backface_matrix.Translate(50.0, 50.0); 4522 backface_matrix.Translate(50.0, 50.0);
4519 backface_matrix.RotateAboutYAxis(180.0); 4523 backface_matrix.RotateAboutYAxis(180.0);
4520 backface_matrix.Translate(-50.0, -50.0); 4524 backface_matrix.Translate(-50.0, -50.0);
4521 4525
4522 // Make our render surface. 4526 // Make our render surface.
4523 animating_surface->SetForceRenderSurface(true); 4527 animating_surface->SetForceRenderSurfaceForTesting(true);
4524 4528
4525 // Animate the transform on the render surface. 4529 // Animate the transform on the render surface.
4526 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(), 4530 AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(),
4527 10.0, 30, 0); 4531 10.0, 30, 0);
4528 // This is just an animating layer, not a surface. 4532 // This is just an animating layer, not a surface.
4529 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 10.0, 4533 AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 10.0,
4530 30, 0); 4534 30, 0);
4531 4535
4532 SetLayerPropertiesForTesting(parent.get(), 4536 SetLayerPropertiesForTesting(parent.get(),
4533 identity_matrix, 4537 identity_matrix,
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after
6455 gfx::PointF(), gfx::Size(20, 20), true, false, 6459 gfx::PointF(), gfx::Size(20, 20), true, false,
6456 false); 6460 false);
6457 SetLayerPropertiesForTesting(child2, identity_transform, gfx::Point3F(), 6461 SetLayerPropertiesForTesting(child2, identity_transform, gfx::Point3F(),
6458 gfx::PointF(), gfx::Size(20, 20), true, false, 6462 gfx::PointF(), gfx::Size(20, 20), true, false,
6459 false); 6463 false);
6460 6464
6461 root->SetShouldFlattenTransform(false); 6465 root->SetShouldFlattenTransform(false);
6462 root->Set3dSortingContextId(1); 6466 root->Set3dSortingContextId(1);
6463 back_facing->Set3dSortingContextId(1); 6467 back_facing->Set3dSortingContextId(1);
6464 back_facing->SetShouldFlattenTransform(false); 6468 back_facing->SetShouldFlattenTransform(false);
6465 render_surface1->SetDoubleSided(false); 6469 render_surface1->test_properties()->double_sided = false;
6466 render_surface2->Set3dSortingContextId(2); 6470 render_surface2->Set3dSortingContextId(2);
6467 render_surface2->SetDoubleSided(false); 6471 render_surface2->test_properties()->double_sided = false;
6468 6472
6469 ExecuteCalculateDrawProperties(root); 6473 ExecuteCalculateDrawProperties(root);
6470 6474
6471 EXPECT_EQ(render_surface1->sorting_context_id(), root->sorting_context_id()); 6475 EXPECT_EQ(render_surface1->sorting_context_id(), root->sorting_context_id());
6472 EXPECT_NE(render_surface2->sorting_context_id(), root->sorting_context_id()); 6476 EXPECT_NE(render_surface2->sorting_context_id(), root->sorting_context_id());
6473 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); 6477 EXPECT_EQ(3u, render_surface_layer_list_impl()->size());
6474 EXPECT_EQ(2u, render_surface_layer_list_impl() 6478 EXPECT_EQ(2u, render_surface_layer_list_impl()
6475 ->at(0) 6479 ->at(0)
6476 ->render_surface() 6480 ->render_surface()
6477 ->layer_list() 6481 ->layer_list()
(...skipping 23 matching lines...) Expand all
6501 ->layer_list() 6505 ->layer_list()
6502 .size()); 6506 .size());
6503 } 6507 }
6504 6508
6505 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { 6509 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) {
6506 LayerImpl* root = root_layer(); 6510 LayerImpl* root = root_layer();
6507 LayerImpl* child = AddChild<LayerImpl>(root); 6511 LayerImpl* child = AddChild<LayerImpl>(root);
6508 LayerImpl* grand_child = AddChild<LayerImpl>(child); 6512 LayerImpl* grand_child = AddChild<LayerImpl>(child);
6509 grand_child->SetDrawsContent(true); 6513 grand_child->SetDrawsContent(true);
6510 6514
6511 child->SetDoubleSided(false); 6515 child->test_properties()->double_sided = false;
6512 grand_child->SetUseParentBackfaceVisibility(true); 6516 grand_child->SetUseParentBackfaceVisibility(true);
6513 6517
6514 gfx::Transform identity_transform; 6518 gfx::Transform identity_transform;
6515 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), 6519 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
6516 gfx::PointF(), gfx::Size(50, 50), false, false, 6520 gfx::PointF(), gfx::Size(50, 50), false, false,
6517 true); 6521 true);
6518 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), 6522 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
6519 gfx::PointF(), gfx::Size(30, 30), false, false, 6523 gfx::PointF(), gfx::Size(30, 30), false, false,
6520 false); 6524 false);
6521 SetLayerPropertiesForTesting(grand_child, identity_transform, gfx::Point3F(), 6525 SetLayerPropertiesForTesting(grand_child, identity_transform, gfx::Point3F(),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
6565 EXPECT_TRUE(grand_child->should_check_backface_visibility()); 6569 EXPECT_TRUE(grand_child->should_check_backface_visibility());
6566 // child uses its local transform for backface visibility as it is the root of 6570 // child uses its local transform for backface visibility as it is the root of
6567 // a 3d rendering context. grand_child is in a 3d rendering context and is not 6571 // a 3d rendering context. grand_child is in a 3d rendering context and is not
6568 // the root, but it derives its backface visibility from its parent which uses 6572 // the root, but it derives its backface visibility from its parent which uses
6569 // its local transform. 6573 // its local transform.
6570 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); 6574 EXPECT_TRUE(root->use_local_transform_for_backface_visibility());
6571 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); 6575 EXPECT_TRUE(child->use_local_transform_for_backface_visibility());
6572 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); 6576 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility());
6573 6577
6574 grand_child->SetUseParentBackfaceVisibility(false); 6578 grand_child->SetUseParentBackfaceVisibility(false);
6575 grand_child->SetDoubleSided(false); 6579 grand_child->test_properties()->double_sided = false;
6576 grand_child->layer_tree_impl()->property_trees()->needs_rebuild = true; 6580 grand_child->layer_tree_impl()->property_trees()->needs_rebuild = true;
6577 6581
6578 ExecuteCalculateDrawProperties(root); 6582 ExecuteCalculateDrawProperties(root);
6579 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); 6583 EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
6580 EXPECT_EQ(0u, render_surface_layer_list_impl() 6584 EXPECT_EQ(0u, render_surface_layer_list_impl()
6581 ->at(0) 6585 ->at(0)
6582 ->render_surface() 6586 ->render_surface()
6583 ->layer_list() 6587 ->layer_list()
6584 .size()); 6588 .size());
6585 6589
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
6993 LayerImpl* root = root_layer(); 6997 LayerImpl* root = root_layer();
6994 LayerImpl* render_surface = AddChild<LayerImpl>(root); 6998 LayerImpl* render_surface = AddChild<LayerImpl>(root);
6995 LayerImpl* fixed = AddChild<LayerImpl>(render_surface); 6999 LayerImpl* fixed = AddChild<LayerImpl>(render_surface);
6996 LayerImpl* child = AddChild<LayerImpl>(fixed); 7000 LayerImpl* child = AddChild<LayerImpl>(fixed);
6997 7001
6998 render_surface->SetDrawsContent(true); 7002 render_surface->SetDrawsContent(true);
6999 fixed->SetDrawsContent(true); 7003 fixed->SetDrawsContent(true);
7000 child->SetDrawsContent(true); 7004 child->SetDrawsContent(true);
7001 7005
7002 root->SetIsContainerForFixedPositionLayers(true); 7006 root->SetIsContainerForFixedPositionLayers(true);
7003 render_surface->SetForceRenderSurface(true); 7007 render_surface->test_properties()->force_render_surface = true;
7004 7008
7005 LayerPositionConstraint constraint; 7009 LayerPositionConstraint constraint;
7006 constraint.set_is_fixed_position(true); 7010 constraint.set_is_fixed_position(true);
7007 fixed->SetPositionConstraint(constraint); 7011 fixed->SetPositionConstraint(constraint);
7008 7012
7009 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), 7013 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
7010 gfx::PointF(), gfx::Size(50, 50), true, false); 7014 gfx::PointF(), gfx::Size(50, 50), true, false);
7011 SetLayerPropertiesForTesting(render_surface, gfx::Transform(), gfx::Point3F(), 7015 SetLayerPropertiesForTesting(render_surface, gfx::Transform(), gfx::Point3F(),
7012 gfx::PointF(7.f, 9.f), gfx::Size(50, 50), true, 7016 gfx::PointF(7.f, 9.f), gfx::Size(50, 50), true,
7013 false); 7017 false);
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
7892 LayerImpl* root_layer = root.get(); 7896 LayerImpl* root_layer = root.get();
7893 std::unique_ptr<LayerImpl> child1 = 7897 std::unique_ptr<LayerImpl> child1 =
7894 LayerImpl::Create(host_impl.active_tree(), 2); 7898 LayerImpl::Create(host_impl.active_tree(), 2);
7895 LayerImpl* child1_layer = child1.get(); 7899 LayerImpl* child1_layer = child1.get();
7896 std::unique_ptr<LayerImpl> child2 = 7900 std::unique_ptr<LayerImpl> child2 =
7897 LayerImpl::Create(host_impl.active_tree(), 3); 7901 LayerImpl::Create(host_impl.active_tree(), 3);
7898 LayerImpl* child2_layer = child2.get(); 7902 LayerImpl* child2_layer = child2.get();
7899 7903
7900 root->AddChild(std::move(child1)); 7904 root->AddChild(std::move(child1));
7901 root->AddChild(std::move(child2)); 7905 root->AddChild(std::move(child2));
7902 root->SetForceRenderSurface(true); 7906 root->test_properties()->force_render_surface = true;
7903 root->SetDrawsContent(true); 7907 root->SetDrawsContent(true);
7904 host_impl.active_tree()->SetRootLayer(std::move(root)); 7908 host_impl.active_tree()->SetRootLayer(std::move(root));
7905 7909
7906 gfx::Transform identity_matrix, scale_transform_child1, 7910 gfx::Transform identity_matrix, scale_transform_child1,
7907 scale_transform_child2; 7911 scale_transform_child2;
7908 scale_transform_child1.Scale(2, 3); 7912 scale_transform_child1.Scale(2, 3);
7909 scale_transform_child2.Scale(4, 5); 7913 scale_transform_child2.Scale(4, 5);
7910 7914
7911 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), 7915 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(),
7912 gfx::PointF(), gfx::Size(1, 1), true, false, 7916 gfx::PointF(), gfx::Size(1, 1), true, false,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
8213 root->AddChild(animated); 8217 root->AddChild(animated);
8214 8218
8215 host()->SetRootLayer(root); 8219 host()->SetRootLayer(root);
8216 8220
8217 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 8221 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
8218 gfx::PointF(), gfx::Size(100, 100), true, false); 8222 gfx::PointF(), gfx::Size(100, 100), true, false);
8219 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), 8223 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(),
8220 gfx::PointF(), gfx::Size(20, 20), true, false); 8224 gfx::PointF(), gfx::Size(20, 20), true, false);
8221 8225
8222 root->SetMasksToBounds(true); 8226 root->SetMasksToBounds(true);
8223 root->SetForceRenderSurface(true); 8227 root->SetForceRenderSurfaceForTesting(true);
8224 animated->SetOpacity(0.f); 8228 animated->SetOpacity(0.f);
8225 8229
8226 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, 8230 AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f,
8227 1.f, false); 8231 1.f, false);
8228 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); 8232 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
8229 8233
8230 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); 8234 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty());
8231 } 8235 }
8232 8236
8233 TEST_F(LayerTreeHostCommonTest, 8237 TEST_F(LayerTreeHostCommonTest,
8234 VisibleContentRectForAnimatedLayerWithSingularTransform) { 8238 VisibleContentRectForAnimatedLayerWithSingularTransform) {
8235 const gfx::Transform identity_matrix; 8239 const gfx::Transform identity_matrix;
8236 scoped_refptr<Layer> root = Layer::Create(); 8240 scoped_refptr<Layer> root = Layer::Create();
8237 scoped_refptr<Layer> clip = Layer::Create(); 8241 scoped_refptr<Layer> clip = Layer::Create();
8238 scoped_refptr<LayerWithForcedDrawsContent> animated = 8242 scoped_refptr<LayerWithForcedDrawsContent> animated =
8239 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8243 make_scoped_refptr(new LayerWithForcedDrawsContent());
8240 scoped_refptr<LayerWithForcedDrawsContent> surface = 8244 scoped_refptr<LayerWithForcedDrawsContent> surface =
8241 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8245 make_scoped_refptr(new LayerWithForcedDrawsContent());
8242 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = 8246 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation =
8243 make_scoped_refptr(new LayerWithForcedDrawsContent()); 8247 make_scoped_refptr(new LayerWithForcedDrawsContent());
8244 8248
8245 root->AddChild(clip); 8249 root->AddChild(clip);
8246 clip->AddChild(animated); 8250 clip->AddChild(animated);
8247 animated->AddChild(surface); 8251 animated->AddChild(surface);
8248 surface->AddChild(descendant_of_animation); 8252 surface->AddChild(descendant_of_animation);
8249 8253
8250 clip->SetMasksToBounds(true); 8254 clip->SetMasksToBounds(true);
8251 surface->SetForceRenderSurface(true); 8255 surface->SetForceRenderSurfaceForTesting(true);
8252 8256
8253 host()->SetRootLayer(root); 8257 host()->SetRootLayer(root);
8254 8258
8255 gfx::Transform uninvertible_matrix; 8259 gfx::Transform uninvertible_matrix;
8256 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); 8260 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f);
8257 8261
8258 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), 8262 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(),
8259 gfx::PointF(), gfx::Size(100, 100), true, false); 8263 gfx::PointF(), gfx::Size(100, 100), true, false);
8260 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), 8264 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(),
8261 gfx::PointF(), gfx::Size(10, 10), true, false); 8265 gfx::PointF(), gfx::Size(10, 10), true, false);
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
8911 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8915 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8912 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8916 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8913 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8917 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8914 requests.clear(); 8918 requests.clear();
8915 grandchild_ptr->PassCopyRequests(&requests); 8919 grandchild_ptr->PassCopyRequests(&requests);
8916 child_ptr->SetOpacity(1.f); 8920 child_ptr->SetOpacity(1.f);
8917 8921
8918 // A double sided render surface with backface visible should not be skipped 8922 // A double sided render surface with backface visible should not be skipped
8919 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); 8923 grandchild_ptr->set_visible_layer_rect(gfx::Rect());
8920 child_ptr->SetHasRenderSurface(true); 8924 child_ptr->SetHasRenderSurface(true);
8921 child_ptr->SetDoubleSided(true); 8925 child_ptr->test_properties()->double_sided = true;
8922 child_ptr->SetTransform(rotate_back_and_translate); 8926 child_ptr->SetTransform(rotate_back_and_translate);
8923 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; 8927 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
8924 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); 8928 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
8925 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); 8929 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
8926 child_ptr->SetTransform(identity); 8930 child_ptr->SetTransform(identity);
8927 8931
8928 std::unique_ptr<KeyframedTransformAnimationCurve> curve( 8932 std::unique_ptr<KeyframedTransformAnimationCurve> curve(
8929 KeyframedTransformAnimationCurve::Create()); 8933 KeyframedTransformAnimationCurve::Create());
8930 TransformOperations start; 8934 TransformOperations start;
8931 start.AppendTranslate(1.f, 2.f, 3.f); 8935 start.AppendTranslate(1.f, 2.f, 3.f);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
9103 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 9107 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9104 child->SetHideLayerAndSubtree(false); 9108 child->SetHideLayerAndSubtree(false);
9105 9109
9106 child->SetBounds(gfx::Size()); 9110 child->SetBounds(gfx::Size());
9107 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9111 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9108 ExecuteCalculateDrawProperties(root); 9112 ExecuteCalculateDrawProperties(root);
9109 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 9113 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9110 child->SetBounds(gfx::Size(10, 10)); 9114 child->SetBounds(gfx::Size(10, 10));
9111 9115
9112 gfx::Transform rotate; 9116 gfx::Transform rotate;
9113 child->SetDoubleSided(false); 9117 child->test_properties()->double_sided = false;
9114 rotate.RotateAboutXAxis(180.f); 9118 rotate.RotateAboutXAxis(180.f);
9115 child->SetTransform(rotate); 9119 child->SetTransform(rotate);
9116 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9120 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9117 ExecuteCalculateDrawProperties(root); 9121 ExecuteCalculateDrawProperties(root);
9118 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 9122 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9119 child->SetDoubleSided(true); 9123 child->test_properties()->double_sided = true;
9120 child->SetTransform(identity); 9124 child->SetTransform(identity);
9121 9125
9122 child->SetOpacity(0.f); 9126 child->SetOpacity(0.f);
9123 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9127 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9124 ExecuteCalculateDrawProperties(root); 9128 ExecuteCalculateDrawProperties(root);
9125 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 9129 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9126 } 9130 }
9127 9131
9128 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { 9132 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) {
9129 // Ensure that the treewalk in LayerTreeHostCommom:: 9133 // Ensure that the treewalk in LayerTreeHostCommom::
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
9237 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 9241 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
9238 true, false); 9242 true, false);
9239 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, 9243 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix,
9240 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), 9244 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
9241 true, false); 9245 true, false);
9242 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), 9246 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(),
9243 gfx::PointF(), gfx::Size(30, 30), true, false); 9247 gfx::PointF(), gfx::Size(30, 30), true, false);
9244 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), 9248 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(),
9245 gfx::PointF(), gfx::Size(30, 30), true, false); 9249 gfx::PointF(), gfx::Size(30, 30), true, false);
9246 9250
9247 root->SetForceRenderSurface(true); 9251 root->test_properties()->force_render_surface = true;
9248 significant_transform->SetForceRenderSurface(false); 9252 significant_transform->test_properties()->force_render_surface = false;
9249 layer_clips_subtree->SetForceRenderSurface(true); 9253 layer_clips_subtree->test_properties()->force_render_surface = true;
9250 render_surface->SetForceRenderSurface(true); 9254 render_surface->test_properties()->force_render_surface = true;
9251 test_layer->SetForceRenderSurface(false); 9255 test_layer->test_properties()->force_render_surface = false;
9252 ExecuteCalculateDrawProperties(root); 9256 ExecuteCalculateDrawProperties(root);
9253 9257
9254 TransformTree transform_tree = 9258 TransformTree transform_tree =
9255 root->layer_tree_impl()->property_trees()->transform_tree; 9259 root->layer_tree_impl()->property_trees()->transform_tree;
9256 TransformNode* transform_node = 9260 TransformNode* transform_node =
9257 transform_tree.Node(significant_transform->transform_tree_index()); 9261 transform_tree.Node(significant_transform->transform_tree_index());
9258 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); 9262 EXPECT_EQ(transform_node->owner_id, significant_transform->id());
9259 9263
9260 EXPECT_TRUE(root->has_render_surface()); 9264 EXPECT_TRUE(root->has_render_surface());
9261 EXPECT_FALSE(significant_transform->has_render_surface()); 9265 EXPECT_FALSE(significant_transform->has_render_surface());
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
10123 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10127 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10124 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10128 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10125 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10129 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10126 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10130 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10127 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10131 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10128 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10132 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10129 } 10133 }
10130 10134
10131 } // namespace 10135 } // namespace
10132 } // namespace cc 10136 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698