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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 12648005: cc: Chromify the LayerTreeHostImpl class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compl Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/delegated_renderer_layer_impl.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/damage_tracker.h" 5 #include "cc/damage_tracker.h"
6 6
7 #include "cc/layer_impl.h" 7 #include "cc/layer_impl.h"
8 #include "cc/layer_tree_host_common.h" 8 #include "cc/layer_tree_host_common.h"
9 #include "cc/math_util.h" 9 #include "cc/math_util.h"
10 #include "cc/single_thread_proxy.h" 10 #include "cc/single_thread_proxy.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 class DamageTrackerTest : public testing::Test { 67 class DamageTrackerTest : public testing::Test {
68 public: 68 public:
69 DamageTrackerTest() 69 DamageTrackerTest()
70 : m_hostImpl(&m_proxy) 70 : m_hostImpl(&m_proxy)
71 { 71 {
72 } 72 }
73 73
74 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() 74 scoped_ptr<LayerImpl> createTestTreeWithOneSurface()
75 { 75 {
76 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.activeTree(), 1); 76 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.active_tree(), 1);
77 scoped_ptr<LayerImpl> child = LayerImpl::Create(m_hostImpl.activeTree(), 2); 77 scoped_ptr<LayerImpl> child = LayerImpl::Create(m_hostImpl.active_tree() , 2);
78 78
79 root->SetPosition(gfx::PointF()); 79 root->SetPosition(gfx::PointF());
80 root->SetAnchorPoint(gfx::PointF()); 80 root->SetAnchorPoint(gfx::PointF());
81 root->SetBounds(gfx::Size(500, 500)); 81 root->SetBounds(gfx::Size(500, 500));
82 root->SetContentBounds(gfx::Size(500, 500)); 82 root->SetContentBounds(gfx::Size(500, 500));
83 root->SetDrawsContent(true); 83 root->SetDrawsContent(true);
84 root->CreateRenderSurface(); 84 root->CreateRenderSurface();
85 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size (500, 500))); 85 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size (500, 500)));
86 86
87 child->SetPosition(gfx::PointF(100, 100)); 87 child->SetPosition(gfx::PointF(100, 100));
88 child->SetAnchorPoint(gfx::PointF()); 88 child->SetAnchorPoint(gfx::PointF());
89 child->SetBounds(gfx::Size(30, 30)); 89 child->SetBounds(gfx::Size(30, 30));
90 child->SetContentBounds(gfx::Size(30, 30)); 90 child->SetContentBounds(gfx::Size(30, 30));
91 child->SetDrawsContent(true); 91 child->SetDrawsContent(true);
92 root->AddChild(child.Pass()); 92 root->AddChild(child.Pass());
93 93
94 return root.Pass(); 94 return root.Pass();
95 } 95 }
96 96
97 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces() 97 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces()
98 { 98 {
99 // This test tree has two render surfaces: one for the root, and one for 99 // This test tree has two render surfaces: one for the root, and one for
100 // child1. Additionally, the root has a second child layer, and child1 h as two 100 // child1. Additionally, the root has a second child layer, and child1 h as two
101 // children of its own. 101 // children of its own.
102 102
103 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.activeTree(), 1); 103 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.active_tree(), 1);
104 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(m_hostImpl.activeTree() , 2); 104 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(m_hostImpl.active_tree( ), 2);
105 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3); 105 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.active_tree( ), 3);
106 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(m_hostImpl.activeT ree(), 4); 106 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(m_hostImpl.active_ tree(), 4);
107 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::Create(m_hostImpl.activeT ree(), 5); 107 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::Create(m_hostImpl.active_ tree(), 5);
108 108
109 root->SetPosition(gfx::PointF()); 109 root->SetPosition(gfx::PointF());
110 root->SetAnchorPoint(gfx::PointF()); 110 root->SetAnchorPoint(gfx::PointF());
111 root->SetBounds(gfx::Size(500, 500)); 111 root->SetBounds(gfx::Size(500, 500));
112 root->SetContentBounds(gfx::Size(500, 500)); 112 root->SetContentBounds(gfx::Size(500, 500));
113 root->SetDrawsContent(true); 113 root->SetDrawsContent(true);
114 root->CreateRenderSurface(); 114 root->CreateRenderSurface();
115 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size (500, 500))); 115 root->render_surface()->SetContentRect(gfx::Rect(gfx::Point(), gfx::Size (500, 500)));
116 116
117 child1->SetPosition(gfx::PointF(100, 100)); 117 child1->SetPosition(gfx::PointF(100, 100));
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer) 529 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer)
530 { 530 {
531 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 531 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
532 LayerImpl* child1 = root->children()[0]; 532 LayerImpl* child1 = root->children()[0];
533 533
534 // CASE 1: Adding a new layer should cause the appropriate damage. 534 // CASE 1: Adding a new layer should cause the appropriate damage.
535 // 535 //
536 clearDamageForAllSurfaces(root.get()); 536 clearDamageForAllSurfaces(root.get());
537 { 537 {
538 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3); 538 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.active_tree( ), 3);
539 child2->SetPosition(gfx::PointF(400, 380)); 539 child2->SetPosition(gfx::PointF(400, 380));
540 child2->SetAnchorPoint(gfx::PointF()); 540 child2->SetAnchorPoint(gfx::PointF());
541 child2->SetBounds(gfx::Size(6, 8)); 541 child2->SetBounds(gfx::Size(6, 8));
542 child2->SetContentBounds(gfx::Size(6, 8)); 542 child2->SetContentBounds(gfx::Size(6, 8));
543 child2->SetDrawsContent(true); 543 child2->SetDrawsContent(true);
544 root->AddChild(child2.Pass()); 544 root->AddChild(child2.Pass());
545 } 545 }
546 emulateDrawingOneFrame(root.get()); 546 emulateDrawingOneFrame(root.get());
547 547
548 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere. 548 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere.
(...skipping 20 matching lines...) Expand all
569 569
570 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer) 570 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer)
571 { 571 {
572 // If child2 is added to the layer tree, but it doesn't have any explicit da mage of 572 // If child2 is added to the layer tree, but it doesn't have any explicit da mage of
573 // its own, it should still indeed damage the target surface. 573 // its own, it should still indeed damage the target surface.
574 574
575 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 575 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
576 576
577 clearDamageForAllSurfaces(root.get()); 577 clearDamageForAllSurfaces(root.get());
578 { 578 {
579 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3); 579 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.active_tree( ), 3);
580 child2->SetPosition(gfx::PointF(400, 380)); 580 child2->SetPosition(gfx::PointF(400, 380));
581 child2->SetAnchorPoint(gfx::PointF()); 581 child2->SetAnchorPoint(gfx::PointF());
582 child2->SetBounds(gfx::Size(6, 8)); 582 child2->SetBounds(gfx::Size(6, 8));
583 child2->SetContentBounds(gfx::Size(6, 8)); 583 child2->SetContentBounds(gfx::Size(6, 8));
584 child2->SetDrawsContent(true); 584 child2->SetDrawsContent(true);
585 child2->ResetAllChangeTrackingForSubtree(); 585 child2->ResetAllChangeTrackingForSubtree();
586 // Sanity check the initial conditions of the test, if these asserts tri gger, it 586 // Sanity check the initial conditions of the test, if these asserts tri gger, it
587 // means the test no longer actually covers the intended scenario. 587 // means the test no longer actually covers the intended scenario.
588 ASSERT_FALSE(child2->LayerPropertyChanged()); 588 ASSERT_FALSE(child2->LayerPropertyChanged());
589 ASSERT_TRUE(child2->update_rect().IsEmpty()); 589 ASSERT_TRUE(child2->update_rect().IsEmpty());
590 root->AddChild(child2.Pass()); 590 root->AddChild(child2.Pass());
591 } 591 }
592 emulateDrawingOneFrame(root.get()); 592 emulateDrawingOneFrame(root.get());
593 593
594 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere. 594 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere.
595 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); 595 ASSERT_EQ(3u, root->render_surface()->layer_list().size());
596 596
597 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect(); 597 gfx::RectF rootDamageRect = root->render_surface()->damage_tracker()->curren t_damage_rect();
598 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect); 598 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect);
599 } 599 }
600 600
601 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers) 601 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers)
602 { 602 {
603 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 603 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
604 LayerImpl* child1 = root->children()[0]; 604 LayerImpl* child1 = root->children()[0];
605 605
606 // In this test we don't want the above tree manipulation to be considered p art of the same frame. 606 // In this test we don't want the above tree manipulation to be considered p art of the same frame.
607 clearDamageForAllSurfaces(root.get()); 607 clearDamageForAllSurfaces(root.get());
608 { 608 {
609 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.activeTree() , 3); 609 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(m_hostImpl.active_tree( ), 3);
610 child2->SetPosition(gfx::PointF(400, 380)); 610 child2->SetPosition(gfx::PointF(400, 380));
611 child2->SetAnchorPoint(gfx::PointF()); 611 child2->SetAnchorPoint(gfx::PointF());
612 child2->SetBounds(gfx::Size(6, 8)); 612 child2->SetBounds(gfx::Size(6, 8));
613 child2->SetContentBounds(gfx::Size(6, 8)); 613 child2->SetContentBounds(gfx::Size(6, 8));
614 child2->SetDrawsContent(true); 614 child2->SetDrawsContent(true);
615 root->AddChild(child2.Pass()); 615 root->AddChild(child2.Pass());
616 } 616 }
617 LayerImpl* child2 = root->children()[1]; 617 LayerImpl* child2 = root->children()[1];
618 emulateDrawingOneFrame(root.get()); 618 emulateDrawingOneFrame(root.get());
619 619
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 LayerImpl* grandChild2 = child1->children()[1]; 820 LayerImpl* grandChild2 = child1->children()[1];
821 821
822 // Damage on a surface that has a reflection should cause the target surface to 822 // Damage on a surface that has a reflection should cause the target surface to
823 // receive the surface's damage and the surface's reflected damage. 823 // receive the surface's damage and the surface's reflected damage.
824 824
825 // For this test case, we modify grandChild2, and add grandChild3 to extend the bounds 825 // For this test case, we modify grandChild2, and add grandChild3 to extend the bounds
826 // of child1's surface. This way, we can test reflection changes without cha nging 826 // of child1's surface. This way, we can test reflection changes without cha nging
827 // contentBounds of the surface. 827 // contentBounds of the surface.
828 grandChild2->SetPosition(gfx::PointF(180, 180)); 828 grandChild2->SetPosition(gfx::PointF(180, 180));
829 { 829 {
830 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::Create(m_hostImpl.activeT ree(), 6); 830 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::Create(m_hostImpl.active_ tree(), 6);
831 grandChild3->SetPosition(gfx::PointF(240, 240)); 831 grandChild3->SetPosition(gfx::PointF(240, 240));
832 grandChild3->SetAnchorPoint(gfx::PointF()); 832 grandChild3->SetAnchorPoint(gfx::PointF());
833 grandChild3->SetBounds(gfx::Size(10, 10)); 833 grandChild3->SetBounds(gfx::Size(10, 10));
834 grandChild3->SetContentBounds(gfx::Size(10, 10)); 834 grandChild3->SetContentBounds(gfx::Size(10, 10));
835 grandChild3->SetDrawsContent(true); 835 grandChild3->SetDrawsContent(true);
836 child1->AddChild(grandChild3.Pass()); 836 child1->AddChild(grandChild3.Pass());
837 } 837 }
838 child1->SetOpacity(0.5); 838 child1->SetOpacity(0.5);
839 emulateDrawingOneFrame(root.get()); 839 emulateDrawingOneFrame(root.get());
840 840
841 // CASE 1: adding a reflection about the left edge of grandChild1. 841 // CASE 1: adding a reflection about the left edge of grandChild1.
842 // 842 //
843 clearDamageForAllSurfaces(root.get()); 843 clearDamageForAllSurfaces(root.get());
844 { 844 {
845 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. activeTree(), 7); 845 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. active_tree(), 7);
846 grandChild1Replica->SetPosition(gfx::PointF()); 846 grandChild1Replica->SetPosition(gfx::PointF());
847 grandChild1Replica->SetAnchorPoint(gfx::PointF()); 847 grandChild1Replica->SetAnchorPoint(gfx::PointF());
848 gfx::Transform reflection; 848 gfx::Transform reflection;
849 reflection.Scale3d(-1, 1, 1); 849 reflection.Scale3d(-1, 1, 1);
850 grandChild1Replica->SetTransform(reflection); 850 grandChild1Replica->SetTransform(reflection);
851 grandChild1->SetReplicaLayer(grandChild1Replica.Pass()); 851 grandChild1->SetReplicaLayer(grandChild1Replica.Pass());
852 } 852 }
853 emulateDrawingOneFrame(root.get()); 853 emulateDrawingOneFrame(root.get());
854 854
855 gfx::RectF grandChildDamageRect = grandChild1->render_surface()->damage_trac ker()->current_damage_rect(); 855 gfx::RectF grandChildDamageRect = grandChild1->render_surface()->damage_trac ker()->current_damage_rect();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 903 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
904 LayerImpl* child = root->children()[0]; 904 LayerImpl* child = root->children()[0];
905 905
906 // In the current implementation of the damage tracker, changes to mask laye rs should 906 // In the current implementation of the damage tracker, changes to mask laye rs should
907 // damage the entire corresponding surface. 907 // damage the entire corresponding surface.
908 908
909 clearDamageForAllSurfaces(root.get()); 909 clearDamageForAllSurfaces(root.get());
910 910
911 // Set up the mask layer. 911 // Set up the mask layer.
912 { 912 {
913 scoped_ptr<LayerImpl> maskLayer = LayerImpl::Create(m_hostImpl.activeTre e(), 3); 913 scoped_ptr<LayerImpl> maskLayer = LayerImpl::Create(m_hostImpl.active_tr ee(), 3);
914 maskLayer->SetPosition(child->position()); 914 maskLayer->SetPosition(child->position());
915 maskLayer->SetAnchorPoint(gfx::PointF()); 915 maskLayer->SetAnchorPoint(gfx::PointF());
916 maskLayer->SetBounds(child->bounds()); 916 maskLayer->SetBounds(child->bounds());
917 maskLayer->SetContentBounds(child->bounds()); 917 maskLayer->SetContentBounds(child->bounds());
918 child->SetMaskLayer(maskLayer.Pass()); 918 child->SetMaskLayer(maskLayer.Pass());
919 } 919 }
920 LayerImpl* maskLayer = child->mask_layer(); 920 LayerImpl* maskLayer = child->mask_layer();
921 921
922 // Add opacity and a grandChild so that the render surface persists even aft er we remove the mask. 922 // Add opacity and a grandChild so that the render surface persists even aft er we remove the mask.
923 child->SetOpacity(0.5); 923 child->SetOpacity(0.5);
924 { 924 {
925 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(m_hostImpl.activeTr ee(), 4); 925 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(m_hostImpl.active_t ree(), 4);
926 grandChild->SetPosition(gfx::PointF(2, 2)); 926 grandChild->SetPosition(gfx::PointF(2, 2));
927 grandChild->SetAnchorPoint(gfx::PointF()); 927 grandChild->SetAnchorPoint(gfx::PointF());
928 grandChild->SetBounds(gfx::Size(2, 2)); 928 grandChild->SetBounds(gfx::Size(2, 2));
929 grandChild->SetContentBounds(gfx::Size(2, 2)); 929 grandChild->SetContentBounds(gfx::Size(2, 2));
930 grandChild->SetDrawsContent(true); 930 grandChild->SetDrawsContent(true);
931 child->AddChild(grandChild.Pass()); 931 child->AddChild(grandChild.Pass());
932 } 932 }
933 emulateDrawingOneFrame(root.get()); 933 emulateDrawingOneFrame(root.get());
934 934
935 // Sanity check that a new surface was created for the child. 935 // Sanity check that a new surface was created for the child.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 LayerImpl* child1 = root->children()[0]; 988 LayerImpl* child1 = root->children()[0];
989 LayerImpl* grandChild1 = child1->children()[0]; 989 LayerImpl* grandChild1 = child1->children()[0];
990 990
991 // Changes to a replica's mask should not damage the original surface, becau se it is 991 // Changes to a replica's mask should not damage the original surface, becau se it is
992 // not masked. But it does damage the ancestor target surface. 992 // not masked. But it does damage the ancestor target surface.
993 993
994 clearDamageForAllSurfaces(root.get()); 994 clearDamageForAllSurfaces(root.get());
995 995
996 // Create a reflection about the left edge of grandChild1. 996 // Create a reflection about the left edge of grandChild1.
997 { 997 {
998 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. activeTree(), 6); 998 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. active_tree(), 6);
999 grandChild1Replica->SetPosition(gfx::PointF()); 999 grandChild1Replica->SetPosition(gfx::PointF());
1000 grandChild1Replica->SetAnchorPoint(gfx::PointF()); 1000 grandChild1Replica->SetAnchorPoint(gfx::PointF());
1001 gfx::Transform reflection; 1001 gfx::Transform reflection;
1002 reflection.Scale3d(-1, 1, 1); 1002 reflection.Scale3d(-1, 1, 1);
1003 grandChild1Replica->SetTransform(reflection); 1003 grandChild1Replica->SetTransform(reflection);
1004 grandChild1->SetReplicaLayer(grandChild1Replica.Pass()); 1004 grandChild1->SetReplicaLayer(grandChild1Replica.Pass());
1005 } 1005 }
1006 LayerImpl* grandChild1Replica = grandChild1->replica_layer(); 1006 LayerImpl* grandChild1Replica = grandChild1->replica_layer();
1007 1007
1008 // Set up the mask layer on the replica layer 1008 // Set up the mask layer on the replica layer
1009 { 1009 {
1010 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::Create(m_hostImpl.ac tiveTree(), 7); 1010 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::Create(m_hostImpl.ac tive_tree(), 7);
1011 replicaMaskLayer->SetPosition(gfx::PointF()); 1011 replicaMaskLayer->SetPosition(gfx::PointF());
1012 replicaMaskLayer->SetAnchorPoint(gfx::PointF()); 1012 replicaMaskLayer->SetAnchorPoint(gfx::PointF());
1013 replicaMaskLayer->SetBounds(grandChild1->bounds()); 1013 replicaMaskLayer->SetBounds(grandChild1->bounds());
1014 replicaMaskLayer->SetContentBounds(grandChild1->bounds()); 1014 replicaMaskLayer->SetContentBounds(grandChild1->bounds());
1015 grandChild1Replica->SetMaskLayer(replicaMaskLayer.Pass()); 1015 grandChild1Replica->SetMaskLayer(replicaMaskLayer.Pass());
1016 } 1016 }
1017 LayerImpl* replicaMaskLayer = grandChild1Replica->mask_layer(); 1017 LayerImpl* replicaMaskLayer = grandChild1Replica->mask_layer();
1018 1018
1019 emulateDrawingOneFrame(root.get()); 1019 emulateDrawingOneFrame(root.get());
1020 1020
(...skipping 29 matching lines...) Expand all
1050 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 1050 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
1051 LayerImpl* child1 = root->children()[0]; 1051 LayerImpl* child1 = root->children()[0];
1052 LayerImpl* grandChild1 = child1->children()[0]; 1052 LayerImpl* grandChild1 = child1->children()[0];
1053 1053
1054 // Verify that the correct replicaOriginTransform is used for the replicaMas k; 1054 // Verify that the correct replicaOriginTransform is used for the replicaMas k;
1055 clearDamageForAllSurfaces(root.get()); 1055 clearDamageForAllSurfaces(root.get());
1056 1056
1057 grandChild1->SetAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a nchor being tested, but by convention its expected to be the same as the replica 's anchor point. 1057 grandChild1->SetAnchorPoint(gfx::PointF(1, 0)); // This is not exactly the a nchor being tested, but by convention its expected to be the same as the replica 's anchor point.
1058 1058
1059 { 1059 {
1060 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. activeTree(), 6); 1060 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::Create(m_hostImpl. active_tree(), 6);
1061 grandChild1Replica->SetPosition(gfx::PointF()); 1061 grandChild1Replica->SetPosition(gfx::PointF());
1062 grandChild1Replica->SetAnchorPoint(gfx::PointF(1, 0)); // This is the an chor being tested. 1062 grandChild1Replica->SetAnchorPoint(gfx::PointF(1, 0)); // This is the an chor being tested.
1063 gfx::Transform reflection; 1063 gfx::Transform reflection;
1064 reflection.Scale3d(-1, 1, 1); 1064 reflection.Scale3d(-1, 1, 1);
1065 grandChild1Replica->SetTransform(reflection); 1065 grandChild1Replica->SetTransform(reflection);
1066 grandChild1->SetReplicaLayer(grandChild1Replica.Pass()); 1066 grandChild1->SetReplicaLayer(grandChild1Replica.Pass());
1067 } 1067 }
1068 LayerImpl* grandChild1Replica = grandChild1->replica_layer(); 1068 LayerImpl* grandChild1Replica = grandChild1->replica_layer();
1069 1069
1070 // Set up the mask layer on the replica layer 1070 // Set up the mask layer on the replica layer
1071 { 1071 {
1072 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::Create(m_hostImpl.ac tiveTree(), 7); 1072 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::Create(m_hostImpl.ac tive_tree(), 7);
1073 replicaMaskLayer->SetPosition(gfx::PointF()); 1073 replicaMaskLayer->SetPosition(gfx::PointF());
1074 replicaMaskLayer->SetAnchorPoint(gfx::PointF()); // note, this is not th e anchor being tested. 1074 replicaMaskLayer->SetAnchorPoint(gfx::PointF()); // note, this is not th e anchor being tested.
1075 replicaMaskLayer->SetBounds(grandChild1->bounds()); 1075 replicaMaskLayer->SetBounds(grandChild1->bounds());
1076 replicaMaskLayer->SetContentBounds(grandChild1->bounds()); 1076 replicaMaskLayer->SetContentBounds(grandChild1->bounds());
1077 grandChild1Replica->SetMaskLayer(replicaMaskLayer.Pass()); 1077 grandChild1Replica->SetMaskLayer(replicaMaskLayer.Pass());
1078 } 1078 }
1079 LayerImpl* replicaMaskLayer = grandChild1Replica->mask_layer(); 1079 LayerImpl* replicaMaskLayer = grandChild1Replica->mask_layer();
1080 1080
1081 emulateDrawingOneFrame(root.get()); 1081 emulateDrawingOneFrame(root.get());
1082 1082
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 emulateDrawingOneFrame(root.get()); 1116 emulateDrawingOneFrame(root.get());
1117 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct(); 1117 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
1118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); 1118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect);
1119 } 1119 }
1120 1120
1121 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList) 1121 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList)
1122 { 1122 {
1123 // Though it should never happen, its a good idea to verify that the damage tracker 1123 // Though it should never happen, its a good idea to verify that the damage tracker
1124 // does not crash when it receives an empty layerList. 1124 // does not crash when it receives an empty layerList.
1125 1125
1126 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.activeTree(), 1); 1126 scoped_ptr<LayerImpl> root = LayerImpl::Create(m_hostImpl.active_tree(), 1);
1127 root->CreateRenderSurface(); 1127 root->CreateRenderSurface();
1128 1128
1129 ASSERT_TRUE(root == root->render_target()); 1129 ASSERT_TRUE(root == root->render_target());
1130 RenderSurfaceImpl* targetSurface = root->render_surface(); 1130 RenderSurfaceImpl* targetSurface = root->render_surface();
1131 targetSurface->ClearLayerLists(); 1131 targetSurface->ClearLayerLists();
1132 targetSurface->damage_tracker()->UpdateDamageTrackingState(targetSurface->la yer_list(), targetSurface->OwningLayerId(), false, gfx::Rect(), 0, WebFilterOper ations(), 0); 1132 targetSurface->damage_tracker()->UpdateDamageTrackingState(targetSurface->la yer_list(), targetSurface->OwningLayerId(), false, gfx::Rect(), 0, WebFilterOper ations(), 0);
1133 1133
1134 gfx::RectF damageRect = targetSurface->damage_tracker()->current_damage_rect (); 1134 gfx::RectF damageRect = targetSurface->damage_tracker()->current_damage_rect ();
1135 EXPECT_TRUE(damageRect.IsEmpty()); 1135 EXPECT_TRUE(damageRect.IsEmpty());
1136 } 1136 }
(...skipping 25 matching lines...) Expand all
1162 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1162 EXPECT_TRUE(rootDamageRect.IsEmpty());
1163 1163
1164 // Damage should remain empty even after one frame, since there's yet no new damage 1164 // Damage should remain empty even after one frame, since there's yet no new damage
1165 emulateDrawingOneFrame(root.get()); 1165 emulateDrawingOneFrame(root.get());
1166 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct(); 1166 rootDamageRect = root->render_surface()->damage_tracker()->current_damage_re ct();
1167 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1167 EXPECT_TRUE(rootDamageRect.IsEmpty());
1168 } 1168 }
1169 1169
1170 } // namespace 1170 } // namespace
1171 } // namespace cc 1171 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/delegated_renderer_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698