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

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

Issue 2253233003: cc : Add OnOpacityAnimated to effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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
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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); 373 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface();
374 LayerImpl* child = root->test_properties()->children[0]; 374 LayerImpl* child = root->test_properties()->children[0];
375 375
376 // CASE 1: The layer's property changed flag takes priority over update rect. 376 // CASE 1: The layer's property changed flag takes priority over update rect.
377 // 377 //
378 child->test_properties()->force_render_surface = true; 378 child->test_properties()->force_render_surface = true;
379 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 379 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
380 EmulateDrawingOneFrame(root); 380 EmulateDrawingOneFrame(root);
381 ClearDamageForAllSurfaces(root); 381 ClearDamageForAllSurfaces(root);
382 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); 382 child->SetUpdateRect(gfx::Rect(10, 11, 12, 13));
383 child->OnOpacityAnimated(0.5f); 383 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated(
384 0.5f, child->effect_tree_index(), root->layer_tree_impl());
384 EmulateDrawingOneFrame(root); 385 EmulateDrawingOneFrame(root);
385 386
386 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); 387 ASSERT_EQ(2u, root->render_surface()->layer_list().size());
387 388
388 // Damage should be the entire child layer in target_surface space. 389 // Damage should be the entire child layer in target_surface space.
389 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30); 390 gfx::Rect expected_rect = gfx::Rect(100, 100, 30, 30);
390 gfx::Rect root_damage_rect = 391 gfx::Rect root_damage_rect =
391 root->render_surface()->damage_tracker()->current_damage_rect(); 392 root->render_surface()->damage_tracker()->current_damage_rect();
392 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString()); 393 EXPECT_EQ(expected_rect.ToString(), root_damage_rect.ToString());
393 394
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); 515 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f)));
515 bool clipped = false; 516 bool clipped = false;
516 MathUtil::MapQuad(transform, test_quad, &clipped); 517 MathUtil::MapQuad(transform, test_quad, &clipped);
517 EXPECT_TRUE(clipped); 518 EXPECT_TRUE(clipped);
518 519
519 // Damage the child without moving it. 520 // Damage the child without moving it.
520 child->test_properties()->force_render_surface = true; 521 child->test_properties()->force_render_surface = true;
521 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 522 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
522 EmulateDrawingOneFrame(root); 523 EmulateDrawingOneFrame(root);
523 ClearDamageForAllSurfaces(root); 524 ClearDamageForAllSurfaces(root);
524 child->OnOpacityAnimated(0.5f); 525 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated(
526 0.5f, child->effect_tree_index(), root->layer_tree_impl());
525 EmulateDrawingOneFrame(root); 527 EmulateDrawingOneFrame(root);
526 528
527 // The expected damage should cover the entire root surface (500x500), but we 529 // The expected damage should cover the entire root surface (500x500), but we
528 // don't care whether the damage rect was clamped or is larger than the 530 // don't care whether the damage rect was clamped or is larger than the
529 // surface for this test. 531 // surface for this test.
530 gfx::Rect root_damage_rect = 532 gfx::Rect root_damage_rect =
531 root->render_surface()->damage_tracker()->current_damage_rect(); 533 root->render_surface()->damage_tracker()->current_damage_rect();
532 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500)); 534 gfx::Rect damage_we_care_about = gfx::Rect(gfx::Size(500, 500));
533 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); 535 EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about));
534 } 536 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 child2->test_properties()->force_render_surface = true; 975 child2->test_properties()->force_render_surface = true;
974 grand_child1->test_properties()->force_render_surface = true; 976 grand_child1->test_properties()->force_render_surface = true;
975 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 977 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
976 EmulateDrawingOneFrame(root); 978 EmulateDrawingOneFrame(root);
977 gfx::Rect child_damage_rect; 979 gfx::Rect child_damage_rect;
978 gfx::Rect root_damage_rect; 980 gfx::Rect root_damage_rect;
979 981
980 // CASE 1: Damage to a descendant surface should propagate properly to 982 // CASE 1: Damage to a descendant surface should propagate properly to
981 // ancestor surface. 983 // ancestor surface.
982 ClearDamageForAllSurfaces(root); 984 ClearDamageForAllSurfaces(root);
983 grand_child1->OnOpacityAnimated(0.5f); 985 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated(
986 0.5f, grand_child1->effect_tree_index(), root->layer_tree_impl());
984 EmulateDrawingOneFrame(root); 987 EmulateDrawingOneFrame(root);
985 child_damage_rect = 988 child_damage_rect =
986 child1->render_surface()->damage_tracker()->current_damage_rect(); 989 child1->render_surface()->damage_tracker()->current_damage_rect();
987 root_damage_rect = 990 root_damage_rect =
988 root->render_surface()->damage_tracker()->current_damage_rect(); 991 root->render_surface()->damage_tracker()->current_damage_rect();
989 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); 992 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString());
990 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString()); 993 EXPECT_EQ(gfx::Rect(300, 300, 6, 8).ToString(), root_damage_rect.ToString());
991 994
992 // CASE 2: Same as previous case, but with additional damage elsewhere that 995 // CASE 2: Same as previous case, but with additional damage elsewhere that
993 // should be properly unioned. 996 // should be properly unioned.
994 // - child1 surface damage in root surface space: 997 // - child1 surface damage in root surface space:
995 // gfx::Rect(300, 300, 6, 8); 998 // gfx::Rect(300, 300, 6, 8);
996 // - child2 damage in root surface space: 999 // - child2 damage in root surface space:
997 // gfx::Rect(11, 11, 18, 18); 1000 // gfx::Rect(11, 11, 18, 18);
998 ClearDamageForAllSurfaces(root); 1001 ClearDamageForAllSurfaces(root);
999 grand_child1->OnOpacityAnimated(0.7f); 1002 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated(
1000 child2->OnOpacityAnimated(0.7f); 1003 0.7f, grand_child1->effect_tree_index(), root->layer_tree_impl());
1004 root->layer_tree_impl()->property_trees()->effect_tree.OnOpacityAnimated(
1005 0.7f, child2->effect_tree_index(), root->layer_tree_impl());
1001 EmulateDrawingOneFrame(root); 1006 EmulateDrawingOneFrame(root);
1002 child_damage_rect = 1007 child_damage_rect =
1003 child1->render_surface()->damage_tracker()->current_damage_rect(); 1008 child1->render_surface()->damage_tracker()->current_damage_rect();
1004 root_damage_rect = 1009 root_damage_rect =
1005 root->render_surface()->damage_tracker()->current_damage_rect(); 1010 root->render_surface()->damage_tracker()->current_damage_rect();
1006 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString()); 1011 EXPECT_EQ(gfx::Rect(200, 200, 6, 8).ToString(), child_damage_rect.ToString());
1007 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(), 1012 EXPECT_EQ(gfx::Rect(11, 11, 295, 297).ToString(),
1008 root_damage_rect.ToString()); 1013 root_damage_rect.ToString());
1009 } 1014 }
1010 1015
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 gfx::Rect root_damage_rect = 1673 gfx::Rect root_damage_rect =
1669 root->render_surface()->damage_tracker()->current_damage_rect(); 1674 root->render_surface()->damage_tracker()->current_damage_rect();
1670 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1675 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1671 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1676 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1672 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1677 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1673 } 1678 }
1674 } 1679 }
1675 1680
1676 } // namespace 1681 } // namespace
1677 } // namespace cc 1682 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698