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

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

Issue 645853008: Standardize usage of virtual/override/final in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatted Created 6 years, 2 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/output/copy_output_request.h" 8 #include "cc/output/copy_output_request.h"
9 #include "cc/output/copy_output_result.h" 9 #include "cc/output/copy_output_result.h"
10 #include "cc/test/layer_tree_test.h" 10 #include "cc/test/layer_tree_test.h"
11 #include "cc/test/test_occlusion_tracker.h" 11 #include "cc/test/test_occlusion_tracker.h"
12 12
13 namespace cc { 13 namespace cc {
14 namespace { 14 namespace {
15 15
16 class TestLayer : public Layer { 16 class TestLayer : public Layer {
17 public: 17 public:
18 static scoped_refptr<TestLayer> Create() { 18 static scoped_refptr<TestLayer> Create() {
19 return make_scoped_refptr(new TestLayer()); 19 return make_scoped_refptr(new TestLayer());
20 } 20 }
21 21
22 virtual bool Update(ResourceUpdateQueue* update_queue, 22 bool Update(ResourceUpdateQueue* update_queue,
23 const OcclusionTracker<Layer>* occlusion) override { 23 const OcclusionTracker<Layer>* occlusion) override {
24 if (!occlusion) 24 if (!occlusion)
25 return false; 25 return false;
26 26
27 const TestOcclusionTracker<Layer>* test_occlusion = 27 const TestOcclusionTracker<Layer>* test_occlusion =
28 static_cast<const TestOcclusionTracker<Layer>*>(occlusion); 28 static_cast<const TestOcclusionTracker<Layer>*>(occlusion);
29 occlusion_ = UnionSimpleEnclosedRegions( 29 occlusion_ = UnionSimpleEnclosedRegions(
30 test_occlusion->occlusion_from_inside_target(), 30 test_occlusion->occlusion_from_inside_target(),
31 test_occlusion->occlusion_from_outside_target()); 31 test_occlusion->occlusion_from_outside_target());
32 return false; 32 return false;
33 } 33 }
34 34
35 const SimpleEnclosedRegion& occlusion() const { return occlusion_; } 35 const SimpleEnclosedRegion& occlusion() const { return occlusion_; }
36 const SimpleEnclosedRegion& expected_occlusion() const { 36 const SimpleEnclosedRegion& expected_occlusion() const {
37 return expected_occlusion_; 37 return expected_occlusion_;
38 } 38 }
39 void set_expected_occlusion(const gfx::Rect& occlusion) { 39 void set_expected_occlusion(const gfx::Rect& occlusion) {
40 expected_occlusion_ = SimpleEnclosedRegion(occlusion); 40 expected_occlusion_ = SimpleEnclosedRegion(occlusion);
41 } 41 }
42 42
43 private: 43 private:
44 TestLayer() : Layer() { 44 TestLayer() : Layer() {
45 SetIsDrawable(true); 45 SetIsDrawable(true);
46 } 46 }
47 virtual ~TestLayer() {} 47 ~TestLayer() override {}
48 48
49 SimpleEnclosedRegion occlusion_; 49 SimpleEnclosedRegion occlusion_;
50 SimpleEnclosedRegion expected_occlusion_; 50 SimpleEnclosedRegion expected_occlusion_;
51 }; 51 };
52 52
53 class LayerTreeHostOcclusionTest : public LayerTreeTest { 53 class LayerTreeHostOcclusionTest : public LayerTreeTest {
54 public: 54 public:
55 LayerTreeHostOcclusionTest() 55 LayerTreeHostOcclusionTest()
56 : root_(TestLayer::Create()), 56 : root_(TestLayer::Create()),
57 child_(TestLayer::Create()), 57 child_(TestLayer::Create()),
58 child2_(TestLayer::Create()), 58 child2_(TestLayer::Create()),
59 grand_child_(TestLayer::Create()), 59 grand_child_(TestLayer::Create()),
60 mask_(TestLayer::Create()) { 60 mask_(TestLayer::Create()) {
61 } 61 }
62 62
63 virtual void BeginTest() override { 63 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
64 PostSetNeedsCommitToMainThread();
65 }
66 64
67 virtual void DidCommit() override { 65 void DidCommit() override {
68 TestLayer* root = static_cast<TestLayer*>(layer_tree_host()->root_layer()); 66 TestLayer* root = static_cast<TestLayer*>(layer_tree_host()->root_layer());
69 VerifyOcclusion(root); 67 VerifyOcclusion(root);
70 68
71 EndTest(); 69 EndTest();
72 } 70 }
73 71
74 virtual void AfterTest() override {} 72 void AfterTest() override {}
75 73
76 void VerifyOcclusion(TestLayer* layer) const { 74 void VerifyOcclusion(TestLayer* layer) const {
77 EXPECT_EQ(layer->expected_occlusion().ToString(), 75 EXPECT_EQ(layer->expected_occlusion().ToString(),
78 layer->occlusion().ToString()); 76 layer->occlusion().ToString());
79 77
80 for (size_t i = 0; i < layer->children().size(); ++i) { 78 for (size_t i = 0; i < layer->children().size(); ++i) {
81 TestLayer* child = static_cast<TestLayer*>(layer->children()[i].get()); 79 TestLayer* child = static_cast<TestLayer*>(layer->children()[i].get());
82 VerifyOcclusion(child); 80 VerifyOcclusion(child);
83 } 81 }
84 } 82 }
85 83
86 void SetLayerPropertiesForTesting(TestLayer* layer, 84 void SetLayerPropertiesForTesting(TestLayer* layer,
87 TestLayer* parent, 85 TestLayer* parent,
88 const gfx::Transform& transform, 86 const gfx::Transform& transform,
89 const gfx::PointF& position, 87 const gfx::PointF& position,
90 const gfx::Size& bounds, 88 const gfx::Size& bounds,
91 bool opaque) const { 89 bool opaque) const {
92 layer->RemoveAllChildren(); 90 layer->RemoveAllChildren();
93 if (parent) 91 if (parent)
94 parent->AddChild(layer); 92 parent->AddChild(layer);
95 layer->SetTransform(transform); 93 layer->SetTransform(transform);
96 layer->SetPosition(position); 94 layer->SetPosition(position);
97 layer->SetBounds(bounds); 95 layer->SetBounds(bounds);
98 layer->SetContentsOpaque(opaque); 96 layer->SetContentsOpaque(opaque);
99 } 97 }
100 98
101 protected: 99 protected:
102 virtual void InitializeSettings(LayerTreeSettings* settings) override { 100 void InitializeSettings(LayerTreeSettings* settings) override {
103 settings->minimum_occlusion_tracking_size = gfx::Size(); 101 settings->minimum_occlusion_tracking_size = gfx::Size();
104 } 102 }
105 103
106 scoped_refptr<TestLayer> root_; 104 scoped_refptr<TestLayer> root_;
107 scoped_refptr<TestLayer> child_; 105 scoped_refptr<TestLayer> child_;
108 scoped_refptr<TestLayer> child2_; 106 scoped_refptr<TestLayer> child2_;
109 scoped_refptr<TestLayer> grand_child_; 107 scoped_refptr<TestLayer> grand_child_;
110 scoped_refptr<TestLayer> mask_; 108 scoped_refptr<TestLayer> mask_;
111 109
112 gfx::Transform identity_matrix_; 110 gfx::Transform identity_matrix_;
113 }; 111 };
114 112
115 113
116 class LayerTreeHostOcclusionTestOcclusionSurfaceClipping 114 class LayerTreeHostOcclusionTestOcclusionSurfaceClipping
117 : public LayerTreeHostOcclusionTest { 115 : public LayerTreeHostOcclusionTest {
118 public: 116 public:
119 virtual void SetupTree() override { 117 void SetupTree() override {
120 // The child layer is a surface and the grand_child is opaque, but clipped 118 // The child layer is a surface and the grand_child is opaque, but clipped
121 // to the child and root 119 // to the child and root
122 SetLayerPropertiesForTesting( 120 SetLayerPropertiesForTesting(
123 root_.get(), NULL, identity_matrix_, 121 root_.get(), NULL, identity_matrix_,
124 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 122 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
125 SetLayerPropertiesForTesting( 123 SetLayerPropertiesForTesting(
126 child_.get(), root_.get(), identity_matrix_, 124 child_.get(), root_.get(), identity_matrix_,
127 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), false); 125 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), false);
128 SetLayerPropertiesForTesting( 126 SetLayerPropertiesForTesting(
129 grand_child_.get(), child_.get(), identity_matrix_, 127 grand_child_.get(), child_.get(), identity_matrix_,
130 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true); 128 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true);
131 129
132 child_->SetMasksToBounds(true); 130 child_->SetMasksToBounds(true);
133 child_->SetForceRenderSurface(true); 131 child_->SetForceRenderSurface(true);
134 132
135 child_->set_expected_occlusion(gfx::Rect(0, 0, 10, 190)); 133 child_->set_expected_occlusion(gfx::Rect(0, 0, 10, 190));
136 root_->set_expected_occlusion(gfx::Rect(10, 10, 10, 190)); 134 root_->set_expected_occlusion(gfx::Rect(10, 10, 10, 190));
137 135
138 layer_tree_host()->SetRootLayer(root_); 136 layer_tree_host()->SetRootLayer(root_);
139 LayerTreeTest::SetupTree(); 137 LayerTreeTest::SetupTree();
140 } 138 }
141 }; 139 };
142 140
143 SINGLE_AND_MULTI_THREAD_TEST_F( 141 SINGLE_AND_MULTI_THREAD_TEST_F(
144 LayerTreeHostOcclusionTestOcclusionSurfaceClipping); 142 LayerTreeHostOcclusionTestOcclusionSurfaceClipping);
145 143
146 class LayerTreeHostOcclusionTestOcclusionSurfaceClippingOpaque 144 class LayerTreeHostOcclusionTestOcclusionSurfaceClippingOpaque
147 : public LayerTreeHostOcclusionTest { 145 : public LayerTreeHostOcclusionTest {
148 public: 146 public:
149 virtual void SetupTree() override { 147 void SetupTree() override {
150 // If the child layer is opaque, then it adds to the occlusion seen by the 148 // If the child layer is opaque, then it adds to the occlusion seen by the
151 // root_. 149 // root_.
152 SetLayerPropertiesForTesting( 150 SetLayerPropertiesForTesting(
153 root_.get(), NULL, identity_matrix_, 151 root_.get(), NULL, identity_matrix_,
154 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 152 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
155 SetLayerPropertiesForTesting( 153 SetLayerPropertiesForTesting(
156 child_.get(), root_.get(), identity_matrix_, 154 child_.get(), root_.get(), identity_matrix_,
157 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); 155 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true);
158 SetLayerPropertiesForTesting( 156 SetLayerPropertiesForTesting(
159 grand_child_.get(), child_.get(), identity_matrix_, 157 grand_child_.get(), child_.get(), identity_matrix_,
160 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true); 158 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true);
161 159
162 child_->SetMasksToBounds(true); 160 child_->SetMasksToBounds(true);
163 child_->SetForceRenderSurface(true); 161 child_->SetForceRenderSurface(true);
164 162
165 child_->set_expected_occlusion(gfx::Rect(0, 0, 10, 190)); 163 child_->set_expected_occlusion(gfx::Rect(0, 0, 10, 190));
166 root_->set_expected_occlusion(gfx::Rect(10, 10, 190, 190)); 164 root_->set_expected_occlusion(gfx::Rect(10, 10, 190, 190));
167 165
168 layer_tree_host()->SetRootLayer(root_); 166 layer_tree_host()->SetRootLayer(root_);
169 LayerTreeTest::SetupTree(); 167 LayerTreeTest::SetupTree();
170 } 168 }
171 }; 169 };
172 170
173 SINGLE_AND_MULTI_THREAD_TEST_F( 171 SINGLE_AND_MULTI_THREAD_TEST_F(
174 LayerTreeHostOcclusionTestOcclusionSurfaceClippingOpaque); 172 LayerTreeHostOcclusionTestOcclusionSurfaceClippingOpaque);
175 173
176 class LayerTreeHostOcclusionTestOcclusionTwoChildren 174 class LayerTreeHostOcclusionTestOcclusionTwoChildren
177 : public LayerTreeHostOcclusionTest { 175 : public LayerTreeHostOcclusionTest {
178 public: 176 public:
179 virtual void SetupTree() override { 177 void SetupTree() override {
180 // Add a second child to the root layer and the regions should merge 178 // Add a second child to the root layer and the regions should merge
181 SetLayerPropertiesForTesting( 179 SetLayerPropertiesForTesting(
182 root_.get(), NULL, identity_matrix_, 180 root_.get(), NULL, identity_matrix_,
183 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 181 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
184 SetLayerPropertiesForTesting( 182 SetLayerPropertiesForTesting(
185 child_.get(), root_.get(), identity_matrix_, 183 child_.get(), root_.get(), identity_matrix_,
186 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), false); 184 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), false);
187 SetLayerPropertiesForTesting( 185 SetLayerPropertiesForTesting(
188 grand_child_.get(), child_.get(), identity_matrix_, 186 grand_child_.get(), child_.get(), identity_matrix_,
189 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true); 187 gfx::PointF(-10.f, -10.f), gfx::Size(20, 500), true);
(...skipping 12 matching lines...) Expand all
202 LayerTreeTest::SetupTree(); 200 LayerTreeTest::SetupTree();
203 } 201 }
204 }; 202 };
205 203
206 SINGLE_AND_MULTI_THREAD_TEST_F( 204 SINGLE_AND_MULTI_THREAD_TEST_F(
207 LayerTreeHostOcclusionTestOcclusionTwoChildren); 205 LayerTreeHostOcclusionTestOcclusionTwoChildren);
208 206
209 class LayerTreeHostOcclusionTestOcclusionMask 207 class LayerTreeHostOcclusionTestOcclusionMask
210 : public LayerTreeHostOcclusionTest { 208 : public LayerTreeHostOcclusionTest {
211 public: 209 public:
212 virtual void SetupTree() override { 210 void SetupTree() override {
213 // If the child layer has a mask on it, then it shouldn't contribute to 211 // If the child layer has a mask on it, then it shouldn't contribute to
214 // occlusion on stuff below it. 212 // occlusion on stuff below it.
215 SetLayerPropertiesForTesting( 213 SetLayerPropertiesForTesting(
216 root_.get(), NULL, identity_matrix_, 214 root_.get(), NULL, identity_matrix_,
217 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 215 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
218 SetLayerPropertiesForTesting( 216 SetLayerPropertiesForTesting(
219 child2_.get(), root_.get(), identity_matrix_, 217 child2_.get(), root_.get(), identity_matrix_,
220 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); 218 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true);
221 SetLayerPropertiesForTesting( 219 SetLayerPropertiesForTesting(
222 child_.get(), root_.get(), identity_matrix_, 220 child_.get(), root_.get(), identity_matrix_,
(...skipping 12 matching lines...) Expand all
235 layer_tree_host()->SetRootLayer(root_); 233 layer_tree_host()->SetRootLayer(root_);
236 LayerTreeTest::SetupTree(); 234 LayerTreeTest::SetupTree();
237 } 235 }
238 }; 236 };
239 237
240 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionMask); 238 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionMask);
241 239
242 class LayerTreeHostOcclusionTestOcclusionMaskBelowOcclusion 240 class LayerTreeHostOcclusionTestOcclusionMaskBelowOcclusion
243 : public LayerTreeHostOcclusionTest { 241 : public LayerTreeHostOcclusionTest {
244 public: 242 public:
245 virtual void SetupTree() override { 243 void SetupTree() override {
246 // If the child layer with a mask is below child2, then child2 should 244 // If the child layer with a mask is below child2, then child2 should
247 // contribute to occlusion on everything, and child shouldn't contribute 245 // contribute to occlusion on everything, and child shouldn't contribute
248 // to the root_. 246 // to the root_.
249 SetLayerPropertiesForTesting( 247 SetLayerPropertiesForTesting(
250 root_.get(), NULL, identity_matrix_, 248 root_.get(), NULL, identity_matrix_,
251 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 249 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
252 SetLayerPropertiesForTesting( 250 SetLayerPropertiesForTesting(
253 child_.get(), root_.get(), identity_matrix_, 251 child_.get(), root_.get(), identity_matrix_,
254 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); 252 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true);
255 SetLayerPropertiesForTesting( 253 SetLayerPropertiesForTesting(
(...skipping 15 matching lines...) Expand all
271 LayerTreeTest::SetupTree(); 269 LayerTreeTest::SetupTree();
272 } 270 }
273 }; 271 };
274 272
275 SINGLE_AND_MULTI_THREAD_TEST_F( 273 SINGLE_AND_MULTI_THREAD_TEST_F(
276 LayerTreeHostOcclusionTestOcclusionMaskBelowOcclusion); 274 LayerTreeHostOcclusionTestOcclusionMaskBelowOcclusion);
277 275
278 class LayerTreeHostOcclusionTestOcclusionOpacity 276 class LayerTreeHostOcclusionTestOcclusionOpacity
279 : public LayerTreeHostOcclusionTest { 277 : public LayerTreeHostOcclusionTest {
280 public: 278 public:
281 virtual void SetupTree() override { 279 void SetupTree() override {
282 // If the child layer has a non-opaque opacity, then it shouldn't 280 // If the child layer has a non-opaque opacity, then it shouldn't
283 // contribute to occlusion on stuff below it 281 // contribute to occlusion on stuff below it
284 SetLayerPropertiesForTesting( 282 SetLayerPropertiesForTesting(
285 root_.get(), NULL, identity_matrix_, 283 root_.get(), NULL, identity_matrix_,
286 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 284 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
287 SetLayerPropertiesForTesting( 285 SetLayerPropertiesForTesting(
288 child2_.get(), root_.get(), identity_matrix_, 286 child2_.get(), root_.get(), identity_matrix_,
289 gfx::PointF(20.f, 10.f), gfx::Size(10, 500), true); 287 gfx::PointF(20.f, 10.f), gfx::Size(10, 500), true);
290 SetLayerPropertiesForTesting( 288 SetLayerPropertiesForTesting(
291 child_.get(), root_.get(), identity_matrix_, 289 child_.get(), root_.get(), identity_matrix_,
(...skipping 12 matching lines...) Expand all
304 layer_tree_host()->SetRootLayer(root_); 302 layer_tree_host()->SetRootLayer(root_);
305 LayerTreeTest::SetupTree(); 303 LayerTreeTest::SetupTree();
306 } 304 }
307 }; 305 };
308 306
309 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionOpacity); 307 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionOpacity);
310 308
311 class LayerTreeHostOcclusionTestOcclusionOpacityBelowOcclusion 309 class LayerTreeHostOcclusionTestOcclusionOpacityBelowOcclusion
312 : public LayerTreeHostOcclusionTest { 310 : public LayerTreeHostOcclusionTest {
313 public: 311 public:
314 virtual void SetupTree() override { 312 void SetupTree() override {
315 // If the child layer with non-opaque opacity is below child2, then 313 // If the child layer with non-opaque opacity is below child2, then
316 // child2 should contribute to occlusion on everything, and child shouldn't 314 // child2 should contribute to occlusion on everything, and child shouldn't
317 // contribute to the root_. 315 // contribute to the root_.
318 SetLayerPropertiesForTesting( 316 SetLayerPropertiesForTesting(
319 root_.get(), NULL, identity_matrix_, 317 root_.get(), NULL, identity_matrix_,
320 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 318 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
321 SetLayerPropertiesForTesting( 319 SetLayerPropertiesForTesting(
322 child_.get(), root_.get(), identity_matrix_, 320 child_.get(), root_.get(), identity_matrix_,
323 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); 321 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true);
324 SetLayerPropertiesForTesting( 322 SetLayerPropertiesForTesting(
(...skipping 15 matching lines...) Expand all
340 LayerTreeTest::SetupTree(); 338 LayerTreeTest::SetupTree();
341 } 339 }
342 }; 340 };
343 341
344 SINGLE_AND_MULTI_THREAD_TEST_F( 342 SINGLE_AND_MULTI_THREAD_TEST_F(
345 LayerTreeHostOcclusionTestOcclusionOpacityBelowOcclusion); 343 LayerTreeHostOcclusionTestOcclusionOpacityBelowOcclusion);
346 344
347 class LayerTreeHostOcclusionTestOcclusionBlending 345 class LayerTreeHostOcclusionTestOcclusionBlending
348 : public LayerTreeHostOcclusionTest { 346 : public LayerTreeHostOcclusionTest {
349 public: 347 public:
350 virtual void SetupTree() override { 348 void SetupTree() override {
351 // If the child layer has a blend mode, then it shouldn't 349 // If the child layer has a blend mode, then it shouldn't
352 // contribute to occlusion on stuff below it 350 // contribute to occlusion on stuff below it
353 SetLayerPropertiesForTesting( 351 SetLayerPropertiesForTesting(
354 root_.get(), NULL, identity_matrix_, 352 root_.get(), NULL, identity_matrix_,
355 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 353 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
356 SetLayerPropertiesForTesting( 354 SetLayerPropertiesForTesting(
357 child2_.get(), root_.get(), identity_matrix_, 355 child2_.get(), root_.get(), identity_matrix_,
358 gfx::PointF(20.f, 10.f), gfx::Size(10, 500), true); 356 gfx::PointF(20.f, 10.f), gfx::Size(10, 500), true);
359 SetLayerPropertiesForTesting( 357 SetLayerPropertiesForTesting(
360 child_.get(), root_.get(), identity_matrix_, 358 child_.get(), root_.get(), identity_matrix_,
(...skipping 12 matching lines...) Expand all
373 layer_tree_host()->SetRootLayer(root_); 371 layer_tree_host()->SetRootLayer(root_);
374 LayerTreeTest::SetupTree(); 372 LayerTreeTest::SetupTree();
375 } 373 }
376 }; 374 };
377 375
378 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionBlending); 376 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionBlending);
379 377
380 class LayerTreeHostOcclusionTestOcclusionBlendingBelowOcclusion 378 class LayerTreeHostOcclusionTestOcclusionBlendingBelowOcclusion
381 : public LayerTreeHostOcclusionTest { 379 : public LayerTreeHostOcclusionTest {
382 public: 380 public:
383 virtual void SetupTree() override { 381 void SetupTree() override {
384 // If the child layer with a blend mode is below child2, then 382 // If the child layer with a blend mode is below child2, then
385 // child2 should contribute to occlusion on everything, and child shouldn't 383 // child2 should contribute to occlusion on everything, and child shouldn't
386 // contribute to the root_. 384 // contribute to the root_.
387 SetLayerPropertiesForTesting( 385 SetLayerPropertiesForTesting(
388 root_.get(), NULL, identity_matrix_, 386 root_.get(), NULL, identity_matrix_,
389 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 387 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
390 SetLayerPropertiesForTesting( 388 SetLayerPropertiesForTesting(
391 child_.get(), root_.get(), identity_matrix_, 389 child_.get(), root_.get(), identity_matrix_,
392 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true); 390 gfx::PointF(10.f, 10.f), gfx::Size(500, 500), true);
393 SetLayerPropertiesForTesting( 391 SetLayerPropertiesForTesting(
(...skipping 14 matching lines...) Expand all
408 LayerTreeTest::SetupTree(); 406 LayerTreeTest::SetupTree();
409 } 407 }
410 }; 408 };
411 409
412 SINGLE_AND_MULTI_THREAD_TEST_F( 410 SINGLE_AND_MULTI_THREAD_TEST_F(
413 LayerTreeHostOcclusionTestOcclusionBlendingBelowOcclusion); 411 LayerTreeHostOcclusionTestOcclusionBlendingBelowOcclusion);
414 412
415 class LayerTreeHostOcclusionTestOcclusionOpacityFilter 413 class LayerTreeHostOcclusionTestOcclusionOpacityFilter
416 : public LayerTreeHostOcclusionTest { 414 : public LayerTreeHostOcclusionTest {
417 public: 415 public:
418 virtual void SetupTree() override { 416 void SetupTree() override {
419 FilterOperations filters; 417 FilterOperations filters;
420 filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 418 filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
421 419
422 // If the child layer has a filter that changes alpha values, and is below 420 // If the child layer has a filter that changes alpha values, and is below
423 // child2, then child2 should contribute to occlusion on everything, 421 // child2, then child2 should contribute to occlusion on everything,
424 // and child shouldn't contribute to the root 422 // and child shouldn't contribute to the root
425 SetLayerPropertiesForTesting( 423 SetLayerPropertiesForTesting(
426 root_.get(), NULL, identity_matrix_, 424 root_.get(), NULL, identity_matrix_,
427 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true); 425 gfx::PointF(0.f, 0.f), gfx::Size(200, 200), true);
428 SetLayerPropertiesForTesting(child_.get(), 426 SetLayerPropertiesForTesting(child_.get(),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 LayerTreeTest::SetupTree(); 458 LayerTreeTest::SetupTree();
461 } 459 }
462 }; 460 };
463 461
464 SINGLE_AND_MULTI_THREAD_TEST_F( 462 SINGLE_AND_MULTI_THREAD_TEST_F(
465 LayerTreeHostOcclusionTestOcclusionOpacityFilter); 463 LayerTreeHostOcclusionTestOcclusionOpacityFilter);
466 464
467 class LayerTreeHostOcclusionTestOcclusionBlurFilter 465 class LayerTreeHostOcclusionTestOcclusionBlurFilter
468 : public LayerTreeHostOcclusionTest { 466 : public LayerTreeHostOcclusionTest {
469 public: 467 public:
470 virtual void SetupTree() override { 468 void SetupTree() override {
471 gfx::Transform child_transform; 469 gfx::Transform child_transform;
472 child_transform.Translate(250.0, 250.0); 470 child_transform.Translate(250.0, 250.0);
473 child_transform.Rotate(90.0); 471 child_transform.Rotate(90.0);
474 child_transform.Translate(-250.0, -250.0); 472 child_transform.Translate(-250.0, -250.0);
475 473
476 FilterOperations filters; 474 FilterOperations filters;
477 filters.Append(FilterOperation::CreateBlurFilter(10.f)); 475 filters.Append(FilterOperation::CreateBlurFilter(10.f));
478 476
479 // If the child layer has a filter that moves pixels/changes alpha, and is 477 // If the child layer has a filter that moves pixels/changes alpha, and is
480 // below child2, then child should not inherit occlusion from outside its 478 // below child2, then child should not inherit occlusion from outside its
(...skipping 23 matching lines...) Expand all
504 }; 502 };
505 503
506 SINGLE_AND_MULTI_THREAD_TEST_F( 504 SINGLE_AND_MULTI_THREAD_TEST_F(
507 LayerTreeHostOcclusionTestOcclusionBlurFilter); 505 LayerTreeHostOcclusionTestOcclusionBlurFilter);
508 506
509 class LayerTreeHostOcclusionTestOcclusionCopyRequest 507 class LayerTreeHostOcclusionTestOcclusionCopyRequest
510 : public LayerTreeHostOcclusionTest { 508 : public LayerTreeHostOcclusionTest {
511 public: 509 public:
512 static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} 510 static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
513 511
514 virtual void SetupTree() override { 512 void SetupTree() override {
515 // If the child layer has copy request, and is below child2, 513 // If the child layer has copy request, and is below child2,
516 // then child should not inherit occlusion from outside its subtree. 514 // then child should not inherit occlusion from outside its subtree.
517 // The child layer will still receive occlusion from inside, and 515 // The child layer will still receive occlusion from inside, and
518 // the root layer will recive occlusion from child. 516 // the root layer will recive occlusion from child.
519 SetLayerPropertiesForTesting( 517 SetLayerPropertiesForTesting(
520 root_.get(), NULL, identity_matrix_, 518 root_.get(), NULL, identity_matrix_,
521 gfx::PointF(), gfx::Size(100, 100), true); 519 gfx::PointF(), gfx::Size(100, 100), true);
522 SetLayerPropertiesForTesting( 520 SetLayerPropertiesForTesting(
523 child_.get(), root_.get(), identity_matrix_, 521 child_.get(), root_.get(), identity_matrix_,
524 gfx::PointF(), gfx::Size(75, 75), true); 522 gfx::PointF(), gfx::Size(75, 75), true);
(...skipping 14 matching lines...) Expand all
539 layer_tree_host()->SetRootLayer(root_); 537 layer_tree_host()->SetRootLayer(root_);
540 LayerTreeTest::SetupTree(); 538 LayerTreeTest::SetupTree();
541 } 539 }
542 }; 540 };
543 541
544 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionCopyRequest); 542 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionCopyRequest);
545 543
546 class LayerTreeHostOcclusionTestOcclusionReplica 544 class LayerTreeHostOcclusionTestOcclusionReplica
547 : public LayerTreeHostOcclusionTest { 545 : public LayerTreeHostOcclusionTest {
548 public: 546 public:
549 virtual void SetupTree() override { 547 void SetupTree() override {
550 // If the child layer has copy request, and is below child2, 548 // If the child layer has copy request, and is below child2,
551 // then child should not inherit occlusion from outside its subtree. 549 // then child should not inherit occlusion from outside its subtree.
552 // The child layer will still receive occlusion from inside, and 550 // The child layer will still receive occlusion from inside, and
553 // the root layer will recive occlusion from child. 551 // the root layer will recive occlusion from child.
554 SetLayerPropertiesForTesting( 552 SetLayerPropertiesForTesting(
555 root_.get(), NULL, identity_matrix_, 553 root_.get(), NULL, identity_matrix_,
556 gfx::PointF(), gfx::Size(100, 100), true); 554 gfx::PointF(), gfx::Size(100, 100), true);
557 SetLayerPropertiesForTesting( 555 SetLayerPropertiesForTesting(
558 child_.get(), root_.get(), identity_matrix_, 556 child_.get(), root_.get(), identity_matrix_,
559 gfx::PointF(), gfx::Size(75, 75), true); 557 gfx::PointF(), gfx::Size(75, 75), true);
(...skipping 14 matching lines...) Expand all
574 layer_tree_host()->SetRootLayer(root_); 572 layer_tree_host()->SetRootLayer(root_);
575 LayerTreeTest::SetupTree(); 573 LayerTreeTest::SetupTree();
576 } 574 }
577 }; 575 };
578 576
579 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionReplica); 577 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestOcclusionReplica);
580 578
581 class LayerTreeHostOcclusionTestManySurfaces 579 class LayerTreeHostOcclusionTestManySurfaces
582 : public LayerTreeHostOcclusionTest { 580 : public LayerTreeHostOcclusionTest {
583 public: 581 public:
584 virtual void SetupTree() override { 582 void SetupTree() override {
585 // We create enough RenderSurfaces that it will trigger Vector reallocation 583 // We create enough RenderSurfaces that it will trigger Vector reallocation
586 // while computing occlusion. 584 // while computing occlusion.
587 std::vector<scoped_refptr<TestLayer>> layers; 585 std::vector<scoped_refptr<TestLayer>> layers;
588 int num_surfaces = 200; 586 int num_surfaces = 200;
589 int root_width = 400; 587 int root_width = 400;
590 int root_height = 400; 588 int root_height = 400;
591 589
592 for (int i = 0; i < num_surfaces; ++i) { 590 for (int i = 0; i < num_surfaces; ++i) {
593 layers.push_back(TestLayer::Create()); 591 layers.push_back(TestLayer::Create());
594 if (i == 0) { 592 if (i == 0) {
(...skipping 25 matching lines...) Expand all
620 618
621 layer_tree_host()->SetRootLayer(layers[0]); 619 layer_tree_host()->SetRootLayer(layers[0]);
622 LayerTreeTest::SetupTree(); 620 LayerTreeTest::SetupTree();
623 } 621 }
624 }; 622 };
625 623
626 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestManySurfaces); 624 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestManySurfaces);
627 625
628 } // namespace 626 } // namespace
629 } // namespace cc 627 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_no_message_loop.cc ('k') | cc/trees/layer_tree_host_unittest_picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698