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 "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 ClearDamageForAllSurfaces(root.get()); | 1256 ClearDamageForAllSurfaces(root.get()); |
1257 replica_mask_layer->SetStackingOrderChanged(true); | 1257 replica_mask_layer->SetStackingOrderChanged(true); |
1258 | 1258 |
1259 EmulateDrawingOneFrame(root.get()); | 1259 EmulateDrawingOneFrame(root.get()); |
1260 | 1260 |
1261 gfx::RectF child_damage_rect = | 1261 gfx::RectF child_damage_rect = |
1262 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1262 child1->render_surface()->damage_tracker()->current_damage_rect(); |
1263 EXPECT_FLOAT_RECT_EQ(gfx::RectF(206.f, 200.f, 6.f, 8.f), child_damage_rect); | 1263 EXPECT_FLOAT_RECT_EQ(gfx::RectF(206.f, 200.f, 6.f, 8.f), child_damage_rect); |
1264 } | 1264 } |
1265 | 1265 |
1266 TEST_F(DamageTrackerTest, VerifyDamageWhenForcedFullDamage) { | 1266 TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { |
1267 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 1267 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
1268 LayerImpl* child = root->children()[0]; | 1268 LayerImpl* child = root->children()[0]; |
1269 | 1269 |
1270 // Case 1: This test ensures that when the tracker is forced to have full | 1270 // Case 1: This test ensures that when the tracker is given damage, that |
1271 // damage, that it takes priority over any other partial damage. | 1271 // it is included with any other partial damage. |
1272 // | 1272 // |
1273 ClearDamageForAllSurfaces(root.get()); | 1273 ClearDamageForAllSurfaces(root.get()); |
1274 child->set_update_rect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); | 1274 child->set_update_rect(gfx::RectF(10, 11, 12, 13)); |
1275 root->render_surface()->damage_tracker()->ForceFullDamageNextUpdate(); | 1275 root->render_surface()->damage_tracker()->AddDamageNextUpdate( |
| 1276 gfx::RectF(15, 16, 32, 33)); |
1276 EmulateDrawingOneFrame(root.get()); | 1277 EmulateDrawingOneFrame(root.get()); |
1277 gfx::RectF root_damage_rect = | 1278 gfx::RectF root_damage_rect = |
1278 root->render_surface()->damage_tracker()->current_damage_rect(); | 1279 root->render_surface()->damage_tracker()->current_damage_rect(); |
1279 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 500.f, 500.f), root_damage_rect); | 1280 EXPECT_FLOAT_RECT_EQ( |
| 1281 gfx::UnionRects(gfx::RectF(15, 16, 32, 33), |
| 1282 gfx::RectF(100+10, 100+11, 12, 13)), |
| 1283 root_damage_rect); |
1280 | 1284 |
1281 // Case 2: An additional sanity check that forcing full damage works even | 1285 // Case 2: An additional sanity check that adding damage works even when |
1282 // when nothing on the layer tree changed. | 1286 // nothing on the layer tree changed. |
1283 // | 1287 // |
1284 ClearDamageForAllSurfaces(root.get()); | 1288 ClearDamageForAllSurfaces(root.get()); |
1285 root->render_surface()->damage_tracker()->ForceFullDamageNextUpdate(); | 1289 root->render_surface()->damage_tracker()->AddDamageNextUpdate( |
| 1290 gfx::RectF(30, 31, 14, 15)); |
1286 EmulateDrawingOneFrame(root.get()); | 1291 EmulateDrawingOneFrame(root.get()); |
1287 root_damage_rect = | 1292 root_damage_rect = |
1288 root->render_surface()->damage_tracker()->current_damage_rect(); | 1293 root->render_surface()->damage_tracker()->current_damage_rect(); |
1289 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 500.f, 500.f), root_damage_rect); | 1294 EXPECT_FLOAT_RECT_EQ(gfx::RectF(30, 31, 14, 15), root_damage_rect); |
1290 } | 1295 } |
1291 | 1296 |
1292 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { | 1297 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { |
1293 // Though it should never happen, its a good idea to verify that the damage | 1298 // Though it should never happen, its a good idea to verify that the damage |
1294 // tracker does not crash when it receives an empty layer_list. | 1299 // tracker does not crash when it receives an empty layer_list. |
1295 | 1300 |
1296 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); | 1301 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); |
1297 root->CreateRenderSurface(); | 1302 root->CreateRenderSurface(); |
1298 | 1303 |
1299 ASSERT_TRUE(root == root->render_target()); | 1304 ASSERT_TRUE(root == root->render_target()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 // Damage should remain empty even after one frame, since there's yet no new | 1351 // Damage should remain empty even after one frame, since there's yet no new |
1347 // damage. | 1352 // damage. |
1348 EmulateDrawingOneFrame(root.get()); | 1353 EmulateDrawingOneFrame(root.get()); |
1349 root_damage_rect = | 1354 root_damage_rect = |
1350 root->render_surface()->damage_tracker()->current_damage_rect(); | 1355 root->render_surface()->damage_tracker()->current_damage_rect(); |
1351 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1356 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
1352 } | 1357 } |
1353 | 1358 |
1354 } // namespace | 1359 } // namespace |
1355 } // namespace cc | 1360 } // namespace cc |
OLD | NEW |