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

Side by Side Diff: cc/damage_tracker_unittest.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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 | « cc/cc_tests.gyp ('k') | cc/delegated_renderer_layer.h » ('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"
11 #include "cc/test/fake_impl_proxy.h"
12 #include "cc/test/fake_layer_tree_host_impl.h"
11 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 15 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
14 #include "ui/gfx/quad_f.h" 16 #include "ui/gfx/quad_f.h"
15 #include <public/WebFilterOperation.h> 17 #include <public/WebFilterOperation.h>
16 #include <public/WebFilterOperations.h> 18 #include <public/WebFilterOperations.h>
17 19
18 using namespace WebKit; 20 using namespace WebKit;
19 using namespace WebKitTests; 21 using namespace WebKitTests;
20 22
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 58
57 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors. 59 // Iterate back-to-front, so that damage correctly propagates from descendan t surfaces to ancestors.
58 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) { 60 for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) {
59 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf ace(); 61 RenderSurfaceImpl* targetSurface = renderSurfaceLayerList[i]->renderSurf ace();
60 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface- >layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i] ->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i]-> filter().get()); 62 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface- >layerList(), targetSurface->owningLayerId(), targetSurface->surfacePropertyChan gedOnlyFromDescendant(), targetSurface->contentRect(), renderSurfaceLayerList[i] ->maskLayer(), renderSurfaceLayerList[i]->filters(), renderSurfaceLayerList[i]-> filter().get());
61 } 63 }
62 64
63 root->resetAllChangeTrackingForSubtree(); 65 root->resetAllChangeTrackingForSubtree();
64 } 66 }
65 67
66 scoped_ptr<LayerImpl> createTestTreeWithOneSurface() 68 class DamageTrackerTest : public testing::Test {
67 { 69 public:
68 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 70 DamageTrackerTest()
69 scoped_ptr<LayerImpl> child = LayerImpl::create(2); 71 : m_hostImpl(&m_proxy)
72 {
73 }
70 74
71 root->setPosition(gfx::PointF()); 75 scoped_ptr<LayerImpl> createTestTreeWithOneSurface()
72 root->setAnchorPoint(gfx::PointF()); 76 {
73 root->setBounds(gfx::Size(500, 500)); 77 scoped_ptr<LayerImpl> root = LayerImpl::create(&m_hostImpl, 1);
74 root->setContentBounds(gfx::Size(500, 500)); 78 scoped_ptr<LayerImpl> child = LayerImpl::create(&m_hostImpl, 2);
75 root->setDrawsContent(true);
76 root->createRenderSurface();
77 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(500, 500)));
78 79
79 child->setPosition(gfx::PointF(100, 100)); 80 root->setPosition(gfx::PointF());
80 child->setAnchorPoint(gfx::PointF()); 81 root->setAnchorPoint(gfx::PointF());
81 child->setBounds(gfx::Size(30, 30)); 82 root->setBounds(gfx::Size(500, 500));
82 child->setContentBounds(gfx::Size(30, 30)); 83 root->setContentBounds(gfx::Size(500, 500));
83 child->setDrawsContent(true); 84 root->setDrawsContent(true);
84 root->addChild(child.Pass()); 85 root->createRenderSurface();
86 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size( 500, 500)));
85 87
86 return root.Pass(); 88 child->setPosition(gfx::PointF(100, 100));
87 } 89 child->setAnchorPoint(gfx::PointF());
90 child->setBounds(gfx::Size(30, 30));
91 child->setContentBounds(gfx::Size(30, 30));
92 child->setDrawsContent(true);
93 root->addChild(child.Pass());
88 94
89 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces() 95 return root.Pass();
90 { 96 }
91 // This test tree has two render surfaces: one for the root, and one for
92 // child1. Additionally, the root has a second child layer, and child1 has t wo
93 // children of its own.
94 97
95 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 98 scoped_ptr<LayerImpl> createTestTreeWithTwoSurfaces()
96 scoped_ptr<LayerImpl> child1 = LayerImpl::create(2); 99 {
97 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); 100 // This test tree has two render surfaces: one for the root, and one for
98 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(4); 101 // child1. Additionally, the root has a second child layer, and child1 h as two
99 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::create(5); 102 // children of its own.
100 103
101 root->setPosition(gfx::PointF()); 104 scoped_ptr<LayerImpl> root = LayerImpl::create(&m_hostImpl, 1);
102 root->setAnchorPoint(gfx::PointF()); 105 scoped_ptr<LayerImpl> child1 = LayerImpl::create(&m_hostImpl, 2);
103 root->setBounds(gfx::Size(500, 500)); 106 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3);
104 root->setContentBounds(gfx::Size(500, 500)); 107 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(&m_hostImpl, 4);
105 root->setDrawsContent(true); 108 scoped_ptr<LayerImpl> grandChild2 = LayerImpl::create(&m_hostImpl, 5);
106 root->createRenderSurface();
107 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size(500, 500)));
108 109
109 child1->setPosition(gfx::PointF(100, 100)); 110 root->setPosition(gfx::PointF());
110 child1->setAnchorPoint(gfx::PointF()); 111 root->setAnchorPoint(gfx::PointF());
111 child1->setBounds(gfx::Size(30, 30)); 112 root->setBounds(gfx::Size(500, 500));
112 child1->setContentBounds(gfx::Size(30, 30)); 113 root->setContentBounds(gfx::Size(500, 500));
113 child1->setOpacity(0.5); // with a child that drawsContent, this will cause the layer to create its own renderSurface. 114 root->setDrawsContent(true);
114 child1->setDrawsContent(false); // this layer does not draw, but is intended to create its own renderSurface. 115 root->createRenderSurface();
115 child1->setForceRenderSurface(true); 116 root->renderSurface()->setContentRect(gfx::Rect(gfx::Point(), gfx::Size( 500, 500)));
116 117
117 child2->setPosition(gfx::PointF(11, 11)); 118 child1->setPosition(gfx::PointF(100, 100));
118 child2->setAnchorPoint(gfx::PointF()); 119 child1->setAnchorPoint(gfx::PointF());
119 child2->setBounds(gfx::Size(18, 18)); 120 child1->setBounds(gfx::Size(30, 30));
120 child2->setContentBounds(gfx::Size(18, 18)); 121 child1->setContentBounds(gfx::Size(30, 30));
121 child2->setDrawsContent(true); 122 child1->setOpacity(0.5); // with a child that drawsContent, this will ca use the layer to create its own renderSurface.
123 child1->setDrawsContent(false); // this layer does not draw, but is inte nded to create its own renderSurface.
124 child1->setForceRenderSurface(true);
122 125
123 grandChild1->setPosition(gfx::PointF(200, 200)); 126 child2->setPosition(gfx::PointF(11, 11));
124 grandChild1->setAnchorPoint(gfx::PointF()); 127 child2->setAnchorPoint(gfx::PointF());
125 grandChild1->setBounds(gfx::Size(6, 8)); 128 child2->setBounds(gfx::Size(18, 18));
126 grandChild1->setContentBounds(gfx::Size(6, 8)); 129 child2->setContentBounds(gfx::Size(18, 18));
127 grandChild1->setDrawsContent(true); 130 child2->setDrawsContent(true);
128 131
129 grandChild2->setPosition(gfx::PointF(190, 190)); 132 grandChild1->setPosition(gfx::PointF(200, 200));
130 grandChild2->setAnchorPoint(gfx::PointF()); 133 grandChild1->setAnchorPoint(gfx::PointF());
131 grandChild2->setBounds(gfx::Size(6, 8)); 134 grandChild1->setBounds(gfx::Size(6, 8));
132 grandChild2->setContentBounds(gfx::Size(6, 8)); 135 grandChild1->setContentBounds(gfx::Size(6, 8));
133 grandChild2->setDrawsContent(true); 136 grandChild1->setDrawsContent(true);
134 137
135 child1->addChild(grandChild1.Pass()); 138 grandChild2->setPosition(gfx::PointF(190, 190));
136 child1->addChild(grandChild2.Pass()); 139 grandChild2->setAnchorPoint(gfx::PointF());
137 root->addChild(child1.Pass()); 140 grandChild2->setBounds(gfx::Size(6, 8));
138 root->addChild(child2.Pass()); 141 grandChild2->setContentBounds(gfx::Size(6, 8));
142 grandChild2->setDrawsContent(true);
139 143
140 return root.Pass(); 144 child1->addChild(grandChild1.Pass());
141 } 145 child1->addChild(grandChild2.Pass());
146 root->addChild(child1.Pass());
147 root->addChild(child2.Pass());
142 148
143 scoped_ptr<LayerImpl> createAndSetUpTestTreeWithOneSurface() 149 return root.Pass();
144 { 150 }
145 scoped_ptr<LayerImpl> root = createTestTreeWithOneSurface();
146 151
147 // Setup includes going past the first frame which always damages everything , so 152 scoped_ptr<LayerImpl> createAndSetUpTestTreeWithOneSurface()
148 // that we can actually perform specific tests. 153 {
149 emulateDrawingOneFrame(root.get()); 154 scoped_ptr<LayerImpl> root = createTestTreeWithOneSurface();
150 155
151 return root.Pass(); 156 // Setup includes going past the first frame which always damages everyt hing, so
152 } 157 // that we can actually perform specific tests.
158 emulateDrawingOneFrame(root.get());
153 159
154 scoped_ptr<LayerImpl> createAndSetUpTestTreeWithTwoSurfaces() 160 return root.Pass();
155 { 161 }
156 scoped_ptr<LayerImpl> root = createTestTreeWithTwoSurfaces();
157 162
158 // Setup includes going past the first frame which always damages everything , so 163 scoped_ptr<LayerImpl> createAndSetUpTestTreeWithTwoSurfaces()
159 // that we can actually perform specific tests. 164 {
160 emulateDrawingOneFrame(root.get()); 165 scoped_ptr<LayerImpl> root = createTestTreeWithTwoSurfaces();
161 166
162 return root.Pass(); 167 // Setup includes going past the first frame which always damages everyt hing, so
163 } 168 // that we can actually perform specific tests.
169 emulateDrawingOneFrame(root.get());
164 170
165 class DamageTrackerTest : public testing::Test { 171 return root.Pass();
172 }
173
174 protected:
175 FakeImplProxy m_proxy;
176 FakeLayerTreeHostImpl m_hostImpl;
166 }; 177 };
167 178
168 TEST_F(DamageTrackerTest, sanityCheckTestTreeWithOneSurface) 179 TEST_F(DamageTrackerTest, sanityCheckTestTreeWithOneSurface)
169 { 180 {
170 // Sanity check that the simple test tree will actually produce the expected render 181 // Sanity check that the simple test tree will actually produce the expected render
171 // surfaces and layer lists. 182 // surfaces and layer lists.
172 183
173 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 184 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
174 185
175 EXPECT_EQ(2u, root->renderSurface()->layerList().size()); 186 EXPECT_EQ(2u, root->renderSurface()->layerList().size());
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 529
519 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer) 530 TEST_F(DamageTrackerTest, verifyDamageForAddingAndRemovingLayer)
520 { 531 {
521 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 532 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
522 LayerImpl* child1 = root->children()[0]; 533 LayerImpl* child1 = root->children()[0];
523 534
524 // CASE 1: Adding a new layer should cause the appropriate damage. 535 // CASE 1: Adding a new layer should cause the appropriate damage.
525 // 536 //
526 clearDamageForAllSurfaces(root.get()); 537 clearDamageForAllSurfaces(root.get());
527 { 538 {
528 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); 539 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3);
529 child2->setPosition(gfx::PointF(400, 380)); 540 child2->setPosition(gfx::PointF(400, 380));
530 child2->setAnchorPoint(gfx::PointF()); 541 child2->setAnchorPoint(gfx::PointF());
531 child2->setBounds(gfx::Size(6, 8)); 542 child2->setBounds(gfx::Size(6, 8));
532 child2->setContentBounds(gfx::Size(6, 8)); 543 child2->setContentBounds(gfx::Size(6, 8));
533 child2->setDrawsContent(true); 544 child2->setDrawsContent(true);
534 root->addChild(child2.Pass()); 545 root->addChild(child2.Pass());
535 } 546 }
536 emulateDrawingOneFrame(root.get()); 547 emulateDrawingOneFrame(root.get());
537 548
538 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere. 549 // Sanity check - all 3 layers should be on the same render surface; render surfaces are tested elsewhere.
(...skipping 19 matching lines...) Expand all
558 569
559 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer) 570 TEST_F(DamageTrackerTest, verifyDamageForNewUnchangedLayer)
560 { 571 {
561 // 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
562 // its own, it should still indeed damage the target surface. 573 // its own, it should still indeed damage the target surface.
563 574
564 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 575 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
565 576
566 clearDamageForAllSurfaces(root.get()); 577 clearDamageForAllSurfaces(root.get());
567 { 578 {
568 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); 579 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3);
569 child2->setPosition(gfx::PointF(400, 380)); 580 child2->setPosition(gfx::PointF(400, 380));
570 child2->setAnchorPoint(gfx::PointF()); 581 child2->setAnchorPoint(gfx::PointF());
571 child2->setBounds(gfx::Size(6, 8)); 582 child2->setBounds(gfx::Size(6, 8));
572 child2->setContentBounds(gfx::Size(6, 8)); 583 child2->setContentBounds(gfx::Size(6, 8));
573 child2->setDrawsContent(true); 584 child2->setDrawsContent(true);
574 child2->resetAllChangeTrackingForSubtree(); 585 child2->resetAllChangeTrackingForSubtree();
575 // 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
576 // means the test no longer actually covers the intended scenario. 587 // means the test no longer actually covers the intended scenario.
577 ASSERT_FALSE(child2->layerPropertyChanged()); 588 ASSERT_FALSE(child2->layerPropertyChanged());
578 ASSERT_TRUE(child2->updateRect().IsEmpty()); 589 ASSERT_TRUE(child2->updateRect().IsEmpty());
579 root->addChild(child2.Pass()); 590 root->addChild(child2.Pass());
580 } 591 }
581 emulateDrawingOneFrame(root.get()); 592 emulateDrawingOneFrame(root.get());
582 593
583 // 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.
584 ASSERT_EQ(3u, root->renderSurface()->layerList().size()); 595 ASSERT_EQ(3u, root->renderSurface()->layerList().size());
585 596
586 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD amageRect(); 597 gfx::RectF rootDamageRect = root->renderSurface()->damageTracker()->currentD amageRect();
587 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect); 598 EXPECT_FLOAT_RECT_EQ(gfx::RectF(400, 380, 6, 8), rootDamageRect);
588 } 599 }
589 600
590 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers) 601 TEST_F(DamageTrackerTest, verifyDamageForMultipleLayers)
591 { 602 {
592 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 603 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
593 LayerImpl* child1 = root->children()[0]; 604 LayerImpl* child1 = root->children()[0];
594 605
595 // 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.
596 clearDamageForAllSurfaces(root.get()); 607 clearDamageForAllSurfaces(root.get());
597 { 608 {
598 scoped_ptr<LayerImpl> child2 = LayerImpl::create(3); 609 scoped_ptr<LayerImpl> child2 = LayerImpl::create(&m_hostImpl, 3);
599 child2->setPosition(gfx::PointF(400, 380)); 610 child2->setPosition(gfx::PointF(400, 380));
600 child2->setAnchorPoint(gfx::PointF()); 611 child2->setAnchorPoint(gfx::PointF());
601 child2->setBounds(gfx::Size(6, 8)); 612 child2->setBounds(gfx::Size(6, 8));
602 child2->setContentBounds(gfx::Size(6, 8)); 613 child2->setContentBounds(gfx::Size(6, 8));
603 child2->setDrawsContent(true); 614 child2->setDrawsContent(true);
604 root->addChild(child2.Pass()); 615 root->addChild(child2.Pass());
605 } 616 }
606 LayerImpl* child2 = root->children()[1]; 617 LayerImpl* child2 = root->children()[1];
607 emulateDrawingOneFrame(root.get()); 618 emulateDrawingOneFrame(root.get());
608 619
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 LayerImpl* grandChild2 = child1->children()[1]; 820 LayerImpl* grandChild2 = child1->children()[1];
810 821
811 // 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
812 // receive the surface's damage and the surface's reflected damage. 823 // receive the surface's damage and the surface's reflected damage.
813 824
814 // 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
815 // 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
816 // contentBounds of the surface. 827 // contentBounds of the surface.
817 grandChild2->setPosition(gfx::PointF(180, 180)); 828 grandChild2->setPosition(gfx::PointF(180, 180));
818 { 829 {
819 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::create(6); 830 scoped_ptr<LayerImpl> grandChild3 = LayerImpl::create(&m_hostImpl, 6);
820 grandChild3->setPosition(gfx::PointF(240, 240)); 831 grandChild3->setPosition(gfx::PointF(240, 240));
821 grandChild3->setAnchorPoint(gfx::PointF()); 832 grandChild3->setAnchorPoint(gfx::PointF());
822 grandChild3->setBounds(gfx::Size(10, 10)); 833 grandChild3->setBounds(gfx::Size(10, 10));
823 grandChild3->setContentBounds(gfx::Size(10, 10)); 834 grandChild3->setContentBounds(gfx::Size(10, 10));
824 grandChild3->setDrawsContent(true); 835 grandChild3->setDrawsContent(true);
825 child1->addChild(grandChild3.Pass()); 836 child1->addChild(grandChild3.Pass());
826 } 837 }
827 child1->setOpacity(0.5); 838 child1->setOpacity(0.5);
828 emulateDrawingOneFrame(root.get()); 839 emulateDrawingOneFrame(root.get());
829 840
830 // CASE 1: adding a reflection about the left edge of grandChild1. 841 // CASE 1: adding a reflection about the left edge of grandChild1.
831 // 842 //
832 clearDamageForAllSurfaces(root.get()); 843 clearDamageForAllSurfaces(root.get());
833 { 844 {
834 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(7); 845 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(&m_hostImpl , 7);
835 grandChild1Replica->setPosition(gfx::PointF()); 846 grandChild1Replica->setPosition(gfx::PointF());
836 grandChild1Replica->setAnchorPoint(gfx::PointF()); 847 grandChild1Replica->setAnchorPoint(gfx::PointF());
837 gfx::Transform reflection; 848 gfx::Transform reflection;
838 reflection.Scale3d(-1, 1, 1); 849 reflection.Scale3d(-1, 1, 1);
839 grandChild1Replica->setTransform(reflection); 850 grandChild1Replica->setTransform(reflection);
840 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 851 grandChild1->setReplicaLayer(grandChild1Replica.Pass());
841 } 852 }
842 emulateDrawingOneFrame(root.get()); 853 emulateDrawingOneFrame(root.get());
843 854
844 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke r()->currentDamageRect(); 855 gfx::RectF grandChildDamageRect = grandChild1->renderSurface()->damageTracke r()->currentDamageRect();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface(); 903 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithOneSurface();
893 LayerImpl* child = root->children()[0]; 904 LayerImpl* child = root->children()[0];
894 905
895 // 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
896 // damage the entire corresponding surface. 907 // damage the entire corresponding surface.
897 908
898 clearDamageForAllSurfaces(root.get()); 909 clearDamageForAllSurfaces(root.get());
899 910
900 // Set up the mask layer. 911 // Set up the mask layer.
901 { 912 {
902 scoped_ptr<LayerImpl> maskLayer = LayerImpl::create(3); 913 scoped_ptr<LayerImpl> maskLayer = LayerImpl::create(&m_hostImpl, 3);
903 maskLayer->setPosition(child->position()); 914 maskLayer->setPosition(child->position());
904 maskLayer->setAnchorPoint(gfx::PointF()); 915 maskLayer->setAnchorPoint(gfx::PointF());
905 maskLayer->setBounds(child->bounds()); 916 maskLayer->setBounds(child->bounds());
906 maskLayer->setContentBounds(child->bounds()); 917 maskLayer->setContentBounds(child->bounds());
907 child->setMaskLayer(maskLayer.Pass()); 918 child->setMaskLayer(maskLayer.Pass());
908 } 919 }
909 LayerImpl* maskLayer = child->maskLayer(); 920 LayerImpl* maskLayer = child->maskLayer();
910 921
911 // 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.
912 child->setOpacity(0.5); 923 child->setOpacity(0.5);
913 { 924 {
914 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(4); 925 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(&m_hostImpl, 4);
915 grandChild->setPosition(gfx::PointF(2, 2)); 926 grandChild->setPosition(gfx::PointF(2, 2));
916 grandChild->setAnchorPoint(gfx::PointF()); 927 grandChild->setAnchorPoint(gfx::PointF());
917 grandChild->setBounds(gfx::Size(2, 2)); 928 grandChild->setBounds(gfx::Size(2, 2));
918 grandChild->setContentBounds(gfx::Size(2, 2)); 929 grandChild->setContentBounds(gfx::Size(2, 2));
919 grandChild->setDrawsContent(true); 930 grandChild->setDrawsContent(true);
920 child->addChild(grandChild.Pass()); 931 child->addChild(grandChild.Pass());
921 } 932 }
922 emulateDrawingOneFrame(root.get()); 933 emulateDrawingOneFrame(root.get());
923 934
924 // 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
977 LayerImpl* child1 = root->children()[0]; 988 LayerImpl* child1 = root->children()[0];
978 LayerImpl* grandChild1 = child1->children()[0]; 989 LayerImpl* grandChild1 = child1->children()[0];
979 990
980 // 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
981 // not masked. But it does damage the ancestor target surface. 992 // not masked. But it does damage the ancestor target surface.
982 993
983 clearDamageForAllSurfaces(root.get()); 994 clearDamageForAllSurfaces(root.get());
984 995
985 // Create a reflection about the left edge of grandChild1. 996 // Create a reflection about the left edge of grandChild1.
986 { 997 {
987 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); 998 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(&m_hostImpl , 6);
988 grandChild1Replica->setPosition(gfx::PointF()); 999 grandChild1Replica->setPosition(gfx::PointF());
989 grandChild1Replica->setAnchorPoint(gfx::PointF()); 1000 grandChild1Replica->setAnchorPoint(gfx::PointF());
990 gfx::Transform reflection; 1001 gfx::Transform reflection;
991 reflection.Scale3d(-1, 1, 1); 1002 reflection.Scale3d(-1, 1, 1);
992 grandChild1Replica->setTransform(reflection); 1003 grandChild1Replica->setTransform(reflection);
993 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 1004 grandChild1->setReplicaLayer(grandChild1Replica.Pass());
994 } 1005 }
995 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); 1006 LayerImpl* grandChild1Replica = grandChild1->replicaLayer();
996 1007
997 // Set up the mask layer on the replica layer 1008 // Set up the mask layer on the replica layer
998 { 1009 {
999 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); 1010 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(&m_hostImpl, 7);
1000 replicaMaskLayer->setPosition(gfx::PointF()); 1011 replicaMaskLayer->setPosition(gfx::PointF());
1001 replicaMaskLayer->setAnchorPoint(gfx::PointF()); 1012 replicaMaskLayer->setAnchorPoint(gfx::PointF());
1002 replicaMaskLayer->setBounds(grandChild1->bounds()); 1013 replicaMaskLayer->setBounds(grandChild1->bounds());
1003 replicaMaskLayer->setContentBounds(grandChild1->bounds()); 1014 replicaMaskLayer->setContentBounds(grandChild1->bounds());
1004 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); 1015 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass());
1005 } 1016 }
1006 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); 1017 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer();
1007 1018
1008 emulateDrawingOneFrame(root.get()); 1019 emulateDrawingOneFrame(root.get());
1009 1020
(...skipping 29 matching lines...) Expand all
1039 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces(); 1050 scoped_ptr<LayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
1040 LayerImpl* child1 = root->children()[0]; 1051 LayerImpl* child1 = root->children()[0];
1041 LayerImpl* grandChild1 = child1->children()[0]; 1052 LayerImpl* grandChild1 = child1->children()[0];
1042 1053
1043 // Verify that the correct replicaOriginTransform is used for the replicaMas k; 1054 // Verify that the correct replicaOriginTransform is used for the replicaMas k;
1044 clearDamageForAllSurfaces(root.get()); 1055 clearDamageForAllSurfaces(root.get());
1045 1056
1046 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.
1047 1058
1048 { 1059 {
1049 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(6); 1060 scoped_ptr<LayerImpl> grandChild1Replica = LayerImpl::create(&m_hostImpl , 6);
1050 grandChild1Replica->setPosition(gfx::PointF()); 1061 grandChild1Replica->setPosition(gfx::PointF());
1051 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.
1052 gfx::Transform reflection; 1063 gfx::Transform reflection;
1053 reflection.Scale3d(-1, 1, 1); 1064 reflection.Scale3d(-1, 1, 1);
1054 grandChild1Replica->setTransform(reflection); 1065 grandChild1Replica->setTransform(reflection);
1055 grandChild1->setReplicaLayer(grandChild1Replica.Pass()); 1066 grandChild1->setReplicaLayer(grandChild1Replica.Pass());
1056 } 1067 }
1057 LayerImpl* grandChild1Replica = grandChild1->replicaLayer(); 1068 LayerImpl* grandChild1Replica = grandChild1->replicaLayer();
1058 1069
1059 // Set up the mask layer on the replica layer 1070 // Set up the mask layer on the replica layer
1060 { 1071 {
1061 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(7); 1072 scoped_ptr<LayerImpl> replicaMaskLayer = LayerImpl::create(&m_hostImpl, 7);
1062 replicaMaskLayer->setPosition(gfx::PointF()); 1073 replicaMaskLayer->setPosition(gfx::PointF());
1063 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.
1064 replicaMaskLayer->setBounds(grandChild1->bounds()); 1075 replicaMaskLayer->setBounds(grandChild1->bounds());
1065 replicaMaskLayer->setContentBounds(grandChild1->bounds()); 1076 replicaMaskLayer->setContentBounds(grandChild1->bounds());
1066 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass()); 1077 grandChild1Replica->setMaskLayer(replicaMaskLayer.Pass());
1067 } 1078 }
1068 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer(); 1079 LayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer();
1069 1080
1070 emulateDrawingOneFrame(root.get()); 1081 emulateDrawingOneFrame(root.get());
1071 1082
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 emulateDrawingOneFrame(root.get()); 1116 emulateDrawingOneFrame(root.get());
1106 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1117 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1107 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect); 1118 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 500, 500), rootDamageRect);
1108 } 1119 }
1109 1120
1110 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList) 1121 TEST_F(DamageTrackerTest, verifyDamageForEmptyLayerList)
1111 { 1122 {
1112 // 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
1113 // does not crash when it receives an empty layerList. 1124 // does not crash when it receives an empty layerList.
1114 1125
1115 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1126 scoped_ptr<LayerImpl> root = LayerImpl::create(&m_hostImpl, 1);
1116 root->createRenderSurface(); 1127 root->createRenderSurface();
1117 1128
1118 ASSERT_TRUE(root == root->renderTarget()); 1129 ASSERT_TRUE(root == root->renderTarget());
1119 RenderSurfaceImpl* targetSurface = root->renderSurface(); 1130 RenderSurfaceImpl* targetSurface = root->renderSurface();
1120 targetSurface->clearLayerLists(); 1131 targetSurface->clearLayerLists();
1121 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay erList(), targetSurface->owningLayerId(), false, gfx::Rect(), 0, WebFilterOperat ions(), 0); 1132 targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->lay erList(), targetSurface->owningLayerId(), false, gfx::Rect(), 0, WebFilterOperat ions(), 0);
1122 1133
1123 gfx::RectF damageRect = targetSurface->damageTracker()->currentDamageRect(); 1134 gfx::RectF damageRect = targetSurface->damageTracker()->currentDamageRect();
1124 EXPECT_TRUE(damageRect.IsEmpty()); 1135 EXPECT_TRUE(damageRect.IsEmpty());
1125 } 1136 }
(...skipping 25 matching lines...) Expand all
1151 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1162 EXPECT_TRUE(rootDamageRect.IsEmpty());
1152 1163
1153 // 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
1154 emulateDrawingOneFrame(root.get()); 1165 emulateDrawingOneFrame(root.get());
1155 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ; 1166 rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect() ;
1156 EXPECT_TRUE(rootDamageRect.IsEmpty()); 1167 EXPECT_TRUE(rootDamageRect.IsEmpty());
1157 } 1168 }
1158 1169
1159 } // namespace 1170 } // namespace
1160 } // namespace cc 1171 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/delegated_renderer_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698