| 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 575 |
| 576 FilterOperations filters; | 576 FilterOperations filters; |
| 577 filters.Append(FilterOperation::CreateReferenceFilter( | 577 filters.Append(FilterOperation::CreateReferenceFilter( |
| 578 SkBlurImageFilter::Make(2, 2, nullptr))); | 578 SkBlurImageFilter::Make(2, 2, nullptr))); |
| 579 | 579 |
| 580 // Setting the filter will damage the whole surface. | 580 // Setting the filter will damage the whole surface. |
| 581 ClearDamageForAllSurfaces(root); | 581 ClearDamageForAllSurfaces(root); |
| 582 child->test_properties()->force_render_surface = true; | 582 child->test_properties()->force_render_surface = true; |
| 583 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 583 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 584 EmulateDrawingOneFrame(root); | 584 EmulateDrawingOneFrame(root); |
| 585 child->OnFilterAnimated(filters); | 585 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( |
| 586 filters, child->effect_tree_index(), child->layer_tree_impl()); |
| 586 EmulateDrawingOneFrame(root); | 587 EmulateDrawingOneFrame(root); |
| 587 root_damage_rect = | 588 root_damage_rect = |
| 588 root->render_surface()->damage_tracker()->current_damage_rect(); | 589 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 589 child_damage_rect = | 590 child_damage_rect = |
| 590 child->render_surface()->damage_tracker()->current_damage_rect(); | 591 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 591 | 592 |
| 592 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. | 593 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. |
| 593 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); | 594 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); |
| 594 | 595 |
| 595 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. | 596 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 625 SkBlurImageFilter::Make(2, 2, nullptr))); | 626 SkBlurImageFilter::Make(2, 2, nullptr))); |
| 626 | 627 |
| 627 // Setting the filter will damage the whole surface. | 628 // Setting the filter will damage the whole surface. |
| 628 gfx::Transform transform; | 629 gfx::Transform transform; |
| 629 transform.RotateAboutYAxis(60); | 630 transform.RotateAboutYAxis(60); |
| 630 ClearDamageForAllSurfaces(root); | 631 ClearDamageForAllSurfaces(root); |
| 631 child->test_properties()->force_render_surface = true; | 632 child->test_properties()->force_render_surface = true; |
| 632 child->test_properties()->transform = transform; | 633 child->test_properties()->transform = transform; |
| 633 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 634 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 634 EmulateDrawingOneFrame(root); | 635 EmulateDrawingOneFrame(root); |
| 635 child->OnFilterAnimated(filters); | 636 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( |
| 637 filters, child->effect_tree_index(), child->layer_tree_impl()); |
| 636 EmulateDrawingOneFrame(root); | 638 EmulateDrawingOneFrame(root); |
| 637 root_damage_rect = | 639 root_damage_rect = |
| 638 root->render_surface()->damage_tracker()->current_damage_rect(); | 640 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 639 child_damage_rect = | 641 child_damage_rect = |
| 640 child->render_surface()->damage_tracker()->current_damage_rect(); | 642 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 641 | 643 |
| 642 // Blur outset is 6px for a 2px blur. | 644 // Blur outset is 6px for a 2px blur. |
| 643 int blur_outset = 6; | 645 int blur_outset = 6; |
| 644 int rotated_outset_left = blur_outset / 2; | 646 int rotated_outset_left = blur_outset / 2; |
| 645 int expected_rotated_width = (30 + 2 * blur_outset) / 2; | 647 int expected_rotated_width = (30 + 2 * blur_outset) / 2; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 682 |
| 681 FilterOperations filters; | 683 FilterOperations filters; |
| 682 filters.Append(FilterOperation::CreateBlurFilter(3.f)); | 684 filters.Append(FilterOperation::CreateBlurFilter(3.f)); |
| 683 | 685 |
| 684 // Setting the filter will damage the whole surface. | 686 // Setting the filter will damage the whole surface. |
| 685 ClearDamageForAllSurfaces(root); | 687 ClearDamageForAllSurfaces(root); |
| 686 child->test_properties()->force_render_surface = true; | 688 child->test_properties()->force_render_surface = true; |
| 687 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 689 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 688 int device_scale_factor = 2; | 690 int device_scale_factor = 2; |
| 689 EmulateDrawingOneFrame(root, device_scale_factor); | 691 EmulateDrawingOneFrame(root, device_scale_factor); |
| 690 child->OnFilterAnimated(filters); | 692 child->layer_tree_impl()->property_trees()->effect_tree.OnFilterAnimated( |
| 693 filters, child->effect_tree_index(), child->layer_tree_impl()); |
| 691 EmulateDrawingOneFrame(root, device_scale_factor); | 694 EmulateDrawingOneFrame(root, device_scale_factor); |
| 692 root_damage_rect = | 695 root_damage_rect = |
| 693 root->render_surface()->damage_tracker()->current_damage_rect(); | 696 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 694 child_damage_rect = | 697 child_damage_rect = |
| 695 child->render_surface()->damage_tracker()->current_damage_rect(); | 698 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 696 | 699 |
| 697 // Blur outset is 9px for a 3px blur, scaled up by DSF. | 700 // Blur outset is 9px for a 3px blur, scaled up by DSF. |
| 698 int blur_outset = 9 * device_scale_factor; | 701 int blur_outset = 9 * device_scale_factor; |
| 699 gfx::Rect original_rect(100, 100, 100, 100); | 702 gfx::Rect original_rect(100, 100, 100, 100); |
| 700 gfx::Rect expected_child_damage_rect(60, 60); | 703 gfx::Rect expected_child_damage_rect(60, 60); |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 gfx::Rect root_damage_rect = | 1677 gfx::Rect root_damage_rect = |
| 1675 root->render_surface()->damage_tracker()->current_damage_rect(); | 1678 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1676 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1679 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1677 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1680 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1678 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1681 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1679 } | 1682 } |
| 1680 } | 1683 } |
| 1681 | 1684 |
| 1682 } // namespace | 1685 } // namespace |
| 1683 } // namespace cc | 1686 } // namespace cc |
| OLD | NEW |