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