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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 for (int i = 0; i < number_of_children; ++i) { | 100 for (int i = 0; i < number_of_children; ++i) { |
101 std::unique_ptr<LayerImpl> child = | 101 std::unique_ptr<LayerImpl> child = |
102 LayerImpl::Create(host_impl_.active_tree(), 2 + i); | 102 LayerImpl::Create(host_impl_.active_tree(), 2 + i); |
103 child->SetPosition(gfx::PointF(100.f, 100.f)); | 103 child->SetPosition(gfx::PointF(100.f, 100.f)); |
104 child->SetBounds(gfx::Size(30, 30)); | 104 child->SetBounds(gfx::Size(30, 30)); |
105 child->SetDrawsContent(true); | 105 child->SetDrawsContent(true); |
106 root->test_properties()->AddChild(std::move(child)); | 106 root->test_properties()->AddChild(std::move(child)); |
107 } | 107 } |
108 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 108 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 109 host_impl_.active_tree()->SetElementIdsForTesting(); |
109 | 110 |
110 return host_impl_.active_tree()->root_layer_for_testing(); | 111 return host_impl_.active_tree()->root_layer_for_testing(); |
111 } | 112 } |
112 | 113 |
113 LayerImpl* CreateTestTreeWithTwoSurfaces() { | 114 LayerImpl* CreateTestTreeWithTwoSurfaces() { |
114 // This test tree has two render surfaces: one for the root, and one for | 115 // This test tree has two render surfaces: one for the root, and one for |
115 // child1. Additionally, the root has a second child layer, and child1 has | 116 // child1. Additionally, the root has a second child layer, and child1 has |
116 // two children of its own. | 117 // two children of its own. |
117 | 118 |
118 host_impl_.active_tree()->DetachLayers(); | 119 host_impl_.active_tree()->DetachLayers(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 151 |
151 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); | 152 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); |
152 grand_child2->SetBounds(gfx::Size(6, 8)); | 153 grand_child2->SetBounds(gfx::Size(6, 8)); |
153 grand_child2->SetDrawsContent(true); | 154 grand_child2->SetDrawsContent(true); |
154 | 155 |
155 child1->test_properties()->AddChild(std::move(grand_child1)); | 156 child1->test_properties()->AddChild(std::move(grand_child1)); |
156 child1->test_properties()->AddChild(std::move(grand_child2)); | 157 child1->test_properties()->AddChild(std::move(grand_child2)); |
157 root->test_properties()->AddChild(std::move(child1)); | 158 root->test_properties()->AddChild(std::move(child1)); |
158 root->test_properties()->AddChild(std::move(child2)); | 159 root->test_properties()->AddChild(std::move(child2)); |
159 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); | 160 host_impl_.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 161 host_impl_.active_tree()->SetElementIdsForTesting(); |
160 | 162 |
161 return host_impl_.active_tree()->root_layer_for_testing(); | 163 return host_impl_.active_tree()->root_layer_for_testing(); |
162 } | 164 } |
163 | 165 |
164 LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { | 166 LayerImpl* CreateAndSetUpTestTreeWithOneSurface(int number_of_children = 1) { |
165 LayerImpl* root = CreateTestTreeWithOneSurface(number_of_children); | 167 LayerImpl* root = CreateTestTreeWithOneSurface(number_of_children); |
166 | 168 |
167 // Setup includes going past the first frame which always damages | 169 // Setup includes going past the first frame which always damages |
168 // everything, so that we can actually perform specific tests. | 170 // everything, so that we can actually perform specific tests. |
169 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 171 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 388 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
387 LayerImpl* child = root->test_properties()->children[0]; | 389 LayerImpl* child = root->test_properties()->children[0]; |
388 | 390 |
389 // CASE 1: The layer's property changed flag takes priority over update rect. | 391 // CASE 1: The layer's property changed flag takes priority over update rect. |
390 // | 392 // |
391 child->test_properties()->force_render_surface = true; | 393 child->test_properties()->force_render_surface = true; |
392 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 394 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
393 EmulateDrawingOneFrame(root); | 395 EmulateDrawingOneFrame(root); |
394 ClearDamageForAllSurfaces(root); | 396 ClearDamageForAllSurfaces(root); |
395 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); | 397 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); |
396 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 398 root->layer_tree_impl()->SetTreeLayerOpacityMutated(child->element_id(), |
397 0.5f, child->effect_tree_index(), root->layer_tree_impl()); | 399 0.5f); |
398 EmulateDrawingOneFrame(root); | 400 EmulateDrawingOneFrame(root); |
399 | 401 |
400 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); | 402 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); |
401 | 403 |
402 // Damage should be the entire child layer in target_surface space. | 404 // Damage should be the entire child layer in target_surface space. |
403 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); | 405 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); |
404 gfx::Rect root_damage_rect; | 406 gfx::Rect root_damage_rect; |
405 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 407 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
406 &root_damage_rect)); | 408 &root_damage_rect)); |
407 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); | 409 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); |
408 | 410 |
409 // CASE 2: If a layer moves due to property change, it damages both the new | 411 // CASE 2: If a layer moves due to property change, it damages both the new |
410 // location and the old (exposed) location. The old location is the | 412 // location and the old (exposed) location. The old location is the |
411 // entire old layer, not just the update_rect. | 413 // entire old layer, not just the update_rect. |
412 | 414 |
413 // Cycle one frame of no change, just to sanity check that the next rect is | 415 // Cycle one frame of no change, just to sanity check that the next rect is |
414 // not because of the old damage state. | 416 // not because of the old damage state. |
415 ClearDamageForAllSurfaces(root); | 417 ClearDamageForAllSurfaces(root); |
416 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 418 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
417 EmulateDrawingOneFrame(root); | 419 EmulateDrawingOneFrame(root); |
418 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 420 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
419 &root_damage_rect)); | 421 &root_damage_rect)); |
420 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 422 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
421 | 423 |
422 // Then, test the actual layer movement. | 424 // Then, test the actual layer movement. |
423 ClearDamageForAllSurfaces(root); | 425 ClearDamageForAllSurfaces(root); |
424 gfx::Transform translation; | 426 gfx::Transform translation; |
425 translation.Translate(100.f, 130.f); | 427 translation.Translate(100.f, 130.f); |
426 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 428 root->layer_tree_impl()->SetTreeLayerTransformMutated(child->element_id(), |
427 translation, child->transform_tree_index(), root->layer_tree_impl()); | 429 translation); |
428 EmulateDrawingOneFrame(root); | 430 EmulateDrawingOneFrame(root); |
429 | 431 |
430 // Expect damage to be the combination of the previous one and the new one. | 432 // Expect damage to be the combination of the previous one and the new one. |
431 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); | 433 expected_rect.Union(gfx::Rect(200, 230, 30, 30)); |
432 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 434 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
433 &root_damage_rect)); | 435 &root_damage_rect)); |
434 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); | 436 EXPECT_FLOAT_RECT_EQ(expected_rect, root_damage_rect); |
435 } | 437 } |
436 | 438 |
437 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { | 439 TEST_F(DamageTrackerTest, VerifyDamageWhenSurfaceRemoved) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 // Sanity check that the layer actually moved to (85, 85), damaging its old | 477 // Sanity check that the layer actually moved to (85, 85), damaging its old |
476 // location and new location. | 478 // location and new location. |
477 gfx::Rect root_damage_rect; | 479 gfx::Rect root_damage_rect; |
478 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 480 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
479 &root_damage_rect)); | 481 &root_damage_rect)); |
480 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); | 482 EXPECT_EQ(gfx::Rect(85, 85, 45, 45).ToString(), root_damage_rect.ToString()); |
481 | 483 |
482 // With the anchor on the layer's center, now we can test the rotation more | 484 // With the anchor on the layer's center, now we can test the rotation more |
483 // intuitively, since it applies about the layer's anchor. | 485 // intuitively, since it applies about the layer's anchor. |
484 ClearDamageForAllSurfaces(root); | 486 ClearDamageForAllSurfaces(root); |
485 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 487 root->layer_tree_impl()->SetTreeLayerTransformMutated(child->element_id(), |
486 rotation, child->transform_tree_index(), root->layer_tree_impl()); | 488 rotation); |
487 EmulateDrawingOneFrame(root); | 489 EmulateDrawingOneFrame(root); |
488 | 490 |
489 // Since the child layer is square, rotation by 45 degrees about the center | 491 // Since the child layer is square, rotation by 45 degrees about the center |
490 // should increase the size of the expected rect by sqrt(2), centered around | 492 // should increase the size of the expected rect by sqrt(2), centered around |
491 // (100, 100). The old exposed region should be fully contained in the new | 493 // (100, 100). The old exposed region should be fully contained in the new |
492 // region. | 494 // region. |
493 float expected_width = 30.f * sqrt(2.f); | 495 float expected_width = 30.f * sqrt(2.f); |
494 float expected_position = 100.f - 0.5f * expected_width; | 496 float expected_position = 100.f - 0.5f * expected_width; |
495 gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( | 497 gfx::Rect expected_rect = gfx::ToEnclosingRect(gfx::RectF( |
496 expected_position, expected_position, expected_width, expected_width)); | 498 expected_position, expected_position, expected_width, expected_width)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 gfx::RectF test_rect(child->position(), gfx::SizeF(child->bounds())); | 535 gfx::RectF test_rect(child->position(), gfx::SizeF(child->bounds())); |
534 bool clipped = false; | 536 bool clipped = false; |
535 MathUtil::MapQuad(transform, gfx::QuadF(test_rect), &clipped); | 537 MathUtil::MapQuad(transform, gfx::QuadF(test_rect), &clipped); |
536 EXPECT_TRUE(clipped); | 538 EXPECT_TRUE(clipped); |
537 | 539 |
538 // Damage the child without moving it. | 540 // Damage the child without moving it. |
539 child->test_properties()->force_render_surface = true; | 541 child->test_properties()->force_render_surface = true; |
540 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 542 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
541 EmulateDrawingOneFrame(root); | 543 EmulateDrawingOneFrame(root); |
542 ClearDamageForAllSurfaces(root); | 544 ClearDamageForAllSurfaces(root); |
543 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 545 root->layer_tree_impl()->SetTreeLayerOpacityMutated(child->element_id(), |
544 0.5f, child->effect_tree_index(), root->layer_tree_impl()); | 546 0.5f); |
545 EmulateDrawingOneFrame(root); | 547 EmulateDrawingOneFrame(root); |
546 | 548 |
547 // The expected damage should cover the entire root surface (500x500), but we | 549 // The expected damage should cover the entire root surface (500x500), but we |
548 // don't care whether the damage rect was clamped or is larger than the | 550 // don't care whether the damage rect was clamped or is larger than the |
549 // surface for this test. | 551 // surface for this test. |
550 gfx::Rect root_damage_rect; | 552 gfx::Rect root_damage_rect; |
551 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 553 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
552 &root_damage_rect)); | 554 &root_damage_rect)); |
553 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); | 555 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); |
554 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); | 556 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 596 |
595 FilterOperations filters; | 597 FilterOperations filters; |
596 filters.Append(FilterOperation::CreateReferenceFilter( | 598 filters.Append(FilterOperation::CreateReferenceFilter( |
597 SkBlurImageFilter::Make(2, 2, nullptr))); | 599 SkBlurImageFilter::Make(2, 2, nullptr))); |
598 | 600 |
599 // Setting the filter will damage the whole surface. | 601 // Setting the filter will damage the whole surface. |
600 ClearDamageForAllSurfaces(root); | 602 ClearDamageForAllSurfaces(root); |
601 child->test_properties()->force_render_surface = true; | 603 child->test_properties()->force_render_surface = true; |
602 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 604 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
603 EmulateDrawingOneFrame(root); | 605 EmulateDrawingOneFrame(root); |
604 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 606 child->layer_tree_impl()->SetTreeLayerFilterMutated(child->element_id(), |
605 filters, child->effect_tree_index(), child->layer_tree_impl()); | 607 filters); |
606 EmulateDrawingOneFrame(root); | 608 EmulateDrawingOneFrame(root); |
607 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 609 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
608 &root_damage_rect)); | 610 &root_damage_rect)); |
609 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 611 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
610 &child_damage_rect)); | 612 &child_damage_rect)); |
611 | 613 |
612 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. | 614 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. |
613 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); | 615 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); |
614 | 616 |
615 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. | 617 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. |
(...skipping 29 matching lines...) Expand all Loading... |
645 SkBlurImageFilter::Make(2, 2, nullptr))); | 647 SkBlurImageFilter::Make(2, 2, nullptr))); |
646 | 648 |
647 // Setting the filter will damage the whole surface. | 649 // Setting the filter will damage the whole surface. |
648 gfx::Transform transform; | 650 gfx::Transform transform; |
649 transform.RotateAboutYAxis(60); | 651 transform.RotateAboutYAxis(60); |
650 ClearDamageForAllSurfaces(root); | 652 ClearDamageForAllSurfaces(root); |
651 child->test_properties()->force_render_surface = true; | 653 child->test_properties()->force_render_surface = true; |
652 child->test_properties()->transform = transform; | 654 child->test_properties()->transform = transform; |
653 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 655 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
654 EmulateDrawingOneFrame(root); | 656 EmulateDrawingOneFrame(root); |
655 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 657 child->layer_tree_impl()->SetTreeLayerFilterMutated(child->element_id(), |
656 filters, child->effect_tree_index(), child->layer_tree_impl()); | 658 filters); |
657 EmulateDrawingOneFrame(root); | 659 EmulateDrawingOneFrame(root); |
658 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 660 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
659 &root_damage_rect)); | 661 &root_damage_rect)); |
660 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 662 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
661 &child_damage_rect)); | 663 &child_damage_rect)); |
662 | 664 |
663 // Blur outset is 6px for a 2px blur. | 665 // Blur outset is 6px for a 2px blur. |
664 int blur_outset = 6; | 666 int blur_outset = 6; |
665 int rotated_outset_left = blur_outset / 2; | 667 int rotated_outset_left = blur_outset / 2; |
666 int expected_rotated_width = (30 + 2 * blur_outset) / 2; | 668 int expected_rotated_width = (30 + 2 * blur_outset) / 2; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 703 |
702 FilterOperations filters; | 704 FilterOperations filters; |
703 filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 705 filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
704 | 706 |
705 // Setting the filter will damage the whole surface. | 707 // Setting the filter will damage the whole surface. |
706 ClearDamageForAllSurfaces(root); | 708 ClearDamageForAllSurfaces(root); |
707 child->test_properties()->force_render_surface = true; | 709 child->test_properties()->force_render_surface = true; |
708 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 710 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
709 int device_scale_factor = 2; | 711 int device_scale_factor = 2; |
710 EmulateDrawingOneFrame(root, device_scale_factor); | 712 EmulateDrawingOneFrame(root, device_scale_factor); |
711 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( | 713 child->layer_tree_impl()->SetTreeLayerFilterMutated(child->element_id(), |
712 filters, child->effect_tree_index(), child->layer_tree_impl()); | 714 filters); |
713 EmulateDrawingOneFrame(root, device_scale_factor); | 715 EmulateDrawingOneFrame(root, device_scale_factor); |
714 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 716 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
715 &root_damage_rect)); | 717 &root_damage_rect)); |
716 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 718 EXPECT_TRUE(child->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
717 &child_damage_rect)); | 719 &child_damage_rect)); |
718 | 720 |
719 // Blur outset is 9px for a 3px blur, scaled up by DSF. | 721 // Blur outset is 9px for a 3px blur, scaled up by DSF. |
720 int blur_outset = 9 * device_scale_factor; | 722 int blur_outset = 9 * device_scale_factor; |
721 gfx::Rect original_rect(100, 100, 100, 100); | 723 gfx::Rect original_rect(100, 100, 100, 100); |
722 gfx::Rect expected_child_damage_rect(60, 60); | 724 gfx::Rect expected_child_damage_rect(60, 60); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 child2->test_properties()->force_render_surface = true; | 1004 child2->test_properties()->force_render_surface = true; |
1003 grand_child1->test_properties()->force_render_surface = true; | 1005 grand_child1->test_properties()->force_render_surface = true; |
1004 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1006 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1005 EmulateDrawingOneFrame(root); | 1007 EmulateDrawingOneFrame(root); |
1006 gfx::Rect child_damage_rect; | 1008 gfx::Rect child_damage_rect; |
1007 gfx::Rect root_damage_rect; | 1009 gfx::Rect root_damage_rect; |
1008 | 1010 |
1009 // CASE 1: Damage to a descendant surface should propagate properly to | 1011 // CASE 1: Damage to a descendant surface should propagate properly to |
1010 // ancestor surface. | 1012 // ancestor surface. |
1011 ClearDamageForAllSurfaces(root); | 1013 ClearDamageForAllSurfaces(root); |
1012 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1014 root->layer_tree_impl()->SetTreeLayerOpacityMutated( |
1013 0.5f, grand_child1->effect_tree_index(), root->layer_tree_impl()); | 1015 grand_child1->element_id(), 0.5f); |
1014 EmulateDrawingOneFrame(root); | 1016 EmulateDrawingOneFrame(root); |
1015 EXPECT_TRUE( | 1017 EXPECT_TRUE( |
1016 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1018 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1017 &child_damage_rect)); | 1019 &child_damage_rect)); |
1018 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1020 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1019 &root_damage_rect)); | 1021 &root_damage_rect)); |
1020 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1022 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
1021 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); | 1023 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); |
1022 | 1024 |
1023 // CASE 2: Same as previous case, but with additional damage elsewhere that | 1025 // CASE 2: Same as previous case, but with additional damage elsewhere that |
1024 // should be properly unioned. | 1026 // should be properly unioned. |
1025 // - child1 surface damage in root surface space: | 1027 // - child1 surface damage in root surface space: |
1026 // gfx::Rect(300, 300, 6, 8); | 1028 // gfx::Rect(300, 300, 6, 8); |
1027 // - child2 damage in root surface space: | 1029 // - child2 damage in root surface space: |
1028 // gfx::Rect(11, 11, 18, 18); | 1030 // gfx::Rect(11, 11, 18, 18); |
1029 ClearDamageForAllSurfaces(root); | 1031 ClearDamageForAllSurfaces(root); |
1030 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1032 root->layer_tree_impl()->SetTreeLayerOpacityMutated( |
1031 0.7f, grand_child1->effect_tree_index(), root->layer_tree_impl()); | 1033 grand_child1->element_id(), 0.7f); |
1032 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated( | 1034 root->layer_tree_impl()->SetTreeLayerOpacityMutated(child2->element_id(), |
1033 0.7f, child2->effect_tree_index(), root->layer_tree_impl()); | 1035 0.7f); |
1034 EmulateDrawingOneFrame(root); | 1036 EmulateDrawingOneFrame(root); |
1035 EXPECT_TRUE( | 1037 EXPECT_TRUE( |
1036 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1038 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1037 &child_damage_rect)); | 1039 &child_damage_rect)); |
1038 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1040 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1039 &root_damage_rect)); | 1041 &root_damage_rect)); |
1040 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); | 1042 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); |
1041 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), | 1043 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), |
1042 root_damage_rect.ToString()); | 1044 root_damage_rect.ToString()); |
1043 } | 1045 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 // transforming it, while the root surface would be damaged appropriately. | 1094 // transforming it, while the root surface would be damaged appropriately. |
1093 | 1095 |
1094 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 1096 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
1095 LayerImpl* child1 = root->test_properties()->children[0]; | 1097 LayerImpl* child1 = root->test_properties()->children[0]; |
1096 gfx::Rect child_damage_rect; | 1098 gfx::Rect child_damage_rect; |
1097 gfx::Rect root_damage_rect; | 1099 gfx::Rect root_damage_rect; |
1098 | 1100 |
1099 ClearDamageForAllSurfaces(root); | 1101 ClearDamageForAllSurfaces(root); |
1100 gfx::Transform translation; | 1102 gfx::Transform translation; |
1101 translation.Translate(-50.f, -50.f); | 1103 translation.Translate(-50.f, -50.f); |
1102 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 1104 root->layer_tree_impl()->SetTreeLayerTransformMutated(child1->element_id(), |
1103 translation, child1->transform_tree_index(), root->layer_tree_impl()); | 1105 translation); |
1104 EmulateDrawingOneFrame(root); | 1106 EmulateDrawingOneFrame(root); |
1105 EXPECT_TRUE( | 1107 EXPECT_TRUE( |
1106 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1108 child1->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1107 &child_damage_rect)); | 1109 &child_damage_rect)); |
1108 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1110 EXPECT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1109 &root_damage_rect)); | 1111 &root_damage_rect)); |
1110 | 1112 |
1111 // The new surface bounds should be damaged entirely. | 1113 // The new surface bounds should be damaged entirely. |
1112 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), | 1114 EXPECT_EQ(gfx::Rect(190, 190, 16, 18).ToString(), |
1113 child_damage_rect.ToString()); | 1115 child_damage_rect.ToString()); |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 ASSERT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( | 1713 ASSERT_TRUE(root->GetRenderSurface()->damage_tracker()->GetDamageRectIfValid( |
1712 &damage_rect)); | 1714 &damage_rect)); |
1713 EXPECT_TRUE(damage_rect.Contains(root->GetRenderSurface()->content_rect())); | 1715 EXPECT_TRUE(damage_rect.Contains(root->GetRenderSurface()->content_rect())); |
1714 EXPECT_TRUE(damage_rect.Contains( | 1716 EXPECT_TRUE(damage_rect.Contains( |
1715 gfx::ToEnclosingRect(child1->GetRenderSurface()->DrawableContentRect()))); | 1717 gfx::ToEnclosingRect(child1->GetRenderSurface()->DrawableContentRect()))); |
1716 EXPECT_EQ(damage_rect, root->GetRenderSurface()->GetDamageRect()); | 1718 EXPECT_EQ(damage_rect, root->GetRenderSurface()->GetDamageRect()); |
1717 } | 1719 } |
1718 | 1720 |
1719 } // namespace | 1721 } // namespace |
1720 } // namespace cc | 1722 } // namespace cc |
OLD | NEW |