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/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 LayerImpl* CreateTestTreeWithOneSurface() { | 90 LayerImpl* CreateTestTreeWithOneSurface() { |
91 host_impl_.active_tree()->ClearLayers(); | 91 host_impl_.active_tree()->ClearLayers(); |
92 std::unique_ptr<LayerImpl> root = | 92 std::unique_ptr<LayerImpl> root = |
93 LayerImpl::Create(host_impl_.active_tree(), 1); | 93 LayerImpl::Create(host_impl_.active_tree(), 1); |
94 std::unique_ptr<LayerImpl> child = | 94 std::unique_ptr<LayerImpl> child = |
95 LayerImpl::Create(host_impl_.active_tree(), 2); | 95 LayerImpl::Create(host_impl_.active_tree(), 2); |
96 | 96 |
97 root->SetPosition(gfx::PointF()); | 97 root->SetPosition(gfx::PointF()); |
98 root->SetBounds(gfx::Size(500, 500)); | 98 root->SetBounds(gfx::Size(500, 500)); |
99 root->SetDrawsContent(true); | 99 root->SetDrawsContent(true); |
100 root->SetForceRenderSurface(true); | 100 root->test_properties()->force_render_surface = true; |
101 | 101 |
102 child->SetPosition(gfx::PointF(100.f, 100.f)); | 102 child->SetPosition(gfx::PointF(100.f, 100.f)); |
103 child->SetBounds(gfx::Size(30, 30)); | 103 child->SetBounds(gfx::Size(30, 30)); |
104 child->SetDrawsContent(true); | 104 child->SetDrawsContent(true); |
105 root->AddChild(std::move(child)); | 105 root->AddChild(std::move(child)); |
106 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 106 host_impl_.active_tree()->SetRootLayer(std::move(root)); |
107 | 107 |
108 return host_impl_.active_tree()->root_layer(); | 108 return host_impl_.active_tree()->root_layer(); |
109 } | 109 } |
110 | 110 |
(...skipping 10 matching lines...) Expand all Loading... | |
121 std::unique_ptr<LayerImpl> child2 = | 121 std::unique_ptr<LayerImpl> child2 = |
122 LayerImpl::Create(host_impl_.active_tree(), 3); | 122 LayerImpl::Create(host_impl_.active_tree(), 3); |
123 std::unique_ptr<LayerImpl> grand_child1 = | 123 std::unique_ptr<LayerImpl> grand_child1 = |
124 LayerImpl::Create(host_impl_.active_tree(), 4); | 124 LayerImpl::Create(host_impl_.active_tree(), 4); |
125 std::unique_ptr<LayerImpl> grand_child2 = | 125 std::unique_ptr<LayerImpl> grand_child2 = |
126 LayerImpl::Create(host_impl_.active_tree(), 5); | 126 LayerImpl::Create(host_impl_.active_tree(), 5); |
127 | 127 |
128 root->SetPosition(gfx::PointF()); | 128 root->SetPosition(gfx::PointF()); |
129 root->SetBounds(gfx::Size(500, 500)); | 129 root->SetBounds(gfx::Size(500, 500)); |
130 root->SetDrawsContent(true); | 130 root->SetDrawsContent(true); |
131 root->SetForceRenderSurface(true); | 131 root->test_properties()->force_render_surface = true; |
132 | 132 |
133 child1->SetPosition(gfx::PointF(100.f, 100.f)); | 133 child1->SetPosition(gfx::PointF(100.f, 100.f)); |
134 child1->SetBounds(gfx::Size(30, 30)); | 134 child1->SetBounds(gfx::Size(30, 30)); |
135 // With a child that draws_content, opacity will cause the layer to create | 135 // With a child that draws_content, opacity will cause the layer to create |
136 // its own RenderSurface. This layer does not draw, but is intended to | 136 // its own RenderSurface. This layer does not draw, but is intended to |
137 // create its own RenderSurface. | 137 // create its own RenderSurface. |
138 child1->SetDrawsContent(false); | 138 child1->SetDrawsContent(false); |
139 child1->SetForceRenderSurface(true); | 139 child1->test_properties()->force_render_surface = true; |
140 | 140 |
141 child2->SetPosition(gfx::PointF(11.f, 11.f)); | 141 child2->SetPosition(gfx::PointF(11.f, 11.f)); |
142 child2->SetBounds(gfx::Size(18, 18)); | 142 child2->SetBounds(gfx::Size(18, 18)); |
143 child2->SetDrawsContent(true); | 143 child2->SetDrawsContent(true); |
144 | 144 |
145 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); | 145 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); |
146 grand_child1->SetBounds(gfx::Size(6, 8)); | 146 grand_child1->SetBounds(gfx::Size(6, 8)); |
147 grand_child1->SetDrawsContent(true); | 147 grand_child1->SetDrawsContent(true); |
148 | 148 |
149 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); | 149 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 root->render_surface()->damage_tracker()->current_damage_rect(); | 372 root->render_surface()->damage_tracker()->current_damage_rect(); |
373 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18))); | 373 EXPECT_EQ(true, root_damage_rect.Contains(gfx::Rect(105, 110, 17, 18))); |
374 } | 374 } |
375 | 375 |
376 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { | 376 TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { |
377 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 377 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
378 LayerImpl* child = root->children()[0]; | 378 LayerImpl* child = root->children()[0]; |
379 | 379 |
380 // CASE 1: The layer's property changed flag takes priority over update rect. | 380 // CASE 1: The layer's property changed flag takes priority over update rect. |
381 // | 381 // |
382 child->SetForceRenderSurface(true); | 382 child->test_properties()->force_render_surface = true; |
383 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 383 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
384 EmulateDrawingOneFrame(root); | 384 EmulateDrawingOneFrame(root); |
385 ClearDamageForAllSurfaces(root); | 385 ClearDamageForAllSurfaces(root); |
386 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 386 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
387 child->OnOpacityAnimated(0.5f); | 387 child->OnOpacityAnimated(0.5f); |
388 EmulateDrawingOneFrame(root); | 388 EmulateDrawingOneFrame(root); |
389 | 389 |
390 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 390 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
391 | 391 |
392 // Damage should be the entire child layer in target_surface space. | 392 // Damage should be the entire child layer in target_surface space. |
(...skipping 28 matching lines...) Expand all Loading... | |
421 root->render_surface()->damage_tracker()->current_damage_rect(); | 421 root->render_surface()->damage_tracker()->current_damage_rect(); |
422 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); | 422 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); |
423 } | 423 } |
424 | 424 |
425 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { | 425 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { |
426 // If a layer is transformed, the damage rect should still enclose the entire | 426 // If a layer is transformed, the damage rect should still enclose the entire |
427 // transformed layer. | 427 // transformed layer. |
428 | 428 |
429 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 429 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
430 LayerImpl* child = root->children()[0]; | 430 LayerImpl* child = root->children()[0]; |
431 child->SetForceRenderSurface(true); | 431 child->test_properties()->force_render_surface = true; |
432 | 432 |
433 gfx::Transform rotation; | 433 gfx::Transform rotation; |
434 rotation.Rotate(45.0); | 434 rotation.Rotate(45.0); |
435 | 435 |
436 ClearDamageForAllSurfaces(root); | 436 ClearDamageForAllSurfaces(root); |
437 child->test_properties()->transform_origin = gfx::Point3F( | 437 child->test_properties()->transform_origin = gfx::Point3F( |
438 child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f); | 438 child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f); |
439 child->SetPosition(gfx::PointF(85.f, 85.f)); | 439 child->SetPosition(gfx::PointF(85.f, 85.f)); |
440 child->NoteLayerPropertyChanged(); | 440 child->NoteLayerPropertyChanged(); |
441 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 441 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 EmulateDrawingOneFrame(root); | 496 EmulateDrawingOneFrame(root); |
497 | 497 |
498 // Sanity check that the child layer's bounds would actually get clipped by | 498 // Sanity check that the child layer's bounds would actually get clipped by |
499 // w < 0, otherwise this test is not actually testing the intended scenario. | 499 // w < 0, otherwise this test is not actually testing the intended scenario. |
500 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); | 500 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); |
501 bool clipped = false; | 501 bool clipped = false; |
502 MathUtil::MapQuad(transform, test_quad, &clipped); | 502 MathUtil::MapQuad(transform, test_quad, &clipped); |
503 EXPECT_TRUE(clipped); | 503 EXPECT_TRUE(clipped); |
504 | 504 |
505 // Damage the child without moving it. | 505 // Damage the child without moving it. |
506 child->SetForceRenderSurface(true); | 506 child->test_properties()->force_render_surface = true; |
507 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 507 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
508 EmulateDrawingOneFrame(root); | 508 EmulateDrawingOneFrame(root); |
509 ClearDamageForAllSurfaces(root); | 509 ClearDamageForAllSurfaces(root); |
510 child->OnOpacityAnimated(0.5f); | 510 child->OnOpacityAnimated(0.5f); |
511 EmulateDrawingOneFrame(root); | 511 EmulateDrawingOneFrame(root); |
512 | 512 |
513 // The expected damage should cover the entire root surface (500x500), but we | 513 // The expected damage should cover the entire root surface (500x500), but we |
514 // don't care whether the damage rect was clamped or is larger than the | 514 // don't care whether the damage rect was clamped or is larger than the |
515 // surface for this test. | 515 // surface for this test. |
516 gfx::Rect root_damage_rect = | 516 gfx::Rect root_damage_rect = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 | 565 |
566 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( | 566 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( |
567 SkBlurImageFilter::Create(SkIntToScalar(2), SkIntToScalar(2))); | 567 SkBlurImageFilter::Create(SkIntToScalar(2), SkIntToScalar(2))); |
568 FilterOperations filters; | 568 FilterOperations filters; |
569 filters.Append(FilterOperation::CreateReferenceFilter(filter)); | 569 filters.Append(FilterOperation::CreateReferenceFilter(filter)); |
570 int outset_top, outset_right, outset_bottom, outset_left; | 570 int outset_top, outset_right, outset_bottom, outset_left; |
571 filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left); | 571 filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left); |
572 | 572 |
573 // Setting the filter will damage the whole surface. | 573 // Setting the filter will damage the whole surface. |
574 ClearDamageForAllSurfaces(root); | 574 ClearDamageForAllSurfaces(root); |
575 child->SetForceRenderSurface(true); | 575 child->test_properties()->force_render_surface = true; |
576 child->NoteLayerPropertyChanged(); | |
ajuma
2016/04/22 18:04:45
It looks like this test has been relying on SetFor
jaydasika
2016/04/22 19:19:08
Done.
| |
576 child->SetFilters(filters); | 577 child->SetFilters(filters); |
577 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 578 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
578 EmulateDrawingOneFrame(root); | 579 EmulateDrawingOneFrame(root); |
579 root_damage_rect = | 580 root_damage_rect = |
580 root->render_surface()->damage_tracker()->current_damage_rect(); | 581 root->render_surface()->damage_tracker()->current_damage_rect(); |
581 child_damage_rect = | 582 child_damage_rect = |
582 child->render_surface()->damage_tracker()->current_damage_rect(); | 583 child->render_surface()->damage_tracker()->current_damage_rect(); |
583 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), | 584 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), |
584 root_damage_rect.ToString()); | 585 root_damage_rect.ToString()); |
585 EXPECT_EQ( | 586 EXPECT_EQ( |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 root->render_surface()->damage_tracker()->current_damage_rect(); | 862 root->render_surface()->damage_tracker()->current_damage_rect(); |
862 EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), | 863 EXPECT_EQ(gfx::Rect(100, 100, 303, 284).ToString(), |
863 root_damage_rect.ToString()); | 864 root_damage_rect.ToString()); |
864 } | 865 } |
865 | 866 |
866 TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { | 867 TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { |
867 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 868 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
868 LayerImpl* child1 = root->children()[0]; | 869 LayerImpl* child1 = root->children()[0]; |
869 LayerImpl* child2 = root->children()[1]; | 870 LayerImpl* child2 = root->children()[1]; |
870 LayerImpl* grand_child1 = root->children()[0]->children()[0]; | 871 LayerImpl* grand_child1 = root->children()[0]->children()[0]; |
871 child2->SetForceRenderSurface(true); | 872 child2->test_properties()->force_render_surface = true; |
872 grand_child1->SetForceRenderSurface(true); | 873 grand_child1->test_properties()->force_render_surface = true; |
873 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 874 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
874 EmulateDrawingOneFrame(root); | 875 EmulateDrawingOneFrame(root); |
875 gfx::Rect child_damage_rect; | 876 gfx::Rect child_damage_rect; |
876 gfx::Rect root_damage_rect; | 877 gfx::Rect root_damage_rect; |
877 | 878 |
878 // CASE 1: Damage to a descendant surface should propagate properly to | 879 // CASE 1: Damage to a descendant surface should propagate properly to |
879 // ancestor surface. | 880 // ancestor surface. |
880 ClearDamageForAllSurfaces(root); | 881 ClearDamageForAllSurfaces(root); |
881 grand_child1->OnOpacityAnimated(0.5f); | 882 grand_child1->OnOpacityAnimated(0.5f); |
882 EmulateDrawingOneFrame(root); | 883 EmulateDrawingOneFrame(root); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 | 987 |
987 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { | 988 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { |
988 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 989 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
989 LayerImpl* child1 = root->children()[0]; | 990 LayerImpl* child1 = root->children()[0]; |
990 gfx::Rect child_damage_rect; | 991 gfx::Rect child_damage_rect; |
991 gfx::Rect root_damage_rect; | 992 gfx::Rect root_damage_rect; |
992 | 993 |
993 // CASE 1: If a descendant surface disappears, its entire old area becomes | 994 // CASE 1: If a descendant surface disappears, its entire old area becomes |
994 // exposed. | 995 // exposed. |
995 ClearDamageForAllSurfaces(root); | 996 ClearDamageForAllSurfaces(root); |
996 child1->SetForceRenderSurface(false); | 997 child1->test_properties()->force_render_surface = false; |
997 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 998 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
998 EmulateDrawingOneFrame(root); | 999 EmulateDrawingOneFrame(root); |
999 | 1000 |
1000 // Sanity check that there is only one surface now. | 1001 // Sanity check that there is only one surface now. |
1001 ASSERT_FALSE(child1->render_surface()); | 1002 ASSERT_FALSE(child1->render_surface()); |
1002 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); | 1003 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); |
1003 | 1004 |
1004 root_damage_rect = | 1005 root_damage_rect = |
1005 root->render_surface()->damage_tracker()->current_damage_rect(); | 1006 root->render_surface()->damage_tracker()->current_damage_rect(); |
1006 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), | 1007 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
1007 root_damage_rect.ToString()); | 1008 root_damage_rect.ToString()); |
1008 | 1009 |
1009 // CASE 2: If a descendant surface appears, its entire old area becomes | 1010 // CASE 2: If a descendant surface appears, its entire old area becomes |
1010 // exposed. | 1011 // exposed. |
1011 | 1012 |
1012 // Cycle one frame of no change, just to sanity check that the next rect is | 1013 // Cycle one frame of no change, just to sanity check that the next rect is |
1013 // not because of the old damage state. | 1014 // not because of the old damage state. |
1014 ClearDamageForAllSurfaces(root); | 1015 ClearDamageForAllSurfaces(root); |
1015 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1016 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1016 EmulateDrawingOneFrame(root); | 1017 EmulateDrawingOneFrame(root); |
1017 root_damage_rect = | 1018 root_damage_rect = |
1018 root->render_surface()->damage_tracker()->current_damage_rect(); | 1019 root->render_surface()->damage_tracker()->current_damage_rect(); |
1019 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1020 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
1020 | 1021 |
1021 // Then change the tree so that the render surface is added back. | 1022 // Then change the tree so that the render surface is added back. |
1022 ClearDamageForAllSurfaces(root); | 1023 ClearDamageForAllSurfaces(root); |
1023 child1->SetForceRenderSurface(true); | 1024 child1->test_properties()->force_render_surface = true; |
1024 | 1025 |
1025 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1026 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1026 EmulateDrawingOneFrame(root); | 1027 EmulateDrawingOneFrame(root); |
1027 | 1028 |
1028 // Sanity check that there is a new surface now. | 1029 // Sanity check that there is a new surface now. |
1029 ASSERT_TRUE(child1->render_surface()); | 1030 ASSERT_TRUE(child1->render_surface()); |
1030 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); | 1031 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); |
1031 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); | 1032 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); |
1032 | 1033 |
1033 child_damage_rect = | 1034 child_damage_rect = |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1121 // | 1122 // |
1122 ClearDamageForAllSurfaces(root); | 1123 ClearDamageForAllSurfaces(root); |
1123 { | 1124 { |
1124 std::unique_ptr<LayerImpl> grand_child1_replica = | 1125 std::unique_ptr<LayerImpl> grand_child1_replica = |
1125 LayerImpl::Create(host_impl_.active_tree(), 7); | 1126 LayerImpl::Create(host_impl_.active_tree(), 7); |
1126 grand_child1_replica->SetPosition(gfx::PointF()); | 1127 grand_child1_replica->SetPosition(gfx::PointF()); |
1127 gfx::Transform reflection; | 1128 gfx::Transform reflection; |
1128 reflection.Scale3d(-1.0, 1.0, 1.0); | 1129 reflection.Scale3d(-1.0, 1.0, 1.0); |
1129 grand_child1_replica->SetTransform(reflection); | 1130 grand_child1_replica->SetTransform(reflection); |
1130 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); | 1131 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); |
1131 grand_child1->SetForceRenderSurface(true); | 1132 grand_child1->test_properties()->force_render_surface = true; |
1133 grand_child1->NoteLayerPropertyChanged(); | |
ajuma
2016/04/22 18:04:45
This one's a bit trickier, since replicas don't or
jaydasika
2016/04/22 19:19:08
Added a test.
| |
1132 } | 1134 } |
1133 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1135 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1134 EmulateDrawingOneFrame(root); | 1136 EmulateDrawingOneFrame(root); |
1135 | 1137 |
1136 gfx::Rect grand_child_damage_rect = | 1138 gfx::Rect grand_child_damage_rect = |
1137 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); | 1139 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); |
1138 gfx::Rect child_damage_rect = | 1140 gfx::Rect child_damage_rect = |
1139 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1141 child1->render_surface()->damage_tracker()->current_damage_rect(); |
1140 gfx::Rect root_damage_rect = | 1142 gfx::Rect root_damage_rect = |
1141 root->render_surface()->damage_tracker()->current_damage_rect(); | 1143 root->render_surface()->damage_tracker()->current_damage_rect(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1175 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); | 1177 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); |
1176 EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(), | 1178 EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(), |
1177 child_damage_rect.ToString()); | 1179 child_damage_rect.ToString()); |
1178 EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(), | 1180 EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(), |
1179 root_damage_rect.ToString()); | 1181 root_damage_rect.ToString()); |
1180 | 1182 |
1181 // CASE 3: removing the reflection should cause the entire region including | 1183 // CASE 3: removing the reflection should cause the entire region including |
1182 // reflection to damage the target surface. | 1184 // reflection to damage the target surface. |
1183 ClearDamageForAllSurfaces(root); | 1185 ClearDamageForAllSurfaces(root); |
1184 grand_child1->SetReplicaLayer(nullptr); | 1186 grand_child1->SetReplicaLayer(nullptr); |
1185 grand_child1->SetForceRenderSurface(false); | 1187 grand_child1->test_properties()->force_render_surface = false; |
1188 grand_child1->NoteLayerPropertyChanged(); | |
1186 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1189 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1187 EmulateDrawingOneFrame(root); | 1190 EmulateDrawingOneFrame(root); |
1188 ASSERT_EQ(old_content_rect.width(), | 1191 ASSERT_EQ(old_content_rect.width(), |
1189 child1->render_surface()->content_rect().width()); | 1192 child1->render_surface()->content_rect().width()); |
1190 ASSERT_EQ(old_content_rect.height(), | 1193 ASSERT_EQ(old_content_rect.height(), |
1191 child1->render_surface()->content_rect().height()); | 1194 child1->render_surface()->content_rect().height()); |
1192 | 1195 |
1193 EXPECT_FALSE(grand_child1->render_surface()); | 1196 EXPECT_FALSE(grand_child1->render_surface()); |
1194 child_damage_rect = | 1197 child_damage_rect = |
1195 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1198 child1->render_surface()->damage_tracker()->current_damage_rect(); |
(...skipping 14 matching lines...) Expand all Loading... | |
1210 | 1213 |
1211 ClearDamageForAllSurfaces(root); | 1214 ClearDamageForAllSurfaces(root); |
1212 | 1215 |
1213 // Set up the mask layer. | 1216 // Set up the mask layer. |
1214 { | 1217 { |
1215 std::unique_ptr<LayerImpl> mask_layer = | 1218 std::unique_ptr<LayerImpl> mask_layer = |
1216 LayerImpl::Create(host_impl_.active_tree(), 3); | 1219 LayerImpl::Create(host_impl_.active_tree(), 3); |
1217 mask_layer->SetPosition(child->position()); | 1220 mask_layer->SetPosition(child->position()); |
1218 mask_layer->SetBounds(child->bounds()); | 1221 mask_layer->SetBounds(child->bounds()); |
1219 child->SetMaskLayer(std::move(mask_layer)); | 1222 child->SetMaskLayer(std::move(mask_layer)); |
1220 child->SetForceRenderSurface(true); | 1223 child->test_properties()->force_render_surface = true; |
1221 } | 1224 } |
1222 LayerImpl* mask_layer = child->mask_layer(); | 1225 LayerImpl* mask_layer = child->mask_layer(); |
1223 | 1226 |
1224 // Add opacity and a grand_child so that the render surface persists even | 1227 // Add opacity and a grand_child so that the render surface persists even |
1225 // after we remove the mask. | 1228 // after we remove the mask. |
1226 { | 1229 { |
1227 std::unique_ptr<LayerImpl> grand_child = | 1230 std::unique_ptr<LayerImpl> grand_child = |
1228 LayerImpl::Create(host_impl_.active_tree(), 4); | 1231 LayerImpl::Create(host_impl_.active_tree(), 4); |
1229 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); | 1232 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); |
1230 grand_child->SetBounds(gfx::Size(2, 2)); | 1233 grand_child->SetBounds(gfx::Size(2, 2)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 | 1309 |
1307 // Create a reflection about the left edge of grand_child1. | 1310 // Create a reflection about the left edge of grand_child1. |
1308 { | 1311 { |
1309 std::unique_ptr<LayerImpl> grand_child1_replica = | 1312 std::unique_ptr<LayerImpl> grand_child1_replica = |
1310 LayerImpl::Create(host_impl_.active_tree(), 6); | 1313 LayerImpl::Create(host_impl_.active_tree(), 6); |
1311 grand_child1_replica->SetPosition(gfx::PointF()); | 1314 grand_child1_replica->SetPosition(gfx::PointF()); |
1312 gfx::Transform reflection; | 1315 gfx::Transform reflection; |
1313 reflection.Scale3d(-1.0, 1.0, 1.0); | 1316 reflection.Scale3d(-1.0, 1.0, 1.0); |
1314 grand_child1_replica->SetTransform(reflection); | 1317 grand_child1_replica->SetTransform(reflection); |
1315 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); | 1318 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); |
1316 grand_child1->SetForceRenderSurface(true); | 1319 grand_child1->test_properties()->force_render_surface = true; |
1317 } | 1320 } |
1318 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1321 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
1319 | 1322 |
1320 // Set up the mask layer on the replica layer | 1323 // Set up the mask layer on the replica layer |
1321 { | 1324 { |
1322 std::unique_ptr<LayerImpl> replica_mask_layer = | 1325 std::unique_ptr<LayerImpl> replica_mask_layer = |
1323 LayerImpl::Create(host_impl_.active_tree(), 7); | 1326 LayerImpl::Create(host_impl_.active_tree(), 7); |
1324 replica_mask_layer->SetPosition(gfx::PointF()); | 1327 replica_mask_layer->SetPosition(gfx::PointF()); |
1325 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1328 replica_mask_layer->SetBounds(grand_child1->bounds()); |
1326 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); | 1329 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1388 | 1391 |
1389 // This is the anchor being tested. | 1392 // This is the anchor being tested. |
1390 grand_child1_replica->test_properties()->transform_origin = | 1393 grand_child1_replica->test_properties()->transform_origin = |
1391 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f); | 1394 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f); |
1392 gfx::Transform reflection; | 1395 gfx::Transform reflection; |
1393 reflection.Scale3d(-1.0, 1.0, 1.0); | 1396 reflection.Scale3d(-1.0, 1.0, 1.0); |
1394 grand_child1_replica->SetTransform(reflection); | 1397 grand_child1_replica->SetTransform(reflection); |
1395 // We need to set parent on replica layer for property tree building. | 1398 // We need to set parent on replica layer for property tree building. |
1396 grand_child1_replica->SetParent(grand_child1); | 1399 grand_child1_replica->SetParent(grand_child1); |
1397 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); | 1400 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); |
1398 grand_child1->SetForceRenderSurface(true); | 1401 grand_child1->test_properties()->force_render_surface = true; |
1399 } | 1402 } |
1400 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1403 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
1401 | 1404 |
1402 // Set up the mask layer on the replica layer | 1405 // Set up the mask layer on the replica layer |
1403 { | 1406 { |
1404 std::unique_ptr<LayerImpl> replica_mask_layer = | 1407 std::unique_ptr<LayerImpl> replica_mask_layer = |
1405 LayerImpl::Create(host_impl_.active_tree(), 7); | 1408 LayerImpl::Create(host_impl_.active_tree(), 7); |
1406 replica_mask_layer->SetPosition(gfx::PointF()); | 1409 replica_mask_layer->SetPosition(gfx::PointF()); |
1407 // Note: this is not the transform origin being tested. | 1410 // Note: this is not the transform origin being tested. |
1408 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1411 replica_mask_layer->SetBounds(grand_child1->bounds()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1460 root->render_surface()->damage_tracker()->current_damage_rect(); | 1463 root->render_surface()->damage_tracker()->current_damage_rect(); |
1461 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); | 1464 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); |
1462 } | 1465 } |
1463 | 1466 |
1464 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { | 1467 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { |
1465 // Though it should never happen, its a good idea to verify that the damage | 1468 // Though it should never happen, its a good idea to verify that the damage |
1466 // tracker does not crash when it receives an empty layer_list. | 1469 // tracker does not crash when it receives an empty layer_list. |
1467 | 1470 |
1468 std::unique_ptr<LayerImpl> root = | 1471 std::unique_ptr<LayerImpl> root = |
1469 LayerImpl::Create(host_impl_.active_tree(), 1); | 1472 LayerImpl::Create(host_impl_.active_tree(), 1); |
1470 root->SetForceRenderSurface(true); | 1473 root->test_properties()->force_render_surface = true; |
1471 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 1474 host_impl_.active_tree()->SetRootLayer(std::move(root)); |
1472 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer(); | 1475 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer(); |
1473 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1476 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1474 EmulateDrawingOneFrame(root_ptr); | 1477 EmulateDrawingOneFrame(root_ptr); |
1475 | 1478 |
1476 DCHECK_EQ(root_ptr->render_surface(), root_ptr->render_target()); | 1479 DCHECK_EQ(root_ptr->render_surface(), root_ptr->render_target()); |
1477 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); | 1480 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); |
1478 | 1481 |
1479 LayerImplList empty_list; | 1482 LayerImplList empty_list; |
1480 target_surface->damage_tracker()->UpdateDamageTrackingState( | 1483 target_surface->damage_tracker()->UpdateDamageTrackingState( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1554 gfx::Rect root_damage_rect = | 1557 gfx::Rect root_damage_rect = |
1555 root->render_surface()->damage_tracker()->current_damage_rect(); | 1558 root->render_surface()->damage_tracker()->current_damage_rect(); |
1556 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1559 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
1557 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1560 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
1558 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1561 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
1559 } | 1562 } |
1560 } | 1563 } |
1561 | 1564 |
1562 } // namespace | 1565 } // namespace |
1563 } // namespace cc | 1566 } // namespace cc |
OLD | NEW |