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

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

Issue 2048863003: Reland of cc : Make LayerImpl destruction independent of tree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 class DamageTrackerTest : public testing::Test { 78 class DamageTrackerTest : public testing::Test {
79 public: 79 public:
80 DamageTrackerTest() 80 DamageTrackerTest()
81 : host_impl_(&task_runner_provider_, 81 : host_impl_(&task_runner_provider_,
82 &shared_bitmap_manager_, 82 &shared_bitmap_manager_,
83 &task_graph_runner_) {} 83 &task_graph_runner_) {}
84 84
85 LayerImpl* CreateTestTreeWithOneSurface() { 85 LayerImpl* CreateTestTreeWithOneSurface() {
86 host_impl_.active_tree()->ClearLayers(); 86 host_impl_.active_tree()->DetachLayers();
87 std::unique_ptr<LayerImpl> root = 87 std::unique_ptr<LayerImpl> root =
88 LayerImpl::Create(host_impl_.active_tree(), 1); 88 LayerImpl::Create(host_impl_.active_tree(), 1);
89 std::unique_ptr<LayerImpl> child = 89 std::unique_ptr<LayerImpl> child =
90 LayerImpl::Create(host_impl_.active_tree(), 2); 90 LayerImpl::Create(host_impl_.active_tree(), 2);
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->AddChild(std::move(child)); 100 root->AddChild(std::move(child));
101 host_impl_.active_tree()->SetRootLayer(std::move(root)); 101 host_impl_.active_tree()->SetRootLayer(std::move(root));
102 102
103 return host_impl_.active_tree()->root_layer(); 103 return host_impl_.active_tree()->root_layer();
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()->ClearLayers(); 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);
114 std::unique_ptr<LayerImpl> child1 = 114 std::unique_ptr<LayerImpl> child1 =
115 LayerImpl::Create(host_impl_.active_tree(), 2); 115 LayerImpl::Create(host_impl_.active_tree(), 2);
116 std::unique_ptr<LayerImpl> child2 = 116 std::unique_ptr<LayerImpl> child2 =
117 LayerImpl::Create(host_impl_.active_tree(), 3); 117 LayerImpl::Create(host_impl_.active_tree(), 3);
118 std::unique_ptr<LayerImpl> grand_child1 = 118 std::unique_ptr<LayerImpl> grand_child1 =
119 LayerImpl::Create(host_impl_.active_tree(), 4); 119 LayerImpl::Create(host_impl_.active_tree(), 4);
120 std::unique_ptr<LayerImpl> grand_child2 = 120 std::unique_ptr<LayerImpl> grand_child2 =
121 LayerImpl::Create(host_impl_.active_tree(), 5); 121 LayerImpl::Create(host_impl_.active_tree(), 5);
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 gfx::Rect root_damage_rect = 1625 gfx::Rect root_damage_rect =
1626 root->render_surface()->damage_tracker()->current_damage_rect(); 1626 root->render_surface()->damage_tracker()->current_damage_rect();
1627 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1627 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1628 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1628 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1629 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1629 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1630 } 1630 }
1631 } 1631 }
1632 1632
1633 } // namespace 1633 } // namespace
1634 } // namespace cc 1634 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698