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 27 matching lines...) Expand all Loading... |
38 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); | 38 CCLayerTreeHostCommon::calculateVisibleRects(renderSurfaceLayerList); |
39 } | 39 } |
40 | 40 |
41 void clearDamageForAllSurfaces(CCLayerImpl* layer) | 41 void clearDamageForAllSurfaces(CCLayerImpl* layer) |
42 { | 42 { |
43 if (layer->renderSurface()) | 43 if (layer->renderSurface()) |
44 layer->renderSurface()->damageTracker()->didDrawDamagedArea(); | 44 layer->renderSurface()->damageTracker()->didDrawDamagedArea(); |
45 | 45 |
46 // Recursively clear damage for any existing surface. | 46 // Recursively clear damage for any existing surface. |
47 for (size_t i = 0; i < layer->children().size(); ++i) | 47 for (size_t i = 0; i < layer->children().size(); ++i) |
48 clearDamageForAllSurfaces(layer->children()[i].get()); | 48 clearDamageForAllSurfaces(layer->children()[i]); |
49 } | 49 } |
50 | 50 |
51 void emulateDrawingOneFrame(CCLayerImpl* root) | 51 void emulateDrawingOneFrame(CCLayerImpl* root) |
52 { | 52 { |
53 // This emulates only the steps that are relevant to testing the damage trac
ker: | 53 // This emulates only the steps that are relevant to testing the damage trac
ker: |
54 // 1. computing the render passes and layerlists | 54 // 1. computing the render passes and layerlists |
55 // 2. updating all damage trackers in the correct order | 55 // 2. updating all damage trackers in the correct order |
56 // 3. resetting all updateRects and propertyChanged flags for all layers a
nd surfaces. | 56 // 3. resetting all updateRects and propertyChanged flags for all layers a
nd surfaces. |
57 | 57 |
58 Vector<CCLayerImpl*> renderSurfaceLayerList; | 58 Vector<CCLayerImpl*> renderSurfaceLayerList; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 186 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
187 } | 187 } |
188 | 188 |
189 TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) | 189 TEST_F(CCDamageTrackerTest, sanityCheckTestTreeWithTwoSurfaces) |
190 { | 190 { |
191 // Sanity check that the complex test tree will actually produce the expecte
d render | 191 // Sanity check that the complex test tree will actually produce the expecte
d render |
192 // surfaces and layer lists. | 192 // surfaces and layer lists. |
193 | 193 |
194 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 194 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
195 | 195 |
196 CCLayerImpl* child1 = root->children()[0].get(); | 196 CCLayerImpl* child1 = root->children()[0]; |
197 CCLayerImpl* child2 = root->children()[1].get(); | 197 CCLayerImpl* child2 = root->children()[1]; |
198 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); | 198 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); |
199 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 199 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
200 | 200 |
201 ASSERT_TRUE(child1->renderSurface()); | 201 ASSERT_TRUE(child1->renderSurface()); |
202 EXPECT_FALSE(child2->renderSurface()); | 202 EXPECT_FALSE(child2->renderSurface()); |
203 EXPECT_EQ(3u, root->renderSurface()->layerList().size()); | 203 EXPECT_EQ(3u, root->renderSurface()->layerList().size()); |
204 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); | 204 EXPECT_EQ(2u, child1->renderSurface()->layerList().size()); |
205 | 205 |
206 // The render surface for child1 only has a contentRect that encloses grandC
hild1 and grandChild2, because child1 does not draw content. | 206 // The render surface for child1 only has a contentRect that encloses grandC
hild1 and grandChild2, because child1 does not draw content. |
207 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); | 207 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); |
208 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 208 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
209 } | 209 } |
210 | 210 |
211 TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects) | 211 TEST_F(CCDamageTrackerTest, verifyDamageForUpdateRects) |
212 { | 212 { |
213 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 213 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
214 CCLayerImpl* child = root->children()[0].get(); | 214 CCLayerImpl* child = root->children()[0]; |
215 | 215 |
216 // CASE 1: Setting the update rect should cause the corresponding damage to
the surface. | 216 // CASE 1: Setting the update rect should cause the corresponding damage to
the surface. |
217 // | 217 // |
218 clearDamageForAllSurfaces(root.get()); | 218 clearDamageForAllSurfaces(root.get()); |
219 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 219 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
220 emulateDrawingOneFrame(root.get()); | 220 emulateDrawingOneFrame(root.get()); |
221 | 221 |
222 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100). | 222 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100). |
223 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 223 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
224 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 12, 13), rootDamageRect); | 224 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 12, 13), rootDamageRect); |
(...skipping 13 matching lines...) Expand all Loading... |
238 emulateDrawingOneFrame(root.get()); | 238 emulateDrawingOneFrame(root.get()); |
239 | 239 |
240 // Damage position on the surface should be: position of updateRect (20, 25)
relative to the child (100, 100). | 240 // Damage position on the surface should be: position of updateRect (20, 25)
relative to the child (100, 100). |
241 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 241 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
242 EXPECT_FLOAT_RECT_EQ(FloatRect(120, 125, 1, 2), rootDamageRect); | 242 EXPECT_FLOAT_RECT_EQ(FloatRect(120, 125, 1, 2), rootDamageRect); |
243 } | 243 } |
244 | 244 |
245 TEST_F(CCDamageTrackerTest, verifyDamageForPropertyChanges) | 245 TEST_F(CCDamageTrackerTest, verifyDamageForPropertyChanges) |
246 { | 246 { |
247 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 247 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
248 CCLayerImpl* child = root->children()[0].get(); | 248 CCLayerImpl* child = root->children()[0]; |
249 | 249 |
250 // CASE 1: The layer's property changed flag takes priority over update rect
. | 250 // CASE 1: The layer's property changed flag takes priority over update rect
. |
251 // | 251 // |
252 clearDamageForAllSurfaces(root.get()); | 252 clearDamageForAllSurfaces(root.get()); |
253 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 253 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
254 child->setOpacity(0.5); | 254 child->setOpacity(0.5); |
255 emulateDrawingOneFrame(root.get()); | 255 emulateDrawingOneFrame(root.get()); |
256 | 256 |
257 // Sanity check - we should not have accidentally created a separate render
surface for the translucent layer. | 257 // Sanity check - we should not have accidentally created a separate render
surface for the translucent layer. |
258 ASSERT_FALSE(child->renderSurface()); | 258 ASSERT_FALSE(child->renderSurface()); |
(...skipping 23 matching lines...) Expand all Loading... |
282 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 282 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
283 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); | 283 EXPECT_FLOAT_RECT_EQ(expectedRect, rootDamageRect); |
284 } | 284 } |
285 | 285 |
286 TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) | 286 TEST_F(CCDamageTrackerTest, verifyDamageForTransformedLayer) |
287 { | 287 { |
288 // If a layer is transformed, the damage rect should still enclose the entir
e | 288 // If a layer is transformed, the damage rect should still enclose the entir
e |
289 // transformed layer. | 289 // transformed layer. |
290 | 290 |
291 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 291 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
292 CCLayerImpl* child = root->children()[0].get(); | 292 CCLayerImpl* child = root->children()[0]; |
293 | 293 |
294 WebTransformationMatrix rotation; | 294 WebTransformationMatrix rotation; |
295 rotation.rotate(45); | 295 rotation.rotate(45); |
296 | 296 |
297 clearDamageForAllSurfaces(root.get()); | 297 clearDamageForAllSurfaces(root.get()); |
298 child->setAnchorPoint(FloatPoint(0.5, 0.5)); | 298 child->setAnchorPoint(FloatPoint(0.5, 0.5)); |
299 child->setPosition(FloatPoint(85, 85)); | 299 child->setPosition(FloatPoint(85, 85)); |
300 emulateDrawingOneFrame(root.get()); | 300 emulateDrawingOneFrame(root.get()); |
301 | 301 |
302 // Sanity check that the layer actually moved to (85, 85), damaging its old
location and new location. | 302 // Sanity check that the layer actually moved to (85, 85), damaging its old
location and new location. |
(...skipping 22 matching lines...) Expand all Loading... |
325 // layer can cause an invalid damage rect. This test checks that the w < 0 c
ase is | 325 // layer can cause an invalid damage rect. This test checks that the w < 0 c
ase is |
326 // tracked properly. | 326 // tracked properly. |
327 // | 327 // |
328 // The transform is constructed so that if w < 0 clipping is not performed,
the | 328 // The transform is constructed so that if w < 0 clipping is not performed,
the |
329 // incorrect rect will be very small, specifically: position (500.972504, 49
8.544617) and size 0.056610 x 2.910767. | 329 // incorrect rect will be very small, specifically: position (500.972504, 49
8.544617) and size 0.056610 x 2.910767. |
330 // Instead, the correctly transformed rect should actually be very huge (i.e
. in theory, -infinity on the left), | 330 // Instead, the correctly transformed rect should actually be very huge (i.e
. in theory, -infinity on the left), |
331 // and positioned so that the right-most bound rect will be approximately 50
1 units in root surface space. | 331 // and positioned so that the right-most bound rect will be approximately 50
1 units in root surface space. |
332 // | 332 // |
333 | 333 |
334 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 334 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
335 CCLayerImpl* child = root->children()[0].get(); | 335 CCLayerImpl* child = root->children()[0]; |
336 | 336 |
337 WebTransformationMatrix transform; | 337 WebTransformationMatrix transform; |
338 transform.translate3d(500, 500, 0); | 338 transform.translate3d(500, 500, 0); |
339 transform.applyPerspective(1); | 339 transform.applyPerspective(1); |
340 transform.rotate3d(0, 45, 0); | 340 transform.rotate3d(0, 45, 0); |
341 transform.translate3d(-50, -50, 0); | 341 transform.translate3d(-50, -50, 0); |
342 | 342 |
343 // Set up the child | 343 // Set up the child |
344 child->setPosition(FloatPoint(0, 0)); | 344 child->setPosition(FloatPoint(0, 0)); |
345 child->setBounds(IntSize(100, 100)); | 345 child->setBounds(IntSize(100, 100)); |
(...skipping 16 matching lines...) Expand all Loading... |
362 // The expected damage should cover the entire root surface (500x500), but w
e don't | 362 // The expected damage should cover the entire root surface (500x500), but w
e don't |
363 // care whether the damage rect was clamped or is larger than the surface fo
r this test. | 363 // care whether the damage rect was clamped or is larger than the surface fo
r this test. |
364 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 364 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
365 FloatRect damageWeCareAbout = FloatRect(FloatPoint::zero(), FloatSize(500, 5
00)); | 365 FloatRect damageWeCareAbout = FloatRect(FloatPoint::zero(), FloatSize(500, 5
00)); |
366 EXPECT_TRUE(rootDamageRect.contains(damageWeCareAbout)); | 366 EXPECT_TRUE(rootDamageRect.contains(damageWeCareAbout)); |
367 } | 367 } |
368 | 368 |
369 TEST_F(CCDamageTrackerTest, verifyDamageForBlurredSurface) | 369 TEST_F(CCDamageTrackerTest, verifyDamageForBlurredSurface) |
370 { | 370 { |
371 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 371 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
372 CCLayerImpl* child = root->children()[0].get(); | 372 CCLayerImpl* child = root->children()[0]; |
373 | 373 |
374 WebFilterOperations filters; | 374 WebFilterOperations filters; |
375 filters.append(WebFilterOperation::createBlurFilter(5)); | 375 filters.append(WebFilterOperation::createBlurFilter(5)); |
376 int outsetTop, outsetRight, outsetBottom, outsetLeft; | 376 int outsetTop, outsetRight, outsetBottom, outsetLeft; |
377 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); | 377 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
378 | 378 |
379 // Setting the filter will damage the whole surface. | 379 // Setting the filter will damage the whole surface. |
380 clearDamageForAllSurfaces(root.get()); | 380 clearDamageForAllSurfaces(root.get()); |
381 root->setFilters(filters); | 381 root->setFilters(filters); |
382 emulateDrawingOneFrame(root.get()); | 382 emulateDrawingOneFrame(root.get()); |
383 | 383 |
384 // Setting the update rect should cause the corresponding damage to the surf
ace, blurred based on the size of the blur filter. | 384 // Setting the update rect should cause the corresponding damage to the surf
ace, blurred based on the size of the blur filter. |
385 clearDamageForAllSurfaces(root.get()); | 385 clearDamageForAllSurfaces(root.get()); |
386 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 386 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
387 emulateDrawingOneFrame(root.get()); | 387 emulateDrawingOneFrame(root.get()); |
388 | 388 |
389 // 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 // Damage position on the surface should be: position of updateRect (10, 11)
relative to the child (100, 100), but expanded by the blur outsets. |
390 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 390 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
391 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); | 391 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); |
392 expectedDamageRect.move(-outsetLeft, -outsetTop); | 392 expectedDamageRect.move(-outsetLeft, -outsetTop); |
393 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); | 393 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); |
394 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); | 394 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); |
395 } | 395 } |
396 | 396 |
397 TEST_F(CCDamageTrackerTest, verifyDamageForBackgroundBlurredChild) | 397 TEST_F(CCDamageTrackerTest, verifyDamageForBackgroundBlurredChild) |
398 { | 398 { |
399 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 399 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
400 CCLayerImpl* child1 = root->children()[0].get(); | 400 CCLayerImpl* child1 = root->children()[0]; |
401 CCLayerImpl* child2 = root->children()[1].get(); | 401 CCLayerImpl* child2 = root->children()[1]; |
402 | 402 |
403 // Allow us to set damage on child1 too. | 403 // Allow us to set damage on child1 too. |
404 child1->setDrawsContent(true); | 404 child1->setDrawsContent(true); |
405 | 405 |
406 WebFilterOperations filters; | 406 WebFilterOperations filters; |
407 filters.append(WebFilterOperation::createBlurFilter(2)); | 407 filters.append(WebFilterOperation::createBlurFilter(2)); |
408 int outsetTop, outsetRight, outsetBottom, outsetLeft; | 408 int outsetTop, outsetRight, outsetBottom, outsetLeft; |
409 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); | 409 filters.getOutsets(outsetTop, outsetRight, outsetBottom, outsetLeft); |
410 | 410 |
411 // Setting the filter will damage the whole surface. | 411 // Setting the filter will damage the whole surface. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // Damage on child1 should be: position of updateRect offset by the child's
position (100, 100), and expanded by the damage. | 493 // Damage on child1 should be: position of updateRect offset by the child's
position (100, 100), and expanded by the damage. |
494 expectedDamageRect = FloatRect(100, 100, 1, 1); | 494 expectedDamageRect = FloatRect(100, 100, 1, 1); |
495 expectedDamageRect.move(-outsetLeft, -outsetTop); | 495 expectedDamageRect.move(-outsetLeft, -outsetTop); |
496 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); | 496 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom
); |
497 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); | 497 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); |
498 } | 498 } |
499 | 499 |
500 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer) | 500 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer) |
501 { | 501 { |
502 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 502 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
503 CCLayerImpl* child1 = root->children()[0].get(); | 503 CCLayerImpl* child1 = root->children()[0]; |
504 | 504 |
505 // CASE 1: Adding a new layer should cause the appropriate damage. | 505 // CASE 1: Adding a new layer should cause the appropriate damage. |
506 // | 506 // |
507 clearDamageForAllSurfaces(root.get()); | 507 clearDamageForAllSurfaces(root.get()); |
508 { | 508 { |
509 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 509 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
510 child2->setPosition(FloatPoint(400, 380)); | 510 child2->setPosition(FloatPoint(400, 380)); |
511 child2->setAnchorPoint(FloatPoint::zero()); | 511 child2->setAnchorPoint(FloatPoint::zero()); |
512 child2->setBounds(IntSize(6, 8)); | 512 child2->setBounds(IntSize(6, 8)); |
513 child2->setContentBounds(IntSize(6, 8)); | 513 child2->setContentBounds(IntSize(6, 8)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. | 564 // Sanity check - all 3 layers should be on the same render surface; render
surfaces are tested elsewhere. |
565 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); | 565 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); |
566 | 566 |
567 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 567 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
568 EXPECT_FLOAT_RECT_EQ(FloatRect(400, 380, 6, 8), rootDamageRect); | 568 EXPECT_FLOAT_RECT_EQ(FloatRect(400, 380, 6, 8), rootDamageRect); |
569 } | 569 } |
570 | 570 |
571 TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers) | 571 TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers) |
572 { | 572 { |
573 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 573 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
574 CCLayerImpl* child1 = root->children()[0].get(); | 574 CCLayerImpl* child1 = root->children()[0]; |
575 | 575 |
576 // In this test we don't want the above tree manipulation to be considered p
art of the same frame. | 576 // In this test we don't want the above tree manipulation to be considered p
art of the same frame. |
577 clearDamageForAllSurfaces(root.get()); | 577 clearDamageForAllSurfaces(root.get()); |
578 { | 578 { |
579 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); | 579 OwnPtr<CCLayerImpl> child2 = CCLayerImpl::create(3); |
580 child2->setPosition(FloatPoint(400, 380)); | 580 child2->setPosition(FloatPoint(400, 380)); |
581 child2->setAnchorPoint(FloatPoint::zero()); | 581 child2->setAnchorPoint(FloatPoint::zero()); |
582 child2->setBounds(IntSize(6, 8)); | 582 child2->setBounds(IntSize(6, 8)); |
583 child2->setContentBounds(IntSize(6, 8)); | 583 child2->setContentBounds(IntSize(6, 8)); |
584 child2->setDrawsContent(true); | 584 child2->setDrawsContent(true); |
585 root->addChild(child2.release()); | 585 root->addChild(child2.release()); |
586 } | 586 } |
587 CCLayerImpl* child2 = root->children()[1].get(); | 587 CCLayerImpl* child2 = root->children()[1]; |
588 emulateDrawingOneFrame(root.get()); | 588 emulateDrawingOneFrame(root.get()); |
589 | 589 |
590 // Damaging two layers simultaneously should cause combined damage. | 590 // Damaging two layers simultaneously should cause combined damage. |
591 // - child1 update rect in surface space: FloatRect(100, 100, 1, 2); | 591 // - child1 update rect in surface space: FloatRect(100, 100, 1, 2); |
592 // - child2 update rect in surface space: FloatRect(400, 380, 3, 4); | 592 // - child2 update rect in surface space: FloatRect(400, 380, 3, 4); |
593 clearDamageForAllSurfaces(root.get()); | 593 clearDamageForAllSurfaces(root.get()); |
594 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); | 594 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); |
595 child2->setUpdateRect(FloatRect(0, 0, 3, 4)); | 595 child2->setUpdateRect(FloatRect(0, 0, 3, 4)); |
596 emulateDrawingOneFrame(root.get()); | 596 emulateDrawingOneFrame(root.get()); |
597 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 597 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
598 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 303, 284), rootDamageRect); | 598 EXPECT_FLOAT_RECT_EQ(FloatRect(100, 100, 303, 284), rootDamageRect); |
599 } | 599 } |
600 | 600 |
601 TEST_F(CCDamageTrackerTest, verifyDamageForNestedSurfaces) | 601 TEST_F(CCDamageTrackerTest, verifyDamageForNestedSurfaces) |
602 { | 602 { |
603 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 603 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
604 CCLayerImpl* child1 = root->children()[0].get(); | 604 CCLayerImpl* child1 = root->children()[0]; |
605 CCLayerImpl* child2 = root->children()[1].get(); | 605 CCLayerImpl* child2 = root->children()[1]; |
606 CCLayerImpl* grandChild1 = root->children()[0]->children()[0].get(); | 606 CCLayerImpl* grandChild1 = root->children()[0]->children()[0]; |
607 FloatRect childDamageRect; | 607 FloatRect childDamageRect; |
608 FloatRect rootDamageRect; | 608 FloatRect rootDamageRect; |
609 | 609 |
610 // CASE 1: Damage to a descendant surface should propagate properly to ances
tor surface. | 610 // CASE 1: Damage to a descendant surface should propagate properly to ances
tor surface. |
611 // | 611 // |
612 clearDamageForAllSurfaces(root.get()); | 612 clearDamageForAllSurfaces(root.get()); |
613 grandChild1->setOpacity(0.5); | 613 grandChild1->setOpacity(0.5); |
614 emulateDrawingOneFrame(root.get()); | 614 emulateDrawingOneFrame(root.get()); |
615 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 615 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
616 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 616 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
(...skipping 16 matching lines...) Expand all Loading... |
633 TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer) | 633 TEST_F(CCDamageTrackerTest, verifyDamageForSurfaceChangeFromDescendantLayer) |
634 { | 634 { |
635 // If descendant layer changes and affects the content bounds of the render
surface, | 635 // If descendant layer changes and affects the content bounds of the render
surface, |
636 // then the entire descendant surface should be damaged, and it should damag
e its | 636 // then the entire descendant surface should be damaged, and it should damag
e its |
637 // ancestor surface with the old and new surface regions. | 637 // ancestor surface with the old and new surface regions. |
638 | 638 |
639 // This is a tricky case, since only the first grandChild changes, but the e
ntire | 639 // This is a tricky case, since only the first grandChild changes, but the e
ntire |
640 // surface should be marked dirty. | 640 // surface should be marked dirty. |
641 | 641 |
642 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 642 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
643 CCLayerImpl* child1 = root->children()[0].get(); | 643 CCLayerImpl* child1 = root->children()[0]; |
644 CCLayerImpl* grandChild1 = root->children()[0]->children()[0].get(); | 644 CCLayerImpl* grandChild1 = root->children()[0]->children()[0]; |
645 FloatRect childDamageRect; | 645 FloatRect childDamageRect; |
646 FloatRect rootDamageRect; | 646 FloatRect rootDamageRect; |
647 | 647 |
648 clearDamageForAllSurfaces(root.get()); | 648 clearDamageForAllSurfaces(root.get()); |
649 grandChild1->setPosition(FloatPoint(195, 205)); | 649 grandChild1->setPosition(FloatPoint(195, 205)); |
650 emulateDrawingOneFrame(root.get()); | 650 emulateDrawingOneFrame(root.get()); |
651 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 651 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
652 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 652 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
653 | 653 |
654 // The new surface bounds should be damaged entirely, even though only one o
f the layers changed. | 654 // The new surface bounds should be damaged entirely, even though only one o
f the layers changed. |
(...skipping 11 matching lines...) Expand all Loading... |
666 // to the subtree (tested in CCLayerImpltest), which damages the entire chil
d1 | 666 // to the subtree (tested in CCLayerImpltest), which damages the entire chil
d1 |
667 // surface, but the damage tracker still needs the correct logic to compute
the | 667 // surface, but the damage tracker still needs the correct logic to compute
the |
668 // exposed region on the root surface. | 668 // exposed region on the root surface. |
669 | 669 |
670 // FIXME: the expectations of this test case should change when we add suppo
rt for a | 670 // FIXME: the expectations of this test case should change when we add suppo
rt for a |
671 // unique scissorRect per renderSurface. In that case, the child1 sur
face | 671 // unique scissorRect per renderSurface. In that case, the child1 sur
face |
672 // should be completely unchanged, since we are only transforming it,
while the | 672 // should be completely unchanged, since we are only transforming it,
while the |
673 // root surface would be damaged appropriately. | 673 // root surface would be damaged appropriately. |
674 | 674 |
675 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 675 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
676 CCLayerImpl* child1 = root->children()[0].get(); | 676 CCLayerImpl* child1 = root->children()[0]; |
677 FloatRect childDamageRect; | 677 FloatRect childDamageRect; |
678 FloatRect rootDamageRect; | 678 FloatRect rootDamageRect; |
679 | 679 |
680 clearDamageForAllSurfaces(root.get()); | 680 clearDamageForAllSurfaces(root.get()); |
681 child1->setPosition(FloatPoint(50, 50)); | 681 child1->setPosition(FloatPoint(50, 50)); |
682 emulateDrawingOneFrame(root.get()); | 682 emulateDrawingOneFrame(root.get()); |
683 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 683 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
684 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 684 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
685 | 685 |
686 // The new surface bounds should be damaged entirely. | 686 // The new surface bounds should be damaged entirely. |
687 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); | 687 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); |
688 | 688 |
689 // The entire child1 surface and the old exposed child1 surface should damag
e the root surface. | 689 // The entire child1 surface and the old exposed child1 surface should damag
e the root surface. |
690 // - old child1 surface in target space: FloatRect(290, 290, 16, 18) | 690 // - old child1 surface in target space: FloatRect(290, 290, 16, 18) |
691 // - new child1 surface in target space: FloatRect(240, 240, 16, 18) | 691 // - new child1 surface in target space: FloatRect(240, 240, 16, 18) |
692 EXPECT_FLOAT_RECT_EQ(FloatRect(240, 240, 66, 68), rootDamageRect); | 692 EXPECT_FLOAT_RECT_EQ(FloatRect(240, 240, 66, 68), rootDamageRect); |
693 } | 693 } |
694 | 694 |
695 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) | 695 TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingRenderSurfaces) |
696 { | 696 { |
697 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 697 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
698 CCLayerImpl* child1 = root->children()[0].get(); | 698 CCLayerImpl* child1 = root->children()[0]; |
699 FloatRect childDamageRect; | 699 FloatRect childDamageRect; |
700 FloatRect rootDamageRect; | 700 FloatRect rootDamageRect; |
701 | 701 |
702 // CASE 1: If a descendant surface disappears, its entire old area becomes e
xposed. | 702 // CASE 1: If a descendant surface disappears, its entire old area becomes e
xposed. |
703 // | 703 // |
704 clearDamageForAllSurfaces(root.get()); | 704 clearDamageForAllSurfaces(root.get()); |
705 child1->setOpacity(1); | 705 child1->setOpacity(1); |
706 emulateDrawingOneFrame(root.get()); | 706 emulateDrawingOneFrame(root.get()); |
707 | 707 |
708 // Sanity check that there is only one surface now. | 708 // Sanity check that there is only one surface now. |
(...skipping 23 matching lines...) Expand all Loading... |
732 | 732 |
733 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 733 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
734 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 734 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
735 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); | 735 EXPECT_FLOAT_RECT_EQ(FloatRect(190, 190, 16, 18), childDamageRect); |
736 EXPECT_FLOAT_RECT_EQ(FloatRect(290, 290, 16, 18), rootDamageRect); | 736 EXPECT_FLOAT_RECT_EQ(FloatRect(290, 290, 16, 18), rootDamageRect); |
737 } | 737 } |
738 | 738 |
739 TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged) | 739 TEST_F(CCDamageTrackerTest, verifyNoDamageWhenNothingChanged) |
740 { | 740 { |
741 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 741 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
742 CCLayerImpl* child1 = root->children()[0].get(); | 742 CCLayerImpl* child1 = root->children()[0]; |
743 FloatRect childDamageRect; | 743 FloatRect childDamageRect; |
744 FloatRect rootDamageRect; | 744 FloatRect rootDamageRect; |
745 | 745 |
746 // CASE 1: If nothing changes, the damage rect should be empty. | 746 // CASE 1: If nothing changes, the damage rect should be empty. |
747 // | 747 // |
748 clearDamageForAllSurfaces(root.get()); | 748 clearDamageForAllSurfaces(root.get()); |
749 emulateDrawingOneFrame(root.get()); | 749 emulateDrawingOneFrame(root.get()); |
750 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 750 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
751 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 751 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
752 EXPECT_TRUE(childDamageRect.isEmpty()); | 752 EXPECT_TRUE(childDamageRect.isEmpty()); |
753 EXPECT_TRUE(rootDamageRect.isEmpty()); | 753 EXPECT_TRUE(rootDamageRect.isEmpty()); |
754 | 754 |
755 // CASE 2: If nothing changes twice in a row, the damage rect should still b
e empty. | 755 // CASE 2: If nothing changes twice in a row, the damage rect should still b
e empty. |
756 // | 756 // |
757 clearDamageForAllSurfaces(root.get()); | 757 clearDamageForAllSurfaces(root.get()); |
758 emulateDrawingOneFrame(root.get()); | 758 emulateDrawingOneFrame(root.get()); |
759 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 759 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
760 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 760 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
761 EXPECT_TRUE(childDamageRect.isEmpty()); | 761 EXPECT_TRUE(childDamageRect.isEmpty()); |
762 EXPECT_TRUE(rootDamageRect.isEmpty()); | 762 EXPECT_TRUE(rootDamageRect.isEmpty()); |
763 } | 763 } |
764 | 764 |
765 TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) | 765 TEST_F(CCDamageTrackerTest, verifyNoDamageForUpdateRectThatDoesNotDrawContent) |
766 { | 766 { |
767 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 767 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
768 CCLayerImpl* child1 = root->children()[0].get(); | 768 CCLayerImpl* child1 = root->children()[0]; |
769 FloatRect childDamageRect; | 769 FloatRect childDamageRect; |
770 FloatRect rootDamageRect; | 770 FloatRect rootDamageRect; |
771 | 771 |
772 // In our specific tree, the update rect of child1 should not cause any dama
ge to any | 772 // In our specific tree, the update rect of child1 should not cause any dama
ge to any |
773 // surface because it does not actually draw content. | 773 // surface because it does not actually draw content. |
774 clearDamageForAllSurfaces(root.get()); | 774 clearDamageForAllSurfaces(root.get()); |
775 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); | 775 child1->setUpdateRect(FloatRect(0, 0, 1, 2)); |
776 emulateDrawingOneFrame(root.get()); | 776 emulateDrawingOneFrame(root.get()); |
777 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 777 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
778 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 778 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
779 EXPECT_TRUE(childDamageRect.isEmpty()); | 779 EXPECT_TRUE(childDamageRect.isEmpty()); |
780 EXPECT_TRUE(rootDamageRect.isEmpty()); | 780 EXPECT_TRUE(rootDamageRect.isEmpty()); |
781 } | 781 } |
782 | 782 |
783 TEST_F(CCDamageTrackerTest, verifyDamageForReplica) | 783 TEST_F(CCDamageTrackerTest, verifyDamageForReplica) |
784 { | 784 { |
785 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 785 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
786 CCLayerImpl* child1 = root->children()[0].get(); | 786 CCLayerImpl* child1 = root->children()[0]; |
787 CCLayerImpl* grandChild1 = child1->children()[0].get(); | 787 CCLayerImpl* grandChild1 = child1->children()[0]; |
788 CCLayerImpl* grandChild2 = child1->children()[1].get(); | 788 CCLayerImpl* grandChild2 = child1->children()[1]; |
789 | 789 |
790 // Damage on a surface that has a reflection should cause the target surface
to | 790 // Damage on a surface that has a reflection should cause the target surface
to |
791 // receive the surface's damage and the surface's reflected damage. | 791 // receive the surface's damage and the surface's reflected damage. |
792 | 792 |
793 // For this test case, we modify grandChild2, and add grandChild3 to extend
the bounds | 793 // For this test case, we modify grandChild2, and add grandChild3 to extend
the bounds |
794 // of child1's surface. This way, we can test reflection changes without cha
nging | 794 // of child1's surface. This way, we can test reflection changes without cha
nging |
795 // contentBounds of the surface. | 795 // contentBounds of the surface. |
796 grandChild2->setPosition(FloatPoint(180, 180)); | 796 grandChild2->setPosition(FloatPoint(180, 180)); |
797 { | 797 { |
798 OwnPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6); | 798 OwnPtr<CCLayerImpl> grandChild3 = CCLayerImpl::create(6); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 862 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
863 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 863 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
864 | 864 |
865 EXPECT_FLOAT_RECT_EQ(FloatRect(189, 205, 12, 8), childDamageRect); | 865 EXPECT_FLOAT_RECT_EQ(FloatRect(189, 205, 12, 8), childDamageRect); |
866 EXPECT_FLOAT_RECT_EQ(FloatRect(289, 305, 12, 8), rootDamageRect); | 866 EXPECT_FLOAT_RECT_EQ(FloatRect(289, 305, 12, 8), rootDamageRect); |
867 } | 867 } |
868 | 868 |
869 TEST_F(CCDamageTrackerTest, verifyDamageForMask) | 869 TEST_F(CCDamageTrackerTest, verifyDamageForMask) |
870 { | 870 { |
871 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 871 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
872 CCLayerImpl* child = root->children()[0].get(); | 872 CCLayerImpl* child = root->children()[0]; |
873 | 873 |
874 // In the current implementation of the damage tracker, changes to mask laye
rs should | 874 // In the current implementation of the damage tracker, changes to mask laye
rs should |
875 // damage the entire corresponding surface. | 875 // damage the entire corresponding surface. |
876 | 876 |
877 clearDamageForAllSurfaces(root.get()); | 877 clearDamageForAllSurfaces(root.get()); |
878 | 878 |
879 // Set up the mask layer. | 879 // Set up the mask layer. |
880 { | 880 { |
881 OwnPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3); | 881 OwnPtr<CCLayerImpl> maskLayer = CCLayerImpl::create(3); |
882 maskLayer->setPosition(child->position()); | 882 maskLayer->setPosition(child->position()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 // Sanity check that a render surface still exists. | 946 // Sanity check that a render surface still exists. |
947 ASSERT_TRUE(child->renderSurface()); | 947 ASSERT_TRUE(child->renderSurface()); |
948 | 948 |
949 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); | 949 childDamageRect = child->renderSurface()->damageTracker()->currentDamageRect
(); |
950 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 30), childDamageRect); | 950 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 30), childDamageRect); |
951 } | 951 } |
952 | 952 |
953 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) | 953 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask) |
954 { | 954 { |
955 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 955 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
956 CCLayerImpl* child1 = root->children()[0].get(); | 956 CCLayerImpl* child1 = root->children()[0]; |
957 CCLayerImpl* grandChild1 = child1->children()[0].get(); | 957 CCLayerImpl* grandChild1 = child1->children()[0]; |
958 | 958 |
959 // Changes to a replica's mask should not damage the original surface, becau
se it is | 959 // Changes to a replica's mask should not damage the original surface, becau
se it is |
960 // not masked. But it does damage the ancestor target surface. | 960 // not masked. But it does damage the ancestor target surface. |
961 | 961 |
962 clearDamageForAllSurfaces(root.get()); | 962 clearDamageForAllSurfaces(root.get()); |
963 | 963 |
964 // Create a reflection about the left edge of grandChild1. | 964 // Create a reflection about the left edge of grandChild1. |
965 { | 965 { |
966 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); | 966 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); |
967 grandChild1Replica->setPosition(FloatPoint::zero()); | 967 grandChild1Replica->setPosition(FloatPoint::zero()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->curren
tDamageRect(); | 1009 grandChildDamageRect = grandChild1->renderSurface()->damageTracker()->curren
tDamageRect(); |
1010 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); | 1010 childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRec
t(); |
1011 | 1011 |
1012 EXPECT_TRUE(grandChildDamageRect.isEmpty()); | 1012 EXPECT_TRUE(grandChildDamageRect.isEmpty()); |
1013 EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); | 1013 EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect); |
1014 } | 1014 } |
1015 | 1015 |
1016 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) | 1016 TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor) |
1017 { | 1017 { |
1018 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 1018 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
1019 CCLayerImpl* child1 = root->children()[0].get(); | 1019 CCLayerImpl* child1 = root->children()[0]; |
1020 CCLayerImpl* grandChild1 = child1->children()[0].get(); | 1020 CCLayerImpl* grandChild1 = child1->children()[0]; |
1021 | 1021 |
1022 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; | 1022 // Verify that the correct replicaOriginTransform is used for the replicaMas
k; |
1023 clearDamageForAllSurfaces(root.get()); | 1023 clearDamageForAllSurfaces(root.get()); |
1024 | 1024 |
1025 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 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. |
1026 | 1026 |
1027 { | 1027 { |
1028 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); | 1028 OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6); |
1029 grandChild1Replica->setPosition(FloatPoint::zero()); | 1029 grandChild1Replica->setPosition(FloatPoint::zero()); |
1030 grandChild1Replica->setAnchorPoint(FloatPoint(1, 0)); // This is the anc
hor being tested. | 1030 grandChild1Replica->setAnchorPoint(FloatPoint(1, 0)); // This is the anc
hor being tested. |
(...skipping 26 matching lines...) Expand all Loading... |
1057 | 1057 |
1058 emulateDrawingOneFrame(root.get()); | 1058 emulateDrawingOneFrame(root.get()); |
1059 | 1059 |
1060 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); | 1060 FloatRect childDamageRect = child1->renderSurface()->damageTracker()->curren
tDamageRect(); |
1061 EXPECT_FLOAT_RECT_EQ(FloatRect(206, 200, 6, 8), childDamageRect); | 1061 EXPECT_FLOAT_RECT_EQ(FloatRect(206, 200, 6, 8), childDamageRect); |
1062 } | 1062 } |
1063 | 1063 |
1064 TEST_F(CCDamageTrackerTest, verifyDamageWhenForcedFullDamage) | 1064 TEST_F(CCDamageTrackerTest, verifyDamageWhenForcedFullDamage) |
1065 { | 1065 { |
1066 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 1066 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
1067 CCLayerImpl* child = root->children()[0].get(); | 1067 CCLayerImpl* child = root->children()[0]; |
1068 | 1068 |
1069 // Case 1: This test ensures that when the tracker is forced to have full da
mage, that | 1069 // Case 1: This test ensures that when the tracker is forced to have full da
mage, that |
1070 // it takes priority over any other partial damage. | 1070 // it takes priority over any other partial damage. |
1071 // | 1071 // |
1072 clearDamageForAllSurfaces(root.get()); | 1072 clearDamageForAllSurfaces(root.get()); |
1073 child->setUpdateRect(FloatRect(10, 11, 12, 13)); | 1073 child->setUpdateRect(FloatRect(10, 11, 12, 13)); |
1074 root->renderSurface()->damageTracker()->forceFullDamageNextUpdate(); | 1074 root->renderSurface()->damageTracker()->forceFullDamageNextUpdate(); |
1075 emulateDrawingOneFrame(root.get()); | 1075 emulateDrawingOneFrame(root.get()); |
1076 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 1076 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
1077 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); | 1077 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect); |
(...skipping 23 matching lines...) Expand all Loading... |
1101 | 1101 |
1102 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); | 1102 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); |
1103 EXPECT_TRUE(damageRect.isEmpty()); | 1103 EXPECT_TRUE(damageRect.isEmpty()); |
1104 } | 1104 } |
1105 | 1105 |
1106 TEST_F(CCDamageTrackerTest, verifyDamageAccumulatesUntilReset) | 1106 TEST_F(CCDamageTrackerTest, verifyDamageAccumulatesUntilReset) |
1107 { | 1107 { |
1108 // If damage is not cleared, it should accumulate. | 1108 // If damage is not cleared, it should accumulate. |
1109 | 1109 |
1110 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 1110 OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
1111 CCLayerImpl* child = root->children()[0].get(); | 1111 CCLayerImpl* child = root->children()[0]; |
1112 | 1112 |
1113 clearDamageForAllSurfaces(root.get()); | 1113 clearDamageForAllSurfaces(root.get()); |
1114 child->setUpdateRect(FloatRect(10, 11, 1, 2)); | 1114 child->setUpdateRect(FloatRect(10, 11, 1, 2)); |
1115 emulateDrawingOneFrame(root.get()); | 1115 emulateDrawingOneFrame(root.get()); |
1116 | 1116 |
1117 // Sanity check damage after the first frame; this isnt the actual test yet. | 1117 // Sanity check damage after the first frame; this isnt the actual test yet. |
1118 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); | 1118 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa
mageRect(); |
1119 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 1, 2), rootDamageRect); | 1119 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 1, 2), rootDamageRect); |
1120 | 1120 |
1121 // New damage, without having cleared the previous damage, should be unioned
to the previous one. | 1121 // New damage, without having cleared the previous damage, should be unioned
to the previous one. |
1122 child->setUpdateRect(FloatRect(20, 25, 1, 2)); | 1122 child->setUpdateRect(FloatRect(20, 25, 1, 2)); |
1123 emulateDrawingOneFrame(root.get()); | 1123 emulateDrawingOneFrame(root.get()); |
1124 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1124 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1125 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 11, 16), rootDamageRect); | 1125 EXPECT_FLOAT_RECT_EQ(FloatRect(110, 111, 11, 16), rootDamageRect); |
1126 | 1126 |
1127 // If we notify the damage tracker that we drew the damaged area, then damag
e should be emptied. | 1127 // If we notify the damage tracker that we drew the damaged area, then damag
e should be emptied. |
1128 root->renderSurface()->damageTracker()->didDrawDamagedArea(); | 1128 root->renderSurface()->damageTracker()->didDrawDamagedArea(); |
1129 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1129 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1130 EXPECT_TRUE(rootDamageRect.isEmpty()); | 1130 EXPECT_TRUE(rootDamageRect.isEmpty()); |
1131 | 1131 |
1132 // Damage should remain empty even after one frame, since there's yet no new
damage | 1132 // Damage should remain empty even after one frame, since there's yet no new
damage |
1133 emulateDrawingOneFrame(root.get()); | 1133 emulateDrawingOneFrame(root.get()); |
1134 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; | 1134 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect()
; |
1135 EXPECT_TRUE(rootDamageRect.isEmpty()); | 1135 EXPECT_TRUE(rootDamageRect.isEmpty()); |
1136 } | 1136 } |
1137 | 1137 |
1138 } // namespace | 1138 } // namespace |
OLD | NEW |