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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/damage_tracker.cc ('k') | cc/debug_rect_history.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/damage_tracker.h" 5 #include "cc/damage_tracker.h"
6 6
7 #include "cc/layer_impl.h" 7 #include "cc/layer_impl.h"
8 #include "cc/layer_tree_host_common.h" 8 #include "cc/layer_tree_host_common.h"
9 #include "cc/math_util.h" 9 #include "cc/math_util.h"
10 #include "cc/single_thread_proxy.h" 10 #include "cc/single_thread_proxy.h"
(...skipping 11 matching lines...) Expand all
22 namespace cc { 22 namespace cc {
23 namespace { 23 namespace {
24 24
25 void executeCalculateDrawProperties(LayerImpl* root, std::vector<LayerImpl*>& re nderSurfaceLayerList) 25 void executeCalculateDrawProperties(LayerImpl* root, std::vector<LayerImpl*>& re nderSurfaceLayerList)
26 { 26 {
27 int dummyMaxTextureSize = 512; 27 int dummyMaxTextureSize = 512;
28 28
29 // Sanity check: The test itself should create the root layer's render surfa ce, so 29 // Sanity check: The test itself should create the root layer's render surfa ce, so
30 // that the surface (and its damage tracker) can persist acros s multiple 30 // that the surface (and its damage tracker) can persist acros s multiple
31 // calls to this function. 31 // calls to this function.
32 ASSERT_TRUE(root->renderSurface()); 32 ASSERT_TRUE(root->render_surface());
33 ASSERT_FALSE(renderSurfaceLayerList.size()); 33 ASSERT_FALSE(renderSurfaceLayerList.size());
34 34
35 LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dum myMaxTextureSize, false, renderSurfaceLayerList, false); 35 LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dum myMaxTextureSize, false, renderSurfaceLayerList, false);
36 } 36 }
37 37
38 void clearDamageForAllSurfaces(LayerImpl* layer) 38 void clearDamageForAllSurfaces(LayerImpl* layer)
39 { 39 {
40 if (layer->renderSurface()) 40 if (layer->render_surface())
41 layer->renderSurface()->damage_tracker()->DidDrawDamagedArea(); 41 layer->render_surface()->damage_tracker()->DidDrawDamagedArea();
42 42
43 // Recursively clear damage for any existing surface. 43 // Recursively clear damage for any existing surface.
44 for (size_t i = 0; i < layer->children().size(); ++i) 44 for (size_t i = 0; i < layer->children().size(); ++i)
45 clearDamageForAllSurfaces(layer->children()[i]); 45 clearDamageForAllSurfaces(layer->children()[i]);
46 } 46 }
47 47
48 void emulateDrawingOneFrame(LayerImpl* root) 48 void emulateDrawingOneFrame(LayerImpl* root)
49 { 49 {
50 // This emulates only the steps that are relevant to testing the damage trac ker: 50 // This emulates only the steps that are relevant to testing the damage trac ker:
51 // 1. computing the render passes and layerlists 51 // 1. computing the render passes and layerlists
52 // 2. updating all damage trackers in the correct order 52 // 2. updating all damage trackers in the correct order
53 // 3. resetting all updateRects and propertyChanged flags for all layers a nd surfaces. 53 // 3. resetting all updateRects and propertyChanged flags for all layers a nd surfaces.
54 54
55 std::vector<LayerImpl*> renderSurfaceLayerList; 55 std::vector<LayerImpl*> renderSurfaceLayerList;
56 executeCalculateDrawProperties(root, renderSurfaceLayerList); 56 executeCalculateDrawProperties(root, renderSurfaceLayerList);
57 57
58 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors. 58 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors.
59 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { 59 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) {
60 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf ace(); 60 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->render_sur face();
61 targetSurface->damage_tracker()->UpdateDamageTrackingState(targetSurface ->layer_list(), targetSurface->OwningLayerId(), targetSurface->SurfacePropertyCh angedOnlyFromDescendant(), targetSurface->content_rect(), renderSurfaceLayerList [i]->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i ]->filter().get()); 61 targetSurface->damage_tracker()->UpdateDamageTrackingState(targetSurface ->layer_list(), targetSurface->OwningLayerId(), targetSurface->SurfacePropertyCh angedOnlyFromDescendant(), targetSurface->content_rect(), renderSurfaceLayerList [i]->mask_layer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[ i]->filter().get());
62 } 62 }
63 63
64 root->resetAllChangeTrackingForSubtree(); 64 root->ResetAllChangeTrackingForSubtree();
65 } 65 }
66 66
67 class DamageTrackerTest : public testing::Test { 67 class DamageTrackerTest : public testing::Test {
68 public: 68 public:
69 DamageTrackerTest() 69 DamageTrackerTest()
70 : m_hostImpl(&m_proxy) 70 : m_hostImpl(&m_proxy)
71 { 71 {
72 } 72 }
73 73
74 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() 74 scoped_ptr<LayerImpl> createTestTreeWithOneSurface()
75 { 75 {
76 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.activeTree(), 1); 76 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.activeTree(), 1);
77 scoped_ptr<LayerImpl> child = LayerImpl::create(m_hostImpl.activeTree(), 2); 77 scoped_ptr<LayerImpl> child = LayerImpl::Create(m_hostImpl.activeTree(), 2);
78 78
79 root->setPosition(gfx::PointF()); 79 root->SetPosition(gfx::PointF());
80 root->setAnchorPoint(gfx::PointF()); 80 root->SetAnchorPoint(gfx::PointF());
81 root->setBounds(gfx::Size(500, 500)); 81 root->SetBounds(gfx::Size(500, 500));
82 root->setContentBounds(gfx::Size(500, 500)); 82 root->SetContentBounds(gfx::Size(500, 500));
83 root->setDrawsContent(true); 83 root->SetDrawsContent(true);
84 root->createRenderSurface(); 84 root->CreateRenderSurface();
85 root->renderSurface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size( 500, 500))); 85 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size (500, 500)));
86 86
87 child->setPosition(gfx::PointF(100, 100)); 87 child->SetPosition(gfx::PointF(100, 100));
88 child->setAnchorPoint(gfx::PointF()); 88 child->SetAnchorPoint(gfx::PointF());
89 child->setBounds(gfx::Size(30, 30)); 89 child->SetBounds(gfx::Size(30, 30));
90 child->setContentBounds(gfx::Size(30, 30)); 90 child->SetContentBounds(gfx::Size(30, 30));
91 child->setDrawsContent(true); 91 child->SetDrawsContent(true);
92 root->addChild(child.Pass()); 92 root->AddChild(child.Pass());
93 93
94 return root.Pass(); 94 return root.Pass();
95 } 95 }
96 96
97 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces() 97 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces()
98 { 98 {
99 // This test tree has two render surfaces: one for the root, and one for 99 // This test tree has two render surfaces: one for the root, and one for
100 // child1. Additionally, the root has a second child layer, and child1 h as two 100 // child1. Additionally, the root has a second child layer, and child1 h as two
101 // children of its own. 101 // children of its own.
102 102
103 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.activeTree(), 1); 103 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.activeTree(), 1);
104 scoped_ptr<LayerImpl> child1 = LayerImpl::create(m_hostImpl.activeTree() , 2); 104 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(m_hostImpl.activeTree() , 2);
105 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree() , 3); 105 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3);
106 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(m_hostImpl.activeT ree(), 4); 106 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(m_hostImpl.activeT ree(), 4);
107 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::create(m_hostImpl.activeT ree(), 5); 107 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::Create(m_hostImpl.activeT ree(), 5);
108 108
109 root->setPosition(gfx::PointF()); 109 root->SetPosition(gfx::PointF());
110 root->setAnchorPoint(gfx::PointF()); 110 root->SetAnchorPoint(gfx::PointF());
111 root->setBounds(gfx::Size(500, 500)); 111 root->SetBounds(gfx::Size(500, 500));
112 root->setContentBounds(gfx::Size(500, 500)); 112 root->SetContentBounds(gfx::Size(500, 500));
113 root->setDrawsContent(true); 113 root->SetDrawsContent(true);
114 root->createRenderSurface(); 114 root->CreateRenderSurface();
115 root->renderSurface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size( 500, 500))); 115 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size (500, 500)));
116 116
117 child1->setPosition(gfx::PointF(100, 100)); 117 child1->SetPosition(gfx::PointF(100, 100));
118 child1->setAnchorPoint(gfx::PointF()); 118 child1->SetAnchorPoint(gfx::PointF());
119 child1->setBounds(gfx::Size(30, 30)); 119 child1->SetBounds(gfx::Size(30, 30));
120 child1->setContentBounds(gfx::Size(30, 30)); 120 child1->SetContentBounds(gfx::Size(30, 30));
121 child1->setOpacity(0.5); // with a child that drawsContent, this will ca use the layer to create its own renderSurface. 121 child1->SetOpacity(0.5); // with a child that drawsContent, this will ca use the layer to create its own renderSurface.
122 child1->setDrawsContent(false); // this layer does not draw, but is inte nded to create its own renderSurface. 122 child1->SetDrawsContent(false); // this layer does not draw, but is inte nded to create its own renderSurface.
123 child1->setForceRenderSurface(true); 123 child1->SetForceRenderSurface(true);
124 124
125 child2->setPosition(gfx::PointF(11, 11)); 125 child2->SetPosition(gfx::PointF(11, 11));
126 child2->setAnchorPoint(gfx::PointF()); 126 child2->SetAnchorPoint(gfx::PointF());
127 child2->setBounds(gfx::Size(18, 18)); 127 child2->SetBounds(gfx::Size(18, 18));
128 child2->setContentBounds(gfx::Size(18, 18)); 128 child2->SetContentBounds(gfx::Size(18, 18));
129 child2->setDrawsContent(true); 129 child2->SetDrawsContent(true);
130 130
131 grandChild1->setPosition(gfx::PointF(200, 200)); 131 grandChild1->SetPosition(gfx::PointF(200, 200));
132 grandChild1->setAnchorPoint(gfx::PointF()); 132 grandChild1->SetAnchorPoint(gfx::PointF());
133 grandChild1->setBounds(gfx::Size(6, 8)); 133 grandChild1->SetBounds(gfx::Size(6, 8));
134 grandChild1->setContentBounds(gfx::Size(6, 8)); 134 grandChild1->SetContentBounds(gfx::Size(6, 8));
135 grandChild1->setDrawsContent(true); 135 grandChild1->SetDrawsContent(true);
136 136
137 grandChild2->setPosition(gfx::PointF(190, 190)); 137 grandChild2->SetPosition(gfx::PointF(190, 190));
138 grandChild2->setAnchorPoint(gfx::PointF()); 138 grandChild2->SetAnchorPoint(gfx::PointF());
139 grandChild2->setBounds(gfx::Size(6, 8)); 139 grandChild2->SetBounds(gfx::Size(6, 8));
140 grandChild2->setContentBounds(gfx::Size(6, 8)); 140 grandChild2->SetContentBounds(gfx::Size(6, 8));
141 grandChild2->setDrawsContent(true); 141 grandChild2->SetDrawsContent(true);
142 142
143 child1->addChild(grandChild1.Pass()); 143 child1->AddChild(grandChild1.Pass());
144 child1->addChild(grandChild2.Pass()); 144 child1->AddChild(grandChild2.Pass());
145 root->addChild(child1.Pass()); 145 root->AddChild(child1.Pass());
146 root->addChild(child2.Pass()); 146 root->AddChild(child2.Pass());
147 147
148 return root.Pass(); 148 return root.Pass();
149 } 149 }
150 150
151 scoped_ptr<LayerImpl> createAndSetUpTestTreeWithOneSurface() 151 scoped_ptr<LayerImpl> createAndSetUpTestTreeWithOneSurface()
152 { 152 {
153 scoped_ptr<LayerImpl> root = createTestTreeWithOneSurface(); 153 scoped_ptr<LayerImpl> root = createTestTreeWithOneSurface();
154 154
155 // Setup includes going past the first frame which always damages everyt hing, so 155 // Setup includes going past the first frame which always damages everyt hing, so
156 // that we can actually perform specific tests. 156 // that we can actually perform specific tests.
(...skipping 18 matching lines...) Expand all
175 FakeLayerTreeHostImpl m_hostImpl; 175 FakeLayerTreeHostImpl m_hostImpl;
176 }; 176 };
177 177
178 TEST_F(DamageTrackerTest, sanityCheckTestTreeWithOneSurface) 178 TEST_F(DamageTrackerTest, sanityCheckTestTreeWithOneSurface)
179 { 179 {
180 // Sanity check that the simple test tree will actually produce the expected render 180 // Sanity check that the simple test tree will actually produce the expected render
181 // surfaces and layer lists. 181 // surfaces and layer lists.
182 182
183 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 183 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
184 184
185 EXPECT_EQ(2u, root->renderSurface()->layer_list().size()); 185 EXPECT_EQ(2u, root->render_surface()->layer_list().size());
186 EXPECT_EQ(1, root->renderSurface()->layer_list()[0]->id()); 186 EXPECT_EQ(1, root->render_surface()->layer_list()[0]->id());
187 EXPECT_EQ(2, root->renderSurface()->layer_list()[1]->id()); 187 EXPECT_EQ(2, root->render_surface()->layer_list()[1]->id());
188 188
189 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 189 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
190 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); 190 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect);
191 } 191 }
192 192
193 TEST_F(DamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) 193 TEST_F(DamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces)
194 { 194 {
195 // Sanity check that the complex test tree will actually produce the expecte d render 195 // Sanity check that the complex test tree will actually produce the expecte d render
196 // surfaces and layer lists. 196 // surfaces and layer lists.
197 197
198 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 198 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
199 199
200 LayerImpl* child1 = root->children()[0]; 200 LayerImpl* child1 = root->children()[0];
201 LayerImpl* child2 = root->children()[1]; 201 LayerImpl* child2 = root->children()[1];
202 gfx::RectF childDamageRect = child1->renderSurface()->damage_tracker()->curr ent_damage_rect(); 202 gfx::RectF childDamageRect = child1->render_surface()->damage_tracker()->cur rent_damage_rect();
203 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 203 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
204 204
205 ASSERT_TRUE(child1->renderSurface()); 205 ASSERT_TRUE(child1->render_surface());
206 EXPECT_FALSE(child2->renderSurface()); 206 EXPECT_FALSE(child2->render_surface());
207 EXPECT_EQ(3u, root->renderSurface()->layer_list().size()); 207 EXPECT_EQ(3u, root->render_surface()->layer_list().size());
208 EXPECT_EQ(2u, child1->renderSurface()->layer_list().size()); 208 EXPECT_EQ(2u, child1->render_surface()->layer_list().size());
209 209
210 // The render surface for child1 only has a contentRect that encloses grandC hild1 and grandChild2, because child1 does not draw content. 210 // The render surface for child1 only has a contentRect that encloses grandC hild1 and grandChild2, because child1 does not draw content.
211 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect); 211 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect);
212 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); 212 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect);
213 } 213 }
214 214
215 TEST_F(DamageTrackerTest, verifyDamageForUpdateRects) 215 TEST_F(DamageTrackerTest, verifyDamageForUpdateRects)
216 { 216 {
217 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 217 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
218 LayerImpl* child = root->children()[0]; 218 LayerImpl* child = root->children()[0];
219 219
220 // CASE 1: Setting the update rect should cause the corresponding damage to the surface. 220 // CASE 1: Setting the update rect should cause the corresponding damage to the surface.
221 // 221 //
222 clearDamageForAllSurfaces(root.get()); 222 clearDamageForAllSurfaces(root.get());
223 child->setUpdateRect(gfx::RectF(10, 11, 12, 13)); 223 child->set_update_rect(gfx::RectF(10, 11, 12, 13));
224 emulateDrawingOneFrame(root.get()); 224 emulateDrawingOneFrame(root.get());
225 225
226 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100). 226 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100).
227 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 227 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
228 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 12, 13), rootDamageRect); 228 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 12, 13), rootDamageRect);
229 229
230 // CASE 2: The same update rect twice in a row still produces the same damag e. 230 // CASE 2: The same update rect twice in a row still produces the same damag e.
231 // 231 //
232 clearDamageForAllSurfaces(root.get()); 232 clearDamageForAllSurfaces(root.get());
233 child->setUpdateRect(gfx::RectF(10, 11, 12, 13)); 233 child->set_update_rect(gfx::RectF(10, 11, 12, 13));
234 emulateDrawingOneFrame(root.get()); 234 emulateDrawingOneFrame(root.get());
235 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 235 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
236 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 12, 13), rootDamageRect); 236 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 12, 13), rootDamageRect);
237 237
238 // CASE 3: Setting a different update rect should cause damage on the new up date region, but no additional exposed old region. 238 // CASE 3: Setting a different update rect should cause damage on the new up date region, but no additional exposed old region.
239 // 239 //
240 clearDamageForAllSurfaces(root.get()); 240 clearDamageForAllSurfaces(root.get());
241 child->setUpdateRect(gfx::RectF(20, 25, 1, 2)); 241 child->set_update_rect(gfx::RectF(20, 25, 1, 2));
242 emulateDrawingOneFrame(root.get()); 242 emulateDrawingOneFrame(root.get());
243 243
244 // Damage position on the surface should be: position of updateRect (20, 25) relative to the child (100, 100). 244 // Damage position on the surface should be: position of updateRect (20, 25) relative to the child (100, 100).
245 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 245 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
246 EXPECT_FLOAT_RECT_EQ(gfx::RectF(120, 125, 1, 2), rootDamageRect); 246 EXPECT_FLOAT_RECT_EQ(gfx::RectF(120, 125, 1, 2), rootDamageRect);
247 } 247 }
248 248
249 TEST_F(DamageTrackerTest, verifyDamageForPropertyChanges) 249 TEST_F(DamageTrackerTest, verifyDamageForPropertyChanges)
250 { 250 {
251 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 251 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
252 LayerImpl* child = root->children()[0]; 252 LayerImpl* child = root->children()[0];
253 253
254 // CASE 1: The layer's property changed flag takes priority over update rect . 254 // CASE 1: The layer's property changed flag takes priority over update rect .
255 // 255 //
256 clearDamageForAllSurfaces(root.get()); 256 clearDamageForAllSurfaces(root.get());
257 child->setUpdateRect(gfx::RectF(10, 11, 12, 13)); 257 child->set_update_rect(gfx::RectF(10, 11, 12, 13));
258 child->setOpacity(0.5); 258 child->SetOpacity(0.5);
259 emulateDrawingOneFrame(root.get()); 259 emulateDrawingOneFrame(root.get());
260 260
261 // Sanity check - we should not have accidentally created a separate render surface for the translucent layer. 261 // Sanity check - we should not have accidentally created a separate render surface for the translucent layer.
262 ASSERT_FALSE(child->renderSurface()); 262 ASSERT_FALSE(child->render_surface());
263 ASSERT_EQ(2u, root->renderSurface()->layer_list().size()); 263 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
264 264
265 // Damage should be the entire child layer in targetSurface space. 265 // Damage should be the entire child layer in targetSurface space.
266 gfx::RectF expectedRect = gfx::RectF(100, 100, 30, 30); 266 gfx::RectF expectedRect = gfx::RectF(100, 100, 30, 30);
267 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 267 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
268 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); 268 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect);
269 269
270 // CASE 2: If a layer moves due to property change, it damages both the new location 270 // CASE 2: If a layer moves due to property change, it damages both the new location
271 // and the old (exposed) location. The old location is the entire ol d layer, 271 // and the old (exposed) location. The old location is the entire ol d layer,
272 // not just the updateRect. 272 // not just the updateRect.
273 273
274 // Cycle one frame of no change, just to sanity check that the next rect is not because of the old damage state. 274 // Cycle one frame of no change, just to sanity check that the next rect is not because of the old damage state.
275 clearDamageForAllSurfaces(root.get()); 275 clearDamageForAllSurfaces(root.get());
276 emulateDrawingOneFrame(root.get()); 276 emulateDrawingOneFrame(root.get());
277 EXPECT_TRUE(root->renderSurface()->damage_tracker()->current_damage_rect().I sEmpty()); 277 EXPECT_TRUE(root->render_surface()->damage_tracker()->current_damage_rect(). IsEmpty());
278 278
279 // Then, test the actual layer movement. 279 // Then, test the actual layer movement.
280 clearDamageForAllSurfaces(root.get()); 280 clearDamageForAllSurfaces(root.get());
281 child->setPosition(gfx::PointF(200, 230)); 281 child->SetPosition(gfx::PointF(200, 230));
282 emulateDrawingOneFrame(root.get()); 282 emulateDrawingOneFrame(root.get());
283 283
284 // Expect damage to be the combination of the previous one and the new one. 284 // Expect damage to be the combination of the previous one and the new one.
285 expectedRect.Union(gfx::RectF(200, 230, 30, 30)); 285 expectedRect.Union(gfx::RectF(200, 230, 30, 30));
286 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 286 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
287 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); 287 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect);
288 } 288 }
289 289
290 TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer) 290 TEST_F(DamageTrackerTest, verifyDamageForTransformedLayer)
291 { 291 {
292 // If a layer is transformed, the damage rect should still enclose the entir e 292 // If a layer is transformed, the damage rect should still enclose the entir e
293 // transformed layer. 293 // transformed layer.
294 294
295 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 295 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
296 LayerImpl* child = root->children()[0]; 296 LayerImpl* child = root->children()[0];
297 297
298 gfx::Transform rotation; 298 gfx::Transform rotation;
299 rotation.Rotate(45); 299 rotation.Rotate(45);
300 300
301 clearDamageForAllSurfaces(root.get()); 301 clearDamageForAllSurfaces(root.get());
302 child->setAnchorPoint(gfx::PointF(0.5, 0.5)); 302 child->SetAnchorPoint(gfx::PointF(0.5, 0.5));
303 child->setPosition(gfx::PointF(85, 85)); 303 child->SetPosition(gfx::PointF(85, 85));
304 emulateDrawingOneFrame(root.get()); 304 emulateDrawingOneFrame(root.get());
305 305
306 // Sanity check that the layer actually moved to (85, 85), damaging its old location and new location. 306 // Sanity check that the layer actually moved to (85, 85), damaging its old location and new location.
307 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 307 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
308 EXPECT_FLOAT_RECT_EQ(gfx::RectF(85, 85, 45, 45), rootDamageRect); 308 EXPECT_FLOAT_RECT_EQ(gfx::RectF(85, 85, 45, 45), rootDamageRect);
309 309
310 // With the anchor on the layer's center, now we can test the rotation more 310 // With the anchor on the layer's center, now we can test the rotation more
311 // intuitively, since it applies about the layer's anchor. 311 // intuitively, since it applies about the layer's anchor.
312 clearDamageForAllSurfaces(root.get()); 312 clearDamageForAllSurfaces(root.get());
313 child->setTransform(rotation); 313 child->SetTransform(rotation);
314 emulateDrawingOneFrame(root.get()); 314 emulateDrawingOneFrame(root.get());
315 315
316 // Since the child layer is square, rotation by 45 degrees about the center should 316 // Since the child layer is square, rotation by 45 degrees about the center should
317 // increase the size of the expected rect by sqrt(2), centered around (100, 100). The 317 // increase the size of the expected rect by sqrt(2), centered around (100, 100). The
318 // old exposed region should be fully contained in the new region. 318 // old exposed region should be fully contained in the new region.
319 double expectedWidth = 30 * sqrt(2.0); 319 double expectedWidth = 30 * sqrt(2.0);
320 double expectedPosition = 100 - 0.5 * expectedWidth; 320 double expectedPosition = 100 - 0.5 * expectedWidth;
321 gfx::RectF expectedRect(expectedPosition, expectedPosition, expectedWidth, e xpectedWidth); 321 gfx::RectF expectedRect(expectedPosition, expectedPosition, expectedWidth, e xpectedWidth);
322 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 322 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
323 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); 323 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect);
324 } 324 }
325 325
326 TEST_F(DamageTrackerTest, verifyDamageForPerspectiveClippedLayer) 326 TEST_F(DamageTrackerTest, verifyDamageForPerspectiveClippedLayer)
327 { 327 {
328 // If a layer has a perspective transform that causes w < 0, then not clippi ng the 328 // If a layer has a perspective transform that causes w < 0, then not clippi ng the
329 // layer can cause an invalid damage rect. This test checks that the w < 0 c ase is 329 // layer can cause an invalid damage rect. This test checks that the w < 0 c ase is
330 // tracked properly. 330 // tracked properly.
331 // 331 //
332 // The transform is constructed so that if w < 0 clipping is not performed, the 332 // The transform is constructed so that if w < 0 clipping is not performed, the
333 // incorrect rect will be very small, specifically: position (500.972504, 49 8.544617) and size 0.056610 x 2.910767. 333 // incorrect rect will be very small, specifically: position (500.972504, 49 8.544617) and size 0.056610 x 2.910767.
334 // Instead, the correctly transformed rect should actually be very huge (i.e . in theory, -infinity on the left), 334 // Instead, the correctly transformed rect should actually be very huge (i.e . in theory, -infinity on the left),
335 // and positioned so that the right-most bound rect will be approximately 50 1 units in root surface space. 335 // and positioned so that the right-most bound rect will be approximately 50 1 units in root surface space.
336 // 336 //
337 337
338 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 338 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
339 LayerImpl* child = root->children()[0]; 339 LayerImpl* child = root->children()[0];
340 340
341 gfx::Transform transform; 341 gfx::Transform transform;
342 transform.Translate3d(500, 500, 0); 342 transform.Translate3d(500, 500, 0);
343 transform.ApplyPerspectiveDepth(1); 343 transform.ApplyPerspectiveDepth(1);
344 transform.RotateAboutYAxis(45); 344 transform.RotateAboutYAxis(45);
345 transform.Translate3d(-50, -50, 0); 345 transform.Translate3d(-50, -50, 0);
346 346
347 // Set up the child 347 // Set up the child
348 child->setPosition(gfx::PointF(0, 0)); 348 child->SetPosition(gfx::PointF(0, 0));
349 child->setBounds(gfx::Size(100, 100)); 349 child->SetBounds(gfx::Size(100, 100));
350 child->setContentBounds(gfx::Size(100, 100)); 350 child->SetContentBounds(gfx::Size(100, 100));
351 child->setTransform(transform); 351 child->SetTransform(transform);
352 emulateDrawingOneFrame(root.get()); 352 emulateDrawingOneFrame(root.get());
353 353
354 // Sanity check that the child layer's bounds would actually get clipped by w < 0, 354 // Sanity check that the child layer's bounds would actually get clipped by w < 0,
355 // otherwise this test is not actually testing the intended scenario. 355 // otherwise this test is not actually testing the intended scenario.
356 gfx::QuadF testQuad(gfx::RectF(gfx::PointF(), gfx::SizeF(100, 100))); 356 gfx::QuadF testQuad(gfx::RectF(gfx::PointF(), gfx::SizeF(100, 100)));
357 bool clipped = false; 357 bool clipped = false;
358 MathUtil::mapQuad(transform, testQuad, clipped); 358 MathUtil::mapQuad(transform, testQuad, clipped);
359 EXPECT_TRUE(clipped); 359 EXPECT_TRUE(clipped);
360 360
361 // Damage the child without moving it. 361 // Damage the child without moving it.
362 clearDamageForAllSurfaces(root.get()); 362 clearDamageForAllSurfaces(root.get());
363 child->setOpacity(0.5); 363 child->SetOpacity(0.5);
364 emulateDrawingOneFrame(root.get()); 364 emulateDrawingOneFrame(root.get());
365 365
366 // The expected damage should cover the entire root surface (500x500), but w e don't 366 // The expected damage should cover the entire root surface (500x500), but w e don't
367 // care whether the damage rect was clamped or is larger than the surface fo r this test. 367 // care whether the damage rect was clamped or is larger than the surface fo r this test.
368 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 368 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
369 gfx::RectF damageWeCareAbout = gfx::RectF(gfx::PointF(), gfx::SizeF(500, 500 )); 369 gfx::RectF damageWeCareAbout = gfx::RectF(gfx::PointF(), gfx::SizeF(500, 500 ));
370 EXPECT_TRUE(rootDamageRect.Contains(damageWeCareAbout)); 370 EXPECT_TRUE(rootDamageRect.Contains(damageWeCareAbout));
371 } 371 }
372 372
373 TEST_F(DamageTrackerTest, verifyDamageForBlurredSurface) 373 TEST_F(DamageTrackerTest, verifyDamageForBlurredSurface)
374 { 374 {
375 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 375 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
376 LayerImpl* child = root->children()[0]; 376 LayerImpl* child = root->children()[0];
377 377
378 WebFilterOperations filters; 378 WebFilterOperations filters;
379 filters.append(WebFilterOperation::createBlurFilter(5)); 379 filters.append(WebFilterOperation::createBlurFilter(5));
380 int outsetTop, outsetRight, outsetBottom, outsetLeft; 380 int outsetTop, outsetRight, outsetBottom, outsetLeft;
381 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); 381 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft);
382 382
383 // Setting the filter will damage the whole surface. 383 // Setting the filter will damage the whole surface.
384 clearDamageForAllSurfaces(root.get()); 384 clearDamageForAllSurfaces(root.get());
385 root->setFilters(filters); 385 root->SetFilters(filters);
386 emulateDrawingOneFrame(root.get()); 386 emulateDrawingOneFrame(root.get());
387 387
388 // Setting the update rect should cause the corresponding damage to the surf ace, blurred based on the size of the blur filter. 388 // Setting the update rect should cause the corresponding damage to the surf ace, blurred based on the size of the blur filter.
389 clearDamageForAllSurfaces(root.get()); 389 clearDamageForAllSurfaces(root.get());
390 child->setUpdateRect(gfx::RectF(10, 11, 12, 13)); 390 child->set_update_rect(gfx::RectF(10, 11, 12, 13));
391 emulateDrawingOneFrame(root.get()); 391 emulateDrawingOneFrame(root.get());
392 392
393 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100), but expanded by the blur outsets. 393 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100), but expanded by the blur outsets.
394 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 394 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
395 gfx::RectF expectedDamageRect = gfx::RectF(110, 111, 12, 13); 395 gfx::RectF expectedDamageRect = gfx::RectF(110, 111, 12, 13);
396 expectedDamageRect.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBotto m); 396 expectedDamageRect.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBotto m);
397 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 397 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
398 } 398 }
399 399
400 TEST_F(DamageTrackerTest, verifyDamageForImageFilter) 400 TEST_F(DamageTrackerTest, verifyDamageForImageFilter)
401 { 401 {
402 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 402 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
403 LayerImpl* child = root->children()[0]; 403 LayerImpl* child = root->children()[0];
404 gfx::RectF rootDamageRect, childDamageRect; 404 gfx::RectF rootDamageRect, childDamageRect;
405 405
406 // Allow us to set damage on child too. 406 // Allow us to set damage on child too.
407 child->setDrawsContent(true); 407 child->SetDrawsContent(true);
408 408
409 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(new SkBlurImageFilter(Sk IntToScalar(2), SkIntToScalar(2))); 409 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(new SkBlurImageFilter(Sk IntToScalar(2), SkIntToScalar(2)));
410 // Setting the filter will damage the whole surface. 410 // Setting the filter will damage the whole surface.
411 clearDamageForAllSurfaces(root.get()); 411 clearDamageForAllSurfaces(root.get());
412 child->setFilter(filter); 412 child->SetFilter(filter);
413 emulateDrawingOneFrame(root.get()); 413 emulateDrawingOneFrame(root.get());
414 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 414 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
415 childDamageRect = child->renderSurface()->damage_tracker()->current_damage_r ect(); 415 childDamageRect = child->render_surface()->damage_tracker()->current_damage_ rect();
416 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect); 416 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect);
417 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); 417 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect);
418 418
419 // CASE 1: Setting the update rect should damage the whole surface (for now) 419 // CASE 1: Setting the update rect should damage the whole surface (for now)
420 clearDamageForAllSurfaces(root.get()); 420 clearDamageForAllSurfaces(root.get());
421 child->setUpdateRect(gfx::RectF(0, 0, 1, 1)); 421 child->set_update_rect(gfx::RectF(0, 0, 1, 1));
422 emulateDrawingOneFrame(root.get()); 422 emulateDrawingOneFrame(root.get());
423 423
424 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 424 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
425 childDamageRect = child->renderSurface()->damage_tracker()->current_damage_r ect(); 425 childDamageRect = child->render_surface()->damage_tracker()->current_damage_ rect();
426 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect); 426 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect);
427 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); 427 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect);
428 } 428 }
429 429
430 TEST_F(DamageTrackerTest, verifyDamageForBackgroundBlurredChild) 430 TEST_F(DamageTrackerTest, verifyDamageForBackgroundBlurredChild)
431 { 431 {
432 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 432 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
433 LayerImpl* child1 = root->children()[0]; 433 LayerImpl* child1 = root->children()[0];
434 LayerImpl* child2 = root->children()[1]; 434 LayerImpl* child2 = root->children()[1];
435 435
436 // Allow us to set damage on child1 too. 436 // Allow us to set damage on child1 too.
437 child1->setDrawsContent(true); 437 child1->SetDrawsContent(true);
438 438
439 WebFilterOperations filters; 439 WebFilterOperations filters;
440 filters.append(WebFilterOperation::createBlurFilter(2)); 440 filters.append(WebFilterOperation::createBlurFilter(2));
441 int outsetTop, outsetRight, outsetBottom, outsetLeft; 441 int outsetTop, outsetRight, outsetBottom, outsetLeft;
442 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); 442 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft);
443 443
444 // Setting the filter will damage the whole surface. 444 // Setting the filter will damage the whole surface.
445 clearDamageForAllSurfaces(root.get()); 445 clearDamageForAllSurfaces(root.get());
446 child1->setBackgroundFilters(filters); 446 child1->SetBackgroundFilters(filters);
447 emulateDrawingOneFrame(root.get()); 447 emulateDrawingOneFrame(root.get());
448 448
449 // CASE 1: Setting the update rect should cause the corresponding damage to 449 // CASE 1: Setting the update rect should cause the corresponding damage to
450 // the surface, blurred based on the size of the child's background blur 450 // the surface, blurred based on the size of the child's background blur
451 // filter. 451 // filter.
452 clearDamageForAllSurfaces(root.get()); 452 clearDamageForAllSurfaces(root.get());
453 root->setUpdateRect(gfx::RectF(297, 297, 2, 2)); 453 root->set_update_rect(gfx::RectF(297, 297, 2, 2));
454 emulateDrawingOneFrame(root.get()); 454 emulateDrawingOneFrame(root.get());
455 455
456 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 456 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
457 // Damage position on the surface should be a composition of the damage on t he root and on child2. 457 // Damage position on the surface should be a composition of the damage on t he root and on child2.
458 // Damage on the root should be: position of updateRect (297, 297), but expa nded by the blur outsets. 458 // Damage on the root should be: position of updateRect (297, 297), but expa nded by the blur outsets.
459 gfx::RectF expectedDamageRect = gfx::RectF(297, 297, 2, 2); 459 gfx::RectF expectedDamageRect = gfx::RectF(297, 297, 2, 2);
460 expectedDamageRect.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBotto m); 460 expectedDamageRect.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBotto m);
461 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 461 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
462 462
463 // CASE 2: Setting the update rect should cause the corresponding damage to 463 // CASE 2: Setting the update rect should cause the corresponding damage to
464 // the surface, blurred based on the size of the child's background blur 464 // the surface, blurred based on the size of the child's background blur
465 // filter. Since the damage extends to the right/bottom outside of the 465 // filter. Since the damage extends to the right/bottom outside of the
466 // blurred layer, only the left/top should end up expanded. 466 // blurred layer, only the left/top should end up expanded.
467 clearDamageForAllSurfaces(root.get()); 467 clearDamageForAllSurfaces(root.get());
468 root->setUpdateRect(gfx::RectF(297, 297, 30, 30)); 468 root->set_update_rect(gfx::RectF(297, 297, 30, 30));
469 emulateDrawingOneFrame(root.get()); 469 emulateDrawingOneFrame(root.get());
470 470
471 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 471 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
472 // Damage position on the surface should be a composition of the damage on t he root and on child2. 472 // Damage position on the surface should be a composition of the damage on t he root and on child2.
473 // Damage on the root should be: position of updateRect (297, 297), but expa nded on the left/top 473 // Damage on the root should be: position of updateRect (297, 297), but expa nded on the left/top
474 // by the blur outsets. 474 // by the blur outsets.
475 expectedDamageRect = gfx::RectF(297, 297, 30, 30); 475 expectedDamageRect = gfx::RectF(297, 297, 30, 30);
476 expectedDamageRect.Inset(-outsetLeft, -outsetTop, 0, 0); 476 expectedDamageRect.Inset(-outsetLeft, -outsetTop, 0, 0);
477 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 477 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
478 478
479 // CASE 3: Setting this update rect outside the blurred contentBounds of the blurred 479 // CASE 3: Setting this update rect outside the blurred contentBounds of the blurred
480 // child1 will not cause it to be expanded. 480 // child1 will not cause it to be expanded.
481 clearDamageForAllSurfaces(root.get()); 481 clearDamageForAllSurfaces(root.get());
482 root->setUpdateRect(gfx::RectF(30, 30, 2, 2)); 482 root->set_update_rect(gfx::RectF(30, 30, 2, 2));
483 emulateDrawingOneFrame(root.get()); 483 emulateDrawingOneFrame(root.get());
484 484
485 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 485 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
486 // Damage on the root should be: position of updateRect (30, 30), not 486 // Damage on the root should be: position of updateRect (30, 30), not
487 // expanded. 487 // expanded.
488 expectedDamageRect = gfx::RectF(30, 30, 2, 2); 488 expectedDamageRect = gfx::RectF(30, 30, 2, 2);
489 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 489 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
490 490
491 // CASE 4: Setting this update rect inside the blurred contentBounds but out side the 491 // CASE 4: Setting this update rect inside the blurred contentBounds but out side the
492 // original contentBounds of the blurred child1 will cause it to be expanded . 492 // original contentBounds of the blurred child1 will cause it to be expanded .
493 clearDamageForAllSurfaces(root.get()); 493 clearDamageForAllSurfaces(root.get());
494 root->setUpdateRect(gfx::RectF(99, 99, 1, 1)); 494 root->set_update_rect(gfx::RectF(99, 99, 1, 1));
495 emulateDrawingOneFrame(root.get()); 495 emulateDrawingOneFrame(root.get());
496 496
497 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 497 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
498 // Damage on the root should be: position of updateRect (99, 99), expanded 498 // Damage on the root should be: position of updateRect (99, 99), expanded
499 // by the blurring on child1, but since it is 1 pixel outside the layer, the 499 // by the blurring on child1, but since it is 1 pixel outside the layer, the
500 // expanding should be reduced by 1. 500 // expanding should be reduced by 1.
501 expectedDamageRect = gfx::RectF(99, 99, 1, 1); 501 expectedDamageRect = gfx::RectF(99, 99, 1, 1);
502 expectedDamageRect.Inset(-outsetLeft + 1, -outsetTop + 1, -outsetRight, -out setBottom); 502 expectedDamageRect.Inset(-outsetLeft + 1, -outsetTop + 1, -outsetRight, -out setBottom);
503 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 503 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
504 504
505 // CASE 5: Setting the update rect on child2, which is above child1, will 505 // CASE 5: Setting the update rect on child2, which is above child1, will
506 // not get blurred by child1, so it does not need to get expanded. 506 // not get blurred by child1, so it does not need to get expanded.
507 clearDamageForAllSurfaces(root.get()); 507 clearDamageForAllSurfaces(root.get());
508 child2->setUpdateRect(gfx::RectF(0, 0, 1, 1)); 508 child2->set_update_rect(gfx::RectF(0, 0, 1, 1));
509 emulateDrawingOneFrame(root.get()); 509 emulateDrawingOneFrame(root.get());
510 510
511 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 511 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
512 // Damage on child2 should be: position of updateRect offset by the child's position (11, 11), and not expanded by anything. 512 // Damage on child2 should be: position of updateRect offset by the child's position (11, 11), and not expanded by anything.
513 expectedDamageRect = gfx::RectF(11, 11, 1, 1); 513 expectedDamageRect = gfx::RectF(11, 11, 1, 1);
514 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 514 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
515 515
516 // CASE 6: Setting the update rect on child1 will also blur the damage, so 516 // CASE 6: Setting the update rect on child1 will also blur the damage, so
517 // that any pixels needed for the blur are redrawn in the current frame. 517 // that any pixels needed for the blur are redrawn in the current frame.
518 clearDamageForAllSurfaces(root.get()); 518 clearDamageForAllSurfaces(root.get());
519 child1->setUpdateRect(gfx::RectF(0, 0, 1, 1)); 519 child1->set_update_rect(gfx::RectF(0, 0, 1, 1));
520 emulateDrawingOneFrame(root.get()); 520 emulateDrawingOneFrame(root.get());
521 521
522 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 522 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
523 // Damage on child1 should be: position of updateRect offset by the child's position (100, 100), and expanded by the damage. 523 // Damage on child1 should be: position of updateRect offset by the child's position (100, 100), and expanded by the damage.
524 expectedDamageRect = gfx::RectF(100, 100, 1, 1); 524 expectedDamageRect = gfx::RectF(100, 100, 1, 1);
525 expectedDamageRect.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBotto m); 525 expectedDamageRect.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBotto m);
526 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); 526 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect);
527 } 527 }
528 528
529 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer) 529 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer)
530 { 530 {
531 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 531 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
532 LayerImpl* child1 = root->children()[0]; 532 LayerImpl* child1 = root->children()[0];
533 533
534 // CASE 1: Adding a new layer should cause the appropriate damage. 534 // CASE 1: Adding a new layer should cause the appropriate damage.
535 // 535 //
536 clearDamageForAllSurfaces(root.get()); 536 clearDamageForAllSurfaces(root.get());
537 { 537 {
538 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree() , 3); 538 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3);
539 child2->setPosition(gfx::PointF(400, 380)); 539 child2->SetPosition(gfx::PointF(400, 380));
540 child2->setAnchorPoint(gfx::PointF()); 540 child2->SetAnchorPoint(gfx::PointF());
541 child2->setBounds(gfx::Size(6, 8)); 541 child2->SetBounds(gfx::Size(6, 8));
542 child2->setContentBounds(gfx::Size(6, 8)); 542 child2->SetContentBounds(gfx::Size(6, 8));
543 child2->setDrawsContent(true); 543 child2->SetDrawsContent(true);
544 root->addChild(child2.Pass()); 544 root->AddChild(child2.Pass());
545 } 545 }
546 emulateDrawingOneFrame(root.get()); 546 emulateDrawingOneFrame(root.get());
547 547
548 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere. 548 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere.
549 ASSERT_EQ(3u, root->renderSurface()->layer_list().size()); 549 ASSERT_EQ(3u, root->render_surface()->layer_list().size());
550 550
551 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 551 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
552 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect); 552 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect);
553 553
554 // CASE 2: If the layer is removed, its entire old layer becomes exposed, no t just the 554 // CASE 2: If the layer is removed, its entire old layer becomes exposed, no t just the
555 // last update rect. 555 // last update rect.
556 556
557 // Advance one frame without damage so that we know the damage rect is not l eftover from the previous case. 557 // Advance one frame without damage so that we know the damage rect is not l eftover from the previous case.
558 clearDamageForAllSurfaces(root.get()); 558 clearDamageForAllSurfaces(root.get());
559 emulateDrawingOneFrame(root.get()); 559 emulateDrawingOneFrame(root.get());
560 EXPECT_TRUE(root->renderSurface()->damage_tracker()->current_damage_rect().I sEmpty()); 560 EXPECT_TRUE(root->render_surface()->damage_tracker()->current_damage_rect(). IsEmpty());
561 561
562 // Then, test removing child1. 562 // Then, test removing child1.
563 root->removeChild(child1); 563 root->RemoveChild(child1);
564 child1 = NULL; 564 child1 = NULL;
565 emulateDrawingOneFrame(root.get()); 565 emulateDrawingOneFrame(root.get());
566 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 566 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
567 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect); 567 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 30, 30), rootDamageRect);
568 } 568 }
569 569
570 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer) 570 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer)
571 { 571 {
572 // If child2 is added to the layer tree, but it doesn't have any explicit da mage of 572 // If child2 is added to the layer tree, but it doesn't have any explicit da mage of
573 // its own, it should still indeed damage the target surface. 573 // its own, it should still indeed damage the target surface.
574 574
575 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 575 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
576 576
577 clearDamageForAllSurfaces(root.get()); 577 clearDamageForAllSurfaces(root.get());
578 { 578 {
579 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree() , 3); 579 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3);
580 child2->setPosition(gfx::PointF(400, 380)); 580 child2->SetPosition(gfx::PointF(400, 380));
581 child2->setAnchorPoint(gfx::PointF()); 581 child2->SetAnchorPoint(gfx::PointF());
582 child2->setBounds(gfx::Size(6, 8)); 582 child2->SetBounds(gfx::Size(6, 8));
583 child2->setContentBounds(gfx::Size(6, 8)); 583 child2->SetContentBounds(gfx::Size(6, 8));
584 child2->setDrawsContent(true); 584 child2->SetDrawsContent(true);
585 child2->resetAllChangeTrackingForSubtree(); 585 child2->ResetAllChangeTrackingForSubtree();
586 // Sanity check the initial conditions of the test, if these asserts tri gger, it 586 // Sanity check the initial conditions of the test, if these asserts tri gger, it
587 // means the test no longer actually covers the intended scenario. 587 // means the test no longer actually covers the intended scenario.
588 ASSERT_FALSE(child2->layerPropertyChanged()); 588 ASSERT_FALSE(child2->LayerPropertyChanged());
589 ASSERT_TRUE(child2->updateRect().IsEmpty()); 589 ASSERT_TRUE(child2->update_rect().IsEmpty());
590 root->addChild(child2.Pass()); 590 root->AddChild(child2.Pass());
591 } 591 }
592 emulateDrawingOneFrame(root.get()); 592 emulateDrawingOneFrame(root.get());
593 593
594 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere. 594 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere.
595 ASSERT_EQ(3u, root->renderSurface()->layer_list().size()); 595 ASSERT_EQ(3u, root->render_surface()->layer_list().size());
596 596
597 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 597 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
598 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect); 598 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect);
599 } 599 }
600 600
601 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers) 601 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers)
602 { 602 {
603 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 603 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
604 LayerImpl* child1 = root->children()[0]; 604 LayerImpl* child1 = root->children()[0];
605 605
606 // In this test we don't want the above tree manipulation to be considered p art of the same frame. 606 // In this test we don't want the above tree manipulation to be considered p art of the same frame.
607 clearDamageForAllSurfaces(root.get()); 607 clearDamageForAllSurfaces(root.get());
608 { 608 {
609 scoped_ptr<LayerImpl> child2 = LayerImpl::create(m_hostImpl.activeTree() , 3); 609 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3);
610 child2->setPosition(gfx::PointF(400, 380)); 610 child2->SetPosition(gfx::PointF(400, 380));
611 child2->setAnchorPoint(gfx::PointF()); 611 child2->SetAnchorPoint(gfx::PointF());
612 child2->setBounds(gfx::Size(6, 8)); 612 child2->SetBounds(gfx::Size(6, 8));
613 child2->setContentBounds(gfx::Size(6, 8)); 613 child2->SetContentBounds(gfx::Size(6, 8));
614 child2->setDrawsContent(true); 614 child2->SetDrawsContent(true);
615 root->addChild(child2.Pass()); 615 root->AddChild(child2.Pass());
616 } 616 }
617 LayerImpl* child2 = root->children()[1]; 617 LayerImpl* child2 = root->children()[1];
618 emulateDrawingOneFrame(root.get()); 618 emulateDrawingOneFrame(root.get());
619 619
620 // Damaging two layers simultaneously should cause combined damage. 620 // Damaging two layers simultaneously should cause combined damage.
621 // - child1 update rect in surface space: gfx::RectF(100, 100, 1, 2); 621 // - child1 update rect in surface space: gfx::RectF(100, 100, 1, 2);
622 // - child2 update rect in surface space: gfx::RectF(400, 380, 3, 4); 622 // - child2 update rect in surface space: gfx::RectF(400, 380, 3, 4);
623 clearDamageForAllSurfaces(root.get()); 623 clearDamageForAllSurfaces(root.get());
624 child1->setUpdateRect(gfx::RectF(0, 0, 1, 2)); 624 child1->set_update_rect(gfx::RectF(0, 0, 1, 2));
625 child2->setUpdateRect(gfx::RectF(0, 0, 3, 4)); 625 child2->set_update_rect(gfx::RectF(0, 0, 3, 4));
626 emulateDrawingOneFrame(root.get()); 626 emulateDrawingOneFrame(root.get());
627 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 627 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
628 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 303, 284), rootDamageRect); 628 EXPECT_FLOAT_RECT_EQ(gfx::RectF(100, 100, 303, 284), rootDamageRect);
629 } 629 }
630 630
631 TEST_F(DamageTrackerTest, verifyDamageForNestedSurfaces) 631 TEST_F(DamageTrackerTest, verifyDamageForNestedSurfaces)
632 { 632 {
633 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 633 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
634 LayerImpl* child1 = root->children()[0]; 634 LayerImpl* child1 = root->children()[0];
635 LayerImpl* child2 = root->children()[1]; 635 LayerImpl* child2 = root->children()[1];
636 LayerImpl* grandChild1 = root->children()[0]->children()[0]; 636 LayerImpl* grandChild1 = root->children()[0]->children()[0];
637 gfx::RectF childDamageRect; 637 gfx::RectF childDamageRect;
638 gfx::RectF rootDamageRect; 638 gfx::RectF rootDamageRect;
639 639
640 // CASE 1: Damage to a descendant surface should propagate properly to ances tor surface. 640 // CASE 1: Damage to a descendant surface should propagate properly to ances tor surface.
641 // 641 //
642 clearDamageForAllSurfaces(root.get()); 642 clearDamageForAllSurfaces(root.get());
643 grandChild1->setOpacity(0.5); 643 grandChild1->SetOpacity(0.5);
644 emulateDrawingOneFrame(root.get()); 644 emulateDrawingOneFrame(root.get());
645 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 645 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
646 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 646 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
647 EXPECT_FLOAT_RECT_EQ(gfx::RectF(200, 200, 6, 8), childDamageRect); 647 EXPECT_FLOAT_RECT_EQ(gfx::RectF(200, 200, 6, 8), childDamageRect);
648 EXPECT_FLOAT_RECT_EQ(gfx::RectF(300, 300, 6, 8), rootDamageRect); 648 EXPECT_FLOAT_RECT_EQ(gfx::RectF(300, 300, 6, 8), rootDamageRect);
649 649
650 // CASE 2: Same as previous case, but with additional damage elsewhere that should be properly unioned. 650 // CASE 2: Same as previous case, but with additional damage elsewhere that should be properly unioned.
651 // - child1 surface damage in root surface space: gfx::RectF(300, 300, 6, 8) ; 651 // - child1 surface damage in root surface space: gfx::RectF(300, 300, 6, 8) ;
652 // - child2 damage in root surface space: gfx::RectF(11, 11, 18, 18); 652 // - child2 damage in root surface space: gfx::RectF(11, 11, 18, 18);
653 clearDamageForAllSurfaces(root.get()); 653 clearDamageForAllSurfaces(root.get());
654 grandChild1->setOpacity(0.7f); 654 grandChild1->SetOpacity(0.7f);
655 child2->setOpacity(0.7f); 655 child2->SetOpacity(0.7f);
656 emulateDrawingOneFrame(root.get()); 656 emulateDrawingOneFrame(root.get());
657 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 657 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
658 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 658 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
659 EXPECT_FLOAT_RECT_EQ(gfx::RectF(200, 200, 6, 8), childDamageRect); 659 EXPECT_FLOAT_RECT_EQ(gfx::RectF(200, 200, 6, 8), childDamageRect);
660 EXPECT_FLOAT_RECT_EQ(gfx::RectF(11, 11, 295, 297), rootDamageRect); 660 EXPECT_FLOAT_RECT_EQ(gfx::RectF(11, 11, 295, 297), rootDamageRect);
661 } 661 }
662 662
663 TEST_F(DamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer) 663 TEST_F(DamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer)
664 { 664 {
665 // If descendant layer changes and affects the content bounds of the render surface, 665 // If descendant layer changes and affects the content bounds of the render surface,
666 // then the entire descendant surface should be damaged, and it should damag e its 666 // then the entire descendant surface should be damaged, and it should damag e its
667 // ancestor surface with the old and new surface regions. 667 // ancestor surface with the old and new surface regions.
668 668
669 // This is a tricky case, since only the first grandChild changes, but the e ntire 669 // This is a tricky case, since only the first grandChild changes, but the e ntire
670 // surface should be marked dirty. 670 // surface should be marked dirty.
671 671
672 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 672 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
673 LayerImpl* child1 = root->children()[0]; 673 LayerImpl* child1 = root->children()[0];
674 LayerImpl* grandChild1 = root->children()[0]->children()[0]; 674 LayerImpl* grandChild1 = root->children()[0]->children()[0];
675 gfx::RectF childDamageRect; 675 gfx::RectF childDamageRect;
676 gfx::RectF rootDamageRect; 676 gfx::RectF rootDamageRect;
677 677
678 clearDamageForAllSurfaces(root.get()); 678 clearDamageForAllSurfaces(root.get());
679 grandChild1->setPosition(gfx::PointF(195, 205)); 679 grandChild1->SetPosition(gfx::PointF(195, 205));
680 emulateDrawingOneFrame(root.get()); 680 emulateDrawingOneFrame(root.get());
681 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 681 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
682 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 682 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
683 683
684 // The new surface bounds should be damaged entirely, even though only one o f the layers changed. 684 // The new surface bounds should be damaged entirely, even though only one o f the layers changed.
685 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 11, 23), childDamageRect); 685 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 11, 23), childDamageRect);
686 686
687 // Damage to the root surface should be the union of child1's *entire* rende r surface 687 // Damage to the root surface should be the union of child1's *entire* rende r surface
688 // (in target space), and its old exposed area (also in target space). 688 // (in target space), and its old exposed area (also in target space).
689 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 23), rootDamageRect); 689 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 23), rootDamageRect);
690 } 690 }
691 691
692 TEST_F(DamageTrackerTest, verifyDamageForSurfaceChangeFromAncestorLayer) 692 TEST_F(DamageTrackerTest, verifyDamageForSurfaceChangeFromAncestorLayer)
693 { 693 {
694 // An ancestor/owning layer changes that affects the position/transform of t he render 694 // An ancestor/owning layer changes that affects the position/transform of t he render
695 // surface. Note that in this case, the layerPropertyChanged flag already pr opagates 695 // surface. Note that in this case, the layerPropertyChanged flag already pr opagates
696 // to the subtree (tested in LayerImpltest), which damages the entire child1 696 // to the subtree (tested in LayerImpltest), which damages the entire child1
697 // surface, but the damage tracker still needs the correct logic to compute the 697 // surface, but the damage tracker still needs the correct logic to compute the
698 // exposed region on the root surface. 698 // exposed region on the root surface.
699 699
700 // FIXME: the expectations of this test case should change when we add suppo rt for a 700 // FIXME: the expectations of this test case should change when we add suppo rt for a
701 // unique scissorRect per renderSurface. In that case, the child1 sur face 701 // unique scissorRect per renderSurface. In that case, the child1 sur face
702 // should be completely unchanged, since we are only transforming it, while the 702 // should be completely unchanged, since we are only transforming it, while the
703 // root surface would be damaged appropriately. 703 // root surface would be damaged appropriately.
704 704
705 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 705 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
706 LayerImpl* child1 = root->children()[0]; 706 LayerImpl* child1 = root->children()[0];
707 gfx::RectF childDamageRect; 707 gfx::RectF childDamageRect;
708 gfx::RectF rootDamageRect; 708 gfx::RectF rootDamageRect;
709 709
710 clearDamageForAllSurfaces(root.get()); 710 clearDamageForAllSurfaces(root.get());
711 child1->setPosition(gfx::PointF(50, 50)); 711 child1->SetPosition(gfx::PointF(50, 50));
712 emulateDrawingOneFrame(root.get()); 712 emulateDrawingOneFrame(root.get());
713 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 713 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
714 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 714 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
715 715
716 // The new surface bounds should be damaged entirely. 716 // The new surface bounds should be damaged entirely.
717 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect); 717 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect);
718 718
719 // The entire child1 surface and the old exposed child1 surface should damag e the root surface. 719 // The entire child1 surface and the old exposed child1 surface should damag e the root surface.
720 // - old child1 surface in target space: gfx::RectF(290, 290, 16, 18) 720 // - old child1 surface in target space: gfx::RectF(290, 290, 16, 18)
721 // - new child1 surface in target space: gfx::RectF(240, 240, 16, 18) 721 // - new child1 surface in target space: gfx::RectF(240, 240, 16, 18)
722 EXPECT_FLOAT_RECT_EQ(gfx::RectF(240, 240, 66, 68), rootDamageRect); 722 EXPECT_FLOAT_RECT_EQ(gfx::RectF(240, 240, 66, 68), rootDamageRect);
723 } 723 }
724 724
725 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) 725 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces)
726 { 726 {
727 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 727 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
728 LayerImpl* child1 = root->children()[0]; 728 LayerImpl* child1 = root->children()[0];
729 gfx::RectF childDamageRect; 729 gfx::RectF childDamageRect;
730 gfx::RectF rootDamageRect; 730 gfx::RectF rootDamageRect;
731 731
732 // CASE 1: If a descendant surface disappears, its entire old area becomes e xposed. 732 // CASE 1: If a descendant surface disappears, its entire old area becomes e xposed.
733 // 733 //
734 clearDamageForAllSurfaces(root.get()); 734 clearDamageForAllSurfaces(root.get());
735 child1->setOpacity(1); 735 child1->SetOpacity(1);
736 child1->setForceRenderSurface(false); 736 child1->SetForceRenderSurface(false);
737 emulateDrawingOneFrame(root.get()); 737 emulateDrawingOneFrame(root.get());
738 738
739 // Sanity check that there is only one surface now. 739 // Sanity check that there is only one surface now.
740 ASSERT_FALSE(child1->renderSurface()); 740 ASSERT_FALSE(child1->render_surface());
741 ASSERT_EQ(4u, root->renderSurface()->layer_list().size()); 741 ASSERT_EQ(4u, root->render_surface()->layer_list().size());
742 742
743 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 743 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
744 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 18), rootDamageRect); 744 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 18), rootDamageRect);
745 745
746 // CASE 2: If a descendant surface appears, its entire old area becomes expo sed. 746 // CASE 2: If a descendant surface appears, its entire old area becomes expo sed.
747 747
748 // Cycle one frame of no change, just to sanity check that the next rect is not because of the old damage state. 748 // Cycle one frame of no change, just to sanity check that the next rect is not because of the old damage state.
749 clearDamageForAllSurfaces(root.get()); 749 clearDamageForAllSurfaces(root.get());
750 emulateDrawingOneFrame(root.get()); 750 emulateDrawingOneFrame(root.get());
751 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 751 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
752 EXPECT_TRUE(rootDamageRect.IsEmpty()); 752 EXPECT_TRUE(rootDamageRect.IsEmpty());
753 753
754 // Then change the tree so that the render surface is added back. 754 // Then change the tree so that the render surface is added back.
755 clearDamageForAllSurfaces(root.get()); 755 clearDamageForAllSurfaces(root.get());
756 child1->setOpacity(0.5); 756 child1->SetOpacity(0.5);
757 child1->setForceRenderSurface(true); 757 child1->SetForceRenderSurface(true);
758 emulateDrawingOneFrame(root.get()); 758 emulateDrawingOneFrame(root.get());
759 759
760 // Sanity check that there is a new surface now. 760 // Sanity check that there is a new surface now.
761 ASSERT_TRUE(child1->renderSurface()); 761 ASSERT_TRUE(child1->render_surface());
762 EXPECT_EQ(3u, root->renderSurface()->layer_list().size()); 762 EXPECT_EQ(3u, root->render_surface()->layer_list().size());
763 EXPECT_EQ(2u, child1->renderSurface()->layer_list().size()); 763 EXPECT_EQ(2u, child1->render_surface()->layer_list().size());
764 764
765 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 765 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
766 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 766 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
767 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect); 767 EXPECT_FLOAT_RECT_EQ(gfx::RectF(190, 190, 16, 18), childDamageRect);
768 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 18), rootDamageRect); 768 EXPECT_FLOAT_RECT_EQ(gfx::RectF(290, 290, 16, 18), rootDamageRect);
769 } 769 }
770 770
771 TEST_F(DamageTrackerTest, verifyNoDamageWhenNothingChanged) 771 TEST_F(DamageTrackerTest, verifyNoDamageWhenNothingChanged)
772 { 772 {
773 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 773 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
774 LayerImpl* child1 = root->children()[0]; 774 LayerImpl* child1 = root->children()[0];
775 gfx::RectF childDamageRect; 775 gfx::RectF childDamageRect;
776 gfx::RectF rootDamageRect; 776 gfx::RectF rootDamageRect;
777 777
778 // CASE 1: If nothing changes, the damage rect should be empty. 778 // CASE 1: If nothing changes, the damage rect should be empty.
779 // 779 //
780 clearDamageForAllSurfaces(root.get()); 780 clearDamageForAllSurfaces(root.get());
781 emulateDrawingOneFrame(root.get()); 781 emulateDrawingOneFrame(root.get());
782 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 782 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
783 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 783 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
784 EXPECT_TRUE(childDamageRect.IsEmpty()); 784 EXPECT_TRUE(childDamageRect.IsEmpty());
785 EXPECT_TRUE(rootDamageRect.IsEmpty()); 785 EXPECT_TRUE(rootDamageRect.IsEmpty());
786 786
787 // CASE 2: If nothing changes twice in a row, the damage rect should still b e empty. 787 // CASE 2: If nothing changes twice in a row, the damage rect should still b e empty.
788 // 788 //
789 clearDamageForAllSurfaces(root.get()); 789 clearDamageForAllSurfaces(root.get());
790 emulateDrawingOneFrame(root.get()); 790 emulateDrawingOneFrame(root.get());
791 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 791 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
792 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 792 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
793 EXPECT_TRUE(childDamageRect.IsEmpty()); 793 EXPECT_TRUE(childDamageRect.IsEmpty());
794 EXPECT_TRUE(rootDamageRect.IsEmpty()); 794 EXPECT_TRUE(rootDamageRect.IsEmpty());
795 } 795 }
796 796
797 TEST_F(DamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) 797 TEST_F(DamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent)
798 { 798 {
799 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 799 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
800 LayerImpl* child1 = root->children()[0]; 800 LayerImpl* child1 = root->children()[0];
801 gfx::RectF childDamageRect; 801 gfx::RectF childDamageRect;
802 gfx::RectF rootDamageRect; 802 gfx::RectF rootDamageRect;
803 803
804 // In our specific tree, the update rect of child1 should not cause any dama ge to any 804 // In our specific tree, the update rect of child1 should not cause any dama ge to any
805 // surface because it does not actually draw content. 805 // surface because it does not actually draw content.
806 clearDamageForAllSurfaces(root.get()); 806 clearDamageForAllSurfaces(root.get());
807 child1->setUpdateRect(gfx::RectF(0, 0, 1, 2)); 807 child1->set_update_rect(gfx::RectF(0, 0, 1, 2));
808 emulateDrawingOneFrame(root.get()); 808 emulateDrawingOneFrame(root.get());
809 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 809 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
810 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 810 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
811 EXPECT_TRUE(childDamageRect.IsEmpty()); 811 EXPECT_TRUE(childDamageRect.IsEmpty());
812 EXPECT_TRUE(rootDamageRect.IsEmpty()); 812 EXPECT_TRUE(rootDamageRect.IsEmpty());
813 } 813 }
814 814
815 TEST_F(DamageTrackerTest, verifyDamageForReplica) 815 TEST_F(DamageTrackerTest, verifyDamageForReplica)
816 { 816 {
817 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 817 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
818 LayerImpl* child1 = root->children()[0]; 818 LayerImpl* child1 = root->children()[0];
819 LayerImpl* grandChild1 = child1->children()[0]; 819 LayerImpl* grandChild1 = child1->children()[0];
820 LayerImpl* grandChild2 = child1->children()[1]; 820 LayerImpl* grandChild2 = child1->children()[1];
821 821
822 // Damage on a surface that has a reflection should cause the target surface to 822 // Damage on a surface that has a reflection should cause the target surface to
823 // receive the surface's damage and the surface's reflected damage. 823 // receive the surface's damage and the surface's reflected damage.
824 824
825 // For this test case, we modify grandChild2, and add grandChild3 to extend the bounds 825 // For this test case, we modify grandChild2, and add grandChild3 to extend the bounds
826 // of child1's surface. This way, we can test reflection changes without cha nging 826 // of child1's surface. This way, we can test reflection changes without cha nging
827 // contentBounds of the surface. 827 // contentBounds of the surface.
828 grandChild2->setPosition(gfx::PointF(180, 180)); 828 grandChild2->SetPosition(gfx::PointF(180, 180));
829 { 829 {
830 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::create(m_hostImpl.activeT ree(), 6); 830 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::Create(m_hostImpl.activeT ree(), 6);
831 grandChild3->setPosition(gfx::PointF(240, 240)); 831 grandChild3->SetPosition(gfx::PointF(240, 240));
832 grandChild3->setAnchorPoint(gfx::PointF()); 832 grandChild3->SetAnchorPoint(gfx::PointF());
833 grandChild3->setBounds(gfx::Size(10, 10)); 833 grandChild3->SetBounds(gfx::Size(10, 10));
834 grandChild3->setContentBounds(gfx::Size(10, 10)); 834 grandChild3->SetContentBounds(gfx::Size(10, 10));
835 grandChild3->setDrawsContent(true); 835 grandChild3->SetDrawsContent(true);
836 child1->addChild(grandChild3.Pass()); 836 child1->AddChild(grandChild3.Pass());
837 } 837 }
838 child1->setOpacity(0.5); 838 child1->SetOpacity(0.5);
839 emulateDrawingOneFrame(root.get()); 839 emulateDrawingOneFrame(root.get());
840 840
841 // CASE 1: adding a reflection about the left edge of grandChild1. 841 // CASE 1: adding a reflection about the left edge of grandChild1.
842 // 842 //
843 clearDamageForAllSurfaces(root.get()); 843 clearDamageForAllSurfaces(root.get());
844 { 844 {
845 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(m_hostImpl. activeTree(), 7); 845 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. activeTree(), 7);
846 grandChild1Replica->setPosition(gfx::PointF()); 846 grandChild1Replica->SetPosition(gfx::PointF());
847 grandChild1Replica->setAnchorPoint(gfx::PointF()); 847 grandChild1Replica->SetAnchorPoint(gfx::PointF());
848 gfx::Transform reflection; 848 gfx::Transform reflection;
849 reflection.Scale3d(-1, 1, 1); 849 reflection.Scale3d(-1, 1, 1);
850 grandChild1Replica->setTransform(reflection); 850 grandChild1Replica->SetTransform(reflection);
851 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 851 grandChild1->SetReplicaLayer(grandChild1Replica.Pass());
852 } 852 }
853 emulateDrawingOneFrame(root.get()); 853 emulateDrawingOneFrame(root.get());
854 854
855 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damage_track er()->current_damage_rect(); 855 gfx::RectF grandChildDamageRect = grandChild1->render_surface()->damage_trac ker()->current_damage_rect();
856 gfx::RectF childDamageRect = child1->renderSurface()->damage_tracker()->curr ent_damage_rect(); 856 gfx::RectF childDamageRect = child1->render_surface()->damage_tracker()->cur rent_damage_rect();
857 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 857 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
858 858
859 // The grandChild surface damage should not include its own replica. The chi ld 859 // The grandChild surface damage should not include its own replica. The chi ld
860 // surface damage should include the normal and replica surfaces. 860 // surface damage should include the normal and replica surfaces.
861 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 6, 8), grandChildDamageRect); 861 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 6, 8), grandChildDamageRect);
862 EXPECT_FLOAT_RECT_EQ(gfx::RectF(194, 200, 12, 8), childDamageRect); 862 EXPECT_FLOAT_RECT_EQ(gfx::RectF(194, 200, 12, 8), childDamageRect);
863 EXPECT_FLOAT_RECT_EQ(gfx::RectF(294, 300, 12, 8), rootDamageRect); 863 EXPECT_FLOAT_RECT_EQ(gfx::RectF(294, 300, 12, 8), rootDamageRect);
864 864
865 // CASE 2: moving the descendant surface should cause both the original and reflected 865 // CASE 2: moving the descendant surface should cause both the original and reflected
866 // areas to be damaged on the target. 866 // areas to be damaged on the target.
867 clearDamageForAllSurfaces(root.get()); 867 clearDamageForAllSurfaces(root.get());
868 gfx::Rect oldContentRect = child1->renderSurface()->content_rect(); 868 gfx::Rect oldContentRect = child1->render_surface()->content_rect();
869 grandChild1->setPosition(gfx::PointF(195, 205)); 869 grandChild1->SetPosition(gfx::PointF(195, 205));
870 emulateDrawingOneFrame(root.get()); 870 emulateDrawingOneFrame(root.get());
871 ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->content_rect().wi dth()); 871 ASSERT_EQ(oldContentRect.width(), child1->render_surface()->content_rect().w idth());
872 ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->content_rect().h eight()); 872 ASSERT_EQ(oldContentRect.height(), child1->render_surface()->content_rect(). height());
873 873
874 grandChildDamageRect = grandChild1->renderSurface()->damage_tracker()->curre nt_damage_rect(); 874 grandChildDamageRect = grandChild1->render_surface()->damage_tracker()->curr ent_damage_rect();
875 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 875 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
876 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 876 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
877 877
878 // The child surface damage should include normal and replica surfaces for b oth old and new locations. 878 // The child surface damage should include normal and replica surfaces for b oth old and new locations.
879 // - old location in target space: gfx::RectF(194, 200, 12, 8) 879 // - old location in target space: gfx::RectF(194, 200, 12, 8)
880 // - new location in target space: gfx::RectF(189, 205, 12, 8) 880 // - new location in target space: gfx::RectF(189, 205, 12, 8)
881 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 6, 8), grandChildDamageRect); 881 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 6, 8), grandChildDamageRect);
882 EXPECT_FLOAT_RECT_EQ(gfx::RectF(189, 200, 17, 13), childDamageRect); 882 EXPECT_FLOAT_RECT_EQ(gfx::RectF(189, 200, 17, 13), childDamageRect);
883 EXPECT_FLOAT_RECT_EQ(gfx::RectF(289, 300, 17, 13), rootDamageRect); 883 EXPECT_FLOAT_RECT_EQ(gfx::RectF(289, 300, 17, 13), rootDamageRect);
884 884
885 // CASE 3: removing the reflection should cause the entire region including reflection 885 // CASE 3: removing the reflection should cause the entire region including reflection
886 // to damage the target surface. 886 // to damage the target surface.
887 clearDamageForAllSurfaces(root.get()); 887 clearDamageForAllSurfaces(root.get());
888 grandChild1->setReplicaLayer(scoped_ptr<LayerImpl>()); 888 grandChild1->SetReplicaLayer(scoped_ptr<LayerImpl>());
889 emulateDrawingOneFrame(root.get()); 889 emulateDrawingOneFrame(root.get());
890 ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->content_rect().wi dth()); 890 ASSERT_EQ(oldContentRect.width(), child1->render_surface()->content_rect().w idth());
891 ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->content_rect().h eight()); 891 ASSERT_EQ(oldContentRect.height(), child1->render_surface()->content_rect(). height());
892 892
893 EXPECT_FALSE(grandChild1->renderSurface()); 893 EXPECT_FALSE(grandChild1->render_surface());
894 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 894 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
895 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 895 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
896 896
897 EXPECT_FLOAT_RECT_EQ(gfx::RectF(189, 205, 12, 8), childDamageRect); 897 EXPECT_FLOAT_RECT_EQ(gfx::RectF(189, 205, 12, 8), childDamageRect);
898 EXPECT_FLOAT_RECT_EQ(gfx::RectF(289, 305, 12, 8), rootDamageRect); 898 EXPECT_FLOAT_RECT_EQ(gfx::RectF(289, 305, 12, 8), rootDamageRect);
899 } 899 }
900 900
901 TEST_F(DamageTrackerTest, verifyDamageForMask) 901 TEST_F(DamageTrackerTest, verifyDamageForMask)
902 { 902 {
903 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 903 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
904 LayerImpl* child = root->children()[0]; 904 LayerImpl* child = root->children()[0];
905 905
906 // In the current implementation of the damage tracker, changes to mask laye rs should 906 // In the current implementation of the damage tracker, changes to mask laye rs should
907 // damage the entire corresponding surface. 907 // damage the entire corresponding surface.
908 908
909 clearDamageForAllSurfaces(root.get()); 909 clearDamageForAllSurfaces(root.get());
910 910
911 // Set up the mask layer. 911 // Set up the mask layer.
912 { 912 {
913 scoped_ptr<LayerImpl> maskLayer = LayerImpl::create(m_hostImpl.activeTre e(), 3); 913 scoped_ptr<LayerImpl> maskLayer = LayerImpl::Create(m_hostImpl.activeTre e(), 3);
914 maskLayer->setPosition(child->position()); 914 maskLayer->SetPosition(child->position());
915 maskLayer->setAnchorPoint(gfx::PointF()); 915 maskLayer->SetAnchorPoint(gfx::PointF());
916 maskLayer->setBounds(child->bounds()); 916 maskLayer->SetBounds(child->bounds());
917 maskLayer->setContentBounds(child->bounds()); 917 maskLayer->SetContentBounds(child->bounds());
918 child->setMaskLayer(maskLayer.Pass()); 918 child->SetMaskLayer(maskLayer.Pass());
919 } 919 }
920 LayerImpl* maskLayer = child->maskLayer(); 920 LayerImpl* maskLayer = child->mask_layer();
921 921
922 // Add opacity and a grandChild so that the render surface persists even aft er we remove the mask. 922 // Add opacity and a grandChild so that the render surface persists even aft er we remove the mask.
923 child->setOpacity(0.5); 923 child->SetOpacity(0.5);
924 { 924 {
925 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(m_hostImpl.activeTr ee(), 4); 925 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(m_hostImpl.activeTr ee(), 4);
926 grandChild->setPosition(gfx::PointF(2, 2)); 926 grandChild->SetPosition(gfx::PointF(2, 2));
927 grandChild->setAnchorPoint(gfx::PointF()); 927 grandChild->SetAnchorPoint(gfx::PointF());
928 grandChild->setBounds(gfx::Size(2, 2)); 928 grandChild->SetBounds(gfx::Size(2, 2));
929 grandChild->setContentBounds(gfx::Size(2, 2)); 929 grandChild->SetContentBounds(gfx::Size(2, 2));
930 grandChild->setDrawsContent(true); 930 grandChild->SetDrawsContent(true);
931 child->addChild(grandChild.Pass()); 931 child->AddChild(grandChild.Pass());
932 } 932 }
933 emulateDrawingOneFrame(root.get()); 933 emulateDrawingOneFrame(root.get());
934 934
935 // Sanity check that a new surface was created for the child. 935 // Sanity check that a new surface was created for the child.
936 ASSERT_TRUE(child->renderSurface()); 936 ASSERT_TRUE(child->render_surface());
937 937
938 // CASE 1: the updateRect on a mask layer should damage the entire target su rface. 938 // CASE 1: the updateRect on a mask layer should damage the entire target su rface.
939 // 939 //
940 clearDamageForAllSurfaces(root.get()); 940 clearDamageForAllSurfaces(root.get());
941 maskLayer->setUpdateRect(gfx::RectF(1, 2, 3, 4)); 941 maskLayer->set_update_rect(gfx::RectF(1, 2, 3, 4));
942 emulateDrawingOneFrame(root.get()); 942 emulateDrawingOneFrame(root.get());
943 gfx::RectF childDamageRect = child->renderSurface()->damage_tracker()->curre nt_damage_rect(); 943 gfx::RectF childDamageRect = child->render_surface()->damage_tracker()->curr ent_damage_rect();
944 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); 944 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect);
945 945
946 // CASE 2: a property change on the mask layer should damage the entire targ et surface. 946 // CASE 2: a property change on the mask layer should damage the entire targ et surface.
947 // 947 //
948 948
949 // Advance one frame without damage so that we know the damage rect is not l eftover from the previous case. 949 // Advance one frame without damage so that we know the damage rect is not l eftover from the previous case.
950 clearDamageForAllSurfaces(root.get()); 950 clearDamageForAllSurfaces(root.get());
951 emulateDrawingOneFrame(root.get()); 951 emulateDrawingOneFrame(root.get());
952 childDamageRect = child->renderSurface()->damage_tracker()->current_damage_r ect(); 952 childDamageRect = child->render_surface()->damage_tracker()->current_damage_ rect();
953 EXPECT_TRUE(childDamageRect.IsEmpty()); 953 EXPECT_TRUE(childDamageRect.IsEmpty());
954 954
955 // Then test the property change. 955 // Then test the property change.
956 clearDamageForAllSurfaces(root.get()); 956 clearDamageForAllSurfaces(root.get());
957 maskLayer->setStackingOrderChanged(true); 957 maskLayer->SetStackingOrderChanged(true);
958 958
959 emulateDrawingOneFrame(root.get()); 959 emulateDrawingOneFrame(root.get());
960 childDamageRect = child->renderSurface()->damage_tracker()->current_damage_r ect(); 960 childDamageRect = child->render_surface()->damage_tracker()->current_damage_ rect();
961 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); 961 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect);
962 962
963 // CASE 3: removing the mask also damages the entire target surface. 963 // CASE 3: removing the mask also damages the entire target surface.
964 // 964 //
965 965
966 // Advance one frame without damage so that we know the damage rect is not l eftover from the previous case. 966 // Advance one frame without damage so that we know the damage rect is not l eftover from the previous case.
967 clearDamageForAllSurfaces(root.get()); 967 clearDamageForAllSurfaces(root.get());
968 emulateDrawingOneFrame(root.get()); 968 emulateDrawingOneFrame(root.get());
969 childDamageRect = child->renderSurface()->damage_tracker()->current_damage_r ect(); 969 childDamageRect = child->render_surface()->damage_tracker()->current_damage_ rect();
970 EXPECT_TRUE(childDamageRect.IsEmpty()); 970 EXPECT_TRUE(childDamageRect.IsEmpty());
971 971
972 // Then test mask removal. 972 // Then test mask removal.
973 clearDamageForAllSurfaces(root.get()); 973 clearDamageForAllSurfaces(root.get());
974 child->setMaskLayer(scoped_ptr<LayerImpl>()); 974 child->SetMaskLayer(scoped_ptr<LayerImpl>());
975 ASSERT_TRUE(child->layerPropertyChanged()); 975 ASSERT_TRUE(child->LayerPropertyChanged());
976 emulateDrawingOneFrame(root.get()); 976 emulateDrawingOneFrame(root.get());
977 977
978 // Sanity check that a render surface still exists. 978 // Sanity check that a render surface still exists.
979 ASSERT_TRUE(child->renderSurface()); 979 ASSERT_TRUE(child->render_surface());
980 980
981 childDamageRect = child->renderSurface()->damage_tracker()->current_damage_r ect(); 981 childDamageRect = child->render_surface()->damage_tracker()->current_damage_ rect();
982 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect); 982 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 30, 30), childDamageRect);
983 } 983 }
984 984
985 TEST_F(DamageTrackerTest, verifyDamageForReplicaMask) 985 TEST_F(DamageTrackerTest, verifyDamageForReplicaMask)
986 { 986 {
987 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 987 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
988 LayerImpl* child1 = root->children()[0]; 988 LayerImpl* child1 = root->children()[0];
989 LayerImpl* grandChild1 = child1->children()[0]; 989 LayerImpl* grandChild1 = child1->children()[0];
990 990
991 // Changes to a replica's mask should not damage the original surface, becau se it is 991 // Changes to a replica's mask should not damage the original surface, becau se it is
992 // not masked. But it does damage the ancestor target surface. 992 // not masked. But it does damage the ancestor target surface.
993 993
994 clearDamageForAllSurfaces(root.get()); 994 clearDamageForAllSurfaces(root.get());
995 995
996 // Create a reflection about the left edge of grandChild1. 996 // Create a reflection about the left edge of grandChild1.
997 { 997 {
998 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(m_hostImpl. activeTree(), 6); 998 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. activeTree(), 6);
999 grandChild1Replica->setPosition(gfx::PointF()); 999 grandChild1Replica->SetPosition(gfx::PointF());
1000 grandChild1Replica->setAnchorPoint(gfx::PointF()); 1000 grandChild1Replica->SetAnchorPoint(gfx::PointF());
1001 gfx::Transform reflection; 1001 gfx::Transform reflection;
1002 reflection.Scale3d(-1, 1, 1); 1002 reflection.Scale3d(-1, 1, 1);
1003 grandChild1Replica->setTransform(reflection); 1003 grandChild1Replica->SetTransform(reflection);
1004 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 1004 grandChild1->SetReplicaLayer(grandChild1Replica.Pass());
1005 } 1005 }
1006 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); 1006 LayerImpl* grandChild1Replica = grandChild1->replica_layer();
1007 1007
1008 // Set up the mask layer on the replica layer 1008 // Set up the mask layer on the replica layer
1009 { 1009 {
1010 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(m_hostImpl.ac tiveTree(), 7); 1010 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::Create(m_hostImpl.ac tiveTree(), 7);
1011 replicaMaskLayer->setPosition(gfx::PointF()); 1011 replicaMaskLayer->SetPosition(gfx::PointF());
1012 replicaMaskLayer->setAnchorPoint(gfx::PointF()); 1012 replicaMaskLayer->SetAnchorPoint(gfx::PointF());
1013 replicaMaskLayer->setBounds(grandChild1->bounds()); 1013 replicaMaskLayer->SetBounds(grandChild1->bounds());
1014 replicaMaskLayer->setContentBounds(grandChild1->bounds()); 1014 replicaMaskLayer->SetContentBounds(grandChild1->bounds());
1015 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); 1015 grandChild1Replica->SetMaskLayer(replicaMaskLayer.Pass());
1016 } 1016 }
1017 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); 1017 LayerImpl* replicaMaskLayer = grandChild1Replica->mask_layer();
1018 1018
1019 emulateDrawingOneFrame(root.get()); 1019 emulateDrawingOneFrame(root.get());
1020 1020
1021 // Sanity check that the appropriate render surfaces were created 1021 // Sanity check that the appropriate render surfaces were created
1022 ASSERT_TRUE(grandChild1->renderSurface()); 1022 ASSERT_TRUE(grandChild1->render_surface());
1023 1023
1024 // CASE 1: a property change on the mask should damage only the reflected re gion on the target surface. 1024 // CASE 1: a property change on the mask should damage only the reflected re gion on the target surface.
1025 clearDamageForAllSurfaces(root.get()); 1025 clearDamageForAllSurfaces(root.get());
1026 replicaMaskLayer->setStackingOrderChanged(true); 1026 replicaMaskLayer->SetStackingOrderChanged(true);
1027 emulateDrawingOneFrame(root.get()); 1027 emulateDrawingOneFrame(root.get());
1028 1028
1029 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damage_track er()->current_damage_rect(); 1029 gfx::RectF grandChildDamageRect = grandChild1->render_surface()->damage_trac ker()->current_damage_rect();
1030 gfx::RectF childDamageRect = child1->renderSurface()->damage_tracker()->curr ent_damage_rect(); 1030 gfx::RectF childDamageRect = child1->render_surface()->damage_tracker()->cur rent_damage_rect();
1031 1031
1032 EXPECT_TRUE(grandChildDamageRect.IsEmpty()); 1032 EXPECT_TRUE(grandChildDamageRect.IsEmpty());
1033 EXPECT_FLOAT_RECT_EQ(gfx::RectF(194, 200, 6, 8), childDamageRect); 1033 EXPECT_FLOAT_RECT_EQ(gfx::RectF(194, 200, 6, 8), childDamageRect);
1034 1034
1035 // CASE 2: removing the replica mask damages only the reflected region on th e target surface. 1035 // CASE 2: removing the replica mask damages only the reflected region on th e target surface.
1036 // 1036 //
1037 clearDamageForAllSurfaces(root.get()); 1037 clearDamageForAllSurfaces(root.get());
1038 grandChild1Replica->setMaskLayer(scoped_ptr<LayerImpl>()); 1038 grandChild1Replica->SetMaskLayer(scoped_ptr<LayerImpl>());
1039 emulateDrawingOneFrame(root.get()); 1039 emulateDrawingOneFrame(root.get());
1040 1040
1041 grandChildDamageRect = grandChild1->renderSurface()->damage_tracker()->curre nt_damage_rect(); 1041 grandChildDamageRect = grandChild1->render_surface()->damage_tracker()->curr ent_damage_rect();
1042 childDamageRect = child1->renderSurface()->damage_tracker()->current_damage_ rect(); 1042 childDamageRect = child1->render_surface()->damage_tracker()->current_damage _rect();
1043 1043
1044 EXPECT_TRUE(grandChildDamageRect.IsEmpty()); 1044 EXPECT_TRUE(grandChildDamageRect.IsEmpty());
1045 EXPECT_FLOAT_RECT_EQ(gfx::RectF(194, 200, 6, 8), childDamageRect); 1045 EXPECT_FLOAT_RECT_EQ(gfx::RectF(194, 200, 6, 8), childDamageRect);
1046 } 1046 }
1047 1047
1048 TEST_F(DamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) 1048 TEST_F(DamageTrackerTest, verifyDamageForReplicaMaskWithAnchor)
1049 { 1049 {
1050 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 1050 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
1051 LayerImpl* child1 = root->children()[0]; 1051 LayerImpl* child1 = root->children()[0];
1052 LayerImpl* grandChild1 = child1->children()[0]; 1052 LayerImpl* grandChild1 = child1->children()[0];
1053 1053
1054 // Verify that the correct replicaOriginTransform is used for the replicaMas k; 1054 // Verify that the correct replicaOriginTransform is used for the replicaMas k;
1055 clearDamageForAllSurfaces(root.get()); 1055 clearDamageForAllSurfaces(root.get());
1056 1056
1057 grandChild1->setAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a nchor being tested, but by convention its expected to be the same as the replica 's anchor point. 1057 grandChild1->SetAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a nchor being tested, but by convention its expected to be the same as the replica 's anchor point.
1058 1058
1059 { 1059 {
1060 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(m_hostImpl. activeTree(), 6); 1060 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. activeTree(), 6);
1061 grandChild1Replica->setPosition(gfx::PointF()); 1061 grandChild1Replica->SetPosition(gfx::PointF());
1062 grandChild1Replica->setAnchorPoint(gfx::PointF(1, 0)); // This is the an chor being tested. 1062 grandChild1Replica->SetAnchorPoint(gfx::PointF(1, 0)); // This is the an chor being tested.
1063 gfx::Transform reflection; 1063 gfx::Transform reflection;
1064 reflection.Scale3d(-1, 1, 1); 1064 reflection.Scale3d(-1, 1, 1);
1065 grandChild1Replica->setTransform(reflection); 1065 grandChild1Replica->SetTransform(reflection);
1066 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 1066 grandChild1->SetReplicaLayer(grandChild1Replica.Pass());
1067 } 1067 }
1068 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); 1068 LayerImpl* grandChild1Replica = grandChild1->replica_layer();
1069 1069
1070 // Set up the mask layer on the replica layer 1070 // Set up the mask layer on the replica layer
1071 { 1071 {
1072 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(m_hostImpl.ac tiveTree(), 7); 1072 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::Create(m_hostImpl.ac tiveTree(), 7);
1073 replicaMaskLayer->setPosition(gfx::PointF()); 1073 replicaMaskLayer->SetPosition(gfx::PointF());
1074 replicaMaskLayer->setAnchorPoint(gfx::PointF()); // note, this is not th e anchor being tested. 1074 replicaMaskLayer->SetAnchorPoint(gfx::PointF()); // note, this is not th e anchor being tested.
1075 replicaMaskLayer->setBounds(grandChild1->bounds()); 1075 replicaMaskLayer->SetBounds(grandChild1->bounds());
1076 replicaMaskLayer->setContentBounds(grandChild1->bounds()); 1076 replicaMaskLayer->SetContentBounds(grandChild1->bounds());
1077 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); 1077 grandChild1Replica->SetMaskLayer(replicaMaskLayer.Pass());
1078 } 1078 }
1079 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); 1079 LayerImpl* replicaMaskLayer = grandChild1Replica->mask_layer();
1080 1080
1081 emulateDrawingOneFrame(root.get()); 1081 emulateDrawingOneFrame(root.get());
1082 1082
1083 // Sanity check that the appropriate render surfaces were created 1083 // Sanity check that the appropriate render surfaces were created
1084 ASSERT_TRUE(grandChild1->renderSurface()); 1084 ASSERT_TRUE(grandChild1->render_surface());
1085 1085
1086 // A property change on the replicaMask should damage the reflected region o n the target surface. 1086 // A property change on the replicaMask should damage the reflected region o n the target surface.
1087 clearDamageForAllSurfaces(root.get()); 1087 clearDamageForAllSurfaces(root.get());
1088 replicaMaskLayer->setStackingOrderChanged(true); 1088 replicaMaskLayer->SetStackingOrderChanged(true);
1089 1089
1090 emulateDrawingOneFrame(root.get()); 1090 emulateDrawingOneFrame(root.get());
1091 1091
1092 gfx::RectF childDamageRect = child1->renderSurface()->damage_tracker()->curr ent_damage_rect(); 1092 gfx::RectF childDamageRect = child1->render_surface()->damage_tracker()->cur rent_damage_rect();
1093 EXPECT_FLOAT_RECT_EQ(gfx::RectF(206, 200, 6, 8), childDamageRect); 1093 EXPECT_FLOAT_RECT_EQ(gfx::RectF(206, 200, 6, 8), childDamageRect);
1094 } 1094 }
1095 1095
1096 TEST_F(DamageTrackerTest, verifyDamageWhenForcedFullDamage) 1096 TEST_F(DamageTrackerTest, verifyDamageWhenForcedFullDamage)
1097 { 1097 {
1098 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 1098 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
1099 LayerImpl* child = root->children()[0]; 1099 LayerImpl* child = root->children()[0];
1100 1100
1101 // Case 1: This test ensures that when the tracker is forced to have full da mage, that 1101 // Case 1: This test ensures that when the tracker is forced to have full da mage, that
1102 // it takes priority over any other partial damage. 1102 // it takes priority over any other partial damage.
1103 // 1103 //
1104 clearDamageForAllSurfaces(root.get()); 1104 clearDamageForAllSurfaces(root.get());
1105 child->setUpdateRect(gfx::RectF(10, 11, 12, 13)); 1105 child->set_update_rect(gfx::RectF(10, 11, 12, 13));
1106 root->renderSurface()->damage_tracker()->ForceFullDamageNextUpdate(); 1106 root->render_surface()->damage_tracker()->ForceFullDamageNextUpdate();
1107 emulateDrawingOneFrame(root.get()); 1107 emulateDrawingOneFrame(root.get());
1108 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 1108 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
1109 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); 1109 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect);
1110 1110
1111 // Case 2: An additional sanity check that forcing full damage works even wh en nothing 1111 // Case 2: An additional sanity check that forcing full damage works even wh en nothing
1112 // on the layer tree changed. 1112 // on the layer tree changed.
1113 // 1113 //
1114 clearDamageForAllSurfaces(root.get()); 1114 clearDamageForAllSurfaces(root.get());
1115 root->renderSurface()->damage_tracker()->ForceFullDamageNextUpdate(); 1115 root->render_surface()->damage_tracker()->ForceFullDamageNextUpdate();
1116 emulateDrawingOneFrame(root.get()); 1116 emulateDrawingOneFrame(root.get());
1117 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 1117 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
1118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); 1118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect);
1119 } 1119 }
1120 1120
1121 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList) 1121 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList)
1122 { 1122 {
1123 // Though it should never happen, its a good idea to verify that the damage tracker 1123 // Though it should never happen, its a good idea to verify that the damage tracker
1124 // does not crash when it receives an empty layerList. 1124 // does not crash when it receives an empty layerList.
1125 1125
1126 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl.activeTree(), 1); 1126 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.activeTree(), 1);
1127 root->createRenderSurface(); 1127 root->CreateRenderSurface();
1128 1128
1129 ASSERT_TRUE(root == root->renderTarget()); 1129 ASSERT_TRUE(root == root->render_target());
1130 RenderSurfaceImpl* targetSurface = root->renderSurface(); 1130 RenderSurfaceImpl* targetSurface = root->render_surface();
1131 targetSurface->ClearLayerLists(); 1131 targetSurface->ClearLayerLists();
1132 targetSurface->damage_tracker()->UpdateDamageTrackingState(targetSurface->la yer_list(), targetSurface->OwningLayerId(), false, gfx::Rect(), 0, WebFilterOper ations(), 0); 1132 targetSurface->damage_tracker()->UpdateDamageTrackingState(targetSurface->la yer_list(), targetSurface->OwningLayerId(), false, gfx::Rect(), 0, WebFilterOper ations(), 0);
1133 1133
1134 gfx::RectF damageRect = targetSurface->damage_tracker()->current_damage_rect (); 1134 gfx::RectF damageRect = targetSurface->damage_tracker()->current_damage_rect ();
1135 EXPECT_TRUE(damageRect.IsEmpty()); 1135 EXPECT_TRUE(damageRect.IsEmpty());
1136 } 1136 }
1137 1137
1138 TEST_F(DamageTrackerTest, verifyDamageAccumulatesUntilReset) 1138 TEST_F(DamageTrackerTest, verifyDamageAccumulatesUntilReset)
1139 { 1139 {
1140 // If damage is not cleared, it should accumulate. 1140 // If damage is not cleared, it should accumulate.
1141 1141
1142 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 1142 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
1143 LayerImpl* child = root->children()[0]; 1143 LayerImpl* child = root->children()[0];
1144 1144
1145 clearDamageForAllSurfaces(root.get()); 1145 clearDamageForAllSurfaces(root.get());
1146 child->setUpdateRect(gfx::RectF(10, 11, 1, 2)); 1146 child->set_update_rect(gfx::RectF(10, 11, 1, 2));
1147 emulateDrawingOneFrame(root.get()); 1147 emulateDrawingOneFrame(root.get());
1148 1148
1149 // Sanity check damage after the first frame; this isnt the actual test yet. 1149 // Sanity check damage after the first frame; this isnt the actual test yet.
1150 gfx::RectF rootDamageRect = root->renderSurface()->damage_tracker()->current _damage_rect(); 1150 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
1151 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 1, 2), rootDamageRect); 1151 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 1, 2), rootDamageRect);
1152 1152
1153 // New damage, without having cleared the previous damage, should be unioned to the previous one. 1153 // New damage, without having cleared the previous damage, should be unioned to the previous one.
1154 child->setUpdateRect(gfx::RectF(20, 25, 1, 2)); 1154 child->set_update_rect(gfx::RectF(20, 25, 1, 2));
1155 emulateDrawingOneFrame(root.get()); 1155 emulateDrawingOneFrame(root.get());
1156 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 1156 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
1157 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 11, 16), rootDamageRect); 1157 EXPECT_FLOAT_RECT_EQ(gfx::RectF(110, 111, 11, 16), rootDamageRect);
1158 1158
1159 // If we notify the damage tracker that we drew the damaged area, then damag e should be emptied. 1159 // If we notify the damage tracker that we drew the damaged area, then damag e should be emptied.
1160 root->renderSurface()->damage_tracker()->DidDrawDamagedArea(); 1160 root->render_surface()->damage_tracker()->DidDrawDamagedArea();
1161 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 1161 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
1162 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1162 EXPECT_TRUE(rootDamageRect.IsEmpty());
1163 1163
1164 // Damage should remain empty even after one frame, since there's yet no new damage 1164 // Damage should remain empty even after one frame, since there's yet no new damage
1165 emulateDrawingOneFrame(root.get()); 1165 emulateDrawingOneFrame(root.get());
1166 rootDamageRect = root->renderSurface()->damage_tracker()->current_damage_rec t(); 1166 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
1167 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1167 EXPECT_TRUE(rootDamageRect.IsEmpty());
1168 } 1168 }
1169 1169
1170 } // namespace 1170 } // namespace
1171 } // namespace cc 1171 } // namespace cc
OLDNEW
« no previous file with comments | « cc/damage_tracker.cc ('k') | cc/debug_rect_history.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698