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 "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
10 #include "CCLayerSorter.h" | 10 #include "CCLayerSorter.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 // 1. computing the render passes and layerlists | 52 // 1. computing the render passes and layerlists |
53 // 2. updating all damage trackers in the correct order | 53 // 2. updating all damage trackers in the correct order |
54 // 3. resetting all updateRects and propertyChanged flags for all layers a nd surfaces. | 54 // 3. resetting all updateRects and propertyChanged flags for all layers a nd surfaces. |
55 | 55 |
56 std::vector<CCLayerImpl*> renderSurfaceLayerList; | 56 std::vector<CCLayerImpl*> renderSurfaceLayerList; |
57 executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList); | 57 executeCalculateDrawTransformsAndVisibility(root, renderSurfaceLayerList); |
58 | 58 |
59 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors. | 59 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors. |
60 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { | 60 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { |
61 CCRenderSurface* targetSurface = renderSurfaceLayerList[i]->renderSurfac e(); | 61 CCRenderSurface* targetSurface = renderSurfaceLayerList[i]->renderSurfac e(); |
62 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface- >layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i] ->maskLayer(), renderSurfaceLayerList[i]->filters()); | 62 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface- >layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i] ->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i]-> filter()); |
63 } | 63 } |
64 | 64 |
65 root->resetAllChangeTrackingForSubtree(); | 65 root->resetAllChangeTrackingForSubtree(); |
66 } | 66 } |
67 | 67 |
68 scoped_ptr<CCLayerImpl> createTestTreeWithOneSurface() | 68 scoped_ptr<CCLayerImpl> createTestTreeWithOneSurface() |
69 { | 69 { |
70 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 70 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
71 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); | 71 scoped_ptr<CCLayerImpl> child = CCLayerImpl::create(2); |
72 | 72 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 emulateDrawingOneFrame(root.get()); | 385 emulateDrawingOneFrame(root.get()); |
386 | 386 |
387 // Damage position on the surface should be: position of updateRect (10, 11) relative to the child (100, 100), but expanded by the blur outsets. | 387 // 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 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa mageRect(); | 388 FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDa mageRect(); |
389 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); | 389 FloatRect expectedDamageRect = FloatRect(110, 111, 12, 13); |
390 expectedDamageRect.move(-outsetLeft, -outsetTop); | 390 expectedDamageRect.move(-outsetLeft, -outsetTop); |
391 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom ); | 391 expectedDamageRect.expand(outsetLeft + outsetRight, outsetTop + outsetBottom ); |
392 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); | 392 EXPECT_FLOAT_RECT_EQ(expectedDamageRect, rootDamageRect); |
393 } | 393 } |
394 | 394 |
395 TEST_F(CCDamageTrackerTest, verifyDamageForBackgroundBlurredChild) | 395 TEST_F(CCDamageTrackerTest, verifyDamageForBackgroundBlurredChild) |
danakj
2012/10/22 18:00:43
Can you add a simple test that verifies if a filte
Stephen White
2012/10/22 18:51:00
Done.
| |
396 { | 396 { |
397 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); | 397 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); |
398 CCLayerImpl* child1 = root->children()[0]; | 398 CCLayerImpl* child1 = root->children()[0]; |
399 CCLayerImpl* child2 = root->children()[1]; | 399 CCLayerImpl* child2 = root->children()[1]; |
400 | 400 |
401 // Allow us to set damage on child1 too. | 401 // Allow us to set damage on child1 too. |
402 child1->setDrawsContent(true); | 402 child1->setDrawsContent(true); |
403 | 403 |
404 WebFilterOperations filters; | 404 WebFilterOperations filters; |
405 filters.append(WebFilterOperation::createBlurFilter(2)); | 405 filters.append(WebFilterOperation::createBlurFilter(2)); |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 { | 1088 { |
1089 // Though it should never happen, its a good idea to verify that the damage tracker | 1089 // Though it should never happen, its a good idea to verify that the damage tracker |
1090 // does not crash when it receives an empty layerList. | 1090 // does not crash when it receives an empty layerList. |
1091 | 1091 |
1092 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); | 1092 scoped_ptr<CCLayerImpl> root = CCLayerImpl::create(1); |
1093 root->createRenderSurface(); | 1093 root->createRenderSurface(); |
1094 | 1094 |
1095 ASSERT_TRUE(root == root->renderTarget()); | 1095 ASSERT_TRUE(root == root->renderTarget()); |
1096 CCRenderSurface* targetSurface = root->renderSurface(); | 1096 CCRenderSurface* targetSurface = root->renderSurface(); |
1097 targetSurface->clearLayerLists(); | 1097 targetSurface->clearLayerLists(); |
1098 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay erList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperatio ns()); | 1098 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay erList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperatio ns(), 0); |
1099 | 1099 |
1100 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); | 1100 FloatRect damageRect = targetSurface->damageTracker()->currentDamageRect(); |
1101 EXPECT_TRUE(damageRect.isEmpty()); | 1101 EXPECT_TRUE(damageRect.isEmpty()); |
1102 } | 1102 } |
1103 | 1103 |
1104 TEST_F(CCDamageTrackerTest, verifyDamageAccumulatesUntilReset) | 1104 TEST_F(CCDamageTrackerTest, verifyDamageAccumulatesUntilReset) |
1105 { | 1105 { |
1106 // If damage is not cleared, it should accumulate. | 1106 // If damage is not cleared, it should accumulate. |
1107 | 1107 |
1108 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); | 1108 scoped_ptr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface(); |
(...skipping 18 matching lines...) Expand all Loading... | |
1127 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; | 1127 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; |
1128 EXPECT_TRUE(rootDamageRect.isEmpty()); | 1128 EXPECT_TRUE(rootDamageRect.isEmpty()); |
1129 | 1129 |
1130 // Damage should remain empty even after one frame, since there's yet no new damage | 1130 // Damage should remain empty even after one frame, since there's yet no new damage |
1131 emulateDrawingOneFrame(root.get()); | 1131 emulateDrawingOneFrame(root.get()); |
1132 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; | 1132 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; |
1133 EXPECT_TRUE(rootDamageRect.isEmpty()); | 1133 EXPECT_TRUE(rootDamageRect.isEmpty()); |
1134 } | 1134 } |
1135 | 1135 |
1136 } // namespace | 1136 } // namespace |
OLD | NEW |