OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/output/compositor_frame.h" | 5 #include "cc/output/compositor_frame.h" |
6 #include "cc/output/delegated_frame_data.h" | 6 #include "cc/output/delegated_frame_data.h" |
7 #include "cc/quads/render_pass.h" | 7 #include "cc/quads/render_pass.h" |
8 #include "cc/quads/render_pass_draw_quad.h" | 8 #include "cc/quads/render_pass_draw_quad.h" |
9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 protected: | 53 protected: |
54 SurfaceManager manager_; | 54 SurfaceManager manager_; |
55 EmptySurfaceFactoryClient empty_client_; | 55 EmptySurfaceFactoryClient empty_client_; |
56 SurfaceFactory factory_; | 56 SurfaceFactory factory_; |
57 SurfaceAggregator aggregator_; | 57 SurfaceAggregator aggregator_; |
58 }; | 58 }; |
59 | 59 |
60 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 60 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
61 SurfaceId one_id(7); | 61 SurfaceId one_id(7); |
62 factory_.Create(one_id, SurfaceSize()); | 62 factory_.Create(one_id); |
63 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); | 63 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); |
64 EXPECT_FALSE(frame); | 64 EXPECT_FALSE(frame); |
65 factory_.Destroy(one_id); | 65 factory_.Destroy(one_id); |
66 } | 66 } |
67 | 67 |
68 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 68 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
69 public: | 69 public: |
70 SurfaceAggregatorValidSurfaceTest() : allocator_(1u), child_allocator_(2u) {} | 70 SurfaceAggregatorValidSurfaceTest() : allocator_(1u), child_allocator_(2u) {} |
71 | 71 |
72 virtual void SetUp() { | 72 virtual void SetUp() { |
73 SurfaceAggregatorTest::SetUp(); | 73 SurfaceAggregatorTest::SetUp(); |
74 root_surface_id_ = allocator_.GenerateId(); | 74 root_surface_id_ = allocator_.GenerateId(); |
75 factory_.Create(root_surface_id_, SurfaceSize()); | 75 factory_.Create(root_surface_id_); |
76 } | 76 } |
77 | 77 |
78 virtual void TearDown() { | 78 virtual void TearDown() { |
79 factory_.Destroy(root_surface_id_); | 79 factory_.Destroy(root_surface_id_); |
80 SurfaceAggregatorTest::TearDown(); | 80 SurfaceAggregatorTest::TearDown(); |
81 } | 81 } |
82 | 82 |
83 void AggregateAndVerify(test::Pass* expected_passes, | 83 void AggregateAndVerify(test::Pass* expected_passes, |
84 size_t expected_pass_count, | 84 size_t expected_pass_count, |
85 SurfaceId* surface_ids, | 85 SurfaceId* surface_ids, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 150 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
151 | 151 |
152 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 152 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
153 | 153 |
154 SurfaceId ids[] = {root_surface_id_}; | 154 SurfaceId ids[] = {root_surface_id_}; |
155 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 155 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
156 } | 156 } |
157 | 157 |
158 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 158 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
159 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 159 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
160 factory_.Create(embedded_surface_id, SurfaceSize()); | 160 factory_.Create(embedded_surface_id); |
161 | 161 |
162 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 162 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
163 test::Pass embedded_passes[] = { | 163 test::Pass embedded_passes[] = { |
164 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 164 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
165 | 165 |
166 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); | 166 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); |
167 | 167 |
168 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 168 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
169 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 169 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
170 | 170 |
(...skipping 12 matching lines...) Expand all Loading... |
183 SharedQuadStateList& shared_quad_state_list( | 183 SharedQuadStateList& shared_quad_state_list( |
184 render_pass_list[0]->shared_quad_state_list); | 184 render_pass_list[0]->shared_quad_state_list); |
185 ASSERT_EQ(1u, shared_quad_state_list.size()); | 185 ASSERT_EQ(1u, shared_quad_state_list.size()); |
186 EXPECT_EQ(.5f, shared_quad_state_list.ElementAt(0)->opacity); | 186 EXPECT_EQ(.5f, shared_quad_state_list.ElementAt(0)->opacity); |
187 | 187 |
188 factory_.Destroy(embedded_surface_id); | 188 factory_.Destroy(embedded_surface_id); |
189 } | 189 } |
190 | 190 |
191 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCombinedWithNesting) { | 191 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCombinedWithNesting) { |
192 SurfaceId surface_id1 = allocator_.GenerateId(); | 192 SurfaceId surface_id1 = allocator_.GenerateId(); |
193 factory_.Create(surface_id1, SurfaceSize()); | 193 factory_.Create(surface_id1); |
194 SurfaceId surface_id2 = allocator_.GenerateId(); | 194 SurfaceId surface_id2 = allocator_.GenerateId(); |
195 factory_.Create(surface_id2, SurfaceSize()); | 195 factory_.Create(surface_id2); |
196 | 196 |
197 // |surface_id1| is color quad. | 197 // |surface_id1| is color quad. |
198 { | 198 { |
199 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 199 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
200 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 200 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
201 SubmitFrame(passes, arraysize(passes), surface_id1); | 201 SubmitFrame(passes, arraysize(passes), surface_id1); |
202 } | 202 } |
203 | 203 |
204 // |surface_id2| has a color quad and a surface quad using |surface_id1| at .5 | 204 // |surface_id2| has a color quad and a surface quad using |surface_id1| at .5 |
205 // opacity. | 205 // opacity. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 SurfaceId ids[] = {root_surface_id_}; | 251 SurfaceId ids[] = {root_surface_id_}; |
252 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 252 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
253 } | 253 } |
254 | 254 |
255 // This tests very simple embedding. root_surface has a frame containing a few | 255 // This tests very simple embedding. root_surface has a frame containing a few |
256 // solid color quads and a surface quad referencing embedded_surface. | 256 // solid color quads and a surface quad referencing embedded_surface. |
257 // embedded_surface has a frame containing only a solid color quad. The solid | 257 // embedded_surface has a frame containing only a solid color quad. The solid |
258 // color quad should be aggregated into the final frame. | 258 // color quad should be aggregated into the final frame. |
259 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 259 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
260 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 260 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
261 factory_.Create(embedded_surface_id, SurfaceSize()); | 261 factory_.Create(embedded_surface_id); |
262 | 262 |
263 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 263 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
264 test::Pass embedded_passes[] = { | 264 test::Pass embedded_passes[] = { |
265 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 265 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
266 | 266 |
267 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); | 267 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); |
268 | 268 |
269 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 269 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
270 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 270 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
271 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 271 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
272 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 272 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
273 | 273 |
274 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); | 274 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); |
275 | 275 |
276 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 276 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
277 test::Quad::SolidColorQuad(SK_ColorGREEN), | 277 test::Quad::SolidColorQuad(SK_ColorGREEN), |
278 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 278 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
279 test::Pass expected_passes[] = { | 279 test::Pass expected_passes[] = { |
280 test::Pass(expected_quads, arraysize(expected_quads))}; | 280 test::Pass(expected_quads, arraysize(expected_quads))}; |
281 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; | 281 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; |
282 AggregateAndVerify( | 282 AggregateAndVerify( |
283 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 283 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
284 | 284 |
285 factory_.Destroy(embedded_surface_id); | 285 factory_.Destroy(embedded_surface_id); |
286 } | 286 } |
287 | 287 |
288 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 288 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
289 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 289 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
290 factory_.Create(embedded_surface_id, SurfaceSize()); | 290 factory_.Create(embedded_surface_id); |
291 | 291 |
292 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 292 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
293 test::Pass embedded_passes[] = { | 293 test::Pass embedded_passes[] = { |
294 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 294 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
295 | 295 |
296 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); | 296 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); |
297 scoped_ptr<CopyOutputRequest> copy_request( | 297 scoped_ptr<CopyOutputRequest> copy_request( |
298 CopyOutputRequest::CreateEmptyRequest()); | 298 CopyOutputRequest::CreateEmptyRequest()); |
299 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 299 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
300 factory_.RequestCopyOfSurface(embedded_surface_id, copy_request.Pass()); | 300 factory_.RequestCopyOfSurface(embedded_surface_id, copy_request.Pass()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 337 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
338 aggregator_.previous_contained_surfaces().end()); | 338 aggregator_.previous_contained_surfaces().end()); |
339 } | 339 } |
340 | 340 |
341 factory_.Destroy(embedded_surface_id); | 341 factory_.Destroy(embedded_surface_id); |
342 } | 342 } |
343 | 343 |
344 // Root surface may contain copy requests. | 344 // Root surface may contain copy requests. |
345 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 345 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
346 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 346 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
347 factory_.Create(embedded_surface_id, SurfaceSize()); | 347 factory_.Create(embedded_surface_id); |
348 | 348 |
349 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 349 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
350 test::Pass embedded_passes[] = { | 350 test::Pass embedded_passes[] = { |
351 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 351 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
352 | 352 |
353 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); | 353 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); |
354 scoped_ptr<CopyOutputRequest> copy_request( | 354 scoped_ptr<CopyOutputRequest> copy_request( |
355 CopyOutputRequest::CreateEmptyRequest()); | 355 CopyOutputRequest::CreateEmptyRequest()); |
356 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 356 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
357 scoped_ptr<CopyOutputRequest> copy_request2( | 357 scoped_ptr<CopyOutputRequest> copy_request2( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 ASSERT_EQ(2u, original_pass_list.size()); | 425 ASSERT_EQ(2u, original_pass_list.size()); |
426 DCHECK(original_pass_list[0]->copy_requests.empty()); | 426 DCHECK(original_pass_list[0]->copy_requests.empty()); |
427 DCHECK(original_pass_list[1]->copy_requests.empty()); | 427 DCHECK(original_pass_list[1]->copy_requests.empty()); |
428 | 428 |
429 factory_.Destroy(embedded_surface_id); | 429 factory_.Destroy(embedded_surface_id); |
430 } | 430 } |
431 | 431 |
432 // This tests referencing a surface that has multiple render passes. | 432 // This tests referencing a surface that has multiple render passes. |
433 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 433 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
434 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); | 434 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); |
435 factory_.Create(embedded_surface_id, SurfaceSize()); | 435 factory_.Create(embedded_surface_id); |
436 | 436 |
437 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 437 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
438 RenderPassId(1, 3)}; | 438 RenderPassId(1, 3)}; |
439 | 439 |
440 test::Quad embedded_quads[][2] = { | 440 test::Quad embedded_quads[][2] = { |
441 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 441 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
442 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 442 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
443 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 443 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
444 test::Pass embedded_passes[] = { | 444 test::Pass embedded_passes[] = { |
445 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 445 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 test::Pass(expected_quads, arraysize(expected_quads))}; | 583 test::Pass(expected_quads, arraysize(expected_quads))}; |
584 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; | 584 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; |
585 AggregateAndVerify( | 585 AggregateAndVerify( |
586 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 586 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
587 } | 587 } |
588 | 588 |
589 // Tests a reference to a valid surface with no submitted frame. This quad | 589 // Tests a reference to a valid surface with no submitted frame. This quad |
590 // should also just be dropped. | 590 // should also just be dropped. |
591 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 591 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
592 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); | 592 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); |
593 factory_.Create(surface_with_no_frame_id, gfx::Size(5, 5)); | 593 factory_.Create(surface_with_no_frame_id); |
594 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 594 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
595 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 595 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
596 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 596 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
597 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 597 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
598 | 598 |
599 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 599 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
600 | 600 |
601 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 601 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
602 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 602 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
603 test::Pass expected_passes[] = { | 603 test::Pass expected_passes[] = { |
(...skipping 17 matching lines...) Expand all Loading... |
621 test::Pass expected_passes[] = { | 621 test::Pass expected_passes[] = { |
622 test::Pass(expected_quads, arraysize(expected_quads))}; | 622 test::Pass(expected_quads, arraysize(expected_quads))}; |
623 SurfaceId ids[] = {root_surface_id_}; | 623 SurfaceId ids[] = {root_surface_id_}; |
624 AggregateAndVerify( | 624 AggregateAndVerify( |
625 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 625 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
626 } | 626 } |
627 | 627 |
628 // Tests a more complex cycle with one intermediate surface. | 628 // Tests a more complex cycle with one intermediate surface. |
629 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 629 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
630 SurfaceId child_surface_id = allocator_.GenerateId(); | 630 SurfaceId child_surface_id = allocator_.GenerateId(); |
631 factory_.Create(child_surface_id, SurfaceSize()); | 631 factory_.Create(child_surface_id); |
632 | 632 |
633 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 633 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
634 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 634 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
635 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 635 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
636 test::Pass parent_passes[] = { | 636 test::Pass parent_passes[] = { |
637 test::Pass(parent_quads, arraysize(parent_quads))}; | 637 test::Pass(parent_quads, arraysize(parent_quads))}; |
638 | 638 |
639 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); | 639 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); |
640 | 640 |
641 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 641 test::Quad child_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
(...skipping 18 matching lines...) Expand all Loading... |
660 SurfaceId ids[] = {root_surface_id_, child_surface_id}; | 660 SurfaceId ids[] = {root_surface_id_, child_surface_id}; |
661 AggregateAndVerify( | 661 AggregateAndVerify( |
662 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 662 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
663 factory_.Destroy(child_surface_id); | 663 factory_.Destroy(child_surface_id); |
664 } | 664 } |
665 | 665 |
666 // Tests that we map render pass IDs from different surfaces into a unified | 666 // Tests that we map render pass IDs from different surfaces into a unified |
667 // namespace and update RenderPassDrawQuad's id references to match. | 667 // namespace and update RenderPassDrawQuad's id references to match. |
668 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 668 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
669 SurfaceId child_surface_id = allocator_.GenerateId(); | 669 SurfaceId child_surface_id = allocator_.GenerateId(); |
670 factory_.Create(child_surface_id, SurfaceSize()); | 670 factory_.Create(child_surface_id); |
671 | 671 |
672 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 672 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
673 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 673 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
674 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 674 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
675 test::Pass surface_passes[] = { | 675 test::Pass surface_passes[] = { |
676 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 676 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
677 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 677 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
678 | 678 |
679 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id); | 679 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id); |
680 | 680 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 SkXfermode::kSrc_Mode, // 1 | 788 SkXfermode::kSrc_Mode, // 1 |
789 SkXfermode::kDst_Mode, // 2 | 789 SkXfermode::kDst_Mode, // 2 |
790 SkXfermode::kSrcOver_Mode, // 3 | 790 SkXfermode::kSrcOver_Mode, // 3 |
791 SkXfermode::kDstOver_Mode, // 4 | 791 SkXfermode::kDstOver_Mode, // 4 |
792 SkXfermode::kSrcIn_Mode, // 5 | 792 SkXfermode::kSrcIn_Mode, // 5 |
793 SkXfermode::kDstIn_Mode, // 6 | 793 SkXfermode::kDstIn_Mode, // 6 |
794 }; | 794 }; |
795 | 795 |
796 RenderPassId pass_id(1, 1); | 796 RenderPassId pass_id(1, 1); |
797 SurfaceId grandchild_surface_id = allocator_.GenerateId(); | 797 SurfaceId grandchild_surface_id = allocator_.GenerateId(); |
798 factory_.Create(grandchild_surface_id, SurfaceSize()); | 798 factory_.Create(grandchild_surface_id); |
799 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 799 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
800 gfx::Rect output_rect(SurfaceSize()); | 800 gfx::Rect output_rect(SurfaceSize()); |
801 gfx::Rect damage_rect(SurfaceSize()); | 801 gfx::Rect damage_rect(SurfaceSize()); |
802 gfx::Transform transform_to_root_target; | 802 gfx::Transform transform_to_root_target; |
803 grandchild_pass->SetNew( | 803 grandchild_pass->SetNew( |
804 pass_id, output_rect, damage_rect, transform_to_root_target); | 804 pass_id, output_rect, damage_rect, transform_to_root_target); |
805 AddSolidColorQuadWithBlendMode( | 805 AddSolidColorQuadWithBlendMode( |
806 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 806 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
807 QueuePassAsFrame(grandchild_pass.Pass(), grandchild_surface_id); | 807 QueuePassAsFrame(grandchild_pass.Pass(), grandchild_surface_id); |
808 | 808 |
809 SurfaceId child_one_surface_id = allocator_.GenerateId(); | 809 SurfaceId child_one_surface_id = allocator_.GenerateId(); |
810 factory_.Create(child_one_surface_id, SurfaceSize()); | 810 factory_.Create(child_one_surface_id); |
811 | 811 |
812 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 812 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
813 child_one_pass->SetNew( | 813 child_one_pass->SetNew( |
814 pass_id, output_rect, damage_rect, transform_to_root_target); | 814 pass_id, output_rect, damage_rect, transform_to_root_target); |
815 AddSolidColorQuadWithBlendMode( | 815 AddSolidColorQuadWithBlendMode( |
816 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 816 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
817 SurfaceDrawQuad* grandchild_surface_quad = | 817 SurfaceDrawQuad* grandchild_surface_quad = |
818 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 818 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
819 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 819 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
820 gfx::Rect(SurfaceSize()), | 820 gfx::Rect(SurfaceSize()), |
821 gfx::Rect(SurfaceSize()), | 821 gfx::Rect(SurfaceSize()), |
822 grandchild_surface_id); | 822 grandchild_surface_id); |
823 AddSolidColorQuadWithBlendMode( | 823 AddSolidColorQuadWithBlendMode( |
824 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 824 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
825 QueuePassAsFrame(child_one_pass.Pass(), child_one_surface_id); | 825 QueuePassAsFrame(child_one_pass.Pass(), child_one_surface_id); |
826 | 826 |
827 SurfaceId child_two_surface_id = allocator_.GenerateId(); | 827 SurfaceId child_two_surface_id = allocator_.GenerateId(); |
828 factory_.Create(child_two_surface_id, SurfaceSize()); | 828 factory_.Create(child_two_surface_id); |
829 | 829 |
830 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 830 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
831 child_two_pass->SetNew( | 831 child_two_pass->SetNew( |
832 pass_id, output_rect, damage_rect, transform_to_root_target); | 832 pass_id, output_rect, damage_rect, transform_to_root_target); |
833 AddSolidColorQuadWithBlendMode( | 833 AddSolidColorQuadWithBlendMode( |
834 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 834 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
835 QueuePassAsFrame(child_two_pass.Pass(), child_two_surface_id); | 835 QueuePassAsFrame(child_two_pass.Pass(), child_two_surface_id); |
836 | 836 |
837 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); | 837 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); |
838 root_pass->SetNew( | 838 root_pass->SetNew( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 // The child surface has two passes. The first pass has a quad with a transform | 896 // The child surface has two passes. The first pass has a quad with a transform |
897 // of +5 in the x direction. The second pass has a reference to the first pass' | 897 // of +5 in the x direction. The second pass has a reference to the first pass' |
898 // pass id and a transform of +8 in the x direction. | 898 // pass id and a transform of +8 in the x direction. |
899 // | 899 // |
900 // After aggregation, the child surface's root pass quad should have both | 900 // After aggregation, the child surface's root pass quad should have both |
901 // transforms concatenated for a total transform of +8 x, +10 y. The | 901 // transforms concatenated for a total transform of +8 x, +10 y. The |
902 // contributing render pass' transform in the aggregate frame should not be | 902 // contributing render pass' transform in the aggregate frame should not be |
903 // affected. | 903 // affected. |
904 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 904 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
905 SurfaceId child_surface_id = allocator_.GenerateId(); | 905 SurfaceId child_surface_id = allocator_.GenerateId(); |
906 factory_.Create(child_surface_id, SurfaceSize()); | 906 factory_.Create(child_surface_id); |
907 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 907 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
908 test::Quad child_quads[][1] = { | 908 test::Quad child_quads[][1] = { |
909 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 909 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
910 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 910 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
911 test::Pass child_passes[] = { | 911 test::Pass child_passes[] = { |
912 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 912 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
913 test::Pass(child_quads[1], arraysize(child_quads[1]), child_pass_id[1])}; | 913 test::Pass(child_quads[1], arraysize(child_quads[1]), child_pass_id[1])}; |
914 | 914 |
915 RenderPassList child_pass_list; | 915 RenderPassList child_pass_list; |
916 AddPasses(&child_pass_list, | 916 AddPasses(&child_pass_list, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 aggregated_pass_list[1] | 1031 aggregated_pass_list[1] |
1032 ->shared_quad_state_list.ElementAt(1) | 1032 ->shared_quad_state_list.ElementAt(1) |
1033 ->clip_rect.ToString()); | 1033 ->clip_rect.ToString()); |
1034 | 1034 |
1035 factory_.Destroy(child_surface_id); | 1035 factory_.Destroy(child_surface_id); |
1036 } | 1036 } |
1037 | 1037 |
1038 // Tests that damage rects are aggregated correctly when surfaces change. | 1038 // Tests that damage rects are aggregated correctly when surfaces change. |
1039 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 1039 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
1040 SurfaceId child_surface_id = allocator_.GenerateId(); | 1040 SurfaceId child_surface_id = allocator_.GenerateId(); |
1041 factory_.Create(child_surface_id, SurfaceSize()); | 1041 factory_.Create(child_surface_id); |
1042 RenderPassId child_pass_id = RenderPassId(1, 1); | 1042 RenderPassId child_pass_id = RenderPassId(1, 1); |
1043 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1043 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1044 test::Pass child_passes[] = { | 1044 test::Pass child_passes[] = { |
1045 test::Pass(child_quads, arraysize(child_quads), child_pass_id)}; | 1045 test::Pass(child_quads, arraysize(child_quads), child_pass_id)}; |
1046 | 1046 |
1047 RenderPassList child_pass_list; | 1047 RenderPassList child_pass_list; |
1048 AddPasses(&child_pass_list, | 1048 AddPasses(&child_pass_list, |
1049 gfx::Rect(SurfaceSize()), | 1049 gfx::Rect(SurfaceSize()), |
1050 child_passes, | 1050 child_passes, |
1051 arraysize(child_passes)); | 1051 arraysize(child_passes)); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 frame_data->render_pass_list.push_back(pass.Pass()); | 1293 frame_data->render_pass_list.push_back(pass.Pass()); |
1294 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 1294 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
1295 frame->delegated_frame_data = frame_data.Pass(); | 1295 frame->delegated_frame_data = frame_data.Pass(); |
1296 factory->SubmitFrame(surface_id, frame.Pass(), base::Closure()); | 1296 factory->SubmitFrame(surface_id, frame.Pass(), base::Closure()); |
1297 } | 1297 } |
1298 | 1298 |
1299 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1299 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
1300 ResourceTrackingSurfaceFactoryClient client; | 1300 ResourceTrackingSurfaceFactoryClient client; |
1301 SurfaceFactory factory(&manager_, &client); | 1301 SurfaceFactory factory(&manager_, &client); |
1302 SurfaceId surface_id(7u); | 1302 SurfaceId surface_id(7u); |
1303 factory.Create(surface_id, SurfaceSize()); | 1303 factory.Create(surface_id); |
1304 | 1304 |
1305 ResourceProvider::ResourceId ids[] = {11, 12, 13}; | 1305 ResourceProvider::ResourceId ids[] = {11, 12, 13}; |
1306 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); | 1306 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); |
1307 | 1307 |
1308 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 1308 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); |
1309 | 1309 |
1310 // Nothing should be available to be returned yet. | 1310 // Nothing should be available to be returned yet. |
1311 EXPECT_TRUE(client.returned_resources().empty()); | 1311 EXPECT_TRUE(client.returned_resources().empty()); |
1312 | 1312 |
1313 SubmitFrameWithResources(NULL, 0u, &factory, surface_id); | 1313 SubmitFrameWithResources(NULL, 0u, &factory, surface_id); |
1314 | 1314 |
1315 frame = aggregator_->Aggregate(surface_id); | 1315 frame = aggregator_->Aggregate(surface_id); |
1316 | 1316 |
1317 ASSERT_EQ(3u, client.returned_resources().size()); | 1317 ASSERT_EQ(3u, client.returned_resources().size()); |
1318 ResourceProvider::ResourceId returned_ids[3]; | 1318 ResourceProvider::ResourceId returned_ids[3]; |
1319 for (size_t i = 0; i < 3; ++i) { | 1319 for (size_t i = 0; i < 3; ++i) { |
1320 returned_ids[i] = client.returned_resources()[i].id; | 1320 returned_ids[i] = client.returned_resources()[i].id; |
1321 } | 1321 } |
1322 EXPECT_THAT(returned_ids, | 1322 EXPECT_THAT(returned_ids, |
1323 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1323 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1324 factory.Destroy(surface_id); | 1324 factory.Destroy(surface_id); |
1325 } | 1325 } |
1326 | 1326 |
1327 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1327 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
1328 ResourceTrackingSurfaceFactoryClient client; | 1328 ResourceTrackingSurfaceFactoryClient client; |
1329 SurfaceFactory factory(&manager_, &client); | 1329 SurfaceFactory factory(&manager_, &client); |
1330 SurfaceId surface_id(7u); | 1330 SurfaceId surface_id(7u); |
1331 factory.Create(surface_id, SurfaceSize()); | 1331 factory.Create(surface_id); |
1332 SurfaceId surface_id2(8u); | 1332 SurfaceId surface_id2(8u); |
1333 factory.Create(surface_id2, SurfaceSize()); | 1333 factory.Create(surface_id2); |
1334 | 1334 |
1335 ResourceProvider::ResourceId ids[] = {11, 12, 13}; | 1335 ResourceProvider::ResourceId ids[] = {11, 12, 13}; |
1336 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); | 1336 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); |
1337 ResourceProvider::ResourceId ids2[] = {14, 15, 16}; | 1337 ResourceProvider::ResourceId ids2[] = {14, 15, 16}; |
1338 SubmitFrameWithResources(ids2, arraysize(ids2), &factory, surface_id2); | 1338 SubmitFrameWithResources(ids2, arraysize(ids2), &factory, surface_id2); |
1339 | 1339 |
1340 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 1340 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); |
1341 | 1341 |
1342 SubmitFrameWithResources(NULL, 0, &factory, surface_id); | 1342 SubmitFrameWithResources(NULL, 0, &factory, surface_id); |
1343 | 1343 |
(...skipping 11 matching lines...) Expand all Loading... |
1355 EXPECT_THAT(returned_ids, | 1355 EXPECT_THAT(returned_ids, |
1356 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1356 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1357 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1357 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1358 factory.Destroy(surface_id); | 1358 factory.Destroy(surface_id); |
1359 factory.Destroy(surface_id2); | 1359 factory.Destroy(surface_id2); |
1360 } | 1360 } |
1361 | 1361 |
1362 } // namespace | 1362 } // namespace |
1363 } // namespace cc | 1363 } // namespace cc |
1364 | 1364 |
OLD | NEW |