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