diff options
Diffstat (limited to 'chromium/cc/trees/damage_tracker_unittest.cc')
-rw-r--r-- | chromium/cc/trees/damage_tracker_unittest.cc | 977 |
1 files changed, 449 insertions, 528 deletions
diff --git a/chromium/cc/trees/damage_tracker_unittest.cc b/chromium/cc/trees/damage_tracker_unittest.cc index f5bb60b229d..d2636625dfb 100644 --- a/chromium/cc/trees/damage_tracker_unittest.cc +++ b/chromium/cc/trees/damage_tracker_unittest.cc @@ -10,12 +10,10 @@ #include "cc/layers/layer_impl.h" #include "cc/paint/filter_operation.h" #include "cc/paint/filter_operations.h" -#include "cc/test/fake_impl_task_runner_provider.h" -#include "cc/test/fake_layer_tree_host_impl.h" +#include "cc/test/fake_picture_layer_impl.h" +#include "cc/test/fake_raster_source.h" #include "cc/test/geometry_test_utils.h" -#include "cc/test/layer_test_common.h" -#include "cc/test/test_task_graph_runner.h" -#include "cc/trees/layer_tree_host_common.h" +#include "cc/test/layer_tree_impl_test_base.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/single_thread_proxy.h" #include "cc/trees/transform_node.h" @@ -28,7 +26,10 @@ namespace { class TestLayerImpl : public LayerImpl { public: - TestLayerImpl(LayerTreeImpl* tree_impl, int id); + static std::unique_ptr<TestLayerImpl> Create(LayerTreeImpl* tree_impl, + int id) { + return base::WrapUnique(new TestLayerImpl(tree_impl, id)); + } void AddDamageRect(const gfx::Rect& damage_rect); @@ -37,6 +38,8 @@ class TestLayerImpl : public LayerImpl { void ResetChangeTracking() override; private: + TestLayerImpl(LayerTreeImpl* tree_impl, int id); + gfx::Rect damage_rect_; }; @@ -56,21 +59,6 @@ void TestLayerImpl::ResetChangeTracking() { damage_rect_.SetRect(0, 0, 0, 0); } -void ExecuteCalculateDrawProperties(LayerImpl* root, - float device_scale_factor, - RenderSurfaceList* render_surface_list) { - // Sanity check: The test itself should create the root layer's render - // surface, so that the surface (and its damage tracker) can - // persist across multiple calls to this function. - ASSERT_FALSE(render_surface_list->size()); - - LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( - root, gfx::Rect(root->bounds()), device_scale_factor, - render_surface_list); - LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); - ASSERT_TRUE(GetRenderSurface(root)); -} - void ClearDamageForAllSurfaces(LayerImpl* root) { for (auto* layer : *root->layer_tree_impl()) { if (GetRenderSurface(layer)) @@ -78,48 +66,29 @@ void ClearDamageForAllSurfaces(LayerImpl* root) { } } -void EmulateDrawingOneFrame(LayerImpl* root, float device_scale_factor = 1.f) { - // This emulates only steps that are relevant to testing the damage tracker: - // 1. computing the render passes and layerlists - // 2. updating all damage trackers in the correct order - // 3. resetting all update_rects and property_changed flags for all layers - // and surfaces. - - RenderSurfaceList render_surface_list; - ExecuteCalculateDrawProperties(root, device_scale_factor, - &render_surface_list); - - DamageTracker::UpdateDamageTracking(root->layer_tree_impl(), - render_surface_list); - - root->layer_tree_impl()->ResetAllChangeTracking(); -} - -class DamageTrackerTest : public testing::Test { +class DamageTrackerTest : public LayerTreeImplTestBase, public testing::Test { public: - DamageTrackerTest() - : host_impl_(&task_runner_provider_, &task_graph_runner_) {} - LayerImpl* CreateTestTreeWithOneSurface(int number_of_children) { - host_impl_.active_tree()->DetachLayers(); - auto root = std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 1); + ClearLayersAndProperties(); + LayerImpl* root = root_layer(); root->SetBounds(gfx::Size(500, 500)); + root->layer_tree_impl()->SetDeviceViewportRect(gfx::Rect(root->bounds())); root->SetDrawsContent(true); - root->test_properties()->force_render_surface = true; + SetupRootProperties(root); + child_layers_.resize(number_of_children); for (int i = 0; i < number_of_children; ++i) { - auto child = - std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 2 + i); - child->test_properties()->position = gfx::PointF(100.f, 100.f); + auto* child = AddLayer<TestLayerImpl>(); child->SetBounds(gfx::Size(30, 30)); child->SetDrawsContent(true); - root->test_properties()->AddChild(std::move(child)); + child_layers_[i] = child; + CopyProperties(root, child); + child->SetOffsetToTransformParent(gfx::Vector2dF(100.f, 100.f)); } - host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); - host_impl_.active_tree()->SetElementIdsForTesting(); + SetElementIdsForTesting(); - return host_impl_.active_tree()->root_layer_for_testing(); + return root; } LayerImpl* CreateTestTreeWithTwoSurfaces() { @@ -127,47 +96,47 @@ class DamageTrackerTest : public testing::Test { // child1. Additionally, the root has a second child layer, and child1 has // two children of its own. - host_impl_.active_tree()->DetachLayers(); - auto root = std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 1); - auto child1 = std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 2); - auto child2 = std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 3); - auto grand_child1 = - std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 4); - auto grand_child2 = - std::make_unique<TestLayerImpl>(host_impl_.active_tree(), 5); + ClearLayersAndProperties(); + LayerImpl* root = root_layer(); root->SetBounds(gfx::Size(500, 500)); + root->layer_tree_impl()->SetDeviceViewportRect(gfx::Rect(root->bounds())); root->SetDrawsContent(true); - root->test_properties()->force_render_surface = true; + SetupRootProperties(root); - child1->test_properties()->position = gfx::PointF(100.f, 100.f); - child1->SetBounds(gfx::Size(30, 30)); + child1_ = AddLayer<TestLayerImpl>(); + grand_child1_ = AddLayer<TestLayerImpl>(); + grand_child2_ = AddLayer<TestLayerImpl>(); + child2_ = AddLayer<TestLayerImpl>(); + SetElementIdsForTesting(); + + child1_->SetBounds(gfx::Size(30, 30)); // With a child that draws_content, opacity will cause the layer to create // its own RenderSurface. This layer does not draw, but is intended to // create its own RenderSurface. - child1->SetDrawsContent(false); - child1->test_properties()->force_render_surface = true; - - child2->test_properties()->position = gfx::PointF(11.f, 11.f); - child2->SetBounds(gfx::Size(18, 18)); - child2->SetDrawsContent(true); - - grand_child1->test_properties()->position = gfx::PointF(200.f, 200.f); - grand_child1->SetBounds(gfx::Size(6, 8)); - grand_child1->SetDrawsContent(true); - - grand_child2->test_properties()->position = gfx::PointF(190.f, 190.f); - grand_child2->SetBounds(gfx::Size(6, 8)); - grand_child2->SetDrawsContent(true); + child1_->SetDrawsContent(false); + CopyProperties(root, child1_); + CreateTransformNode(child1_).post_translation = + gfx::Vector2dF(100.f, 100.f); + CreateEffectNode(child1_).render_surface_reason = + RenderSurfaceReason::kTest; + + grand_child1_->SetBounds(gfx::Size(6, 8)); + grand_child1_->SetDrawsContent(true); + CopyProperties(child1_, grand_child1_); + grand_child1_->SetOffsetToTransformParent(gfx::Vector2dF(200.f, 200.f)); + + grand_child2_->SetBounds(gfx::Size(6, 8)); + grand_child2_->SetDrawsContent(true); + CopyProperties(child1_, grand_child2_); + grand_child2_->SetOffsetToTransformParent(gfx::Vector2dF(190.f, 190.f)); + + child2_->SetBounds(gfx::Size(18, 18)); + child2_->SetDrawsContent(true); + CopyProperties(root, child2_); + child2_->SetOffsetToTransformParent(gfx::Vector2dF(11.f, 11.f)); - child1->test_properties()->AddChild(std::move(grand_child1)); - child1->test_properties()->AddChild(std::move(grand_child2)); - root->test_properties()->AddChild(std::move(child1)); - root->test_properties()->AddChild(std::move(child2)); - host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); - host_impl_.active_tree()->SetElementIdsForTesting(); - - return host_impl_.active_tree()->root_layer_for_testing(); + return root; } LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { @@ -175,7 +144,6 @@ class DamageTrackerTest : public testing::Test { // Setup includes going past the first frame which always damages // everything, so that we can actually perform specific tests. - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); return root; @@ -186,16 +154,44 @@ class DamageTrackerTest : public testing::Test { // Setup includes going past the first frame which always damages // everything, so that we can actually perform specific tests. - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); return root; } + void EmulateDrawingOneFrame(LayerImpl* root, + float device_scale_factor = 1.f) { + // This emulates only steps that are relevant to testing the damage tracker: + // 1. computing the render passes and layerlists + // 2. updating all damage trackers in the correct order + // 3. resetting all update_rects and property_changed flags for all layers + // and surfaces. + + root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); + root->layer_tree_impl()->set_needs_update_draw_properties(); + UpdateDrawProperties(root->layer_tree_impl()); + + DamageTracker::UpdateDamageTracking(root->layer_tree_impl()); + + root->layer_tree_impl()->ResetAllChangeTracking(); + } + protected: - FakeImplTaskRunnerProvider task_runner_provider_; - TestTaskGraphRunner task_graph_runner_; - FakeLayerTreeHostImpl host_impl_; + void ClearLayersAndProperties() { + host_impl()->active_tree()->DetachLayersKeepingRootLayerForTesting(); + host_impl()->active_tree()->property_trees()->clear(); + child_layers_.clear(); + child1_ = child2_ = grand_child1_ = grand_child2_ = nullptr; + } + + // Stores result of CreateTestTreeWithOneSurface(). + std::vector<TestLayerImpl*> child_layers_; + + // Store result of CreateTestTreeWithTwoSurfaces(). + TestLayerImpl* child1_ = nullptr; + TestLayerImpl* child2_ = nullptr; + TestLayerImpl* grand_child1_ = nullptr; + TestLayerImpl* grand_child2_ = nullptr; }; TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { @@ -203,7 +199,7 @@ TEST_F(DamageTrackerTest, SanityCheckTestTreeWithOneSurface) { // render surfaces. LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; EXPECT_EQ(2, GetRenderSurface(root)->num_contributors()); EXPECT_TRUE(root->contributes_to_drawn_render_surface()); @@ -225,23 +221,20 @@ TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* child2 = root->test_properties()->children[1]; - gfx::Rect child_damage_rect; - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); gfx::Rect root_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); - EXPECT_NE(GetRenderSurface(child1), GetRenderSurface(root)); - EXPECT_EQ(GetRenderSurface(child2), GetRenderSurface(root)); + EXPECT_NE(GetRenderSurface(child1_), GetRenderSurface(root)); + EXPECT_EQ(GetRenderSurface(child2_), GetRenderSurface(root)); EXPECT_EQ(3, GetRenderSurface(root)->num_contributors()); - EXPECT_EQ(2, GetRenderSurface(child1)->num_contributors()); + EXPECT_EQ(2, GetRenderSurface(child1_)->num_contributors()); - // The render surface for child1 only has a content_rect that encloses - // grand_child1 and grand_child2, because child1 does not draw content. + // The render surface for child1_ only has a content_rect that encloses + // grand_child1_ and grand_child2_, because child1_ does not draw content. EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), child_damage_rect.ToString()); EXPECT_EQ(gfx::Rect(500, 500).ToString(), root_damage_rect.ToString()); @@ -249,20 +242,19 @@ TEST_F(DamageTrackerTest, SanityCheckTestTreeWithTwoSurfaces) { EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; // CASE 1: Setting the update rect should cause the corresponding damage to // the surface. ClearDamageForAllSurfaces(root); child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of update_rect (10, 11) @@ -277,7 +269,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // damage. ClearDamageForAllSurfaces(root); child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -288,7 +279,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // update region, but no additional exposed old region. ClearDamageForAllSurfaces(root); child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of update_rect (20, 25) @@ -303,14 +293,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - auto* child = - static_cast<TestLayerImpl*>(root->test_properties()->children[0]); + TestLayerImpl* child = child_layers_[0]; // CASE 1: Adding the layer damage rect should cause the corresponding damage // to the surface. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of layer damage_rect @@ -324,7 +312,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { // damage. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -334,7 +321,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { // new damaged region, but no additional exposed old region. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of layer damage_rect @@ -348,7 +334,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(20, 25, 1, 2)); child->AddDamageRect(gfx::Rect(10, 15, 3, 4)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of layer damage_rect @@ -364,15 +349,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerDamageRects) { TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - auto* child = - static_cast<TestLayerImpl*>(root->test_properties()->children[0]); + TestLayerImpl* child = child_layers_[0]; // CASE 1: Adding the layer damage rect and update rect should cause the // corresponding damage to the surface. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(5, 6, 12, 13)); child->SetUpdateRect(gfx::Rect(15, 16, 14, 10)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of unified layer @@ -388,7 +371,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); child->SetUpdateRect(gfx::Rect(10, 11, 14, 15)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -399,7 +381,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(20, 25, 2, 3)); child->SetUpdateRect(gfx::Rect(5, 10, 7, 8)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of unified layer damage @@ -414,12 +395,11 @@ TEST_F(DamageTrackerTest, VerifyDamageForLayerUpdateAndDamageRects) { TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; // CASE 1: The layer's property changed flag takes priority over update rect. // - child->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); @@ -448,7 +428,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { // Cycle one frame of no change, just to sanity check that the next rect is // not because of the old damage state. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -456,6 +435,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { // Then, test the actual layer movement. ClearDamageForAllSurfaces(root); + CreateTransformNode(child).post_translation = + child->offset_to_transform_parent(); + child->SetOffsetToTransformParent(gfx::Vector2dF()); gfx::Transform translation; translation.Translate(100.f, 130.f); root->layer_tree_impl()->SetTransformMutated(child->element_id(), @@ -470,57 +452,53 @@ TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - // Transform from browser animation should not be considered as damage from - // contributing layer since it is applied to the whole layer which has a - // render surface. - EXPECT_FALSE(GetRenderSurface(child) - ->damage_tracker() - ->has_damage_from_contributing_content()); + // TODO(crbug.com/1001882): Transform from browser animation should not be + // considered as damage from contributing layer since it is applied to the + // whole layer which has a render surface. + EXPECT_TRUE(GetRenderSurface(child) + ->damage_tracker() + ->has_damage_from_contributing_content()); } TEST_F(DamageTrackerTest, VerifyDamageForPropertyChangesFromContributingContents) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* child2 = root->test_properties()->children[1]; - LayerImpl* grandchild1 = child1->test_properties()->children[0]; - // CASE 1: The child1's opacity changed. + // CASE 1: child1_'s opacity changed. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->SetOpacityMutated(child1->element_id(), 0.5f); + root->layer_tree_impl()->SetOpacityMutated(child1_->element_id(), 0.5f); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child1) + EXPECT_FALSE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); - // CASE 2: The layer2's opacity changed. - child2->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + // CASE 2: layer2_'s opacity changed. + CreateEffectNode(child2_).render_surface_reason = RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->SetOpacityMutated(child2->element_id(), 0.5f); + root->layer_tree_impl()->SetOpacityMutated(child2_->element_id(), 0.5f); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child1) + EXPECT_FALSE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); - // CASE 3: The grandchild1's opacity changed. - grandchild1->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + // CASE 3: grand_child1_'s opacity changed. + CreateEffectNode(grand_child1_).render_surface_reason = + RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->SetOpacityMutated(grandchild1->element_id(), 0.5f); + root->layer_tree_impl()->SetOpacityMutated(grand_child1_->element_id(), 0.5f); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } @@ -528,11 +506,12 @@ TEST_F(DamageTrackerTest, // Regression test for http://crbug.com/923794 TEST_F(DamageTrackerTest, EffectPropertyChangeNoSurface) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; // Create a separate effect node for the child, but no render surface. - child->test_properties()->opacity = 0.5; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + auto& effect_node = CreateEffectNode(child); + effect_node.opacity = 0.5; + effect_node.has_potential_opacity_animation = true; EmulateDrawingOneFrame(root); EXPECT_EQ(root->transform_tree_index(), child->transform_tree_index()); @@ -550,13 +529,12 @@ TEST_F(DamageTrackerTest, EffectPropertyChangeNoSurface) { // Regression test for http://crbug.com/923794 TEST_F(DamageTrackerTest, TransformPropertyChangeNoSurface) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; // Create a separate transform node for the child, but no render surface. gfx::Transform trans1; trans1.Scale(2, 1); - child->test_properties()->transform = trans1; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + CreateTransformNode(child).local = trans1; EmulateDrawingOneFrame(root); EXPECT_NE(root->transform_tree_index(), child->transform_tree_index()); @@ -576,66 +554,58 @@ TEST_F(DamageTrackerTest, TransformPropertyChangeNoSurface) { TEST_F(DamageTrackerTest, VerifyDamageForUpdateAndDamageRectsFromContributingContents) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - auto* child1 = - static_cast<TestLayerImpl*>(root->test_properties()->children[0]); - auto* child2 = - static_cast<TestLayerImpl*>(root->test_properties()->children[1]); - auto* grandchild1 = - static_cast<TestLayerImpl*>(child1->test_properties()->children[0]); - - // CASE 1: Adding the layer1's damage rect and update rect should cause the + + // CASE 1: Adding child1_'s damage rect and update rect should cause the // corresponding damage to the surface. - child1->SetDrawsContent(true); + child1_->SetDrawsContent(true); ClearDamageForAllSurfaces(root); - child1->AddDamageRect(gfx::Rect(105, 106, 12, 15)); - child1->SetUpdateRect(gfx::Rect(115, 116, 12, 15)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + child1_->AddDamageRect(gfx::Rect(105, 106, 12, 15)); + child1_->SetUpdateRect(gfx::Rect(115, 116, 12, 15)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); - // CASE 2: Adding the layer2's damage rect and update rect should cause the + // CASE 2: Adding child2_'s damage rect and update rect should cause the // corresponding damage to the surface. ClearDamageForAllSurfaces(root); - child2->AddDamageRect(gfx::Rect(11, 11, 12, 15)); - child2->SetUpdateRect(gfx::Rect(12, 12, 12, 15)); + child2_->AddDamageRect(gfx::Rect(11, 11, 12, 15)); + child2_->SetUpdateRect(gfx::Rect(12, 12, 12, 15)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child1) + EXPECT_FALSE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); - // CASE 3: Adding the grandchild1's damage rect and update rect should cause + // CASE 3: Adding grand_child1_'s damage rect and update rect should cause // the corresponding damage to the surface. ClearDamageForAllSurfaces(root); - grandchild1->AddDamageRect(gfx::Rect(1, 0, 2, 5)); - grandchild1->SetUpdateRect(gfx::Rect(2, 1, 2, 5)); + grand_child1_->AddDamageRect(gfx::Rect(1, 0, 2, 5)); + grand_child1_->SetUpdateRect(gfx::Rect(2, 1, 2, 5)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* surface = root->test_properties()->children[0]; - LayerImpl* child = surface->test_properties()->children[0]; + LayerImpl* surface = child1_; + LayerImpl* child = grand_child1_; child->SetDrawsContent(true); EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); - surface->test_properties()->force_render_surface = false; + SetRenderSurfaceReason(surface, RenderSurfaceReason::kNone); child->SetDrawsContent(false); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); gfx::Rect root_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -652,18 +622,20 @@ TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { // transformed layer. LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; - child->test_properties()->force_render_surface = true; + LayerImpl* child = child_layers_[0]; gfx::Transform rotation; rotation.Rotate(45.0); ClearDamageForAllSurfaces(root); - child->test_properties()->transform_origin = gfx::Point3F( - child->bounds().width() * 0.5f, child->bounds().height() * 0.5f, 0.f); - child->test_properties()->position = gfx::PointF(85.f, 85.f); + auto& transform_node = CreateTransformNode(child); + transform_node.origin = gfx::Point3F(child->bounds().width() * 0.5f, + child->bounds().height() * 0.5f, 0.f); + transform_node.post_translation = gfx::Vector2dF(85.f, 85.f); + child->SetOffsetToTransformParent(gfx::Vector2dF()); + CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; + child->NoteLayerPropertyChanged(); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Sanity check that the layer actually moved to (85, 85), damaging its old @@ -723,7 +695,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { // LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; gfx::Transform transform; transform.Translate3d(550.0, 500.0, 0.0); @@ -732,23 +704,20 @@ TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { transform.Translate3d(-50.0, -50.0, 0.0); // Set up the child - child->test_properties()->position = gfx::PointF(0.f, 0.f); child->SetBounds(gfx::Size(100, 100)); - child->test_properties()->transform = transform; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + CreateTransformNode(child).local = transform; + child->SetOffsetToTransformParent(gfx::Vector2dF()); EmulateDrawingOneFrame(root); // Sanity check that the child layer's bounds would actually get clipped by // w < 0, otherwise this test is not actually testing the intended scenario. - gfx::RectF test_rect(child->test_properties()->position, - gfx::SizeF(child->bounds())); + gfx::RectF test_rect(gfx::SizeF(child->bounds())); bool clipped = false; MathUtil::MapQuad(transform, gfx::QuadF(test_rect), &clipped); EXPECT_TRUE(clipped); // Damage the child without moving it. - child->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); root->layer_tree_impl()->SetOpacityMutated(child->element_id(), 0.5f); @@ -772,20 +741,20 @@ TEST_F(DamageTrackerTest, VerifyDamageForPerspectiveClippedLayer) { TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* surface = root->test_properties()->children[0]; - LayerImpl* child = surface->test_properties()->children[0]; + LayerImpl* surface = child1_; + LayerImpl* child = grand_child1_; FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(5.f)); - // Setting the filter should not damage the conrresponding render surface. + // TODO(crbug.com/1001882): Setting the filter on an existing render surface + // should not damage the conrresponding render surface. ClearDamageForAllSurfaces(root); - surface->test_properties()->filters = filters; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + SetFilter(surface, filters); EmulateDrawingOneFrame(root); - EXPECT_FALSE(GetRenderSurface(root) - ->damage_tracker() - ->has_damage_from_contributing_content()); + EXPECT_TRUE(GetRenderSurface(root) + ->damage_tracker() + ->has_damage_from_contributing_content()); EXPECT_FALSE(GetRenderSurface(surface) ->damage_tracker() ->has_damage_from_contributing_content()); @@ -794,7 +763,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { // surface, blurred based on the size of the blur filter. ClearDamageForAllSurfaces(root); child->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of update_rect (1, 2) @@ -814,7 +782,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; gfx::Rect root_damage_rect, child_damage_rect; // Allow us to set damage on child too. @@ -826,8 +794,10 @@ TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { 2, 2, BlurPaintFilter::TileMode::kClampToBlack_TileMode, nullptr))); // Setting the filter will damage the whole surface. - child->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + CreateTransformNode(child).post_translation = + child->offset_to_transform_parent(); + child->SetOffsetToTransformParent(gfx::Vector2dF()); + CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); @@ -896,7 +866,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { TEST_F(DamageTrackerTest, VerifyDamageForTransformedImageFilter) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; gfx::Rect root_damage_rect, child_damage_rect; // Allow us to set damage on child too. @@ -911,9 +881,14 @@ TEST_F(DamageTrackerTest, VerifyDamageForTransformedImageFilter) { gfx::Transform transform; transform.RotateAboutYAxis(60); ClearDamageForAllSurfaces(root); - child->test_properties()->force_render_surface = true; - child->test_properties()->transform = transform; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + auto& transform_node = CreateTransformNode(child); + transform_node.local = transform; + transform_node.post_translation = child->offset_to_transform_parent(); + child->SetOffsetToTransformParent(gfx::Vector2dF()); + auto& effect_node = CreateEffectNode(child); + effect_node.render_surface_reason = RenderSurfaceReason::kFilter; + effect_node.has_potential_filter_animation = true; + EmulateDrawingOneFrame(root); child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); EmulateDrawingOneFrame(root); @@ -955,21 +930,27 @@ TEST_F(DamageTrackerTest, VerifyDamageForTransformedImageFilter) { TEST_F(DamageTrackerTest, VerifyDamageForHighDPIImageFilter) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; gfx::Rect root_damage_rect, child_damage_rect; + ClearDamageForAllSurfaces(root); + int device_scale_factor = 2; + EmulateDrawingOneFrame(root, device_scale_factor); + // Allow us to set damage on child too. child->SetDrawsContent(true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(3.f)); - // Setting the filter will damage the whole surface. + // Setting the filter and creating a new render surface will damage the whole + // surface. + ClearDamageForAllSurfaces(root); + CreateTransformNode(child).post_translation = + child->offset_to_transform_parent(); + child->SetOffsetToTransformParent(gfx::Vector2dF()); + CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; ClearDamageForAllSurfaces(root); - child->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; - int device_scale_factor = 2; - EmulateDrawingOneFrame(root, device_scale_factor); child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); EmulateDrawingOneFrame(root, device_scale_factor); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -979,14 +960,11 @@ TEST_F(DamageTrackerTest, VerifyDamageForHighDPIImageFilter) { // Blur outset is 9px for a 3px blur, scaled up by DSF. int blur_outset = 9 * device_scale_factor; - gfx::Rect original_rect(100, 100, 100, 100); gfx::Rect expected_child_damage_rect(60, 60); expected_child_damage_rect.Inset(-blur_outset, -blur_outset); gfx::Rect expected_root_damage_rect(child_damage_rect); expected_root_damage_rect.Offset(200, 200); - gfx::Rect expected_total_damage_rect = expected_root_damage_rect; - expected_total_damage_rect.Union(original_rect); - EXPECT_EQ(expected_total_damage_rect, root_damage_rect); + EXPECT_EQ(expected_root_damage_rect, root_damage_rect); EXPECT_EQ(expected_child_damage_rect, child_damage_rect); // Setting the update rect should damage only the affected area (original, @@ -1006,36 +984,32 @@ TEST_F(DamageTrackerTest, VerifyDamageForHighDPIImageFilter) { TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* child2 = root->test_properties()->children[1]; - // Allow us to set damage on child1 too. - child1->SetDrawsContent(true); + // Allow us to set damage on child1_ too. + child1_->SetDrawsContent(true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(2.f)); // Setting the filter will damage the whole surface. ClearDamageForAllSurfaces(root); - child1->test_properties()->backdrop_filters = filters; - child1->NoteLayerPropertyChanged(); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + SetBackdropFilter(child1_, filters); + child1_->NoteLayerPropertyChanged(); EmulateDrawingOneFrame(root); // CASE 1: Setting the update rect should cause the corresponding damage to // the surface, blurred based on the size of the child's backdrop - // blur filter. Note that child1's render surface has a size of - // 206x208 due to contributions from grand_child1 and grand_child2. + // blur filter. Note that child1_'s render surface has a size of + // 206x208 due to contributions from grand_child1_ and grand_child2_. ClearDamageForAllSurfaces(root); root->SetUpdateRect(gfx::Rect(297, 297, 2, 2)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); gfx::Rect root_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); // Damage position on the surface should be a composition of the damage on - // the root and on child2. Damage on the root should be: position of + // the root and on child2_. Damage on the root should be: position of // update_rect (297, 297), but expanded by the blur outsets. gfx::Rect expected_damage_rect = gfx::Rect(297, 297, 2, 2); @@ -1049,13 +1023,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { // of the blurred layer, only the left/top should end up expanded. ClearDamageForAllSurfaces(root); root->SetUpdateRect(gfx::Rect(297, 297, 30, 30)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); // Damage position on the surface should be a composition of the damage on - // the root and on child2. Damage on the root should be: position of + // the root and on child2_. Damage on the root should be: position of // update_rect (297, 297), but expanded on the left/top by the blur outsets. expected_damage_rect = gfx::Rect(297, 297, 30, 30); @@ -1064,10 +1037,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 3: Setting this update rect outside the blurred content_bounds of the - // blurred child1 will not cause it to be expanded. + // blurred child1_ will not cause it to be expanded. ClearDamageForAllSurfaces(root); root->SetUpdateRect(gfx::Rect(30, 30, 2, 2)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1079,11 +1051,10 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); // CASE 4: Setting this update rect inside the blurred content_bounds but - // outside the original content_bounds of the blurred child1 will + // outside the original content_bounds of the blurred child1_ will // cause it to be expanded. ClearDamageForAllSurfaces(root); root->SetUpdateRect(gfx::Rect(99, 99, 1, 1)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1096,37 +1067,35 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { expected_damage_rect = gfx::Rect(99, 99, 7, 7); EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); - // CASE 5: Setting the update rect on child2, which is above child1, will - // not get blurred by child1, so it does not need to get expanded. + // CASE 5: Setting the update rect on child2_, which is above child1_, will + // not get blurred by child1_, so it does not need to get expanded. ClearDamageForAllSurfaces(root); - child2->SetUpdateRect(gfx::Rect(1, 1)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + child2_->SetUpdateRect(gfx::Rect(1, 1)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); - // Damage on child2 should be: position of update_rect offset by the child's + // Damage on child2_ should be: position of update_rect offset by the child's // position (11, 11), and not expanded by anything. expected_damage_rect = gfx::Rect(11, 11, 1, 1); EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); - // CASE 6: Setting the update rect on child1 will also blur the damage, so + // CASE 6: Setting the update rect on child1_ will also blur the damage, so // that any pixels needed for the blur are redrawn in the current // frame. ClearDamageForAllSurfaces(root); - child1->SetUpdateRect(gfx::Rect(1, 1)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + child1_->SetUpdateRect(gfx::Rect(1, 1)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); - // Damage on child1 should be: position of update_rect offset by the child's + // Damage on child1_ should be: position of update_rect offset by the child's // position (100, 100), and expanded by the damage. - // Damage should be (0,0 1x1), offset by the 100,100 offset of child1 in + // Damage should be (0,0 1x1), offset by the 100,100 offset of child1_ in // root, and expanded 6px for the 2px blur (i.e., 94,94 13x13), but there - // should be no damage outside child1 (i.e. none above or to the left of + // should be no damage outside child1_ (i.e. none above or to the left of // 100,100. expected_damage_rect = gfx::Rect(100, 100, 7, 7); EXPECT_EQ(expected_damage_rect.ToString(), root_damage_rect.ToString()); @@ -1134,17 +1103,20 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { // CASE 7: No changes, so should not damage the surface. ClearDamageForAllSurfaces(root); // We want to make sure that the backdrop filter doesn't cause empty damage - // to get expanded. We position child1 so that an expansion of the empty rect - // would have non-empty intersection with child1 in its target space (root + // to get expanded. We position child1_ so that an expansion of the empty rect + // would have non-empty intersection with child1_ in its target space (root // space). - child1->test_properties()->position = gfx::PointF(); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + SetPostTranslation(child1_, gfx::Vector2dF()); + child1_->NoteLayerPropertyChanged(); + // The first call clears the damage caused by the movement. + EmulateDrawingOneFrame(root); + ClearDamageForAllSurfaces(root); EmulateDrawingOneFrame(root); gfx::Rect child_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); // Should not be expanded by the blur filter. @@ -1154,20 +1126,17 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackdropBlurredChild) { TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child1 = root->test_properties()->children[0]; + LayerImpl* child1 = child_layers_[0]; // CASE 1: Adding a new layer should cause the appropriate damage. // ClearDamageForAllSurfaces(root); - { - std::unique_ptr<LayerImpl> child2 = - LayerImpl::Create(host_impl_.active_tree(), 3); - child2->test_properties()->position = gfx::PointF(400.f, 380.f); - child2->SetBounds(gfx::Size(6, 8)); - child2->SetDrawsContent(true); - root->test_properties()->AddChild(std::move(child2)); - } - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + + LayerImpl* child2 = AddLayer<LayerImpl>(); + child2->SetBounds(gfx::Size(6, 8)); + child2->SetDrawsContent(true); + CopyProperties(root, child2); + child2->SetOffsetToTransformParent(gfx::Vector2dF(400.f, 380.f)); EmulateDrawingOneFrame(root); // Sanity check - all 3 layers should be on the same render surface; render @@ -1188,17 +1157,20 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { // Advance one frame without damage so that we know the damage rect is not // leftover from the previous case. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); EXPECT_TRUE(root_damage_rect.IsEmpty()); - // Then, test removing child1. - root->test_properties()->RemoveChild(child1); - child1 = nullptr; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + // Then, test removing child1_. + { + OwnedLayerImplList layers = + host_impl()->active_tree()->DetachLayersKeepingRootLayerForTesting(); + ASSERT_EQ(3u, layers.size()); + ASSERT_EQ(child1, layers[1].get()); + host_impl()->active_tree()->AddLayer(std::move(layers[2])); + } EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1211,29 +1183,25 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { } TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { - // If child2 is added to the layer tree, but it doesn't have any explicit + // If child2_ is added to the layer tree, but it doesn't have any explicit // damage of its own, it should still indeed damage the target surface. LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); ClearDamageForAllSurfaces(root); - { - std::unique_ptr<LayerImpl> child2 = - LayerImpl::Create(host_impl_.active_tree(), 3); - child2->test_properties()->position = gfx::PointF(400.f, 380.f); - child2->SetBounds(gfx::Size(6, 8)); - child2->SetDrawsContent(true); - root->test_properties()->AddChild(std::move(child2)); - root->layer_tree_impl()->BuildLayerListForTesting(); - host_impl_.active_tree()->ResetAllChangeTracking(); - LayerImpl* child2_ptr = host_impl_.active_tree()->LayerById(3); - // Sanity check the initial conditions of the test, if these asserts - // trigger, it means the test no longer actually covers the intended - // scenario. - ASSERT_FALSE(child2_ptr->LayerPropertyChanged()); - ASSERT_TRUE(child2_ptr->update_rect().IsEmpty()); - } - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + + LayerImpl* child2 = AddLayer<LayerImpl>(); + child2->SetBounds(gfx::Size(6, 8)); + child2->SetDrawsContent(true); + CopyProperties(root, child2); + child2->SetOffsetToTransformParent(gfx::Vector2dF(400.f, 380.f)); + host_impl()->active_tree()->ResetAllChangeTracking(); + // Sanity check the initial conditions of the test, if these asserts + // trigger, it means the test no longer actually covers the intended + // scenario. + ASSERT_FALSE(child2->LayerPropertyChanged()); + ASSERT_TRUE(child2->update_rect().IsEmpty()); + EmulateDrawingOneFrame(root); // Sanity check - all 3 layers should be on the same render surface; render @@ -1251,30 +1219,24 @@ TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child1 = root->test_properties()->children[0]; + LayerImpl* child1 = child_layers_[0]; // In this test we don't want the above tree manipulation to be considered // part of the same frame. ClearDamageForAllSurfaces(root); - { - std::unique_ptr<LayerImpl> child2 = - LayerImpl::Create(host_impl_.active_tree(), 3); - child2->test_properties()->position = gfx::PointF(400.f, 380.f); - child2->SetBounds(gfx::Size(6, 8)); - child2->SetDrawsContent(true); - root->test_properties()->AddChild(std::move(child2)); - } - LayerImpl* child2 = root->test_properties()->children[1]; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + LayerImpl* child2 = AddLayer<LayerImpl>(); + child2->SetBounds(gfx::Size(6, 8)); + child2->SetDrawsContent(true); + CopyProperties(root, child2); + child2->SetOffsetToTransformParent(gfx::Vector2dF(400.f, 380.f)); EmulateDrawingOneFrame(root); // Damaging two layers simultaneously should cause combined damage. - // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); - // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); + // - child1_ update rect in surface space: gfx::Rect(100, 100, 1, 2); + // - child2_ update rect in surface space: gfx::Rect(400, 380, 3, 4); ClearDamageForAllSurfaces(root); child1->SetUpdateRect(gfx::Rect(1, 2)); child2->SetUpdateRect(gfx::Rect(3, 4)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); gfx::Rect root_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1288,13 +1250,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* child2 = root->test_properties()->children[1]; - LayerImpl* grand_child1 = - root->test_properties()->children[0]->test_properties()->children[0]; - child2->test_properties()->force_render_surface = true; - grand_child1->test_properties()->force_render_surface = true; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + CreateEffectNode(child2_).render_surface_reason = RenderSurfaceReason::kTest; + CreateEffectNode(grand_child1_).render_surface_reason = + RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; @@ -1302,9 +1260,9 @@ TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { // CASE 1: Damage to a descendant surface should propagate properly to // ancestor surface. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->SetOpacityMutated(grand_child1->element_id(), 0.5f); + root->layer_tree_impl()->SetOpacityMutated(grand_child1_->element_id(), 0.5f); EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1313,27 +1271,27 @@ TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child2) + EXPECT_FALSE(GetRenderSurface(child2_) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(grand_child1) + EXPECT_FALSE(GetRenderSurface(grand_child1_) ->damage_tracker() ->has_damage_from_contributing_content()); // CASE 2: Same as previous case, but with additional damage elsewhere that // should be properly unioned. - // - child1 surface damage in root surface space: + // - child1_ surface damage in root surface space: // gfx::Rect(300, 300, 6, 8); - // - child2 damage in root surface space: + // - child2_ damage in root surface space: // gfx::Rect(11, 11, 18, 18); ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->SetOpacityMutated(grand_child1->element_id(), 0.7f); - root->layer_tree_impl()->SetOpacityMutated(child2->element_id(), 0.7f); + root->layer_tree_impl()->SetOpacityMutated(grand_child1_->element_id(), 0.7f); + root->layer_tree_impl()->SetOpacityMutated(child2_->element_id(), 0.7f); EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1343,13 +1301,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForNestedSurfaces) { EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child2) + EXPECT_FALSE(GetRenderSurface(child2_) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(grand_child1) + EXPECT_FALSE(GetRenderSurface(grand_child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } @@ -1363,17 +1321,13 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { // entire surface should be marked dirty. LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* grand_child1 = - root->test_properties()->children[0]->test_properties()->children[0]; gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; ClearDamageForAllSurfaces(root); - grand_child1->test_properties()->position = gfx::PointF(195.f, 205.f); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + grand_child1_->SetOffsetToTransformParent(gfx::Vector2dF(195.f, 205.f)); EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1383,7 +1337,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { EXPECT_EQ(gfx::Rect(190, 190, 11, 23).ToString(), child_damage_rect.ToString()); - // Damage to the root surface should be the union of child1's *entire* render + // Damage to the root surface should be the union of child1_'s *entire* render // surface (in target space), and its old exposed area (also in target // space). EXPECT_EQ(gfx::Rect(290, 290, 16, 23).ToString(), @@ -1392,7 +1346,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantLayer) { EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } @@ -1402,37 +1356,34 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromDescendantSurface) { // damaged with the old and new descendant surface regions. LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - child1->SetDrawsContent(true); + child1_->SetDrawsContent(true); EmulateDrawingOneFrame(root); gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; ClearDamageForAllSurfaces(root); - child1->test_properties()->position = gfx::PointF(105.f, 107.f); - child1->NoteLayerPropertyChanged(); - TransformNode* child1_transform = - root->layer_tree_impl()->property_trees()->transform_tree.Node( - child1->transform_tree_index()); - child1_transform->transform_changed = true; + SetPostTranslation(child1_, gfx::Vector2dF(105.f, 107.f)); + child1_->NoteLayerPropertyChanged(); EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); - // Damage to the root surface should be the union of child1's *entire* render + // Damage to the root surface should be the union of child1_'s *entire* render // surface (in target space), and its old exposed area (also in target // space). - EXPECT_EQ(gfx::Rect(100, 100, 206, 208).ToString(), + EXPECT_EQ(gfx::UnionRects(gfx::Rect(100, 100, 206, 208), + gfx::Rect(105, 107, 206, 208)) + .ToString(), root_damage_rect.ToString()); // The child surface should also be damaged. EXPECT_EQ(gfx::Rect(0, 0, 206, 208).ToString(), child_damage_rect.ToString()); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } @@ -1441,26 +1392,25 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromAncestorLayer) { // An ancestor/owning layer changes that affects the position/transform of // the render surface. Note that in this case, the layer_property_changed flag // already propagates to the subtree (tested in LayerImpltest), which damages - // the entire child1 surface, but the damage tracker still needs the correct + // the entire child1_ surface, but the damage tracker still needs the correct // logic to compute the exposed region on the root surface. // TODO(shawnsingh): the expectations of this test case should change when we // add support for a unique scissor_rect per RenderSurface. In that case, the - // child1 surface should be completely unchanged, since we are only + // child1_ surface should be completely unchanged, since we are only // transforming it, while the root surface would be damaged appropriately. LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; ClearDamageForAllSurfaces(root); gfx::Transform translation; translation.Translate(-50.f, -50.f); - root->layer_tree_impl()->SetTransformMutated(child1->element_id(), + root->layer_tree_impl()->SetTransformMutated(child1_->element_id(), translation); EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1469,36 +1419,34 @@ TEST_F(DamageTrackerTest, VerifyDamageForSurfaceChangeFromAncestorLayer) { EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), child_damage_rect.ToString()); - // The entire child1 surface and the old exposed child1 surface should damage - // the root surface. - // - old child1 surface in target space: gfx::Rect(290, 290, 16, 18) - // - new child1 surface in target space: gfx::Rect(240, 240, 16, 18) + // The entire child1_ surface and the old exposed child1_ surface should + // damage the root surface. + // - old child1_ surface in target space: gfx::Rect(290, 290, 16, 18) + // - new child1_ surface in target space: gfx::Rect(240, 240, 16, 18) EXPECT_EQ(gfx::Rect(240, 240, 66, 68).ToString(), root_damage_rect.ToString()); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child1) + EXPECT_FALSE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; // CASE 1: If a descendant surface disappears, its entire old area becomes // exposed. ClearDamageForAllSurfaces(root); - child1->test_properties()->force_render_surface = false; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + SetRenderSurfaceReason(child1_, RenderSurfaceReason::kNone); EmulateDrawingOneFrame(root); // Sanity check that there is only one surface now. - ASSERT_EQ(GetRenderSurface(child1), GetRenderSurface(root)); + ASSERT_EQ(GetRenderSurface(child1_), GetRenderSurface(root)); ASSERT_EQ(4, GetRenderSurface(root)->num_contributors()); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1516,7 +1464,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { // Cycle one frame of no change, just to sanity check that the next rect is // not because of the old damage state. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1524,17 +1471,16 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { // Then change the tree so that the render surface is added back. ClearDamageForAllSurfaces(root); - child1->test_properties()->force_render_surface = true; + SetRenderSurfaceReason(child1_, RenderSurfaceReason::kTest); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Sanity check that there is a new surface now. - ASSERT_TRUE(GetRenderSurface(child1)); + ASSERT_TRUE(GetRenderSurface(child1_)); EXPECT_EQ(3, GetRenderSurface(root)->num_contributors()); - EXPECT_EQ(2, GetRenderSurface(child1)->num_contributors()); + EXPECT_EQ(2, GetRenderSurface(child1_)->num_contributors()); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1549,16 +1495,14 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; // CASE 1: If nothing changes, the damage rect should be empty. // ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1572,9 +1516,8 @@ TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { // empty. // ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1587,17 +1530,15 @@ TEST_F(DamageTrackerTest, VerifyNoDamageWhenNothingChanged) { TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; gfx::Rect child_damage_rect; gfx::Rect root_damage_rect; - // In our specific tree, the update rect of child1 should not cause any + // In our specific tree, the update rect of child1_ should not cause any // damage to any surface because it does not actually draw content. ClearDamageForAllSurfaces(root); - child1->SetUpdateRect(gfx::Rect(1, 2)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + child1_->SetUpdateRect(gfx::Rect(1, 2)); EmulateDrawingOneFrame(root); - EXPECT_TRUE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( + EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1610,55 +1551,57 @@ TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { TEST_F(DamageTrackerTest, VerifyDamageForMask) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; // In the current implementation of the damage tracker, changes to mask // layers should damage the entire corresponding surface. ClearDamageForAllSurfaces(root); + CreateTransformNode(child).post_translation = + child->offset_to_transform_parent(); + child->SetOffsetToTransformParent(gfx::Vector2dF()); + // Set up the mask layer. - { - std::unique_ptr<LayerImpl> mask_layer = - LayerImpl::Create(host_impl_.active_tree(), 3); - mask_layer->test_properties()->position = - child->test_properties()->position; - mask_layer->SetBounds(child->bounds()); - child->test_properties()->SetMaskLayer(std::move(mask_layer)); - child->test_properties()->force_render_surface = true; - } - LayerImpl* mask_layer = child->test_properties()->mask_layer; + CreateEffectNode(child); + auto* mask_layer = AddLayer<FakePictureLayerImpl>(); + SetupMaskProperties(child, mask_layer); + Region empty_invalidation; + mask_layer->UpdateRasterSource( + FakeRasterSource::CreateFilled(child->bounds()), &empty_invalidation, + nullptr, nullptr); // Add opacity and a grand_child so that the render surface persists even // after we remove the mask. - { - std::unique_ptr<LayerImpl> grand_child = - LayerImpl::Create(host_impl_.active_tree(), 4); - grand_child->test_properties()->position = gfx::PointF(2.f, 2.f); - grand_child->SetBounds(gfx::Size(2, 2)); - grand_child->SetDrawsContent(true); - child->test_properties()->AddChild(std::move(grand_child)); - } - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + LayerImpl* grand_child = AddLayer<LayerImpl>(); + grand_child->SetBounds(gfx::Size(2, 2)); + grand_child->SetDrawsContent(true); + CopyProperties(child, grand_child); + grand_child->SetOffsetToTransformParent(gfx::Vector2dF(2.f, 2.f)); EmulateDrawingOneFrame(root); - // CASE 1: the update_rect on a mask layer should damage the entire target - // surface. + EXPECT_EQ(2, GetRenderSurface(root)->num_contributors()); + EXPECT_TRUE(root->contributes_to_drawn_render_surface()); + EXPECT_EQ(3, GetRenderSurface(child)->num_contributors()); + EXPECT_TRUE(child->contributes_to_drawn_render_surface()); + EXPECT_EQ(GetRenderSurface(child), GetRenderSurface(mask_layer)); + EXPECT_TRUE(mask_layer->contributes_to_drawn_render_surface()); + + // CASE 1: the update_rect on a mask layer should damage the rect. ClearDamageForAllSurfaces(root); mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); gfx::Rect child_damage_rect; EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); - EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(1, 2, 3, 4), child_damage_rect); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child) - ->damage_tracker() - ->has_damage_from_contributing_content()); + EXPECT_TRUE(GetRenderSurface(child) + ->damage_tracker() + ->has_damage_from_contributing_content()); // CASE 2: a property change on the mask layer should damage the entire // target surface. @@ -1666,7 +1609,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { // Advance one frame without damage so that we know the damage rect is not // leftover from the previous case. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); @@ -1676,18 +1618,17 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { ClearDamageForAllSurfaces(root); mask_layer->NoteLayerPropertyChanged(); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); - EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(30, 30), child_damage_rect); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_FALSE(GetRenderSurface(child) - ->damage_tracker() - ->has_damage_from_contributing_content()); + EXPECT_TRUE(GetRenderSurface(child) + ->damage_tracker() + ->has_damage_from_contributing_content()); // CASE 3: removing the mask also damages the entire target surface. // @@ -1695,7 +1636,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { // Advance one frame without damage so that we know the damage rect is not // leftover from the previous case. ClearDamageForAllSurfaces(root); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); @@ -1703,10 +1643,17 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { // Then test mask removal. ClearDamageForAllSurfaces(root); - child->test_properties()->SetMaskLayer(nullptr); - child->NoteLayerPropertyChanged(); - ASSERT_TRUE(child->LayerPropertyChanged()); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + auto layers = + root->layer_tree_impl()->DetachLayersKeepingRootLayerForTesting(); + ASSERT_EQ(layers[1].get(), child); + root->layer_tree_impl()->AddLayer(std::move(layers[1])); + ASSERT_EQ(layers[2].get(), mask_layer); + ASSERT_EQ(layers[3].get(), grand_child); + root->layer_tree_impl()->AddLayer(std::move(layers[3])); + CopyProperties(root, child); + CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; + CopyProperties(child, grand_child); + EmulateDrawingOneFrame(root); // Sanity check that a render surface still exists. @@ -1714,7 +1661,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); - EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); + EXPECT_EQ(gfx::Rect(30, 30), child_damage_rect); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() @@ -1723,7 +1670,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; // Case 1: This test ensures that when the tracker is given damage, that // it is included with any other partial damage. @@ -1732,7 +1679,6 @@ TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); GetRenderSurface(root)->damage_tracker()->AddDamageNextUpdate( gfx::Rect(15, 16, 32, 33)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); gfx::Rect root_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1750,7 +1696,6 @@ TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { ClearDamageForAllSurfaces(root); GetRenderSurface(root)->damage_tracker()->AddDamageNextUpdate( gfx::Rect(30, 31, 14, 15)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1761,34 +1706,33 @@ TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { } TEST_F(DamageTrackerTest, VerifyDamageWithNoContributingLayers) { - std::unique_ptr<LayerImpl> root = - LayerImpl::Create(host_impl_.active_tree(), 1); - root->test_properties()->force_render_surface = true; - host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); - LayerImpl* root_ptr = host_impl_.active_tree()->root_layer_for_testing(); - root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; - EmulateDrawingOneFrame(root_ptr); - - DCHECK_EQ(GetRenderSurface(root_ptr), root_ptr->render_target()); - RenderSurfaceImpl* target_surface = GetRenderSurface(root_ptr); + LayerImpl* root = root_layer(); + ClearDamageForAllSurfaces(root); + + LayerImpl* empty_surface = AddLayer<LayerImpl>(); + CopyProperties(root, empty_surface); + CreateEffectNode(empty_surface).render_surface_reason = + RenderSurfaceReason::kTest; + EmulateDrawingOneFrame(root); + + DCHECK_EQ(GetRenderSurface(empty_surface), empty_surface->render_target()); + RenderSurfaceImpl* target_surface = GetRenderSurface(empty_surface); gfx::Rect damage_rect; EXPECT_TRUE( target_surface->damage_tracker()->GetDamageRectIfValid(&damage_rect)); EXPECT_TRUE(damage_rect.IsEmpty()); - EXPECT_FALSE(GetRenderSurface(root_ptr) - ->damage_tracker() - ->has_damage_from_contributing_content()); + EXPECT_FALSE( + target_surface->damage_tracker()->has_damage_from_contributing_content()); } TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { // If damage is not cleared, it should accumulate. LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; ClearDamageForAllSurfaces(root); child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); // Sanity check damage after the first frame; this isnt the actual test yet. @@ -1803,7 +1747,6 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { // New damage, without having cleared the previous damage, should be unioned // to the previous one. child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1825,7 +1768,6 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { // Damage should remain empty even after one frame, since there's yet no new // damage. - root->layer_tree_impl()->property_trees()->needs_rebuild = true; EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -1844,7 +1786,7 @@ TEST_F(DamageTrackerTest, HugeDamageRect) { for (int i = 0; i < kRange; ++i) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); - LayerImpl* child = root->test_properties()->children[0]; + LayerImpl* child = child_layers_[0]; gfx::Transform transform; transform.Translate(-kBigNumber, -kBigNumber); @@ -1852,8 +1794,11 @@ TEST_F(DamageTrackerTest, HugeDamageRect) { // The child layer covers (0, 0, i, i) of the viewport, // but has a huge negative position. child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); - child->test_properties()->transform = transform; - root->layer_tree_impl()->property_trees()->needs_rebuild = true; + auto& transform_node = CreateTransformNode(child); + transform_node.local = transform; + transform_node.post_translation = child->offset_to_transform_parent(); + child->SetOffsetToTransformParent(gfx::Vector2dF()); + float device_scale_factor = 1.f; // Visible rects computed from combining clips in target space and root // space don't match because of the loss in floating point accuracy. So, we @@ -1876,20 +1821,19 @@ TEST_F(DamageTrackerTest, HugeDamageRect) { TEST_F(DamageTrackerTest, DamageRectTooBig) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(2); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* child2 = root->test_properties()->children[1]; + LayerImpl* child1 = child_layers_[0]; + LayerImpl* child2 = child_layers_[1]; // Really far left. - child1->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::min() + 100, 0); + child1->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::min() + 100, 0)); child1->SetBounds(gfx::Size(1, 1)); // Really far right. - child2->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::max() - 100, 0); + child2->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::max() - 100, 0)); child2->SetBounds(gfx::Size(1, 1)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; float device_scale_factor = 1.f; EmulateDrawingOneFrame(root, device_scale_factor); @@ -1907,25 +1851,24 @@ TEST_F(DamageTrackerTest, DamageRectTooBig) { TEST_F(DamageTrackerTest, DamageRectTooBigWithFilter) { LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(2); - LayerImpl* child1 = root->test_properties()->children[0]; - LayerImpl* child2 = root->test_properties()->children[1]; + LayerImpl* child1 = child_layers_[0]; + LayerImpl* child2 = child_layers_[1]; FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(5.f)); root->SetDrawsContent(true); - root->test_properties()->backdrop_filters = filters; + SetBackdropFilter(root, filters); // Really far left. - child1->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::min() + 100, 0); + child1->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::min() + 100, 0)); child1->SetBounds(gfx::Size(1, 1)); // Really far right. - child2->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::max() - 100, 0); + child2->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::max() - 100, 0)); child2->SetBounds(gfx::Size(1, 1)); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; float device_scale_factor = 1.f; EmulateDrawingOneFrame(root, device_scale_factor); @@ -1943,190 +1886,168 @@ TEST_F(DamageTrackerTest, DamageRectTooBigWithFilter) { TEST_F(DamageTrackerTest, DamageRectTooBigInRenderSurface) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - auto* grandchild1 = - static_cast<TestLayerImpl*>(child1->test_properties()->children[0]); - auto* grandchild2 = - static_cast<TestLayerImpl*>(child1->test_properties()->children[1]); // Really far left. - grandchild1->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::min() + 500, 0); - grandchild1->SetBounds(gfx::Size(1, 1)); - grandchild1->SetDrawsContent(true); + grand_child1_->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::min() + 500, 0)); + grand_child1_->SetBounds(gfx::Size(1, 1)); + grand_child1_->SetDrawsContent(true); // Really far right. - grandchild2->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::max() - 500, 0); - grandchild2->SetBounds(gfx::Size(1, 1)); - grandchild2->SetDrawsContent(true); + grand_child2_->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::max() - 500, 0)); + grand_child2_->SetBounds(gfx::Size(1, 1)); + grand_child2_->SetDrawsContent(true); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; - float device_scale_factor = 1.f; - RenderSurfaceList render_surface_list; - ExecuteCalculateDrawProperties(root, device_scale_factor, - &render_surface_list); + UpdateDrawProperties(host_impl()->active_tree()); // Avoid the descendant-only property change path that skips unioning damage // from descendant layers. - GetRenderSurface(child1)->NoteAncestorPropertyChanged(); - DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), - render_surface_list); + GetRenderSurface(child1_)->NoteAncestorPropertyChanged(); + DamageTracker::UpdateDamageTracking(host_impl()->active_tree()); // The expected damage would be too large to store in a gfx::Rect, so we - // should damage everything on child1. + // should damage everything on child1_. gfx::Rect damage_rect; - EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( - &damage_rect)); - EXPECT_EQ(GetRenderSurface(child1)->content_rect(), - GetRenderSurface(child1)->GetDamageRect()); + EXPECT_FALSE( + GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( + &damage_rect)); + EXPECT_EQ(GetRenderSurface(child1_)->content_rect(), + GetRenderSurface(child1_)->GetDamageRect()); - // However, the root should just use the child1 render surface's content rect + // However, the root should just use the child1_ render surface's content rect // as damage. ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &damage_rect)); EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); EXPECT_TRUE(damage_rect.Contains( - gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); + gfx::ToEnclosingRect(GetRenderSurface(child1_)->DrawableContentRect()))); EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); // Add new damage, without changing properties, which goes down a different // path in the damage tracker. root->layer_tree_impl()->ResetAllChangeTracking(); - grandchild1->AddDamageRect(gfx::Rect(grandchild1->bounds())); - grandchild2->AddDamageRect(gfx::Rect(grandchild1->bounds())); + grand_child1_->AddDamageRect(gfx::Rect(grand_child1_->bounds())); + grand_child2_->AddDamageRect(gfx::Rect(grand_child1_->bounds())); // Recompute all damage / properties. - render_surface_list.clear(); - ExecuteCalculateDrawProperties(root, device_scale_factor, - &render_surface_list); - DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), - render_surface_list); + UpdateDrawProperties(host_impl()->active_tree()); + DamageTracker::UpdateDamageTracking(host_impl()->active_tree()); // Child1 should still not have a valid rect, since the union of the damage of // its children is not representable by a single rect. - EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( - &damage_rect)); - EXPECT_EQ(GetRenderSurface(child1)->content_rect(), - GetRenderSurface(child1)->GetDamageRect()); + EXPECT_FALSE( + GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( + &damage_rect)); + EXPECT_EQ(GetRenderSurface(child1_)->content_rect(), + GetRenderSurface(child1_)->GetDamageRect()); // Root should have valid damage and contain both its content rect and the - // drawable content rect of child1. + // drawable content rect of child1_. ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &damage_rect)); EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); EXPECT_TRUE(damage_rect.Contains( - gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); + gfx::ToEnclosingRect(GetRenderSurface(child1_)->DrawableContentRect()))); EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } TEST_F(DamageTrackerTest, DamageRectTooBigInRenderSurfaceWithFilter) { LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); - LayerImpl* child1 = root->test_properties()->children[0]; - auto* grandchild1 = - static_cast<TestLayerImpl*>(child1->test_properties()->children[0]); - auto* grandchild2 = - static_cast<TestLayerImpl*>(child1->test_properties()->children[1]); // Set up a moving pixels filter on the child. FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(5.f)); - child1->SetDrawsContent(true); - child1->test_properties()->backdrop_filters = filters; + child1_->SetDrawsContent(true); + SetBackdropFilter(child1_, filters); // Really far left. - grandchild1->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::min() + 500, 0); - grandchild1->SetBounds(gfx::Size(1, 1)); - grandchild1->SetDrawsContent(true); + grand_child1_->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::min() + 500, 0)); + grand_child1_->SetBounds(gfx::Size(1, 1)); + grand_child1_->SetDrawsContent(true); // Really far right. - grandchild2->test_properties()->position = - gfx::PointF(std::numeric_limits<int>::max() - 500, 0); - grandchild2->SetBounds(gfx::Size(1, 1)); - grandchild2->SetDrawsContent(true); + grand_child2_->SetOffsetToTransformParent( + gfx::Vector2dF(std::numeric_limits<int>::max() - 500, 0)); + grand_child2_->SetBounds(gfx::Size(1, 1)); + grand_child2_->SetDrawsContent(true); - root->layer_tree_impl()->property_trees()->needs_rebuild = true; - float device_scale_factor = 1.f; - RenderSurfaceList render_surface_list; - ExecuteCalculateDrawProperties(root, device_scale_factor, - &render_surface_list); + UpdateDrawProperties(host_impl()->active_tree()); // Avoid the descendant-only property change path that skips unioning damage // from descendant layers. - GetRenderSurface(child1)->NoteAncestorPropertyChanged(); - DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), - render_surface_list); + GetRenderSurface(child1_)->NoteAncestorPropertyChanged(); + DamageTracker::UpdateDamageTracking(host_impl()->active_tree()); // The expected damage would be too large to store in a gfx::Rect, so we - // should damage everything on child1. + // should damage everything on child1_. gfx::Rect damage_rect; - EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( - &damage_rect)); - EXPECT_EQ(GetRenderSurface(child1)->content_rect(), - GetRenderSurface(child1)->GetDamageRect()); + EXPECT_FALSE( + GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( + &damage_rect)); + EXPECT_EQ(GetRenderSurface(child1_)->content_rect(), + GetRenderSurface(child1_)->GetDamageRect()); - // However, the root should just use the child1 render surface's content rect + // However, the root should just use the child1_ render surface's content rect // as damage. ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &damage_rect)); EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); EXPECT_TRUE(damage_rect.Contains( - gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); + gfx::ToEnclosingRect(GetRenderSurface(child1_)->DrawableContentRect()))); EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); // Add new damage, without changing properties, which goes down a different // path in the damage tracker. root->layer_tree_impl()->ResetAllChangeTracking(); - grandchild1->AddDamageRect(gfx::Rect(grandchild1->bounds())); - grandchild2->AddDamageRect(gfx::Rect(grandchild1->bounds())); + grand_child1_->AddDamageRect(gfx::Rect(grand_child1_->bounds())); + grand_child2_->AddDamageRect(gfx::Rect(grand_child1_->bounds())); // Recompute all damage / properties. - render_surface_list.clear(); - ExecuteCalculateDrawProperties(root, device_scale_factor, - &render_surface_list); - DamageTracker::UpdateDamageTracking(host_impl_.active_tree(), - render_surface_list); + UpdateDrawProperties(host_impl()->active_tree()); + DamageTracker::UpdateDamageTracking(host_impl()->active_tree()); // Child1 should still not have a valid rect, since the union of the damage of // its children is not representable by a single rect. - EXPECT_FALSE(GetRenderSurface(child1)->damage_tracker()->GetDamageRectIfValid( - &damage_rect)); - EXPECT_EQ(GetRenderSurface(child1)->content_rect(), - GetRenderSurface(child1)->GetDamageRect()); + EXPECT_FALSE( + GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( + &damage_rect)); + EXPECT_EQ(GetRenderSurface(child1_)->content_rect(), + GetRenderSurface(child1_)->GetDamageRect()); // Root should have valid damage and contain both its content rect and the - // drawable content rect of child1. + // drawable content rect of child1_. ASSERT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &damage_rect)); EXPECT_TRUE(damage_rect.Contains(GetRenderSurface(root)->content_rect())); EXPECT_TRUE(damage_rect.Contains( - gfx::ToEnclosingRect(GetRenderSurface(child1)->DrawableContentRect()))); + gfx::ToEnclosingRect(GetRenderSurface(child1_)->DrawableContentRect()))); EXPECT_EQ(damage_rect, GetRenderSurface(root)->GetDamageRect()); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() ->has_damage_from_contributing_content()); - EXPECT_TRUE(GetRenderSurface(child1) + EXPECT_TRUE(GetRenderSurface(child1_) ->damage_tracker() ->has_damage_from_contributing_content()); } |