Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: cc/trees/damage_tracker_unittest.cc

Issue 2110683004: cc: Move filters to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/animation_timelines_test_common.cc ('k') | cc/trees/draw_property_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Iterate back-to-front, so that damage correctly propagates from descendant 60 // Iterate back-to-front, so that damage correctly propagates from descendant
61 // surfaces to ancestors. 61 // surfaces to ancestors.
62 size_t render_surface_layer_list_size = render_surface_layer_list.size(); 62 size_t render_surface_layer_list_size = render_surface_layer_list.size();
63 for (size_t i = 0; i < render_surface_layer_list_size; ++i) { 63 for (size_t i = 0; i < render_surface_layer_list_size; ++i) {
64 size_t index = render_surface_layer_list_size - 1 - i; 64 size_t index = render_surface_layer_list_size - 1 - i;
65 RenderSurfaceImpl* target_surface = 65 RenderSurfaceImpl* target_surface =
66 render_surface_layer_list[index]->render_surface(); 66 render_surface_layer_list[index]->render_surface();
67 target_surface->damage_tracker()->UpdateDamageTrackingState( 67 target_surface->damage_tracker()->UpdateDamageTrackingState(
68 target_surface->layer_list(), target_surface, 68 target_surface->layer_list(), target_surface,
69 target_surface->SurfacePropertyChangedOnlyFromDescendant(), 69 target_surface->SurfacePropertyChangedOnlyFromDescendant(),
70 target_surface->content_rect(), 70 target_surface->content_rect(), target_surface->MaskLayer(),
71 render_surface_layer_list[index]->render_surface()->MaskLayer(), 71 target_surface->Filters());
72 render_surface_layer_list[index]->filters());
73 } 72 }
74 73
75 root->layer_tree_impl()->ResetAllChangeTracking(); 74 root->layer_tree_impl()->ResetAllChangeTracking();
76 } 75 }
77 76
78 class DamageTrackerTest : public testing::Test { 77 class DamageTrackerTest : public testing::Test {
79 public: 78 public:
80 DamageTrackerTest() 79 DamageTrackerTest()
81 : host_impl_(&task_runner_provider_, 80 : host_impl_(&task_runner_provider_,
82 &shared_bitmap_manager_, 81 &shared_bitmap_manager_,
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { 534 TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) {
536 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces(); 535 LayerImpl* root = CreateAndSetUpTestTreeWithTwoSurfaces();
537 LayerImpl* surface = root->test_properties()->children[0]; 536 LayerImpl* surface = root->test_properties()->children[0];
538 LayerImpl* child = surface->test_properties()->children[0]; 537 LayerImpl* child = surface->test_properties()->children[0];
539 538
540 FilterOperations filters; 539 FilterOperations filters;
541 filters.Append(FilterOperation::CreateBlurFilter(5.f)); 540 filters.Append(FilterOperation::CreateBlurFilter(5.f));
542 541
543 // Setting the filter will damage the whole surface. 542 // Setting the filter will damage the whole surface.
544 ClearDamageForAllSurfaces(root); 543 ClearDamageForAllSurfaces(root);
545 surface->SetFilters(filters); 544 surface->test_properties()->filters = filters;
546 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 545 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
547 EmulateDrawingOneFrame(root); 546 EmulateDrawingOneFrame(root);
548 547
549 // Setting the update rect should cause the corresponding damage to the 548 // Setting the update rect should cause the corresponding damage to the
550 // surface, blurred based on the size of the blur filter. 549 // surface, blurred based on the size of the blur filter.
551 ClearDamageForAllSurfaces(root); 550 ClearDamageForAllSurfaces(root);
552 child->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); 551 child->SetUpdateRect(gfx::Rect(1, 2, 3, 4));
553 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 552 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
554 EmulateDrawingOneFrame(root); 553 EmulateDrawingOneFrame(root);
555 554
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 586
588 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter. 587 // gfx::Rect(100, 100, 30, 30), expanded by 6px for the 2px blur filter.
589 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect); 588 EXPECT_EQ(gfx::Rect(94, 94, 42, 42), root_damage_rect);
590 589
591 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter. 590 // gfx::Rect(0, 0, 30, 30), expanded by 6px for the 2px blur filter.
592 EXPECT_EQ(gfx::Rect(-6, -6, 42, 42), child_damage_rect); 591 EXPECT_EQ(gfx::Rect(-6, -6, 42, 42), child_damage_rect);
593 592
594 // CASE 1: Setting the update rect should damage the whole surface (for now) 593 // CASE 1: Setting the update rect should damage the whole surface (for now)
595 ClearDamageForAllSurfaces(root); 594 ClearDamageForAllSurfaces(root);
596 child->SetUpdateRect(gfx::Rect(1, 1)); 595 child->SetUpdateRect(gfx::Rect(1, 1));
597 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
598 EmulateDrawingOneFrame(root); 596 EmulateDrawingOneFrame(root);
599 597
600 root_damage_rect = 598 root_damage_rect =
601 root->render_surface()->damage_tracker()->current_damage_rect(); 599 root->render_surface()->damage_tracker()->current_damage_rect();
602 child_damage_rect = 600 child_damage_rect =
603 child->render_surface()->damage_tracker()->current_damage_rect(); 601 child->render_surface()->damage_tracker()->current_damage_rect();
604 602
605 // gfx::Rect(100, 100, 1, 1), expanded by 6px for the 2px blur filter. 603 // gfx::Rect(100, 100, 1, 1), expanded by 6px for the 2px blur filter.
606 EXPECT_EQ(gfx::Rect(94, 94, 13, 13), root_damage_rect); 604 EXPECT_EQ(gfx::Rect(94, 94, 13, 13), root_damage_rect);
607 605
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 expected_rotated_width, 30 + 2 * blur_outset); 642 expected_rotated_width, 30 + 2 * blur_outset);
645 expected_root_damage.Union(gfx::Rect(100, 100, 30, 30)); 643 expected_root_damage.Union(gfx::Rect(100, 100, 30, 30));
646 EXPECT_EQ(expected_root_damage, root_damage_rect); 644 EXPECT_EQ(expected_root_damage, root_damage_rect);
647 EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, 30 + 2 * blur_outset, 645 EXPECT_EQ(gfx::Rect(-blur_outset, -blur_outset, 30 + 2 * blur_outset,
648 30 + 2 * blur_outset), 646 30 + 2 * blur_outset),
649 child_damage_rect); 647 child_damage_rect);
650 648
651 // Setting the update rect should damage the whole surface (for now) 649 // Setting the update rect should damage the whole surface (for now)
652 ClearDamageForAllSurfaces(root); 650 ClearDamageForAllSurfaces(root);
653 child->SetUpdateRect(gfx::Rect(30, 30)); 651 child->SetUpdateRect(gfx::Rect(30, 30));
654 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
655 EmulateDrawingOneFrame(root); 652 EmulateDrawingOneFrame(root);
656 653
657 root_damage_rect = 654 root_damage_rect =
658 root->render_surface()->damage_tracker()->current_damage_rect(); 655 root->render_surface()->damage_tracker()->current_damage_rect();
659 child_damage_rect = 656 child_damage_rect =
660 child->render_surface()->damage_tracker()->current_damage_rect(); 657 child->render_surface()->damage_tracker()->current_damage_rect();
661 658
662 int expect_width = 30 + 2 * blur_outset; 659 int expect_width = 30 + 2 * blur_outset;
663 int expect_height = 30 + 2 * blur_outset; 660 int expect_height = 30 + 2 * blur_outset;
664 EXPECT_EQ(gfx::Rect(100 - blur_outset / 2, 100 - blur_outset, 661 EXPECT_EQ(gfx::Rect(100 - blur_outset / 2, 100 - blur_outset,
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 gfx::Rect root_damage_rect = 1615 gfx::Rect root_damage_rect =
1619 root->render_surface()->damage_tracker()->current_damage_rect(); 1616 root->render_surface()->damage_tracker()->current_damage_rect();
1620 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1617 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1621 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1618 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1622 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1619 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1623 } 1620 }
1624 } 1621 }
1625 1622
1626 } // namespace 1623 } // namespace
1627 } // namespace cc 1624 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/animation_timelines_test_common.cc ('k') | cc/trees/draw_property_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698