OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCDamageTracker.h" | 7 #include "CCDamageTracker.h" |
8 | 8 |
9 #include "CCGeometryTestUtils.h" | 9 #include "CCGeometryTestUtils.h" |
10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 // Iterate back-to-front, so that damage correctly propagates from descendan
t surfaces to ancestors. | 60 // Iterate back-to-front, so that damage correctly propagates from descendan
t surfaces to ancestors. |
61 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { | 61 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { |
62 CCRenderSurface* targetSurface = renderSurfaceLayerList[i]->renderSurfac
e(); | 62 CCRenderSurface* targetSurface = renderSurfaceLayerList[i]->renderSurfac
e(); |
63 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface-
>layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan
gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i]
->maskLayer(), renderSurfaceLayerList[i]->filters()); | 63 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface-
>layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan
gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i]
->maskLayer(), renderSurfaceLayerList[i]->filters()); |
64 } | 64 } |
65 | 65 |
66 root->resetAllChangeTrackingForSubtree(); | 66 root->resetAllChangeTrackingForSubtree(); |
67 } | 67 } |
68 | 68 |
69 PassOwnPtr<CCLayerImpl> createTestTreeWithOneSurface() | 69 scoped_ptr<CCLayerImpl> createTestTreeWithOneSurface() |
70 { | 70 { |
71 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 71 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
72 OwnPtr<CCLayerImpl> child = CCLayerImpl::create(2); | 72 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); |
73 | 73 |
74 root->setPosition(FloatPoint::zero()); | 74 root->setPosition(FloatPoint::zero()); |
75 root->setAnchorPoint(FloatPoint::zero()); | 75 root->setAnchorPoint(FloatPoint::zero()); |
76 root->setBounds(IntSize(500, 500)); | 76 root->setBounds(IntSize(500, 500)); |
77 root->setContentBounds(IntSize(500, 500)); | 77 root->setContentBounds(IntSize(500, 500)); |
78 root->setDrawsContent(true); | 78 root->setDrawsContent(true); |
79 root->createRenderSurface(); | 79 root->createRenderSurface(); |
80 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(500, 500))
); | 80 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(500, 500))
); |
81 | 81 |
82 child->setPosition(FloatPoint(100, 100)); | 82 child->setPosition(FloatPoint(100, 100)); |
83 child->setAnchorPoint(FloatPoint::zero()); | 83 child->setAnchorPoint(FloatPoint::zero()); |
84 child->setBounds(IntSize(30, 30)); | 84 child->setBounds(IntSize(30, 30)); |
85 child->setContentBounds(IntSize(30, 30)); | 85 child->setContentBounds(IntSize(30, 30)); |
86 child->setDrawsContent(true); | 86 child->setDrawsContent(true); |
87 root->addChild(child.release()); | 87 root->addChild(child.Pass()); |
88 | 88 |
89 return root.release(); | 89 return root.Pass(); |
90 } | 90 } |
91 | 91 |
92 PassOwnPtr<CCLayerImpl> createTestTreeWithTwoSurfaces() | 92 scoped_ptr<CCLayerImpl> createTestTreeWithTwoSurfaces() |
93 { | 93 { |
94 // This test tree has two render surfaces: one for the root, and one for | 94 // This test tree has two render surfaces: one for the root, and one for |
95 // child1. Additionally, the root has a second child layer, and child1 has t
wo | 95 // child1. Additionally, the root has a second child layer, and child1 has t
wo |
96 // children of its own. | 96 // children of its own. |
97 | 97 |
98 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 98 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
99 OwnPtr<CCLayerImpl> child1 = CCLayerImpl::create(2); | 99 scoped_ptr<CCLayerImpl> child1 = CCLayerImpl::create(2); |
100 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 100 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
101 OwnPtr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); | 101 scoped_ptr<CCLayerImpl> grandChild1 = CCLayerImpl::create(4); |
102 OwnPtr<CCLayerImpl> grandChild2 = CCLayerImpl::create(5); | 102 scoped_ptr<CCLayerImpl> grandChild2 = CCLayerImpl::create(5); |
103 | 103 |
104 root->setPosition(FloatPoint::zero()); | 104 root->setPosition(FloatPoint::zero()); |
105 root->setAnchorPoint(FloatPoint::zero()); | 105 root->setAnchorPoint(FloatPoint::zero()); |
106 root->setBounds(IntSize(500, 500)); | 106 root->setBounds(IntSize(500, 500)); |
107 root->setContentBounds(IntSize(500, 500)); | 107 root->setContentBounds(IntSize(500, 500)); |
108 root->setDrawsContent(true); | 108 root->setDrawsContent(true); |
109 root->createRenderSurface(); | 109 root->createRenderSurface(); |
110 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(500, 500))
); | 110 root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(500, 500))
); |
111 | 111 |
112 child1->setPosition(FloatPoint(100, 100)); | 112 child1->setPosition(FloatPoint(100, 100)); |
(...skipping 14 matching lines...) Expand all Loading... |
127 grandChild1->setBounds(IntSize(6, 8)); | 127 grandChild1->setBounds(IntSize(6, 8)); |
128 grandChild1->setContentBounds(IntSize(6, 8)); | 128 grandChild1->setContentBounds(IntSize(6, 8)); |
129 grandChild1->setDrawsContent(true); | 129 grandChild1->setDrawsContent(true); |
130 | 130 |
131 grandChild2->setPosition(FloatPoint(190, 190)); | 131 grandChild2->setPosition(FloatPoint(190, 190)); |
132 grandChild2->setAnchorPoint(FloatPoint::zero()); | 132 grandChild2->setAnchorPoint(FloatPoint::zero()); |
133 grandChild2->setBounds(IntSize(6, 8)); | 133 grandChild2->setBounds(IntSize(6, 8)); |
134 grandChild2->setContentBounds(IntSize(6, 8)); | 134 grandChild2->setContentBounds(IntSize(6, 8)); |
135 grandChild2->setDrawsContent(true); | 135 grandChild2->setDrawsContent(true); |
136 | 136 |
137 child1->addChild(grandChild1.release()); | 137 child1->addChild(grandChild1.Pass()); |
138 child1->addChild(grandChild2.release()); | 138 child1->addChild(grandChild2.Pass()); |
139 root->addChild(child1.release()); | 139 root->addChild(child1.Pass()); |
140 root->addChild(child2.release()); | 140 root->addChild(child2.Pass()); |
141 | 141 |
142 return root.release(); | 142 return root.Pass(); |
143 } | 143 } |
144 | 144 |
145 PassOwnPtr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface() | 145 scoped_ptr<CCLayerImpl> createAndSetUpTestTreeWithOneSurface() |
146 { | 146 { |
147 OwnPtr<CCLayerImpl> root = createTestTreeWithOneSurface(); | 147 scoped_ptr<CCLayerImpl> root = createTestTreeWithOneSurface(); |
148 | 148 |
149 // Setup includes going past the first frame which always damages everything
, so | 149 // Setup includes going past the first frame which always damages everything
, so |
150 // that we can actually perform specific tests. | 150 // that we can actually perform specific tests. |
151 emulateDrawingOneFrame(root.get()); | 151 emulateDrawingOneFrame(root.get()); |
152 | 152 |
153 return root.release(); | 153 return root.Pass(); |
154 } | 154 } |
155 | 155 |
156 PassOwnPtr<CCLayerImpl> createAndSetUpTestTreeWithTwoSurfaces() | 156 scoped_ptr<CCLayerImpl> createAndSetUpTestTreeWithTwoSurfaces() |
157 { | 157 { |
158 OwnPtr<CCLayerImpl> root = createTestTreeWithTwoSurfaces(); | 158 scoped_ptr<CCLayerImpl> root = createTestTreeWithTwoSurfaces(); |
159 | 159 |
160 // Setup includes going past the first frame which always damages everything
, so | 160 // Setup includes going past the first frame which always damages everything
, so |
161 // that we can actually perform specific tests. | 161 // that we can actually perform specific tests. |
162 emulateDrawingOneFrame(root.get()); | 162 emulateDrawingOneFrame(root.get()); |
163 | 163 |
164 return root.release(); | 164 return root.Pass(); |
165 } | 165 } |
166 | 166 |
167 class CCDamageTrackerTest : public testing::Test { | 167 class CCDamageTrackerTest : public testing::Test { |
168 private: | 168 private: |
169 // For testing purposes, fake that we are on the impl thread. | 169 // For testing purposes, fake that we are on the impl thread. |
170 DebugScopedSetImplThread setImplThread; | 170 DebugScopedSetImplThread setImplThread; |
171 }; | 171 }; |
172 | 172 |
173 TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithOneSurface) | 173 TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithOneSurface) |
174 { | 174 { |
175 // Sanity check that the simple test tree will actually produce the expected
render | 175 // Sanity check that the simple test tree will actually produce the expected
render |
176 // surfaces and layer lists. | 176 // surfaces and layer lists. |
177 | 177 |
178 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 178 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
179 | 179 |
180 EXPECT_EQ(2u, root->renderSurface()->layerList().size()); | 180 EXPECT_EQ(2u, root->renderSurface()->layerList().size()); |
181 EXPECT_EQ(1, root->renderSurface()->layerList()[0]->id()); | 181 EXPECT_EQ(1, root->renderSurface()->layerList()[0]->id()); |
182 EXPECT_EQ(2, root->renderSurface()->layerList()[1]->id()); | 182 EXPECT_EQ(2, root->renderSurface()->layerList()[1]->id()); |
183 | 183 |
184 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 184 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
185 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 185 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
186 } | 186 } |
187 | 187 |
188 TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) | 188 TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) |
189 { | 189 { |
190 // Sanity check that the complex test tree will actually produce the expecte
d render | 190 // Sanity check that the complex test tree will actually produce the expecte
d render |
191 // surfaces and layer lists. | 191 // surfaces and layer lists. |
192 | 192 |
193 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 193 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
194 | 194 |
195 CCLayerImpl* child1 = root->children()[0]; | 195 CCLayerImpl* child1 = root->children()[0]; |
196 CCLayerImpl* child2 = root->children()[1]; | 196 CCLayerImpl* child2 = root->children()[1]; |
197 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); | 197 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); |
198 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 198 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
199 | 199 |
200 ASSERT_TRUE(child1->renderSurface()); | 200 ASSERT_TRUE(child1->renderSurface()); |
201 EXPECT_FALSE(child2->renderSurface()); | 201 EXPECT_FALSE(child2->renderSurface()); |
202 EXPECT_EQ(3u, root->renderSurface()->layerList().size()); | 202 EXPECT_EQ(3u, root->renderSurface()->layerList().size()); |
203 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); | 203 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); |
204 | 204 |
205 // The render surface for child1 only has a contentRect that encloses grandC
hild1 and grandChild2, because child1 does not draw content. | 205 // The render surface for child1 only has a contentRect that encloses grandC
hild1 and grandChild2, because child1 does not draw content. |
206 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); | 206 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); |
207 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 207 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
208 } | 208 } |
209 | 209 |
210 TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects) | 210 TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects) |
211 { | 211 { |
212 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 212 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
213 CCLayerImpl* child = root->children()[0]; | 213 CCLayerImpl* child = root->children()[0]; |
214 | 214 |
215 // CASE 1: Setting the update rect should cause the corresponding damage to
the surface. | 215 // CASE 1: Setting the update rect should cause the corresponding damage to
the surface. |
216 // | 216 // |
217 clearDamageForAllSurfaces(root.get()); | 217 clearDamageForAllSurfaces(root.get()); |
218 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 218 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
219 emulateDrawingOneFrame(root.get()); | 219 emulateDrawingOneFrame(root.get()); |
220 | 220 |
221 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100). | 221 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100). |
222 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 222 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
(...skipping 13 matching lines...) Expand all Loading... |
236 child->setUpdateRect(FloatRect(20, 25, 1, 2)); | 236 child->setUpdateRect(FloatRect(20, 25, 1, 2)); |
237 emulateDrawingOneFrame(root.get()); | 237 emulateDrawingOneFrame(root.get()); |
238 | 238 |
239 // Damage position on the surface should be: position of updateRect (20, 25)
relative to the child (100, 100). | 239 // Damage position on the surface should be: position of updateRect (20, 25)
relative to the child (100, 100). |
240 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 240 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
241 EXPECT_FLOAT_RECT_EQ(FloatRect(120, 125, 1, 2), rootDamageRect); | 241 EXPECT_FLOAT_RECT_EQ(FloatRect(120, 125, 1, 2), rootDamageRect); |
242 } | 242 } |
243 | 243 |
244 TEST_F(CCDamageTrackerTest, verifyDamageForPropertyChanges) | 244 TEST_F(CCDamageTrackerTest, verifyDamageForPropertyChanges) |
245 { | 245 { |
246 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 246 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
247 CCLayerImpl* child = root->children()[0]; | 247 CCLayerImpl* child = root->children()[0]; |
248 | 248 |
249 // CASE 1: The layer's property changed flag takes priority over update rect
. | 249 // CASE 1: The layer's property changed flag takes priority over update rect
. |
250 // | 250 // |
251 clearDamageForAllSurfaces(root.get()); | 251 clearDamageForAllSurfaces(root.get()); |
252 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 252 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
253 child->setOpacity(0.5); | 253 child->setOpacity(0.5); |
254 emulateDrawingOneFrame(root.get()); | 254 emulateDrawingOneFrame(root.get()); |
255 | 255 |
256 // Sanity check - we should not have accidentally created a separate render
surface for the translucent layer. | 256 // Sanity check - we should not have accidentally created a separate render
surface for the translucent layer. |
(...skipping 23 matching lines...) Expand all Loading... |
280 expectedRect.uniteIfNonZero(FloatRect(200, 230, 30, 30)); | 280 expectedRect.uniteIfNonZero(FloatRect(200, 230, 30, 30)); |
281 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 281 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
282 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); | 282 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); |
283 } | 283 } |
284 | 284 |
285 TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) | 285 TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) |
286 { | 286 { |
287 // If a layer is transformed, the damage rect should still enclose the entir
e | 287 // If a layer is transformed, the damage rect should still enclose the entir
e |
288 // transformed layer. | 288 // transformed layer. |
289 | 289 |
290 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 290 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
291 CCLayerImpl* child = root->children()[0]; | 291 CCLayerImpl* child = root->children()[0]; |
292 | 292 |
293 WebTransformationMatrix rotation; | 293 WebTransformationMatrix rotation; |
294 rotation.rotate(45); | 294 rotation.rotate(45); |
295 | 295 |
296 clearDamageForAllSurfaces(root.get()); | 296 clearDamageForAllSurfaces(root.get()); |
297 child->setAnchorPoint(FloatPoint(0.5, 0.5)); | 297 child->setAnchorPoint(FloatPoint(0.5, 0.5)); |
298 child->setPosition(FloatPoint(85, 85)); | 298 child->setPosition(FloatPoint(85, 85)); |
299 emulateDrawingOneFrame(root.get()); | 299 emulateDrawingOneFrame(root.get()); |
300 | 300 |
(...skipping 22 matching lines...) Expand all Loading... |
323 // If a layer has a perspective transform that causes w < 0, then not clippi
ng the | 323 // If a layer has a perspective transform that causes w < 0, then not clippi
ng the |
324 // layer can cause an invalid damage rect. This test checks that the w < 0 c
ase is | 324 // layer can cause an invalid damage rect. This test checks that the w < 0 c
ase is |
325 // tracked properly. | 325 // tracked properly. |
326 // | 326 // |
327 // The transform is constructed so that if w < 0 clipping is not performed,
the | 327 // The transform is constructed so that if w < 0 clipping is not performed,
the |
328 // incorrect rect will be very small, specifically: position (500.972504, 49
8.544617) and size 0.056610 x 2.910767. | 328 // incorrect rect will be very small, specifically: position (500.972504, 49
8.544617) and size 0.056610 x 2.910767. |
329 // Instead, the correctly transformed rect should actually be very huge (i.e
. in theory, -infinity on the left), | 329 // Instead, the correctly transformed rect should actually be very huge (i.e
. in theory, -infinity on the left), |
330 // and positioned so that the right-most bound rect will be approximately 50
1 units in root surface space. | 330 // and positioned so that the right-most bound rect will be approximately 50
1 units in root surface space. |
331 // | 331 // |
332 | 332 |
333 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 333 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
334 CCLayerImpl* child = root->children()[0]; | 334 CCLayerImpl* child = root->children()[0]; |
335 | 335 |
336 WebTransformationMatrix transform; | 336 WebTransformationMatrix transform; |
337 transform.translate3d(500, 500, 0); | 337 transform.translate3d(500, 500, 0); |
338 transform.applyPerspective(1); | 338 transform.applyPerspective(1); |
339 transform.rotate3d(0, 45, 0); | 339 transform.rotate3d(0, 45, 0); |
340 transform.translate3d(-50, -50, 0); | 340 transform.translate3d(-50, -50, 0); |
341 | 341 |
342 // Set up the child | 342 // Set up the child |
343 child->setPosition(FloatPoint(0, 0)); | 343 child->setPosition(FloatPoint(0, 0)); |
(...skipping 16 matching lines...) Expand all Loading... |
360 | 360 |
361 // The expected damage should cover the entire root surface (500x500), but w
e don't | 361 // The expected damage should cover the entire root surface (500x500), but w
e don't |
362 // care whether the damage rect was clamped or is larger than the surface fo
r this test. | 362 // care whether the damage rect was clamped or is larger than the surface fo
r this test. |
363 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 363 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
364 FloatRect damageWeCareAbout = FloatRect(FloatPoint::zero(), FloatSize(500, 5
00)); | 364 FloatRect damageWeCareAbout = FloatRect(FloatPoint::zero(), FloatSize(500, 5
00)); |
365 EXPECT_TRUE(rootDamageRect.contains(damageWeCareAbout)); | 365 EXPECT_TRUE(rootDamageRect.contains(damageWeCareAbout)); |
366 } | 366 } |
367 | 367 |
368 TEST_F(CCDamageTrackerTest, verifyDamageForBlurredSurface) | 368 TEST_F(CCDamageTrackerTest, verifyDamageForBlurredSurface) |
369 { | 369 { |
370 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 370 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
371 CCLayerImpl* child = root->children()[0]; | 371 CCLayerImpl* child = root->children()[0]; |
372 | 372 |
373 WebFilterOperations filters; | 373 WebFilterOperations filters; |
374 filters.append(WebFilterOperation::createBlurFilter(5)); | 374 filters.append(WebFilterOperation::createBlurFilter(5)); |
375 int outsetTop, outsetRight, outsetBottom, outsetLeft; | 375 int outsetTop, outsetRight, outsetBottom, outsetLeft; |
376 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); | 376 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
377 | 377 |
378 // Setting the filter will damage the whole surface. | 378 // Setting the filter will damage the whole surface. |
379 clearDamageForAllSurfaces(root.get()); | 379 clearDamageForAllSurfaces(root.get()); |
380 root->setFilters(filters); | 380 root->setFilters(filters); |
381 emulateDrawingOneFrame(root.get()); | 381 emulateDrawingOneFrame(root.get()); |
382 | 382 |
383 // Setting the update rect should cause the corresponding damage to the surf
ace, blurred based on the size of the blur filter. | 383 // Setting the update rect should cause the corresponding damage to the surf
ace, blurred based on the size of the blur filter. |
384 clearDamageForAllSurfaces(root.get()); | 384 clearDamageForAllSurfaces(root.get()); |
385 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 385 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
386 emulateDrawingOneFrame(root.get()); | 386 emulateDrawingOneFrame(root.get()); |
387 | 387 |
388 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100), but expanded by the blur outsets. | 388 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100), but expanded by the blur outsets. |
389 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 389 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
390 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); | 390 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); |
391 expectedDamageRect.move(-outsetLeft, -outsetTop); | 391 expectedDamageRect.move(-outsetLeft, -outsetTop); |
392 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); | 392 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); |
393 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); | 393 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); |
394 } | 394 } |
395 | 395 |
396 TEST_F(CCDamageTrackerTest, verifyDamageForBackgroundBlurredChild) | 396 TEST_F(CCDamageTrackerTest, verifyDamageForBackgroundBlurredChild) |
397 { | 397 { |
398 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 398 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
399 CCLayerImpl* child1 = root->children()[0]; | 399 CCLayerImpl* child1 = root->children()[0]; |
400 CCLayerImpl* child2 = root->children()[1]; | 400 CCLayerImpl* child2 = root->children()[1]; |
401 | 401 |
402 // Allow us to set damage on child1 too. | 402 // Allow us to set damage on child1 too. |
403 child1->setDrawsContent(true); | 403 child1->setDrawsContent(true); |
404 | 404 |
405 WebFilterOperations filters; | 405 WebFilterOperations filters; |
406 filters.append(WebFilterOperation::createBlurFilter(2)); | 406 filters.append(WebFilterOperation::createBlurFilter(2)); |
407 int outsetTop, outsetRight, outsetBottom, outsetLeft; | 407 int outsetTop, outsetRight, outsetBottom, outsetLeft; |
408 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); | 408 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 491 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
492 // Damage on child1 should be: position of updateRect offset by the child's
position (100, 100), and expanded by the damage. | 492 // Damage on child1 should be: position of updateRect offset by the child's
position (100, 100), and expanded by the damage. |
493 expectedDamageRect = FloatRect(100, 100, 1, 1); | 493 expectedDamageRect = FloatRect(100, 100, 1, 1); |
494 expectedDamageRect.move(-outsetLeft, -outsetTop); | 494 expectedDamageRect.move(-outsetLeft, -outsetTop); |
495 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); | 495 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); |
496 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); | 496 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); |
497 } | 497 } |
498 | 498 |
499 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer) | 499 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer) |
500 { | 500 { |
501 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 501 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
502 CCLayerImpl* child1 = root->children()[0]; | 502 CCLayerImpl* child1 = root->children()[0]; |
503 | 503 |
504 // CASE 1: Adding a new layer should cause the appropriate damage. | 504 // CASE 1: Adding a new layer should cause the appropriate damage. |
505 // | 505 // |
506 clearDamageForAllSurfaces(root.get()); | 506 clearDamageForAllSurfaces(root.get()); |
507 { | 507 { |
508 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 508 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
509 child2->setPosition(FloatPoint(400, 380)); | 509 child2->setPosition(FloatPoint(400, 380)); |
510 child2->setAnchorPoint(FloatPoint::zero()); | 510 child2->setAnchorPoint(FloatPoint::zero()); |
511 child2->setBounds(IntSize(6, 8)); | 511 child2->setBounds(IntSize(6, 8)); |
512 child2->setContentBounds(IntSize(6, 8)); | 512 child2->setContentBounds(IntSize(6, 8)); |
513 child2->setDrawsContent(true); | 513 child2->setDrawsContent(true); |
514 root->addChild(child2.release()); | 514 root->addChild(child2.Pass()); |
515 } | 515 } |
516 emulateDrawingOneFrame(root.get()); | 516 emulateDrawingOneFrame(root.get()); |
517 | 517 |
518 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. | 518 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. |
519 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); | 519 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); |
520 | 520 |
521 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 521 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
522 EXPECT_FLOAT_RECT_EQ(FloatRect(400, 380, 6, 8), rootDamageRect); | 522 EXPECT_FLOAT_RECT_EQ(FloatRect(400, 380, 6, 8), rootDamageRect); |
523 | 523 |
524 // CASE 2: If the layer is removed, its entire old layer becomes exposed, no
t just the | 524 // CASE 2: If the layer is removed, its entire old layer becomes exposed, no
t just the |
525 // last update rect. | 525 // last update rect. |
526 | 526 |
527 // Advance one frame without damage so that we know the damage rect is not l
eftover from the previous case. | 527 // Advance one frame without damage so that we know the damage rect is not l
eftover from the previous case. |
528 clearDamageForAllSurfaces(root.get()); | 528 clearDamageForAllSurfaces(root.get()); |
529 emulateDrawingOneFrame(root.get()); | 529 emulateDrawingOneFrame(root.get()); |
530 EXPECT_TRUE(root->renderSurface()->damageTracker()->currentDamageRect().isEm
pty()); | 530 EXPECT_TRUE(root->renderSurface()->damageTracker()->currentDamageRect().isEm
pty()); |
531 | 531 |
532 // Then, test removing child1. | 532 // Then, test removing child1. |
533 child1->removeFromParent(); | 533 child1->removeFromParent(); |
534 emulateDrawingOneFrame(root.get()); | 534 emulateDrawingOneFrame(root.get()); |
535 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 535 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
536 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 30, 30), rootDamageRect); | 536 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 30, 30), rootDamageRect); |
537 } | 537 } |
538 | 538 |
539 TEST_F(CCDamageTrackerTest, verifyDamageForNewUnchangedLayer) | 539 TEST_F(CCDamageTrackerTest, verifyDamageForNewUnchangedLayer) |
540 { | 540 { |
541 // If child2 is added to the layer tree, but it doesn't have any explicit da
mage of | 541 // If child2 is added to the layer tree, but it doesn't have any explicit da
mage of |
542 // its own, it should still indeed damage the target surface. | 542 // its own, it should still indeed damage the target surface. |
543 | 543 |
544 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 544 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
545 | 545 |
546 clearDamageForAllSurfaces(root.get()); | 546 clearDamageForAllSurfaces(root.get()); |
547 { | 547 { |
548 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 548 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
549 child2->setPosition(FloatPoint(400, 380)); | 549 child2->setPosition(FloatPoint(400, 380)); |
550 child2->setAnchorPoint(FloatPoint::zero()); | 550 child2->setAnchorPoint(FloatPoint::zero()); |
551 child2->setBounds(IntSize(6, 8)); | 551 child2->setBounds(IntSize(6, 8)); |
552 child2->setContentBounds(IntSize(6, 8)); | 552 child2->setContentBounds(IntSize(6, 8)); |
553 child2->setDrawsContent(true); | 553 child2->setDrawsContent(true); |
554 child2->resetAllChangeTrackingForSubtree(); | 554 child2->resetAllChangeTrackingForSubtree(); |
555 // Sanity check the initial conditions of the test, if these asserts tri
gger, it | 555 // Sanity check the initial conditions of the test, if these asserts tri
gger, it |
556 // means the test no longer actually covers the intended scenario. | 556 // means the test no longer actually covers the intended scenario. |
557 ASSERT_FALSE(child2->layerPropertyChanged()); | 557 ASSERT_FALSE(child2->layerPropertyChanged()); |
558 ASSERT_TRUE(child2->updateRect().isEmpty()); | 558 ASSERT_TRUE(child2->updateRect().isEmpty()); |
559 root->addChild(child2.release()); | 559 root->addChild(child2.Pass()); |
560 } | 560 } |
561 emulateDrawingOneFrame(root.get()); | 561 emulateDrawingOneFrame(root.get()); |
562 | 562 |
563 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. | 563 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. |
564 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); | 564 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); |
565 | 565 |
566 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 566 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
567 EXPECT_FLOAT_RECT_EQ(FloatRect(400, 380, 6, 8), rootDamageRect); | 567 EXPECT_FLOAT_RECT_EQ(FloatRect(400, 380, 6, 8), rootDamageRect); |
568 } | 568 } |
569 | 569 |
570 TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers) | 570 TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers) |
571 { | 571 { |
572 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 572 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
573 CCLayerImpl* child1 = root->children()[0]; | 573 CCLayerImpl* child1 = root->children()[0]; |
574 | 574 |
575 // In this test we don't want the above tree manipulation to be considered p
art of the same frame. | 575 // In this test we don't want the above tree manipulation to be considered p
art of the same frame. |
576 clearDamageForAllSurfaces(root.get()); | 576 clearDamageForAllSurfaces(root.get()); |
577 { | 577 { |
578 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 578 scoped_ptr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
579 child2->setPosition(FloatPoint(400, 380)); | 579 child2->setPosition(FloatPoint(400, 380)); |
580 child2->setAnchorPoint(FloatPoint::zero()); | 580 child2->setAnchorPoint(FloatPoint::zero()); |
581 child2->setBounds(IntSize(6, 8)); | 581 child2->setBounds(IntSize(6, 8)); |
582 child2->setContentBounds(IntSize(6, 8)); | 582 child2->setContentBounds(IntSize(6, 8)); |
583 child2->setDrawsContent(true); | 583 child2->setDrawsContent(true); |
584 root->addChild(child2.release()); | 584 root->addChild(child2.Pass()); |
585 } | 585 } |
586 CCLayerImpl* child2 = root->children()[1]; | 586 CCLayerImpl* child2 = root->children()[1]; |
587 emulateDrawingOneFrame(root.get()); | 587 emulateDrawingOneFrame(root.get()); |
588 | 588 |
589 // Damaging two layers simultaneously should cause combined damage. | 589 // Damaging two layers simultaneously should cause combined damage. |
590 // - child1 update rect in surface space: FloatRect(100, 100, 1, 2); | 590 // - child1 update rect in surface space: FloatRect(100, 100, 1, 2); |
591 // - child2 update rect in surface space: FloatRect(400, 380, 3, 4); | 591 // - child2 update rect in surface space: FloatRect(400, 380, 3, 4); |
592 clearDamageForAllSurfaces(root.get()); | 592 clearDamageForAllSurfaces(root.get()); |
593 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); | 593 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); |
594 child2->setUpdateRect(FloatRect(0, 0, 3, 4)); | 594 child2->setUpdateRect(FloatRect(0, 0, 3, 4)); |
595 emulateDrawingOneFrame(root.get()); | 595 emulateDrawingOneFrame(root.get()); |
596 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 596 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
597 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 303, 284), rootDamageRect); | 597 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 303, 284), rootDamageRect); |
598 } | 598 } |
599 | 599 |
600 TEST_F(CCDamageTrackerTest, verifyDamageForNestedSurfaces) | 600 TEST_F(CCDamageTrackerTest, verifyDamageForNestedSurfaces) |
601 { | 601 { |
602 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 602 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
603 CCLayerImpl* child1 = root->children()[0]; | 603 CCLayerImpl* child1 = root->children()[0]; |
604 CCLayerImpl* child2 = root->children()[1]; | 604 CCLayerImpl* child2 = root->children()[1]; |
605 CCLayerImpl* grandChild1 = root->children()[0]->children()[0]; | 605 CCLayerImpl* grandChild1 = root->children()[0]->children()[0]; |
606 FloatRect childDamageRect; | 606 FloatRect childDamageRect; |
607 FloatRect rootDamageRect; | 607 FloatRect rootDamageRect; |
608 | 608 |
609 // CASE 1: Damage to a descendant surface should propagate properly to ances
tor surface. | 609 // CASE 1: Damage to a descendant surface should propagate properly to ances
tor surface. |
610 // | 610 // |
611 clearDamageForAllSurfaces(root.get()); | 611 clearDamageForAllSurfaces(root.get()); |
612 grandChild1->setOpacity(0.5); | 612 grandChild1->setOpacity(0.5); |
(...skipping 18 matching lines...) Expand all Loading... |
631 | 631 |
632 TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer) | 632 TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer) |
633 { | 633 { |
634 // If descendant layer changes and affects the content bounds of the render
surface, | 634 // If descendant layer changes and affects the content bounds of the render
surface, |
635 // then the entire descendant surface should be damaged, and it should damag
e its | 635 // then the entire descendant surface should be damaged, and it should damag
e its |
636 // ancestor surface with the old and new surface regions. | 636 // ancestor surface with the old and new surface regions. |
637 | 637 |
638 // This is a tricky case, since only the first grandChild changes, but the e
ntire | 638 // This is a tricky case, since only the first grandChild changes, but the e
ntire |
639 // surface should be marked dirty. | 639 // surface should be marked dirty. |
640 | 640 |
641 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 641 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
642 CCLayerImpl* child1 = root->children()[0]; | 642 CCLayerImpl* child1 = root->children()[0]; |
643 CCLayerImpl* grandChild1 = root->children()[0]->children()[0]; | 643 CCLayerImpl* grandChild1 = root->children()[0]->children()[0]; |
644 FloatRect childDamageRect; | 644 FloatRect childDamageRect; |
645 FloatRect rootDamageRect; | 645 FloatRect rootDamageRect; |
646 | 646 |
647 clearDamageForAllSurfaces(root.get()); | 647 clearDamageForAllSurfaces(root.get()); |
648 grandChild1->setPosition(FloatPoint(195, 205)); | 648 grandChild1->setPosition(FloatPoint(195, 205)); |
649 emulateDrawingOneFrame(root.get()); | 649 emulateDrawingOneFrame(root.get()); |
650 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 650 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
651 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 651 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
(...skipping 12 matching lines...) Expand all Loading... |
664 // surface. Note that in this case, the layerPropertyChanged flag already pr
opagates | 664 // surface. Note that in this case, the layerPropertyChanged flag already pr
opagates |
665 // to the subtree (tested in CCLayerImpltest), which damages the entire chil
d1 | 665 // to the subtree (tested in CCLayerImpltest), which damages the entire chil
d1 |
666 // surface, but the damage tracker still needs the correct logic to compute
the | 666 // surface, but the damage tracker still needs the correct logic to compute
the |
667 // exposed region on the root surface. | 667 // exposed region on the root surface. |
668 | 668 |
669 // FIXME: the expectations of this test case should change when we add suppo
rt for a | 669 // FIXME: the expectations of this test case should change when we add suppo
rt for a |
670 // unique scissorRect per renderSurface. In that case, the child1 sur
face | 670 // unique scissorRect per renderSurface. In that case, the child1 sur
face |
671 // should be completely unchanged, since we are only transforming it,
while the | 671 // should be completely unchanged, since we are only transforming it,
while the |
672 // root surface would be damaged appropriately. | 672 // root surface would be damaged appropriately. |
673 | 673 |
674 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 674 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
675 CCLayerImpl* child1 = root->children()[0]; | 675 CCLayerImpl* child1 = root->children()[0]; |
676 FloatRect childDamageRect; | 676 FloatRect childDamageRect; |
677 FloatRect rootDamageRect; | 677 FloatRect rootDamageRect; |
678 | 678 |
679 clearDamageForAllSurfaces(root.get()); | 679 clearDamageForAllSurfaces(root.get()); |
680 child1->setPosition(FloatPoint(50, 50)); | 680 child1->setPosition(FloatPoint(50, 50)); |
681 emulateDrawingOneFrame(root.get()); | 681 emulateDrawingOneFrame(root.get()); |
682 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 682 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
683 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 683 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
684 | 684 |
685 // The new surface bounds should be damaged entirely. | 685 // The new surface bounds should be damaged entirely. |
686 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); | 686 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); |
687 | 687 |
688 // The entire child1 surface and the old exposed child1 surface should damag
e the root surface. | 688 // The entire child1 surface and the old exposed child1 surface should damag
e the root surface. |
689 // - old child1 surface in target space: FloatRect(290, 290, 16, 18) | 689 // - old child1 surface in target space: FloatRect(290, 290, 16, 18) |
690 // - new child1 surface in target space: FloatRect(240, 240, 16, 18) | 690 // - new child1 surface in target space: FloatRect(240, 240, 16, 18) |
691 EXPECT_FLOAT_RECT_EQ(FloatRect(240, 240, 66, 68), rootDamageRect); | 691 EXPECT_FLOAT_RECT_EQ(FloatRect(240, 240, 66, 68), rootDamageRect); |
692 } | 692 } |
693 | 693 |
694 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) | 694 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) |
695 { | 695 { |
696 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 696 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
697 CCLayerImpl* child1 = root->children()[0]; | 697 CCLayerImpl* child1 = root->children()[0]; |
698 FloatRect childDamageRect; | 698 FloatRect childDamageRect; |
699 FloatRect rootDamageRect; | 699 FloatRect rootDamageRect; |
700 | 700 |
701 // CASE 1: If a descendant surface disappears, its entire old area becomes e
xposed. | 701 // CASE 1: If a descendant surface disappears, its entire old area becomes e
xposed. |
702 // | 702 // |
703 clearDamageForAllSurfaces(root.get()); | 703 clearDamageForAllSurfaces(root.get()); |
704 child1->setOpacity(1); | 704 child1->setOpacity(1); |
705 emulateDrawingOneFrame(root.get()); | 705 emulateDrawingOneFrame(root.get()); |
706 | 706 |
(...skipping 23 matching lines...) Expand all Loading... |
730 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); | 730 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); |
731 | 731 |
732 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 732 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
733 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 733 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
734 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); | 734 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); |
735 EXPECT_FLOAT_RECT_EQ(FloatRect(290, 290, 16, 18), rootDamageRect); | 735 EXPECT_FLOAT_RECT_EQ(FloatRect(290, 290, 16, 18), rootDamageRect); |
736 } | 736 } |
737 | 737 |
738 TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged) | 738 TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged) |
739 { | 739 { |
740 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 740 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
741 CCLayerImpl* child1 = root->children()[0]; | 741 CCLayerImpl* child1 = root->children()[0]; |
742 FloatRect childDamageRect; | 742 FloatRect childDamageRect; |
743 FloatRect rootDamageRect; | 743 FloatRect rootDamageRect; |
744 | 744 |
745 // CASE 1: If nothing changes, the damage rect should be empty. | 745 // CASE 1: If nothing changes, the damage rect should be empty. |
746 // | 746 // |
747 clearDamageForAllSurfaces(root.get()); | 747 clearDamageForAllSurfaces(root.get()); |
748 emulateDrawingOneFrame(root.get()); | 748 emulateDrawingOneFrame(root.get()); |
749 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 749 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
750 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 750 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
751 EXPECT_TRUE(childDamageRect.isEmpty()); | 751 EXPECT_TRUE(childDamageRect.isEmpty()); |
752 EXPECT_TRUE(rootDamageRect.isEmpty()); | 752 EXPECT_TRUE(rootDamageRect.isEmpty()); |
753 | 753 |
754 // CASE 2: If nothing changes twice in a row, the damage rect should still b
e empty. | 754 // CASE 2: If nothing changes twice in a row, the damage rect should still b
e empty. |
755 // | 755 // |
756 clearDamageForAllSurfaces(root.get()); | 756 clearDamageForAllSurfaces(root.get()); |
757 emulateDrawingOneFrame(root.get()); | 757 emulateDrawingOneFrame(root.get()); |
758 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 758 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
759 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 759 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
760 EXPECT_TRUE(childDamageRect.isEmpty()); | 760 EXPECT_TRUE(childDamageRect.isEmpty()); |
761 EXPECT_TRUE(rootDamageRect.isEmpty()); | 761 EXPECT_TRUE(rootDamageRect.isEmpty()); |
762 } | 762 } |
763 | 763 |
764 TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) | 764 TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) |
765 { | 765 { |
766 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 766 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
767 CCLayerImpl* child1 = root->children()[0]; | 767 CCLayerImpl* child1 = root->children()[0]; |
768 FloatRect childDamageRect; | 768 FloatRect childDamageRect; |
769 FloatRect rootDamageRect; | 769 FloatRect rootDamageRect; |
770 | 770 |
771 // In our specific tree, the update rect of child1 should not cause any dama
ge to any | 771 // In our specific tree, the update rect of child1 should not cause any dama
ge to any |
772 // surface because it does not actually draw content. | 772 // surface because it does not actually draw content. |
773 clearDamageForAllSurfaces(root.get()); | 773 clearDamageForAllSurfaces(root.get()); |
774 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); | 774 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); |
775 emulateDrawingOneFrame(root.get()); | 775 emulateDrawingOneFrame(root.get()); |
776 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 776 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
777 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 777 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
778 EXPECT_TRUE(childDamageRect.isEmpty()); | 778 EXPECT_TRUE(childDamageRect.isEmpty()); |
779 EXPECT_TRUE(rootDamageRect.isEmpty()); | 779 EXPECT_TRUE(rootDamageRect.isEmpty()); |
780 } | 780 } |
781 | 781 |
782 TEST_F(CCDamageTrackerTest, verifyDamageForReplica) | 782 TEST_F(CCDamageTrackerTest, verifyDamageForReplica) |
783 { | 783 { |
784 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 784 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
785 CCLayerImpl* child1 = root->children()[0]; | 785 CCLayerImpl* child1 = root->children()[0]; |
786 CCLayerImpl* grandChild1 = child1->children()[0]; | 786 CCLayerImpl* grandChild1 = child1->children()[0]; |
787 CCLayerImpl* grandChild2 = child1->children()[1]; | 787 CCLayerImpl* grandChild2 = child1->children()[1]; |
788 | 788 |
789 // Damage on a surface that has a reflection should cause the target surface
to | 789 // Damage on a surface that has a reflection should cause the target surface
to |
790 // receive the surface's damage and the surface's reflected damage. | 790 // receive the surface's damage and the surface's reflected damage. |
791 | 791 |
792 // For this test case, we modify grandChild2, and add grandChild3 to extend
the bounds | 792 // For this test case, we modify grandChild2, and add grandChild3 to extend
the bounds |
793 // of child1's surface. This way, we can test reflection changes without cha
nging | 793 // of child1's surface. This way, we can test reflection changes without cha
nging |
794 // contentBounds of the surface. | 794 // contentBounds of the surface. |
795 grandChild2->setPosition(FloatPoint(180, 180)); | 795 grandChild2->setPosition(FloatPoint(180, 180)); |
796 { | 796 { |
797 OwnPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6); | 797 scoped_ptr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6); |
798 grandChild3->setPosition(FloatPoint(240, 240)); | 798 grandChild3->setPosition(FloatPoint(240, 240)); |
799 grandChild3->setAnchorPoint(FloatPoint::zero()); | 799 grandChild3->setAnchorPoint(FloatPoint::zero()); |
800 grandChild3->setBounds(IntSize(10, 10)); | 800 grandChild3->setBounds(IntSize(10, 10)); |
801 grandChild3->setContentBounds(IntSize(10, 10)); | 801 grandChild3->setContentBounds(IntSize(10, 10)); |
802 grandChild3->setDrawsContent(true); | 802 grandChild3->setDrawsContent(true); |
803 child1->addChild(grandChild3.release()); | 803 child1->addChild(grandChild3.Pass()); |
804 } | 804 } |
805 child1->setOpacity(0.5); | 805 child1->setOpacity(0.5); |
806 emulateDrawingOneFrame(root.get()); | 806 emulateDrawingOneFrame(root.get()); |
807 | 807 |
808 // CASE 1: adding a reflection about the left edge of grandChild1. | 808 // CASE 1: adding a reflection about the left edge of grandChild1. |
809 // | 809 // |
810 clearDamageForAllSurfaces(root.get()); | 810 clearDamageForAllSurfaces(root.get()); |
811 { | 811 { |
812 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7); | 812 scoped_ptr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(7); |
813 grandChild1Replica->setPosition(FloatPoint::zero()); | 813 grandChild1Replica->setPosition(FloatPoint::zero()); |
814 grandChild1Replica->setAnchorPoint(FloatPoint::zero()); | 814 grandChild1Replica->setAnchorPoint(FloatPoint::zero()); |
815 WebTransformationMatrix reflection; | 815 WebTransformationMatrix reflection; |
816 reflection.scale3d(-1, 1, 1); | 816 reflection.scale3d(-1, 1, 1); |
817 grandChild1Replica->setTransform(reflection); | 817 grandChild1Replica->setTransform(reflection); |
818 grandChild1->setReplicaLayer(grandChild1Replica.release()); | 818 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
819 } | 819 } |
820 emulateDrawingOneFrame(root.get()); | 820 emulateDrawingOneFrame(root.get()); |
821 | 821 |
822 FloatRect grandChildDamageRect = grandChild1->renderSurface()->damageTracker
()->currentDamageRect(); | 822 FloatRect grandChildDamageRect = grandChild1->renderSurface()->damageTracker
()->currentDamageRect(); |
823 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); | 823 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); |
824 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 824 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
825 | 825 |
826 // The grandChild surface damage should not include its own replica. The chi
ld | 826 // The grandChild surface damage should not include its own replica. The chi
ld |
827 // surface damage should include the normal and replica surfaces. | 827 // surface damage should include the normal and replica surfaces. |
828 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 6, 8), grandChildDamageRect); | 828 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 6, 8), grandChildDamageRect); |
(...skipping 16 matching lines...) Expand all Loading... |
845 // The child surface damage should include normal and replica surfaces for b
oth old and new locations. | 845 // The child surface damage should include normal and replica surfaces for b
oth old and new locations. |
846 // - old location in target space: FloatRect(194, 200, 12, 8) | 846 // - old location in target space: FloatRect(194, 200, 12, 8) |
847 // - new location in target space: FloatRect(189, 205, 12, 8) | 847 // - new location in target space: FloatRect(189, 205, 12, 8) |
848 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 6, 8), grandChildDamageRect); | 848 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 6, 8), grandChildDamageRect); |
849 EXPECT_FLOAT_RECT_EQ(FloatRect(189, 200, 17, 13), childDamageRect); | 849 EXPECT_FLOAT_RECT_EQ(FloatRect(189, 200, 17, 13), childDamageRect); |
850 EXPECT_FLOAT_RECT_EQ(FloatRect(289, 300, 17, 13), rootDamageRect); | 850 EXPECT_FLOAT_RECT_EQ(FloatRect(289, 300, 17, 13), rootDamageRect); |
851 | 851 |
852 // CASE 3: removing the reflection should cause the entire region including
reflection | 852 // CASE 3: removing the reflection should cause the entire region including
reflection |
853 // to damage the target surface. | 853 // to damage the target surface. |
854 clearDamageForAllSurfaces(root.get()); | 854 clearDamageForAllSurfaces(root.get()); |
855 grandChild1->setReplicaLayer(nullptr); | 855 grandChild1->setReplicaLayer(scoped_ptr<CCLayerImpl>()); |
856 emulateDrawingOneFrame(root.get()); | 856 emulateDrawingOneFrame(root.get()); |
857 ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->contentRect().wid
th()); | 857 ASSERT_EQ(oldContentRect.width(), child1->renderSurface()->contentRect().wid
th()); |
858 ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->contentRect().he
ight()); | 858 ASSERT_EQ(oldContentRect.height(), child1->renderSurface()->contentRect().he
ight()); |
859 | 859 |
860 EXPECT_FALSE(grandChild1->renderSurface()); | 860 EXPECT_FALSE(grandChild1->renderSurface()); |
861 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 861 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
862 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 862 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
863 | 863 |
864 EXPECT_FLOAT_RECT_EQ(FloatRect(189, 205, 12, 8), childDamageRect); | 864 EXPECT_FLOAT_RECT_EQ(FloatRect(189, 205, 12, 8), childDamageRect); |
865 EXPECT_FLOAT_RECT_EQ(FloatRect(289, 305, 12, 8), rootDamageRect); | 865 EXPECT_FLOAT_RECT_EQ(FloatRect(289, 305, 12, 8), rootDamageRect); |
866 } | 866 } |
867 | 867 |
868 TEST_F(CCDamageTrackerTest, verifyDamageForMask) | 868 TEST_F(CCDamageTrackerTest, verifyDamageForMask) |
869 { | 869 { |
870 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 870 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
871 CCLayerImpl* child = root->children()[0]; | 871 CCLayerImpl* child = root->children()[0]; |
872 | 872 |
873 // In the current implementation of the damage tracker, changes to mask laye
rs should | 873 // In the current implementation of the damage tracker, changes to mask laye
rs should |
874 // damage the entire corresponding surface. | 874 // damage the entire corresponding surface. |
875 | 875 |
876 clearDamageForAllSurfaces(root.get()); | 876 clearDamageForAllSurfaces(root.get()); |
877 | 877 |
878 // Set up the mask layer. | 878 // Set up the mask layer. |
879 { | 879 { |
880 OwnPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3); | 880 scoped_ptr<CCLayerImpl> maskLayer = CCLayerImpl::create(3); |
881 maskLayer->setPosition(child->position()); | 881 maskLayer->setPosition(child->position()); |
882 maskLayer->setAnchorPoint(FloatPoint::zero()); | 882 maskLayer->setAnchorPoint(FloatPoint::zero()); |
883 maskLayer->setBounds(child->bounds()); | 883 maskLayer->setBounds(child->bounds()); |
884 maskLayer->setContentBounds(child->bounds()); | 884 maskLayer->setContentBounds(child->bounds()); |
885 child->setMaskLayer(maskLayer.release()); | 885 child->setMaskLayer(maskLayer.Pass()); |
886 } | 886 } |
887 CCLayerImpl* maskLayer = child->maskLayer(); | 887 CCLayerImpl* maskLayer = child->maskLayer(); |
888 | 888 |
889 // Add opacity and a grandChild so that the render surface persists even aft
er we remove the mask. | 889 // Add opacity and a grandChild so that the render surface persists even aft
er we remove the mask. |
890 child->setOpacity(0.5); | 890 child->setOpacity(0.5); |
891 { | 891 { |
892 OwnPtr<CCLayerImpl> grandChild = CCLayerImpl::create(4); | 892 scoped_ptr<CCLayerImpl> grandChild = CCLayerImpl::create(4); |
893 grandChild->setPosition(FloatPoint(2, 2)); | 893 grandChild->setPosition(FloatPoint(2, 2)); |
894 grandChild->setAnchorPoint(FloatPoint::zero()); | 894 grandChild->setAnchorPoint(FloatPoint::zero()); |
895 grandChild->setBounds(IntSize(2, 2)); | 895 grandChild->setBounds(IntSize(2, 2)); |
896 grandChild->setContentBounds(IntSize(2, 2)); | 896 grandChild->setContentBounds(IntSize(2, 2)); |
897 grandChild->setDrawsContent(true); | 897 grandChild->setDrawsContent(true); |
898 child->addChild(grandChild.release()); | 898 child->addChild(grandChild.Pass()); |
899 } | 899 } |
900 emulateDrawingOneFrame(root.get()); | 900 emulateDrawingOneFrame(root.get()); |
901 | 901 |
902 // Sanity check that a new surface was created for the child. | 902 // Sanity check that a new surface was created for the child. |
903 ASSERT_TRUE(child->renderSurface()); | 903 ASSERT_TRUE(child->renderSurface()); |
904 | 904 |
905 // CASE 1: the updateRect on a mask layer should damage the entire target su
rface. | 905 // CASE 1: the updateRect on a mask layer should damage the entire target su
rface. |
906 // | 906 // |
907 clearDamageForAllSurfaces(root.get()); | 907 clearDamageForAllSurfaces(root.get()); |
908 maskLayer->setUpdateRect(FloatRect(1, 2, 3, 4)); | 908 maskLayer->setUpdateRect(FloatRect(1, 2, 3, 4)); |
(...skipping 22 matching lines...) Expand all Loading... |
931 // | 931 // |
932 | 932 |
933 // Advance one frame without damage so that we know the damage rect is not l
eftover from the previous case. | 933 // Advance one frame without damage so that we know the damage rect is not l
eftover from the previous case. |
934 clearDamageForAllSurfaces(root.get()); | 934 clearDamageForAllSurfaces(root.get()); |
935 emulateDrawingOneFrame(root.get()); | 935 emulateDrawingOneFrame(root.get()); |
936 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); | 936 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); |
937 EXPECT_TRUE(childDamageRect.isEmpty()); | 937 EXPECT_TRUE(childDamageRect.isEmpty()); |
938 | 938 |
939 // Then test mask removal. | 939 // Then test mask removal. |
940 clearDamageForAllSurfaces(root.get()); | 940 clearDamageForAllSurfaces(root.get()); |
941 child->setMaskLayer(nullptr); | 941 child->setMaskLayer(scoped_ptr<CCLayerImpl>()); |
942 ASSERT_TRUE(child->layerPropertyChanged()); | 942 ASSERT_TRUE(child->layerPropertyChanged()); |
943 emulateDrawingOneFrame(root.get()); | 943 emulateDrawingOneFrame(root.get()); |
944 | 944 |
945 // Sanity check that a render surface still exists. | 945 // Sanity check that a render surface still exists. |
946 ASSERT_TRUE(child->renderSurface()); | 946 ASSERT_TRUE(child->renderSurface()); |
947 | 947 |
948 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); | 948 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); |
949 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 30), childDamageRect); | 949 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 30), childDamageRect); |
950 } | 950 } |
951 | 951 |
952 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) | 952 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) |
953 { | 953 { |
954 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 954 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
955 CCLayerImpl* child1 = root->children()[0]; | 955 CCLayerImpl* child1 = root->children()[0]; |
956 CCLayerImpl* grandChild1 = child1->children()[0]; | 956 CCLayerImpl* grandChild1 = child1->children()[0]; |
957 | 957 |
958 // Changes to a replica's mask should not damage the original surface, becau
se it is | 958 // Changes to a replica's mask should not damage the original surface, becau
se it is |
959 // not masked. But it does damage the ancestor target surface. | 959 // not masked. But it does damage the ancestor target surface. |
960 | 960 |
961 clearDamageForAllSurfaces(root.get()); | 961 clearDamageForAllSurfaces(root.get()); |
962 | 962 |
963 // Create a reflection about the left edge of grandChild1. | 963 // Create a reflection about the left edge of grandChild1. |
964 { | 964 { |
965 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); | 965 scoped_ptr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); |
966 grandChild1Replica->setPosition(FloatPoint::zero()); | 966 grandChild1Replica->setPosition(FloatPoint::zero()); |
967 grandChild1Replica->setAnchorPoint(FloatPoint::zero()); | 967 grandChild1Replica->setAnchorPoint(FloatPoint::zero()); |
968 WebTransformationMatrix reflection; | 968 WebTransformationMatrix reflection; |
969 reflection.scale3d(-1, 1, 1); | 969 reflection.scale3d(-1, 1, 1); |
970 grandChild1Replica->setTransform(reflection); | 970 grandChild1Replica->setTransform(reflection); |
971 grandChild1->setReplicaLayer(grandChild1Replica.release()); | 971 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
972 } | 972 } |
973 CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer(); | 973 CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer(); |
974 | 974 |
975 // Set up the mask layer on the replica layer | 975 // Set up the mask layer on the replica layer |
976 { | 976 { |
977 OwnPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7); | 977 scoped_ptr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7); |
978 replicaMaskLayer->setPosition(FloatPoint::zero()); | 978 replicaMaskLayer->setPosition(FloatPoint::zero()); |
979 replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); | 979 replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); |
980 replicaMaskLayer->setBounds(grandChild1->bounds()); | 980 replicaMaskLayer->setBounds(grandChild1->bounds()); |
981 replicaMaskLayer->setContentBounds(grandChild1->bounds()); | 981 replicaMaskLayer->setContentBounds(grandChild1->bounds()); |
982 grandChild1Replica->setMaskLayer(replicaMaskLayer.release()); | 982 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); |
983 } | 983 } |
984 CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); | 984 CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); |
985 | 985 |
986 emulateDrawingOneFrame(root.get()); | 986 emulateDrawingOneFrame(root.get()); |
987 | 987 |
988 // Sanity check that the appropriate render surfaces were created | 988 // Sanity check that the appropriate render surfaces were created |
989 ASSERT_TRUE(grandChild1->renderSurface()); | 989 ASSERT_TRUE(grandChild1->renderSurface()); |
990 | 990 |
991 // CASE 1: a property change on the mask should damage only the reflected re
gion on the target surface. | 991 // CASE 1: a property change on the mask should damage only the reflected re
gion on the target surface. |
992 clearDamageForAllSurfaces(root.get()); | 992 clearDamageForAllSurfaces(root.get()); |
993 replicaMaskLayer->setStackingOrderChanged(true); | 993 replicaMaskLayer->setStackingOrderChanged(true); |
994 emulateDrawingOneFrame(root.get()); | 994 emulateDrawingOneFrame(root.get()); |
995 | 995 |
996 FloatRect grandChildDamageRect = grandChild1->renderSurface()->damageTracker
()->currentDamageRect(); | 996 FloatRect grandChildDamageRect = grandChild1->renderSurface()->damageTracker
()->currentDamageRect(); |
997 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); | 997 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); |
998 | 998 |
999 EXPECT_TRUE(grandChildDamageRect.isEmpty()); | 999 EXPECT_TRUE(grandChildDamageRect.isEmpty()); |
1000 EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); | 1000 EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); |
1001 | 1001 |
1002 // CASE 2: removing the replica mask damages only the reflected region on th
e target surface. | 1002 // CASE 2: removing the replica mask damages only the reflected region on th
e target surface. |
1003 // | 1003 // |
1004 clearDamageForAllSurfaces(root.get()); | 1004 clearDamageForAllSurfaces(root.get()); |
1005 grandChild1Replica->setMaskLayer(nullptr); | 1005 grandChild1Replica->setMaskLayer(scoped_ptr<CCLayerImpl>()); |
1006 emulateDrawingOneFrame(root.get()); | 1006 emulateDrawingOneFrame(root.get()); |
1007 | 1007 |
1008 grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->curren
tDamageRect(); | 1008 grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->curren
tDamageRect(); |
1009 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 1009 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
1010 | 1010 |
1011 EXPECT_TRUE(grandChildDamageRect.isEmpty()); | 1011 EXPECT_TRUE(grandChildDamageRect.isEmpty()); |
1012 EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); | 1012 EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); |
1013 } | 1013 } |
1014 | 1014 |
1015 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) | 1015 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) |
1016 { | 1016 { |
1017 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 1017 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
1018 CCLayerImpl* child1 = root->children()[0]; | 1018 CCLayerImpl* child1 = root->children()[0]; |
1019 CCLayerImpl* grandChild1 = child1->children()[0]; | 1019 CCLayerImpl* grandChild1 = child1->children()[0]; |
1020 | 1020 |
1021 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; | 1021 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; |
1022 clearDamageForAllSurfaces(root.get()); | 1022 clearDamageForAllSurfaces(root.get()); |
1023 | 1023 |
1024 grandChild1->setAnchorPoint(FloatPoint(1, 0)); // This is not exactly the an
chor being tested, but by convention its expected to be the same as the replica'
s anchor point. | 1024 grandChild1->setAnchorPoint(FloatPoint(1, 0)); // This is not exactly the an
chor being tested, but by convention its expected to be the same as the replica'
s anchor point. |
1025 | 1025 |
1026 { | 1026 { |
1027 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); | 1027 scoped_ptr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); |
1028 grandChild1Replica->setPosition(FloatPoint::zero()); | 1028 grandChild1Replica->setPosition(FloatPoint::zero()); |
1029 grandChild1Replica->setAnchorPoint(FloatPoint(1, 0)); // This is the anc
hor being tested. | 1029 grandChild1Replica->setAnchorPoint(FloatPoint(1, 0)); // This is the anc
hor being tested. |
1030 WebTransformationMatrix reflection; | 1030 WebTransformationMatrix reflection; |
1031 reflection.scale3d(-1, 1, 1); | 1031 reflection.scale3d(-1, 1, 1); |
1032 grandChild1Replica->setTransform(reflection); | 1032 grandChild1Replica->setTransform(reflection); |
1033 grandChild1->setReplicaLayer(grandChild1Replica.release()); | 1033 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); |
1034 } | 1034 } |
1035 CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer(); | 1035 CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer(); |
1036 | 1036 |
1037 // Set up the mask layer on the replica layer | 1037 // Set up the mask layer on the replica layer |
1038 { | 1038 { |
1039 OwnPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7); | 1039 scoped_ptr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7); |
1040 replicaMaskLayer->setPosition(FloatPoint::zero()); | 1040 replicaMaskLayer->setPosition(FloatPoint::zero()); |
1041 replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); // note, this is n
ot the anchor being tested. | 1041 replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); // note, this is n
ot the anchor being tested. |
1042 replicaMaskLayer->setBounds(grandChild1->bounds()); | 1042 replicaMaskLayer->setBounds(grandChild1->bounds()); |
1043 replicaMaskLayer->setContentBounds(grandChild1->bounds()); | 1043 replicaMaskLayer->setContentBounds(grandChild1->bounds()); |
1044 grandChild1Replica->setMaskLayer(replicaMaskLayer.release()); | 1044 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); |
1045 } | 1045 } |
1046 CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); | 1046 CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); |
1047 | 1047 |
1048 emulateDrawingOneFrame(root.get()); | 1048 emulateDrawingOneFrame(root.get()); |
1049 | 1049 |
1050 // Sanity check that the appropriate render surfaces were created | 1050 // Sanity check that the appropriate render surfaces were created |
1051 ASSERT_TRUE(grandChild1->renderSurface()); | 1051 ASSERT_TRUE(grandChild1->renderSurface()); |
1052 | 1052 |
1053 // A property change on the replicaMask should damage the reflected region o
n the target surface. | 1053 // A property change on the replicaMask should damage the reflected region o
n the target surface. |
1054 clearDamageForAllSurfaces(root.get()); | 1054 clearDamageForAllSurfaces(root.get()); |
1055 replicaMaskLayer->setStackingOrderChanged(true); | 1055 replicaMaskLayer->setStackingOrderChanged(true); |
1056 | 1056 |
1057 emulateDrawingOneFrame(root.get()); | 1057 emulateDrawingOneFrame(root.get()); |
1058 | 1058 |
1059 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); | 1059 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); |
1060 EXPECT_FLOAT_RECT_EQ(FloatRect(206, 200, 6, 8), childDamageRect); | 1060 EXPECT_FLOAT_RECT_EQ(FloatRect(206, 200, 6, 8), childDamageRect); |
1061 } | 1061 } |
1062 | 1062 |
1063 TEST_F(CCDamageTrackerTest, verifyDamageWhenForcedFullDamage) | 1063 TEST_F(CCDamageTrackerTest, verifyDamageWhenForcedFullDamage) |
1064 { | 1064 { |
1065 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 1065 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
1066 CCLayerImpl* child = root->children()[0]; | 1066 CCLayerImpl* child = root->children()[0]; |
1067 | 1067 |
1068 // Case 1: This test ensures that when the tracker is forced to have full da
mage, that | 1068 // Case 1: This test ensures that when the tracker is forced to have full da
mage, that |
1069 // it takes priority over any other partial damage. | 1069 // it takes priority over any other partial damage. |
1070 // | 1070 // |
1071 clearDamageForAllSurfaces(root.get()); | 1071 clearDamageForAllSurfaces(root.get()); |
1072 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 1072 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
1073 root->renderSurface()->damageTracker()->forceFullDamageNextUpdate(); | 1073 root->renderSurface()->damageTracker()->forceFullDamageNextUpdate(); |
1074 emulateDrawingOneFrame(root.get()); | 1074 emulateDrawingOneFrame(root.get()); |
1075 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 1075 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
1076 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 1076 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
1077 | 1077 |
1078 // Case 2: An additional sanity check that forcing full damage works even wh
en nothing | 1078 // Case 2: An additional sanity check that forcing full damage works even wh
en nothing |
1079 // on the layer tree changed. | 1079 // on the layer tree changed. |
1080 // | 1080 // |
1081 clearDamageForAllSurfaces(root.get()); | 1081 clearDamageForAllSurfaces(root.get()); |
1082 root->renderSurface()->damageTracker()->forceFullDamageNextUpdate(); | 1082 root->renderSurface()->damageTracker()->forceFullDamageNextUpdate(); |
1083 emulateDrawingOneFrame(root.get()); | 1083 emulateDrawingOneFrame(root.get()); |
1084 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1084 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1085 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 1085 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
1086 } | 1086 } |
1087 | 1087 |
1088 TEST_F(CCDamageTrackerTest, verifyDamageForEmptyLayerList) | 1088 TEST_F(CCDamageTrackerTest, verifyDamageForEmptyLayerList) |
1089 { | 1089 { |
1090 // Though it should never happen, its a good idea to verify that the damage
tracker | 1090 // Though it should never happen, its a good idea to verify that the damage
tracker |
1091 // does not crash when it receives an empty layerList. | 1091 // does not crash when it receives an empty layerList. |
1092 | 1092 |
1093 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); | 1093 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1094 root->createRenderSurface(); | 1094 root->createRenderSurface(); |
1095 | 1095 |
1096 ASSERT_TRUE(root == root->renderTarget()); | 1096 ASSERT_TRUE(root == root->renderTarget()); |
1097 CCRenderSurface* targetSurface = root->renderSurface(); | 1097 CCRenderSurface* targetSurface = root->renderSurface(); |
1098 targetSurface->clearLayerLists(); | 1098 targetSurface->clearLayerLists(); |
1099 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay
erList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperatio
ns()); | 1099 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay
erList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperatio
ns()); |
1100 | 1100 |
1101 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); | 1101 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); |
1102 EXPECT_TRUE(damageRect.isEmpty()); | 1102 EXPECT_TRUE(damageRect.isEmpty()); |
1103 } | 1103 } |
1104 | 1104 |
1105 TEST_F(CCDamageTrackerTest, verifyDamageAccumulatesUntilReset) | 1105 TEST_F(CCDamageTrackerTest, verifyDamageAccumulatesUntilReset) |
1106 { | 1106 { |
1107 // If damage is not cleared, it should accumulate. | 1107 // If damage is not cleared, it should accumulate. |
1108 | 1108 |
1109 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 1109 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
1110 CCLayerImpl* child = root->children()[0]; | 1110 CCLayerImpl* child = root->children()[0]; |
1111 | 1111 |
1112 clearDamageForAllSurfaces(root.get()); | 1112 clearDamageForAllSurfaces(root.get()); |
1113 child->setUpdateRect(FloatRect(10, 11, 1, 2)); | 1113 child->setUpdateRect(FloatRect(10, 11, 1, 2)); |
1114 emulateDrawingOneFrame(root.get()); | 1114 emulateDrawingOneFrame(root.get()); |
1115 | 1115 |
1116 // Sanity check damage after the first frame; this isnt the actual test yet. | 1116 // Sanity check damage after the first frame; this isnt the actual test yet. |
1117 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 1117 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
1118 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 1, 2), rootDamageRect); | 1118 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 1, 2), rootDamageRect); |
1119 | 1119 |
1120 // New damage, without having cleared the previous damage, should be unioned
to the previous one. | 1120 // New damage, without having cleared the previous damage, should be unioned
to the previous one. |
1121 child->setUpdateRect(FloatRect(20, 25, 1, 2)); | 1121 child->setUpdateRect(FloatRect(20, 25, 1, 2)); |
1122 emulateDrawingOneFrame(root.get()); | 1122 emulateDrawingOneFrame(root.get()); |
1123 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1123 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1124 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 11, 16), rootDamageRect); | 1124 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 11, 16), rootDamageRect); |
1125 | 1125 |
1126 // If we notify the damage tracker that we drew the damaged area, then damag
e should be emptied. | 1126 // If we notify the damage tracker that we drew the damaged area, then damag
e should be emptied. |
1127 root->renderSurface()->damageTracker()->didDrawDamagedArea(); | 1127 root->renderSurface()->damageTracker()->didDrawDamagedArea(); |
1128 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1128 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1129 EXPECT_TRUE(rootDamageRect.isEmpty()); | 1129 EXPECT_TRUE(rootDamageRect.isEmpty()); |
1130 | 1130 |
1131 // Damage should remain empty even after one frame, since there's yet no new
damage | 1131 // Damage should remain empty even after one frame, since there's yet no new
damage |
1132 emulateDrawingOneFrame(root.get()); | 1132 emulateDrawingOneFrame(root.get()); |
1133 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1133 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1134 EXPECT_TRUE(rootDamageRect.isEmpty()); | 1134 EXPECT_TRUE(rootDamageRect.isEmpty()); |
1135 } | 1135 } |
1136 | 1136 |
1137 } // namespace | 1137 } // namespace |
OLD | NEW |