| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 root->SetPosition(gfx::PointF()); | 92 root->SetPosition(gfx::PointF()); |
| 93 root->SetBounds(gfx::Size(500, 500)); | 93 root->SetBounds(gfx::Size(500, 500)); |
| 94 root->SetDrawsContent(true); | 94 root->SetDrawsContent(true); |
| 95 root->test_properties()->force_render_surface = true; | 95 root->test_properties()->force_render_surface = true; |
| 96 | 96 |
| 97 child->SetPosition(gfx::PointF(100.f, 100.f)); | 97 child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 98 child->SetBounds(gfx::Size(30, 30)); | 98 child->SetBounds(gfx::Size(30, 30)); |
| 99 child->SetDrawsContent(true); | 99 child->SetDrawsContent(true); |
| 100 root->test_properties()->AddChild(std::move(child)); | 100 root->test_properties()->AddChild(std::move(child)); |
| 101 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 101 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 102 | 102 |
| 103 return host_impl_.active_tree()->root_layer(); | 103 return host_impl_.active_tree()->root_layer_for_testing(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 LayerImpl* CreateTestTreeWithTwoSurfaces() { | 106 LayerImpl* CreateTestTreeWithTwoSurfaces() { |
| 107 // This test tree has two render surfaces: one for the root, and one for | 107 // This test tree has two render surfaces: one for the root, and one for |
| 108 // child1. Additionally, the root has a second child layer, and child1 has | 108 // child1. Additionally, the root has a second child layer, and child1 has |
| 109 // two children of its own. | 109 // two children of its own. |
| 110 | 110 |
| 111 host_impl_.active_tree()->DetachLayers(); | 111 host_impl_.active_tree()->DetachLayers(); |
| 112 std::unique_ptr<LayerImpl> root = | 112 std::unique_ptr<LayerImpl> root = |
| 113 LayerImpl::Create(host_impl_.active_tree(), 1); | 113 LayerImpl::Create(host_impl_.active_tree(), 1); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 142 grand_child1->SetDrawsContent(true); | 142 grand_child1->SetDrawsContent(true); |
| 143 | 143 |
| 144 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); | 144 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); |
| 145 grand_child2->SetBounds(gfx::Size(6, 8)); | 145 grand_child2->SetBounds(gfx::Size(6, 8)); |
| 146 grand_child2->SetDrawsContent(true); | 146 grand_child2->SetDrawsContent(true); |
| 147 | 147 |
| 148 child1->test_properties()->AddChild(std::move(grand_child1)); | 148 child1->test_properties()->AddChild(std::move(grand_child1)); |
| 149 child1->test_properties()->AddChild(std::move(grand_child2)); | 149 child1->test_properties()->AddChild(std::move(grand_child2)); |
| 150 root->test_properties()->AddChild(std::move(child1)); | 150 root->test_properties()->AddChild(std::move(child1)); |
| 151 root->test_properties()->AddChild(std::move(child2)); | 151 root->test_properties()->AddChild(std::move(child2)); |
| 152 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 152 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 153 | 153 |
| 154 return host_impl_.active_tree()->root_layer(); | 154 return host_impl_.active_tree()->root_layer_for_testing(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 LayerImpl* CreateAndSetUpTestTreeWithOneSurface() { | 157 LayerImpl* CreateAndSetUpTestTreeWithOneSurface() { |
| 158 LayerImpl* root = CreateTestTreeWithOneSurface(); | 158 LayerImpl* root = CreateTestTreeWithOneSurface(); |
| 159 | 159 |
| 160 // Setup includes going past the first frame which always damages | 160 // Setup includes going past the first frame which always damages |
| 161 // everything, so that we can actually perform specific tests. | 161 // everything, so that we can actually perform specific tests. |
| 162 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 162 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 163 EmulateDrawingOneFrame(root); | 163 EmulateDrawingOneFrame(root); |
| 164 | 164 |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); | 1545 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { | 1548 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { |
| 1549 // Though it should never happen, its a good idea to verify that the damage | 1549 // Though it should never happen, its a good idea to verify that the damage |
| 1550 // tracker does not crash when it receives an empty layer_list. | 1550 // tracker does not crash when it receives an empty layer_list. |
| 1551 | 1551 |
| 1552 std::unique_ptr<LayerImpl> root = | 1552 std::unique_ptr<LayerImpl> root = |
| 1553 LayerImpl::Create(host_impl_.active_tree(), 1); | 1553 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 1554 root->test_properties()->force_render_surface = true; | 1554 root->test_properties()->force_render_surface = true; |
| 1555 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 1555 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 1556 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer(); | 1556 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer_for_testing(); |
| 1557 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1557 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1558 EmulateDrawingOneFrame(root_ptr); | 1558 EmulateDrawingOneFrame(root_ptr); |
| 1559 | 1559 |
| 1560 DCHECK_EQ(root_ptr->render_surface(), root_ptr->render_target()); | 1560 DCHECK_EQ(root_ptr->render_surface(), root_ptr->render_target()); |
| 1561 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); | 1561 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); |
| 1562 | 1562 |
| 1563 LayerImplList empty_list; | 1563 LayerImplList empty_list; |
| 1564 target_surface->damage_tracker()->UpdateDamageTrackingState( | 1564 target_surface->damage_tracker()->UpdateDamageTrackingState( |
| 1565 empty_list, target_surface, false, gfx::Rect(), NULL, FilterOperations()); | 1565 empty_list, target_surface, false, gfx::Rect(), NULL, FilterOperations()); |
| 1566 | 1566 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 gfx::Rect root_damage_rect = | 1638 gfx::Rect root_damage_rect = |
| 1639 root->render_surface()->damage_tracker()->current_damage_rect(); | 1639 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1640 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1640 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1641 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1641 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1642 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1642 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1643 } | 1643 } |
| 1644 } | 1644 } |
| 1645 | 1645 |
| 1646 } // namespace | 1646 } // namespace |
| 1647 } // namespace cc | 1647 } // namespace cc |
| OLD | NEW |