| 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 "cc/trees/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 // leftover from the previous case. | 1190 // leftover from the previous case. |
| 1191 ClearDamageForAllSurfaces(root.get()); | 1191 ClearDamageForAllSurfaces(root.get()); |
| 1192 EmulateDrawingOneFrame(root.get()); | 1192 EmulateDrawingOneFrame(root.get()); |
| 1193 child_damage_rect = | 1193 child_damage_rect = |
| 1194 child->render_surface()->damage_tracker()->current_damage_rect(); | 1194 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 1195 EXPECT_TRUE(child_damage_rect.IsEmpty()); | 1195 EXPECT_TRUE(child_damage_rect.IsEmpty()); |
| 1196 | 1196 |
| 1197 // Then test the property change. | 1197 // Then test the property change. |
| 1198 ClearDamageForAllSurfaces(root.get()); | 1198 ClearDamageForAllSurfaces(root.get()); |
| 1199 mask_layer->SetStackingOrderChanged(true); | 1199 mask_layer->SetStackingOrderChanged(true); |
| 1200 mask_layer->NoteLayerPropertyChanged(); |
| 1200 | 1201 |
| 1201 EmulateDrawingOneFrame(root.get()); | 1202 EmulateDrawingOneFrame(root.get()); |
| 1202 child_damage_rect = | 1203 child_damage_rect = |
| 1203 child->render_surface()->damage_tracker()->current_damage_rect(); | 1204 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 1204 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); | 1205 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
| 1205 | 1206 |
| 1206 // CASE 3: removing the mask also damages the entire target surface. | 1207 // CASE 3: removing the mask also damages the entire target surface. |
| 1207 // | 1208 // |
| 1208 | 1209 |
| 1209 // Advance one frame without damage so that we know the damage rect is not | 1210 // Advance one frame without damage so that we know the damage rect is not |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 | 1265 |
| 1265 EmulateDrawingOneFrame(root.get()); | 1266 EmulateDrawingOneFrame(root.get()); |
| 1266 | 1267 |
| 1267 // Sanity check that the appropriate render surfaces were created | 1268 // Sanity check that the appropriate render surfaces were created |
| 1268 ASSERT_TRUE(grand_child1->render_surface()); | 1269 ASSERT_TRUE(grand_child1->render_surface()); |
| 1269 | 1270 |
| 1270 // CASE 1: a property change on the mask should damage only the reflected | 1271 // CASE 1: a property change on the mask should damage only the reflected |
| 1271 // region on the target surface. | 1272 // region on the target surface. |
| 1272 ClearDamageForAllSurfaces(root.get()); | 1273 ClearDamageForAllSurfaces(root.get()); |
| 1273 replica_mask_layer->SetStackingOrderChanged(true); | 1274 replica_mask_layer->SetStackingOrderChanged(true); |
| 1275 replica_mask_layer->NoteLayerPropertyChanged(); |
| 1274 EmulateDrawingOneFrame(root.get()); | 1276 EmulateDrawingOneFrame(root.get()); |
| 1275 | 1277 |
| 1276 gfx::Rect grand_child_damage_rect = | 1278 gfx::Rect grand_child_damage_rect = |
| 1277 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); | 1279 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 1278 gfx::Rect child_damage_rect = | 1280 gfx::Rect child_damage_rect = |
| 1279 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1281 child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 1280 | 1282 |
| 1281 EXPECT_TRUE(grand_child_damage_rect.IsEmpty()); | 1283 EXPECT_TRUE(grand_child_damage_rect.IsEmpty()); |
| 1282 EXPECT_EQ(gfx::Rect(194, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1284 EXPECT_EQ(gfx::Rect(194, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1283 | 1285 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 | 1344 |
| 1343 EmulateDrawingOneFrame(root.get()); | 1345 EmulateDrawingOneFrame(root.get()); |
| 1344 | 1346 |
| 1345 // Sanity check that the appropriate render surfaces were created | 1347 // Sanity check that the appropriate render surfaces were created |
| 1346 ASSERT_TRUE(grand_child1->render_surface()); | 1348 ASSERT_TRUE(grand_child1->render_surface()); |
| 1347 | 1349 |
| 1348 // A property change on the replica_mask should damage the reflected region on | 1350 // A property change on the replica_mask should damage the reflected region on |
| 1349 // the target surface. | 1351 // the target surface. |
| 1350 ClearDamageForAllSurfaces(root.get()); | 1352 ClearDamageForAllSurfaces(root.get()); |
| 1351 replica_mask_layer->SetStackingOrderChanged(true); | 1353 replica_mask_layer->SetStackingOrderChanged(true); |
| 1354 replica_mask_layer->NoteLayerPropertyChanged(); |
| 1352 | 1355 |
| 1353 EmulateDrawingOneFrame(root.get()); | 1356 EmulateDrawingOneFrame(root.get()); |
| 1354 | 1357 |
| 1355 gfx::Rect child_damage_rect = | 1358 gfx::Rect child_damage_rect = |
| 1356 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1359 child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 1357 EXPECT_EQ(gfx::Rect(206, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1360 EXPECT_EQ(gfx::Rect(206, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1358 } | 1361 } |
| 1359 | 1362 |
| 1360 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { | 1363 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { |
| 1361 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 1364 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 gfx::Rect root_damage_rect = | 1481 gfx::Rect root_damage_rect = |
| 1479 root->render_surface()->damage_tracker()->current_damage_rect(); | 1482 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1480 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1483 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1481 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1484 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1482 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1485 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1483 } | 1486 } |
| 1484 } | 1487 } |
| 1485 | 1488 |
| 1486 } // namespace | 1489 } // namespace |
| 1487 } // namespace cc | 1490 } // namespace cc |
| OLD | NEW |