| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 411 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 412 EmulateDrawingOneFrame(root); | 412 EmulateDrawingOneFrame(root); |
| 413 | 413 |
| 414 // Expect damage to be the combination of the previous one and the new one. | 414 // Expect damage to be the combination of the previous one and the new one. |
| 415 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); | 415 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); |
| 416 root_damage_rect = | 416 root_damage_rect = |
| 417 root->render_surface()->damage_tracker()->current_damage_rect(); | 417 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 418 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); | 418 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); |
| 419 } | 419 } |
| 420 | 420 |
| 421 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { |
| 422 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 423 LayerImpl* surface = root->children()[0]; |
| 424 LayerImpl* child = surface->children()[0]; |
| 425 child->SetDrawsContent(true); |
| 426 EmulateDrawingOneFrame(root); |
| 427 ClearDamageForAllSurfaces(root); |
| 428 |
| 429 surface->test_properties()->force_render_surface = false; |
| 430 child->SetDrawsContent(false); |
| 431 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 432 EmulateDrawingOneFrame(root); |
| 433 gfx::Rect root_damage_rect = |
| 434 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 435 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 436 root_damage_rect.ToString()); |
| 437 } |
| 438 |
| 421 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { | 439 TEST_F(DamageTrackerTest, VerifyDamageForTransformedLayer) { |
| 422 // If a layer is transformed, the damage rect should still enclose the entire | 440 // If a layer is transformed, the damage rect should still enclose the entire |
| 423 // transformed layer. | 441 // transformed layer. |
| 424 | 442 |
| 425 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 443 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 426 LayerImpl* child = root->children()[0]; | 444 LayerImpl* child = root->children()[0]; |
| 427 child->test_properties()->force_render_surface = true; | 445 child->test_properties()->force_render_surface = true; |
| 428 | 446 |
| 429 gfx::Transform rotation; | 447 gfx::Transform rotation; |
| 430 rotation.Rotate(45.0); | 448 rotation.Rotate(45.0); |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 gfx::Rect root_damage_rect = | 1629 gfx::Rect root_damage_rect = |
| 1612 root->render_surface()->damage_tracker()->current_damage_rect(); | 1630 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1613 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1631 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1614 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1632 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1615 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1633 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1616 } | 1634 } |
| 1617 } | 1635 } |
| 1618 | 1636 |
| 1619 } // namespace | 1637 } // namespace |
| 1620 } // namespace cc | 1638 } // namespace cc |
| OLD | NEW |