| 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/filter_operation.h" | 9 #include "cc/base/filter_operation.h" |
| 10 #include "cc/base/filter_operations.h" | 10 #include "cc/base/filter_operations.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 for (int i = 0; i < number_of_children; ++i) { | 93 for (int i = 0; i < number_of_children; ++i) { |
| 94 std::unique_ptr<LayerImpl> child = | 94 std::unique_ptr<LayerImpl> child = |
| 95 LayerImpl::Create(host_impl_.active_tree(), 2 + i); | 95 LayerImpl::Create(host_impl_.active_tree(), 2 + i); |
| 96 child->SetPosition(gfx::PointF(100.f, 100.f)); | 96 child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 97 child->SetBounds(gfx::Size(30, 30)); | 97 child->SetBounds(gfx::Size(30, 30)); |
| 98 child->SetDrawsContent(true); | 98 child->SetDrawsContent(true); |
| 99 root->test_properties()->AddChild(std::move(child)); | 99 root->test_properties()->AddChild(std::move(child)); |
| 100 } | 100 } |
| 101 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 101 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 102 host_impl_.active_tree()->SetElementIdsForTesting(); |
| 102 | 103 |
| 103 return host_impl_.active_tree()->root_layer_for_testing(); | 104 return host_impl_.active_tree()->root_layer_for_testing(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 LayerImpl* CreateTestTreeWithTwoSurfaces() { | 107 LayerImpl* CreateTestTreeWithTwoSurfaces() { |
| 107 // This test tree has two render surfaces: one for the root, and one for | 108 // This test tree has two render surfaces: one for the root, and one for |
| 108 // child1. Additionally, the root has a second child layer, and child1 has | 109 // child1. Additionally, the root has a second child layer, and child1 has |
| 109 // two children of its own. | 110 // two children of its own. |
| 110 | 111 |
| 111 host_impl_.active_tree()->DetachLayers(); | 112 host_impl_.active_tree()->DetachLayers(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 144 |
| 144 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); | 145 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); |
| 145 grand_child2->SetBounds(gfx::Size(6, 8)); | 146 grand_child2->SetBounds(gfx::Size(6, 8)); |
| 146 grand_child2->SetDrawsContent(true); | 147 grand_child2->SetDrawsContent(true); |
| 147 | 148 |
| 148 child1->test_properties()->AddChild(std::move(grand_child1)); | 149 child1->test_properties()->AddChild(std::move(grand_child1)); |
| 149 child1->test_properties()->AddChild(std::move(grand_child2)); | 150 child1->test_properties()->AddChild(std::move(grand_child2)); |
| 150 root->test_properties()->AddChild(std::move(child1)); | 151 root->test_properties()->AddChild(std::move(child1)); |
| 151 root->test_properties()->AddChild(std::move(child2)); | 152 root->test_properties()->AddChild(std::move(child2)); |
| 152 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 153 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 154 host_impl_.active_tree()->SetElementIdsForTesting(); |
| 153 | 155 |
| 154 return host_impl_.active_tree()->root_layer_for_testing(); | 156 return host_impl_.active_tree()->root_layer_for_testing(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { | 159 LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { |
| 158 LayerImpl* root = CreateTestTreeWithOneSurface(number_of_children); | 160 LayerImpl* root = CreateTestTreeWithOneSurface(number_of_children); |
| 159 | 161 |
| 160 // Setup includes going past the first frame which always damages | 162 // Setup includes going past the first frame which always damages |
| 161 // everything, so that we can actually perform specific tests. | 163 // everything, so that we can actually perform specific tests. |
| 162 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 164 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 381 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 380 LayerImpl* child = root->test_properties()->children[0]; | 382 LayerImpl* child = root->test_properties()->children[0]; |
| 381 | 383 |
| 382 // CASE 1: The layer's property changed flag takes priority over update rect. | 384 // CASE 1: The layer's property changed flag takes priority over update rect. |
| 383 // | 385 // |
| 384 child->test_properties()->force_render_surface = true; | 386 child->test_properties()->force_render_surface = true; |
| 385 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 387 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 386 EmulateDrawingOneFrame(root); | 388 EmulateDrawingOneFrame(root); |
| 387 ClearDamageForAllSurfaces(root); | 389 ClearDamageForAllSurfaces(root); |
| 388 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 390 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
| 389 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 391 root->layer_tree_impl()->SetOpacityMutated(child->element_id(), 0.5f); |
| 390 0.5f, child->effect_tree_index(), root->layer_tree_impl()); | |
| 391 EmulateDrawingOneFrame(root); | 392 EmulateDrawingOneFrame(root); |
| 392 | 393 |
| 393 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); | 394 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); |
| 394 | 395 |
| 395 // Damage should be the entire child layer in target_surface space. | 396 // Damage should be the entire child layer in target_surface space. |
| 396 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); | 397 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); |
| 397 gfx::Rect root_damage_rect; | 398 gfx::Rect root_damage_rect; |
| 398 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 399 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 399 &root_damage_rect)); | 400 &root_damage_rect)); |
| 400 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); | 401 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); |
| 401 | 402 |
| 402 // CASE 2: If a layer moves due to property change, it damages both the new | 403 // CASE 2: If a layer moves due to property change, it damages both the new |
| 403 // location and the old (exposed) location. The old location is the | 404 // location and the old (exposed) location. The old location is the |
| 404 // entire old layer, not just the update_rect. | 405 // entire old layer, not just the update_rect. |
| 405 | 406 |
| 406 // Cycle one frame of no change, just to sanity check that the next rect is | 407 // Cycle one frame of no change, just to sanity check that the next rect is |
| 407 // not because of the old damage state. | 408 // not because of the old damage state. |
| 408 ClearDamageForAllSurfaces(root); | 409 ClearDamageForAllSurfaces(root); |
| 409 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 410 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 410 EmulateDrawingOneFrame(root); | 411 EmulateDrawingOneFrame(root); |
| 411 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 412 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 412 &root_damage_rect)); | 413 &root_damage_rect)); |
| 413 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 414 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 414 | 415 |
| 415 // Then, test the actual layer movement. | 416 // Then, test the actual layer movement. |
| 416 ClearDamageForAllSurfaces(root); | 417 ClearDamageForAllSurfaces(root); |
| 417 gfx::Transform translation; | 418 gfx::Transform translation; |
| 418 translation.Translate(100.f, 130.f); | 419 translation.Translate(100.f, 130.f); |
| 419 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 420 root->layer_tree_impl()->SetTransformMutated(child->element_id(), |
| 420 translation, child->transform_tree_index(), root->layer_tree_impl()); | 421 translation); |
| 421 EmulateDrawingOneFrame(root); | 422 EmulateDrawingOneFrame(root); |
| 422 | 423 |
| 423 // Expect damage to be the combination of the previous one and the new one. | 424 // Expect damage to be the combination of the previous one and the new one. |
| 424 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); | 425 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); |
| 425 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 426 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 426 &root_damage_rect)); | 427 &root_damage_rect)); |
| 427 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); | 428 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); |
| 428 } | 429 } |
| 429 | 430 |
| 430 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { | 431 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 // Sanity check that the layer actually moved to (85, 85), damaging its old | 469 // Sanity check that the layer actually moved to (85, 85), damaging its old |
| 469 // location and new location. | 470 // location and new location. |
| 470 gfx::Rect root_damage_rect; | 471 gfx::Rect root_damage_rect; |
| 471 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 472 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 472 &root_damage_rect)); | 473 &root_damage_rect)); |
| 473 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); | 474 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); |
| 474 | 475 |
| 475 // With the anchor on the layer's center, now we can test the rotation more | 476 // With the anchor on the layer's center, now we can test the rotation more |
| 476 // intuitively, since it applies about the layer's anchor. | 477 // intuitively, since it applies about the layer's anchor. |
| 477 ClearDamageForAllSurfaces(root); | 478 ClearDamageForAllSurfaces(root); |
| 478 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 479 root->layer_tree_impl()->SetTransformMutated(child->element_id(), rotation); |
| 479 rotation, child->transform_tree_index(), root->layer_tree_impl()); | |
| 480 EmulateDrawingOneFrame(root); | 480 EmulateDrawingOneFrame(root); |
| 481 | 481 |
| 482 // Since the child layer is square, rotation by 45 degrees about the center | 482 // Since the child layer is square, rotation by 45 degrees about the center |
| 483 // should increase the size of the expected rect by sqrt(2), centered around | 483 // should increase the size of the expected rect by sqrt(2), centered around |
| 484 // (100, 100). The old exposed region should be fully contained in the new | 484 // (100, 100). The old exposed region should be fully contained in the new |
| 485 // region. | 485 // region. |
| 486 float expected_width = 30.f * sqrt(2.f); | 486 float expected_width = 30.f * sqrt(2.f); |
| 487 float expected_position = 100.f - 0.5f * expected_width; | 487 float expected_position = 100.f - 0.5f * expected_width; |
| 488 gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( | 488 gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( |
| 489 expected_position, expected_position, expected_width, expected_width)); | 489 expected_position, expected_position, expected_width, expected_width)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 gfx::RectF test_rect(child->position(), gfx::SizeF(child->bounds())); | 526 gfx::RectF test_rect(child->position(), gfx::SizeF(child->bounds())); |
| 527 bool clipped = false; | 527 bool clipped = false; |
| 528 MathUtil::MapQuad(transform, gfx::QuadF(test_rect), &clipped); | 528 MathUtil::MapQuad(transform, gfx::QuadF(test_rect), &clipped); |
| 529 EXPECT_TRUE(clipped); | 529 EXPECT_TRUE(clipped); |
| 530 | 530 |
| 531 // Damage the child without moving it. | 531 // Damage the child without moving it. |
| 532 child->test_properties()->force_render_surface = true; | 532 child->test_properties()->force_render_surface = true; |
| 533 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 533 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 534 EmulateDrawingOneFrame(root); | 534 EmulateDrawingOneFrame(root); |
| 535 ClearDamageForAllSurfaces(root); | 535 ClearDamageForAllSurfaces(root); |
| 536 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 536 root->layer_tree_impl()->SetOpacityMutated(child->element_id(), 0.5f); |
| 537 0.5f, child->effect_tree_index(), root->layer_tree_impl()); | |
| 538 EmulateDrawingOneFrame(root); | 537 EmulateDrawingOneFrame(root); |
| 539 | 538 |
| 540 // The expected damage should cover the entire root surface (500x500), but we | 539 // The expected damage should cover the entire root surface (500x500), but we |
| 541 // don't care whether the damage rect was clamped or is larger than the | 540 // don't care whether the damage rect was clamped or is larger than the |
| 542 // surface for this test. | 541 // surface for this test. |
| 543 gfx::Rect root_damage_rect; | 542 gfx::Rect root_damage_rect; |
| 544 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 543 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 545 &root_damage_rect)); | 544 &root_damage_rect)); |
| 546 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); | 545 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); |
| 547 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); | 546 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 586 |
| 588 FilterOperations filters; | 587 FilterOperations filters; |
| 589 filters.Append(FilterOperation::CreateReferenceFilter( | 588 filters.Append(FilterOperation::CreateReferenceFilter( |
| 590 SkBlurImageFilter::Make(2, 2, nullptr))); | 589 SkBlurImageFilter::Make(2, 2, nullptr))); |
| 591 | 590 |
| 592 // Setting the filter will damage the whole surface. | 591 // Setting the filter will damage the whole surface. |
| 593 ClearDamageForAllSurfaces(root); | 592 ClearDamageForAllSurfaces(root); |
| 594 child->test_properties()->force_render_surface = true; | 593 child->test_properties()->force_render_surface = true; |
| 595 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 594 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 596 EmulateDrawingOneFrame(root); | 595 EmulateDrawingOneFrame(root); |
| 597 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 596 child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); |
| 598 filters, child->effect_tree_index(), child->layer_tree_impl()); | |
| 599 EmulateDrawingOneFrame(root); | 597 EmulateDrawingOneFrame(root); |
| 600 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 598 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 601 &root_damage_rect)); | 599 &root_damage_rect)); |
| 602 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 600 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 603 &child_damage_rect)); | 601 &child_damage_rect)); |
| 604 | 602 |
| 605 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. | 603 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. |
| 606 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); | 604 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); |
| 607 | 605 |
| 608 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. | 606 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 638 SkBlurImageFilter::Make(2, 2, nullptr))); | 636 SkBlurImageFilter::Make(2, 2, nullptr))); |
| 639 | 637 |
| 640 // Setting the filter will damage the whole surface. | 638 // Setting the filter will damage the whole surface. |
| 641 gfx::Transform transform; | 639 gfx::Transform transform; |
| 642 transform.RotateAboutYAxis(60); | 640 transform.RotateAboutYAxis(60); |
| 643 ClearDamageForAllSurfaces(root); | 641 ClearDamageForAllSurfaces(root); |
| 644 child->test_properties()->force_render_surface = true; | 642 child->test_properties()->force_render_surface = true; |
| 645 child->test_properties()->transform = transform; | 643 child->test_properties()->transform = transform; |
| 646 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 644 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 647 EmulateDrawingOneFrame(root); | 645 EmulateDrawingOneFrame(root); |
| 648 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 646 child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); |
| 649 filters, child->effect_tree_index(), child->layer_tree_impl()); | |
| 650 EmulateDrawingOneFrame(root); | 647 EmulateDrawingOneFrame(root); |
| 651 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 648 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 652 &root_damage_rect)); | 649 &root_damage_rect)); |
| 653 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 650 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 654 &child_damage_rect)); | 651 &child_damage_rect)); |
| 655 | 652 |
| 656 // Blur outset is 6px for a 2px blur. | 653 // Blur outset is 6px for a 2px blur. |
| 657 int blur_outset = 6; | 654 int blur_outset = 6; |
| 658 int rotated_outset_left = blur_outset / 2; | 655 int rotated_outset_left = blur_outset / 2; |
| 659 int expected_rotated_width = (30 + 2 * blur_outset) / 2; | 656 int expected_rotated_width = (30 + 2 * blur_outset) / 2; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 | 691 |
| 695 FilterOperations filters; | 692 FilterOperations filters; |
| 696 filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 693 filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
| 697 | 694 |
| 698 // Setting the filter will damage the whole surface. | 695 // Setting the filter will damage the whole surface. |
| 699 ClearDamageForAllSurfaces(root); | 696 ClearDamageForAllSurfaces(root); |
| 700 child->test_properties()->force_render_surface = true; | 697 child->test_properties()->force_render_surface = true; |
| 701 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 698 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 702 int device_scale_factor = 2; | 699 int device_scale_factor = 2; |
| 703 EmulateDrawingOneFrame(root, device_scale_factor); | 700 EmulateDrawingOneFrame(root, device_scale_factor); |
| 704 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 701 child->layer_tree_impl()->SetFilterMutated(child->element_id(), filters); |
| 705 filters, child->effect_tree_index(), child->layer_tree_impl()); | |
| 706 EmulateDrawingOneFrame(root, device_scale_factor); | 702 EmulateDrawingOneFrame(root, device_scale_factor); |
| 707 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 703 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 708 &root_damage_rect)); | 704 &root_damage_rect)); |
| 709 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 705 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 710 &child_damage_rect)); | 706 &child_damage_rect)); |
| 711 | 707 |
| 712 // Blur outset is 9px for a 3px blur, scaled up by DSF. | 708 // Blur outset is 9px for a 3px blur, scaled up by DSF. |
| 713 int blur_outset = 9 * device_scale_factor; | 709 int blur_outset = 9 * device_scale_factor; |
| 714 gfx::Rect original_rect(100, 100, 100, 100); | 710 gfx::Rect original_rect(100, 100, 100, 100); |
| 715 gfx::Rect expected_child_damage_rect(60, 60); | 711 gfx::Rect expected_child_damage_rect(60, 60); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 child2->test_properties()->force_render_surface = true; | 991 child2->test_properties()->force_render_surface = true; |
| 996 grand_child1->test_properties()->force_render_surface = true; | 992 grand_child1->test_properties()->force_render_surface = true; |
| 997 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 993 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 998 EmulateDrawingOneFrame(root); | 994 EmulateDrawingOneFrame(root); |
| 999 gfx::Rect child_damage_rect; | 995 gfx::Rect child_damage_rect; |
| 1000 gfx::Rect root_damage_rect; | 996 gfx::Rect root_damage_rect; |
| 1001 | 997 |
| 1002 // CASE 1: Damage to a descendant surface should propagate properly to | 998 // CASE 1: Damage to a descendant surface should propagate properly to |
| 1003 // ancestor surface. | 999 // ancestor surface. |
| 1004 ClearDamageForAllSurfaces(root); | 1000 ClearDamageForAllSurfaces(root); |
| 1005 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1001 root->layer_tree_impl()->SetOpacityMutated(grand_child1->element_id(), 0.5f); |
| 1006 0.5f, grand_child1->effect_tree_index(), root->layer_tree_impl()); | |
| 1007 EmulateDrawingOneFrame(root); | 1002 EmulateDrawingOneFrame(root); |
| 1008 EXPECT_TRUE( | 1003 EXPECT_TRUE( |
| 1009 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1004 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1010 &child_damage_rect)); | 1005 &child_damage_rect)); |
| 1011 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1006 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1012 &root_damage_rect)); | 1007 &root_damage_rect)); |
| 1013 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1008 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1014 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); | 1009 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); |
| 1015 | 1010 |
| 1016 // CASE 2: Same as previous case, but with additional damage elsewhere that | 1011 // CASE 2: Same as previous case, but with additional damage elsewhere that |
| 1017 // should be properly unioned. | 1012 // should be properly unioned. |
| 1018 // - child1 surface damage in root surface space: | 1013 // - child1 surface damage in root surface space: |
| 1019 // gfx::Rect(300, 300, 6, 8); | 1014 // gfx::Rect(300, 300, 6, 8); |
| 1020 // - child2 damage in root surface space: | 1015 // - child2 damage in root surface space: |
| 1021 // gfx::Rect(11, 11, 18, 18); | 1016 // gfx::Rect(11, 11, 18, 18); |
| 1022 ClearDamageForAllSurfaces(root); | 1017 ClearDamageForAllSurfaces(root); |
| 1023 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1018 root->layer_tree_impl()->SetOpacityMutated(grand_child1->element_id(), 0.7f); |
| 1024 0.7f, grand_child1->effect_tree_index(), root->layer_tree_impl()); | 1019 root->layer_tree_impl()->SetOpacityMutated(child2->element_id(), 0.7f); |
| 1025 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | |
| 1026 0.7f, child2->effect_tree_index(), root->layer_tree_impl()); | |
| 1027 EmulateDrawingOneFrame(root); | 1020 EmulateDrawingOneFrame(root); |
| 1028 EXPECT_TRUE( | 1021 EXPECT_TRUE( |
| 1029 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1022 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1030 &child_damage_rect)); | 1023 &child_damage_rect)); |
| 1031 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1024 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1032 &root_damage_rect)); | 1025 &root_damage_rect)); |
| 1033 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1026 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
| 1034 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), | 1027 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), |
| 1035 root_damage_rect.ToString()); | 1028 root_damage_rect.ToString()); |
| 1036 } | 1029 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 // transforming it, while the root surface would be damaged appropriately. | 1078 // transforming it, while the root surface would be damaged appropriately. |
| 1086 | 1079 |
| 1087 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 1080 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 1088 LayerImpl* child1 = root->test_properties()->children[0]; | 1081 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1089 gfx::Rect child_damage_rect; | 1082 gfx::Rect child_damage_rect; |
| 1090 gfx::Rect root_damage_rect; | 1083 gfx::Rect root_damage_rect; |
| 1091 | 1084 |
| 1092 ClearDamageForAllSurfaces(root); | 1085 ClearDamageForAllSurfaces(root); |
| 1093 gfx::Transform translation; | 1086 gfx::Transform translation; |
| 1094 translation.Translate(-50.f, -50.f); | 1087 translation.Translate(-50.f, -50.f); |
| 1095 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 1088 root->layer_tree_impl()->SetTransformMutated(child1->element_id(), |
| 1096 translation, child1->transform_tree_index(), root->layer_tree_impl()); | 1089 translation); |
| 1097 EmulateDrawingOneFrame(root); | 1090 EmulateDrawingOneFrame(root); |
| 1098 EXPECT_TRUE( | 1091 EXPECT_TRUE( |
| 1099 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1092 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1100 &child_damage_rect)); | 1093 &child_damage_rect)); |
| 1101 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1094 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1102 &root_damage_rect)); | 1095 &root_damage_rect)); |
| 1103 | 1096 |
| 1104 // The new surface bounds should be damaged entirely. | 1097 // The new surface bounds should be damaged entirely. |
| 1105 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), | 1098 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
| 1106 child_damage_rect.ToString()); | 1099 child_damage_rect.ToString()); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 ASSERT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1685 ASSERT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
| 1693 &damage_rect)); | 1686 &damage_rect)); |
| 1694 EXPECT_TRUE(damage_rect.Contains(root->GetRenderSurface()->content_rect())); | 1687 EXPECT_TRUE(damage_rect.Contains(root->GetRenderSurface()->content_rect())); |
| 1695 EXPECT_TRUE(damage_rect.Contains( | 1688 EXPECT_TRUE(damage_rect.Contains( |
| 1696 gfx::ToEnclosingRect(child1->GetRenderSurface()->DrawableContentRect()))); | 1689 gfx::ToEnclosingRect(child1->GetRenderSurface()->DrawableContentRect()))); |
| 1697 EXPECT_EQ(damage_rect, root->GetRenderSurface()->GetDamageRect()); | 1690 EXPECT_EQ(damage_rect, root->GetRenderSurface()->GetDamageRect()); |
| 1698 } | 1691 } |
| 1699 | 1692 |
| 1700 } // namespace | 1693 } // namespace |
| 1701 } // namespace cc | 1694 } // namespace cc |
| OLD | NEW |