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/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 SurfaceManager manager_; | 74 SurfaceManager manager_; |
75 EmptySurfaceFactoryClient empty_client_; | 75 EmptySurfaceFactoryClient empty_client_; |
76 SurfaceFactory factory_; | 76 SurfaceFactory factory_; |
77 SurfaceAggregator aggregator_; | 77 SurfaceAggregator aggregator_; |
78 }; | 78 }; |
79 | 79 |
80 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 80 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
81 SurfaceId one_id(0, 7, 0); | 81 SurfaceId one_id(0, 7, 0); |
82 factory_.Create(one_id); | 82 factory_.Create(one_id); |
83 | 83 |
84 std::unique_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); | 84 CompositorFrame frame = aggregator_.Aggregate(one_id); |
85 EXPECT_FALSE(frame); | 85 EXPECT_FALSE(frame.delegated_frame_data); |
86 | 86 |
87 factory_.Destroy(one_id); | 87 factory_.Destroy(one_id); |
88 } | 88 } |
89 | 89 |
90 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 90 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
91 public: | 91 public: |
92 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 92 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
93 : SurfaceAggregatorTest(use_damage_rect), | 93 : SurfaceAggregatorTest(use_damage_rect), |
94 allocator_(1u), | 94 allocator_(1u), |
95 child_allocator_(2u) {} | 95 child_allocator_(2u) {} |
96 SurfaceAggregatorValidSurfaceTest() | 96 SurfaceAggregatorValidSurfaceTest() |
97 : SurfaceAggregatorValidSurfaceTest(false) {} | 97 : SurfaceAggregatorValidSurfaceTest(false) {} |
98 | 98 |
99 void SetUp() override { | 99 void SetUp() override { |
100 SurfaceAggregatorTest::SetUp(); | 100 SurfaceAggregatorTest::SetUp(); |
101 root_surface_id_ = allocator_.GenerateId(); | 101 root_surface_id_ = allocator_.GenerateId(); |
102 factory_.Create(root_surface_id_); | 102 factory_.Create(root_surface_id_); |
103 root_surface_ = manager_.GetSurfaceForId(root_surface_id_); | 103 root_surface_ = manager_.GetSurfaceForId(root_surface_id_); |
104 } | 104 } |
105 | 105 |
106 void TearDown() override { | 106 void TearDown() override { |
107 factory_.Destroy(root_surface_id_); | 107 factory_.Destroy(root_surface_id_); |
108 SurfaceAggregatorTest::TearDown(); | 108 SurfaceAggregatorTest::TearDown(); |
109 } | 109 } |
110 | 110 |
111 void AggregateAndVerify(test::Pass* expected_passes, | 111 void AggregateAndVerify(test::Pass* expected_passes, |
112 size_t expected_pass_count, | 112 size_t expected_pass_count, |
113 SurfaceId* surface_ids, | 113 SurfaceId* surface_ids, |
114 size_t expected_surface_count) { | 114 size_t expected_surface_count) { |
115 std::unique_ptr<CompositorFrame> aggregated_frame = | 115 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
116 aggregator_.Aggregate(root_surface_id_); | |
117 | 116 |
118 ASSERT_TRUE(aggregated_frame); | 117 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
119 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
120 | 118 |
121 DelegatedFrameData* frame_data = | 119 DelegatedFrameData* frame_data = |
122 aggregated_frame->delegated_frame_data.get(); | 120 aggregated_frame.delegated_frame_data.get(); |
123 | 121 |
124 TestPassesMatchExpectations( | 122 TestPassesMatchExpectations( |
125 expected_passes, expected_pass_count, &frame_data->render_pass_list); | 123 expected_passes, expected_pass_count, &frame_data->render_pass_list); |
126 | 124 |
127 // Ensure no duplicate pass ids output. | 125 // Ensure no duplicate pass ids output. |
128 std::set<RenderPassId> used_passes; | 126 std::set<RenderPassId> used_passes; |
129 for (const auto& pass : frame_data->render_pass_list) { | 127 for (const auto& pass : frame_data->render_pass_list) { |
130 EXPECT_TRUE(used_passes.insert(pass->id).second); | 128 EXPECT_TRUE(used_passes.insert(pass->id).second); |
131 } | 129 } |
132 | 130 |
133 EXPECT_EQ(expected_surface_count, | 131 EXPECT_EQ(expected_surface_count, |
134 aggregator_.previous_contained_surfaces().size()); | 132 aggregator_.previous_contained_surfaces().size()); |
135 for (size_t i = 0; i < expected_surface_count; i++) { | 133 for (size_t i = 0; i < expected_surface_count; i++) { |
136 EXPECT_TRUE( | 134 EXPECT_TRUE( |
137 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 135 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
138 aggregator_.previous_contained_surfaces().end()); | 136 aggregator_.previous_contained_surfaces().end()); |
139 } | 137 } |
140 } | 138 } |
141 | 139 |
142 void SubmitPassListAsFrame(SurfaceId surface_id, RenderPassList* pass_list) { | 140 void SubmitPassListAsFrame(SurfaceId surface_id, RenderPassList* pass_list) { |
143 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 141 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
144 pass_list->swap(frame_data->render_pass_list); | 142 pass_list->swap(frame_data->render_pass_list); |
145 | 143 |
146 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 144 CompositorFrame frame; |
147 frame->delegated_frame_data = std::move(frame_data); | 145 frame.delegated_frame_data = std::move(frame_data); |
148 | 146 |
149 factory_.SubmitCompositorFrame(surface_id, std::move(frame), | 147 factory_.SubmitCompositorFrame(surface_id, std::move(frame), |
150 SurfaceFactory::DrawCallback()); | 148 SurfaceFactory::DrawCallback()); |
151 } | 149 } |
152 | 150 |
153 void SubmitCompositorFrame(test::Pass* passes, | 151 void SubmitCompositorFrame(test::Pass* passes, |
154 size_t pass_count, | 152 size_t pass_count, |
155 SurfaceId surface_id) { | 153 SurfaceId surface_id) { |
156 RenderPassList pass_list; | 154 RenderPassList pass_list; |
157 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 155 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
158 SubmitPassListAsFrame(surface_id, &pass_list); | 156 SubmitPassListAsFrame(surface_id, &pass_list); |
159 } | 157 } |
160 | 158 |
161 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, | 159 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, |
162 SurfaceId surface_id) { | 160 SurfaceId surface_id) { |
163 std::unique_ptr<DelegatedFrameData> delegated_frame_data( | 161 std::unique_ptr<DelegatedFrameData> delegated_frame_data( |
164 new DelegatedFrameData); | 162 new DelegatedFrameData); |
165 delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 163 delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
166 | 164 |
167 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 165 CompositorFrame child_frame; |
168 child_frame->delegated_frame_data = std::move(delegated_frame_data); | 166 child_frame.delegated_frame_data = std::move(delegated_frame_data); |
169 | 167 |
170 factory_.SubmitCompositorFrame(surface_id, std::move(child_frame), | 168 factory_.SubmitCompositorFrame(surface_id, std::move(child_frame), |
171 SurfaceFactory::DrawCallback()); | 169 SurfaceFactory::DrawCallback()); |
172 } | 170 } |
173 | 171 |
174 protected: | 172 protected: |
175 SurfaceId root_surface_id_; | 173 SurfaceId root_surface_id_; |
176 Surface* root_surface_; | 174 Surface* root_surface_; |
177 SurfaceIdAllocator allocator_; | 175 SurfaceIdAllocator allocator_; |
178 SurfaceIdAllocator child_allocator_; | 176 SurfaceIdAllocator child_allocator_; |
(...skipping 27 matching lines...) Expand all Loading... |
206 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 204 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
207 | 205 |
208 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 206 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
209 embedded_surface_id); | 207 embedded_surface_id); |
210 | 208 |
211 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 209 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
212 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 210 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
213 | 211 |
214 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 212 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
215 | 213 |
216 std::unique_ptr<CompositorFrame> aggregated_frame = | 214 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
217 aggregator_.Aggregate(root_surface_id_); | |
218 | 215 |
219 ASSERT_TRUE(aggregated_frame); | 216 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
220 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
221 | 217 |
222 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 218 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
223 | 219 |
224 RenderPassList& render_pass_list(frame_data->render_pass_list); | 220 RenderPassList& render_pass_list(frame_data->render_pass_list); |
225 ASSERT_EQ(2u, render_pass_list.size()); | 221 ASSERT_EQ(2u, render_pass_list.size()); |
226 SharedQuadStateList& shared_quad_state_list( | 222 SharedQuadStateList& shared_quad_state_list( |
227 render_pass_list[0]->shared_quad_state_list); | 223 render_pass_list[0]->shared_quad_state_list); |
228 ASSERT_EQ(2u, shared_quad_state_list.size()); | 224 ASSERT_EQ(2u, shared_quad_state_list.size()); |
229 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); | 225 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); |
230 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); | 226 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); |
231 | 227 |
232 SharedQuadStateList& shared_quad_state_list2( | 228 SharedQuadStateList& shared_quad_state_list2( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 298 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
303 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); | 299 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); |
304 | 300 |
305 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 301 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
306 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 302 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
307 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 303 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
308 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 304 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
309 | 305 |
310 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 306 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
311 | 307 |
312 std::unique_ptr<CompositorFrame> aggregated_frame = | 308 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
313 aggregator_.Aggregate(root_surface_id_); | |
314 | 309 |
315 ASSERT_TRUE(aggregated_frame); | 310 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
316 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
317 | 311 |
318 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 312 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
319 | 313 |
320 test::Quad expected_quads[] = { | 314 test::Quad expected_quads[] = { |
321 test::Quad::SolidColorQuad(SK_ColorWHITE), | 315 test::Quad::SolidColorQuad(SK_ColorWHITE), |
322 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), | 316 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), |
323 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 317 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
324 test::Pass expected_passes[] = { | 318 test::Pass expected_passes[] = { |
325 test::Pass(embedded_quads, arraysize(embedded_quads)), | 319 test::Pass(embedded_quads, arraysize(embedded_quads)), |
326 test::Pass(expected_quads, arraysize(expected_quads))}; | 320 test::Pass(expected_quads, arraysize(expected_quads))}; |
327 TestPassesMatchExpectations(expected_passes, | 321 TestPassesMatchExpectations(expected_passes, |
328 arraysize(expected_passes), | 322 arraysize(expected_passes), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 AddPasses(&pass_list, | 368 AddPasses(&pass_list, |
375 gfx::Rect(SurfaceSize()), | 369 gfx::Rect(SurfaceSize()), |
376 root_passes, | 370 root_passes, |
377 arraysize(root_passes)); | 371 arraysize(root_passes)); |
378 pass_list[0]->copy_requests.push_back(std::move(copy_request)); | 372 pass_list[0]->copy_requests.push_back(std::move(copy_request)); |
379 pass_list[1]->copy_requests.push_back(std::move(copy_request2)); | 373 pass_list[1]->copy_requests.push_back(std::move(copy_request2)); |
380 | 374 |
381 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 375 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
382 pass_list.swap(frame_data->render_pass_list); | 376 pass_list.swap(frame_data->render_pass_list); |
383 | 377 |
384 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 378 CompositorFrame frame; |
385 frame->delegated_frame_data = std::move(frame_data); | 379 frame.delegated_frame_data = std::move(frame_data); |
386 | 380 |
387 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), | 381 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), |
388 SurfaceFactory::DrawCallback()); | 382 SurfaceFactory::DrawCallback()); |
389 } | 383 } |
390 | 384 |
391 std::unique_ptr<CompositorFrame> aggregated_frame = | 385 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
392 aggregator_.Aggregate(root_surface_id_); | |
393 | 386 |
394 ASSERT_TRUE(aggregated_frame); | 387 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
395 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
396 | 388 |
397 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 389 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
398 | 390 |
399 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 391 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
400 test::Quad::SolidColorQuad(SK_ColorGREEN), | 392 test::Quad::SolidColorQuad(SK_ColorGREEN), |
401 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 393 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
402 test::Pass expected_passes[] = { | 394 test::Pass expected_passes[] = { |
403 test::Pass(expected_quads, arraysize(expected_quads)), | 395 test::Pass(expected_quads, arraysize(expected_quads)), |
404 test::Pass(root_quads2, arraysize(root_quads2))}; | 396 test::Pass(root_quads2, arraysize(root_quads2))}; |
405 TestPassesMatchExpectations(expected_passes, | 397 TestPassesMatchExpectations(expected_passes, |
406 arraysize(expected_passes), | 398 arraysize(expected_passes), |
407 &frame_data->render_pass_list); | 399 &frame_data->render_pass_list); |
408 ASSERT_EQ(2u, frame_data->render_pass_list.size()); | 400 ASSERT_EQ(2u, frame_data->render_pass_list.size()); |
409 ASSERT_EQ(1u, frame_data->render_pass_list[0]->copy_requests.size()); | 401 ASSERT_EQ(1u, frame_data->render_pass_list[0]->copy_requests.size()); |
410 DCHECK_EQ(copy_request_ptr, | 402 DCHECK_EQ(copy_request_ptr, |
411 frame_data->render_pass_list[0]->copy_requests[0].get()); | 403 frame_data->render_pass_list[0]->copy_requests[0].get()); |
412 ASSERT_EQ(1u, frame_data->render_pass_list[1]->copy_requests.size()); | 404 ASSERT_EQ(1u, frame_data->render_pass_list[1]->copy_requests.size()); |
413 DCHECK_EQ(copy_request2_ptr, | 405 DCHECK_EQ(copy_request2_ptr, |
414 frame_data->render_pass_list[1]->copy_requests[0].get()); | 406 frame_data->render_pass_list[1]->copy_requests[0].get()); |
415 | 407 |
416 SurfaceId surface_ids[] = {root_surface_id_, embedded_surface_id}; | 408 SurfaceId surface_ids[] = {root_surface_id_, embedded_surface_id}; |
417 EXPECT_EQ(arraysize(surface_ids), | 409 EXPECT_EQ(arraysize(surface_ids), |
418 aggregator_.previous_contained_surfaces().size()); | 410 aggregator_.previous_contained_surfaces().size()); |
419 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 411 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
420 EXPECT_TRUE( | 412 EXPECT_TRUE( |
421 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 413 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
422 aggregator_.previous_contained_surfaces().end()); | 414 aggregator_.previous_contained_surfaces().end()); |
423 } | 415 } |
424 | 416 |
425 // Ensure copy requests have been removed from root surface. | 417 // Ensure copy requests have been removed from root surface. |
426 const CompositorFrame* original_frame = | 418 const CompositorFrame& original_frame = |
427 manager_.GetSurfaceForId(root_surface_id_)->GetEligibleFrame(); | 419 manager_.GetSurfaceForId(root_surface_id_)->GetEligibleFrame(); |
428 RenderPassList& original_pass_list = | 420 RenderPassList& original_pass_list = |
429 original_frame->delegated_frame_data->render_pass_list; | 421 original_frame.delegated_frame_data->render_pass_list; |
430 ASSERT_EQ(2u, original_pass_list.size()); | 422 ASSERT_EQ(2u, original_pass_list.size()); |
431 DCHECK(original_pass_list[0]->copy_requests.empty()); | 423 DCHECK(original_pass_list[0]->copy_requests.empty()); |
432 DCHECK(original_pass_list[1]->copy_requests.empty()); | 424 DCHECK(original_pass_list[1]->copy_requests.empty()); |
433 | 425 |
434 factory_.Destroy(embedded_surface_id); | 426 factory_.Destroy(embedded_surface_id); |
435 } | 427 } |
436 | 428 |
437 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 429 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
438 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 430 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
439 SurfaceId nonexistent_surface_id = allocator_.GenerateId(); | 431 SurfaceId nonexistent_surface_id = allocator_.GenerateId(); |
(...skipping 18 matching lines...) Expand all Loading... |
458 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 450 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
459 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 451 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
460 test::Pass parent_passes[] = { | 452 test::Pass parent_passes[] = { |
461 test::Pass(parent_quads, arraysize(parent_quads))}; | 453 test::Pass(parent_quads, arraysize(parent_quads))}; |
462 | 454 |
463 { | 455 { |
464 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 456 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
465 AddPasses(&frame_data->render_pass_list, gfx::Rect(SurfaceSize()), | 457 AddPasses(&frame_data->render_pass_list, gfx::Rect(SurfaceSize()), |
466 parent_passes, arraysize(parent_passes)); | 458 parent_passes, arraysize(parent_passes)); |
467 | 459 |
468 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 460 CompositorFrame frame; |
469 frame->delegated_frame_data = std::move(frame_data); | 461 frame.delegated_frame_data = std::move(frame_data); |
470 frame->metadata.referenced_surfaces.push_back(embedded_surface_id); | 462 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); |
471 | 463 |
472 factory_.SubmitCompositorFrame(parent_surface_id, std::move(frame), | 464 factory_.SubmitCompositorFrame(parent_surface_id, std::move(frame), |
473 SurfaceFactory::DrawCallback()); | 465 SurfaceFactory::DrawCallback()); |
474 } | 466 } |
475 | 467 |
476 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 468 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
477 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 469 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
478 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 470 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
479 | 471 |
480 { | 472 { |
481 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 473 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
482 AddPasses(&frame_data->render_pass_list, gfx::Rect(SurfaceSize()), | 474 AddPasses(&frame_data->render_pass_list, gfx::Rect(SurfaceSize()), |
483 root_passes, arraysize(root_passes)); | 475 root_passes, arraysize(root_passes)); |
484 | 476 |
485 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 477 CompositorFrame frame; |
486 frame->delegated_frame_data = std::move(frame_data); | 478 frame.delegated_frame_data = std::move(frame_data); |
487 frame->metadata.referenced_surfaces.push_back(parent_surface_id); | 479 frame.metadata.referenced_surfaces.push_back(parent_surface_id); |
488 // Reference to Surface ID of a Surface that doesn't exist should be | 480 // Reference to Surface ID of a Surface that doesn't exist should be |
489 // included in previous_contained_surfaces, but otherwise ignored. | 481 // included in previous_contained_surfaces, but otherwise ignored. |
490 frame->metadata.referenced_surfaces.push_back(nonexistent_surface_id); | 482 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id); |
491 | 483 |
492 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), | 484 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), |
493 SurfaceFactory::DrawCallback()); | 485 SurfaceFactory::DrawCallback()); |
494 } | 486 } |
495 | 487 |
496 std::unique_ptr<CompositorFrame> aggregated_frame = | 488 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
497 aggregator_.Aggregate(root_surface_id_); | |
498 | 489 |
499 ASSERT_TRUE(aggregated_frame); | 490 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
500 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
501 | 491 |
502 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 492 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
503 | 493 |
504 // First pass should come from surface that had a copy request but was not | 494 // First pass should come from surface that had a copy request but was not |
505 // referenced directly. The second pass comes from the root surface. | 495 // referenced directly. The second pass comes from the root surface. |
506 // parent_quad should be ignored because it is neither referenced through a | 496 // parent_quad should be ignored because it is neither referenced through a |
507 // SurfaceDrawQuad nor has a copy request on it. | 497 // SurfaceDrawQuad nor has a copy request on it. |
508 test::Pass expected_passes[] = { | 498 test::Pass expected_passes[] = { |
509 test::Pass(embedded_quads, arraysize(embedded_quads)), | 499 test::Pass(embedded_quads, arraysize(embedded_quads)), |
510 test::Pass(root_quads, arraysize(root_quads))}; | 500 test::Pass(root_quads, arraysize(root_quads))}; |
511 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), | 501 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), |
512 &frame_data->render_pass_list); | 502 &frame_data->render_pass_list); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 544 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
555 test::Quad::RenderPassQuad(pass_ids[0])}, | 545 test::Quad::RenderPassQuad(pass_ids[0])}, |
556 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; | 546 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; |
557 test::Pass root_passes[] = { | 547 test::Pass root_passes[] = { |
558 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), | 548 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), |
559 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), | 549 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), |
560 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; | 550 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; |
561 | 551 |
562 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 552 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
563 | 553 |
564 std::unique_ptr<CompositorFrame> aggregated_frame = | 554 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
565 aggregator_.Aggregate(root_surface_id_); | |
566 | 555 |
567 ASSERT_TRUE(aggregated_frame); | 556 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
568 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
569 | 557 |
570 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 558 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
571 | 559 |
572 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 560 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
573 | 561 |
574 ASSERT_EQ(5u, aggregated_pass_list.size()); | 562 ASSERT_EQ(5u, aggregated_pass_list.size()); |
575 RenderPassId actual_pass_ids[] = { | 563 RenderPassId actual_pass_ids[] = { |
576 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, | 564 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, |
577 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id, | 565 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id, |
578 aggregated_pass_list[4]->id}; | 566 aggregated_pass_list[4]->id}; |
579 for (size_t i = 0; i < 5; ++i) { | 567 for (size_t i = 0; i < 5; ++i) { |
580 for (size_t j = 0; j < i; ++j) { | 568 for (size_t j = 0; j < i; ++j) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 test::Quad parent_quad[][1] = { | 778 test::Quad parent_quad[][1] = { |
791 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 779 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
792 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 780 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
793 test::Pass parent_passes[] = { | 781 test::Pass parent_passes[] = { |
794 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 782 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
795 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 783 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
796 | 784 |
797 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 785 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), |
798 root_surface_id_); | 786 root_surface_id_); |
799 | 787 |
800 std::unique_ptr<CompositorFrame> aggregated_frame = | 788 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
801 aggregator_.Aggregate(root_surface_id_); | |
802 | 789 |
803 ASSERT_TRUE(aggregated_frame); | 790 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
804 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
805 | 791 |
806 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 792 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
807 | 793 |
808 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 794 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
809 | 795 |
810 ASSERT_EQ(3u, aggregated_pass_list.size()); | 796 ASSERT_EQ(3u, aggregated_pass_list.size()); |
811 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, | 797 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, |
812 aggregated_pass_list[1]->id, | 798 aggregated_pass_list[1]->id, |
813 aggregated_pass_list[2]->id}; | 799 aggregated_pass_list[2]->id}; |
814 // Make sure the aggregated frame's pass IDs are all unique. | 800 // Make sure the aggregated frame's pass IDs are all unique. |
815 for (size_t i = 0; i < 3; ++i) { | 801 for (size_t i = 0; i < 3; ++i) { |
816 for (size_t j = 0; j < i; ++j) { | 802 for (size_t j = 0; j < i; ++j) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 939 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
954 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 940 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
955 gfx::Rect(SurfaceSize()), | 941 gfx::Rect(SurfaceSize()), |
956 gfx::Rect(SurfaceSize()), | 942 gfx::Rect(SurfaceSize()), |
957 child_two_surface_id); | 943 child_two_surface_id); |
958 AddSolidColorQuadWithBlendMode( | 944 AddSolidColorQuadWithBlendMode( |
959 SurfaceSize(), root_pass.get(), blend_modes[6]); | 945 SurfaceSize(), root_pass.get(), blend_modes[6]); |
960 | 946 |
961 QueuePassAsFrame(std::move(root_pass), root_surface_id_); | 947 QueuePassAsFrame(std::move(root_pass), root_surface_id_); |
962 | 948 |
963 std::unique_ptr<CompositorFrame> aggregated_frame = | 949 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
964 aggregator_.Aggregate(root_surface_id_); | |
965 | 950 |
966 ASSERT_TRUE(aggregated_frame); | 951 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
967 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
968 | 952 |
969 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 953 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
970 | 954 |
971 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 955 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
972 | 956 |
973 ASSERT_EQ(1u, aggregated_pass_list.size()); | 957 ASSERT_EQ(1u, aggregated_pass_list.size()); |
974 | 958 |
975 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 959 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
976 | 960 |
977 ASSERT_EQ(7u, aggregated_quad_list.size()); | 961 ASSERT_EQ(7u, aggregated_quad_list.size()); |
978 | 962 |
979 for (auto iter = aggregated_quad_list.cbegin(); | 963 for (auto iter = aggregated_quad_list.cbegin(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 SharedQuadState* child_root_pass_sqs = | 1018 SharedQuadState* child_root_pass_sqs = |
1035 child_root_pass->shared_quad_state_list.front(); | 1019 child_root_pass->shared_quad_state_list.front(); |
1036 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1020 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1037 child_root_pass_sqs->is_clipped = true; | 1021 child_root_pass_sqs->is_clipped = true; |
1038 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); | 1022 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); |
1039 | 1023 |
1040 std::unique_ptr<DelegatedFrameData> child_frame_data( | 1024 std::unique_ptr<DelegatedFrameData> child_frame_data( |
1041 new DelegatedFrameData); | 1025 new DelegatedFrameData); |
1042 child_pass_list.swap(child_frame_data->render_pass_list); | 1026 child_pass_list.swap(child_frame_data->render_pass_list); |
1043 | 1027 |
1044 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1028 CompositorFrame child_frame; |
1045 child_frame->delegated_frame_data = std::move(child_frame_data); | 1029 child_frame.delegated_frame_data = std::move(child_frame_data); |
1046 | 1030 |
1047 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 1031 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
1048 SurfaceFactory::DrawCallback()); | 1032 SurfaceFactory::DrawCallback()); |
1049 } | 1033 } |
1050 | 1034 |
1051 // Middle child surface. | 1035 // Middle child surface. |
1052 SurfaceId middle_surface_id = allocator_.GenerateId(); | 1036 SurfaceId middle_surface_id = allocator_.GenerateId(); |
1053 factory_.Create(middle_surface_id); | 1037 factory_.Create(middle_surface_id); |
1054 { | 1038 { |
1055 test::Quad middle_quads[] = { | 1039 test::Quad middle_quads[] = { |
(...skipping 10 matching lines...) Expand all Loading... |
1066 middle_root_pass->quad_list.ElementAt(0)->visible_rect = | 1050 middle_root_pass->quad_list.ElementAt(0)->visible_rect = |
1067 gfx::Rect(0, 1, 100, 7); | 1051 gfx::Rect(0, 1, 100, 7); |
1068 SharedQuadState* middle_root_pass_sqs = | 1052 SharedQuadState* middle_root_pass_sqs = |
1069 middle_root_pass->shared_quad_state_list.front(); | 1053 middle_root_pass->shared_quad_state_list.front(); |
1070 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); | 1054 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); |
1071 | 1055 |
1072 std::unique_ptr<DelegatedFrameData> middle_frame_data( | 1056 std::unique_ptr<DelegatedFrameData> middle_frame_data( |
1073 new DelegatedFrameData); | 1057 new DelegatedFrameData); |
1074 middle_pass_list.swap(middle_frame_data->render_pass_list); | 1058 middle_pass_list.swap(middle_frame_data->render_pass_list); |
1075 | 1059 |
1076 std::unique_ptr<CompositorFrame> middle_frame(new CompositorFrame); | 1060 CompositorFrame middle_frame; |
1077 middle_frame->delegated_frame_data = std::move(middle_frame_data); | 1061 middle_frame.delegated_frame_data = std::move(middle_frame_data); |
1078 | 1062 |
1079 factory_.SubmitCompositorFrame(middle_surface_id, std::move(middle_frame), | 1063 factory_.SubmitCompositorFrame(middle_surface_id, std::move(middle_frame), |
1080 SurfaceFactory::DrawCallback()); | 1064 SurfaceFactory::DrawCallback()); |
1081 } | 1065 } |
1082 | 1066 |
1083 // Root surface. | 1067 // Root surface. |
1084 test::Quad secondary_quads[] = { | 1068 test::Quad secondary_quads[] = { |
1085 test::Quad::SolidColorQuad(1), | 1069 test::Quad::SolidColorQuad(1), |
1086 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; | 1070 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; |
1087 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; | 1071 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; |
(...skipping 14 matching lines...) Expand all Loading... |
1102 ->shared_quad_state_list.ElementAt(1) | 1086 ->shared_quad_state_list.ElementAt(1) |
1103 ->quad_to_target_transform.Translate(0, 10); | 1087 ->quad_to_target_transform.Translate(0, 10); |
1104 root_pass_list[0]->quad_list.ElementAt(1)->visible_rect = | 1088 root_pass_list[0]->quad_list.ElementAt(1)->visible_rect = |
1105 gfx::Rect(0, 0, 8, 100); | 1089 gfx::Rect(0, 0, 8, 100); |
1106 | 1090 |
1107 root_pass_list[0]->transform_to_root_target.Translate(10, 5); | 1091 root_pass_list[0]->transform_to_root_target.Translate(10, 5); |
1108 | 1092 |
1109 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1093 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1110 root_pass_list.swap(root_frame_data->render_pass_list); | 1094 root_pass_list.swap(root_frame_data->render_pass_list); |
1111 | 1095 |
1112 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1096 CompositorFrame root_frame; |
1113 root_frame->delegated_frame_data = std::move(root_frame_data); | 1097 root_frame.delegated_frame_data = std::move(root_frame_data); |
1114 | 1098 |
1115 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1099 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1116 SurfaceFactory::DrawCallback()); | 1100 SurfaceFactory::DrawCallback()); |
1117 | 1101 |
1118 std::unique_ptr<CompositorFrame> aggregated_frame = | 1102 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1119 aggregator_.Aggregate(root_surface_id_); | |
1120 | 1103 |
1121 ASSERT_TRUE(aggregated_frame); | 1104 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1122 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1123 | 1105 |
1124 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1106 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
1125 | 1107 |
1126 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1108 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1127 | 1109 |
1128 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1110 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1129 | 1111 |
1130 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 1112 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
1131 | 1113 |
1132 // The first pass should have one shared quad state for the one solid color | 1114 // The first pass should have one shared quad state for the one solid color |
1133 // quad. | 1115 // quad. |
1134 EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 1116 EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 arraysize(child_passes)); | 1191 arraysize(child_passes)); |
1210 | 1192 |
1211 RenderPass* child_root_pass = child_pass_list[0].get(); | 1193 RenderPass* child_root_pass = child_pass_list[0].get(); |
1212 SharedQuadState* child_root_pass_sqs = | 1194 SharedQuadState* child_root_pass_sqs = |
1213 child_root_pass->shared_quad_state_list.front(); | 1195 child_root_pass->shared_quad_state_list.front(); |
1214 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1196 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1215 | 1197 |
1216 std::unique_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 1198 std::unique_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
1217 child_pass_list.swap(child_frame_data->render_pass_list); | 1199 child_pass_list.swap(child_frame_data->render_pass_list); |
1218 | 1200 |
1219 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1201 CompositorFrame child_frame; |
1220 child_frame->delegated_frame_data = std::move(child_frame_data); | 1202 child_frame.delegated_frame_data = std::move(child_frame_data); |
1221 | 1203 |
1222 SurfaceId child_surface_id = allocator_.GenerateId(); | 1204 SurfaceId child_surface_id = allocator_.GenerateId(); |
1223 factory_.Create(child_surface_id); | 1205 factory_.Create(child_surface_id); |
1224 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 1206 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
1225 SurfaceFactory::DrawCallback()); | 1207 SurfaceFactory::DrawCallback()); |
1226 | 1208 |
1227 test::Quad parent_surface_quads[] = { | 1209 test::Quad parent_surface_quads[] = { |
1228 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1210 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1229 test::Pass parent_surface_passes[] = { | 1211 test::Pass parent_surface_passes[] = { |
1230 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), | 1212 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), |
1231 RenderPassId(1, 1))}; | 1213 RenderPassId(1, 1))}; |
1232 | 1214 |
1233 RenderPassList parent_surface_pass_list; | 1215 RenderPassList parent_surface_pass_list; |
1234 AddPasses(&parent_surface_pass_list, | 1216 AddPasses(&parent_surface_pass_list, |
1235 gfx::Rect(SurfaceSize()), | 1217 gfx::Rect(SurfaceSize()), |
1236 parent_surface_passes, | 1218 parent_surface_passes, |
1237 arraysize(parent_surface_passes)); | 1219 arraysize(parent_surface_passes)); |
1238 | 1220 |
1239 // Parent surface is only used to test if the transform is applied correctly | 1221 // Parent surface is only used to test if the transform is applied correctly |
1240 // to the child surface's damage. | 1222 // to the child surface's damage. |
1241 std::unique_ptr<DelegatedFrameData> parent_surface_frame_data( | 1223 std::unique_ptr<DelegatedFrameData> parent_surface_frame_data( |
1242 new DelegatedFrameData); | 1224 new DelegatedFrameData); |
1243 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list); | 1225 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list); |
1244 | 1226 |
1245 std::unique_ptr<CompositorFrame> parent_surface_frame(new CompositorFrame); | 1227 CompositorFrame parent_surface_frame; |
1246 parent_surface_frame->delegated_frame_data = | 1228 parent_surface_frame.delegated_frame_data = |
1247 std::move(parent_surface_frame_data); | 1229 std::move(parent_surface_frame_data); |
1248 | 1230 |
1249 SurfaceId parent_surface_id = allocator_.GenerateId(); | 1231 SurfaceId parent_surface_id = allocator_.GenerateId(); |
1250 factory_.Create(parent_surface_id); | 1232 factory_.Create(parent_surface_id); |
1251 factory_.SubmitCompositorFrame(parent_surface_id, | 1233 factory_.SubmitCompositorFrame(parent_surface_id, |
1252 std::move(parent_surface_frame), | 1234 std::move(parent_surface_frame), |
1253 SurfaceFactory::DrawCallback()); | 1235 SurfaceFactory::DrawCallback()); |
1254 | 1236 |
1255 test::Quad root_surface_quads[] = { | 1237 test::Quad root_surface_quads[] = { |
1256 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; | 1238 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; |
(...skipping 14 matching lines...) Expand all Loading... |
1271 | 1253 |
1272 root_pass_list[0] | 1254 root_pass_list[0] |
1273 ->shared_quad_state_list.front() | 1255 ->shared_quad_state_list.front() |
1274 ->quad_to_target_transform.Translate(0, 10); | 1256 ->quad_to_target_transform.Translate(0, 10); |
1275 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); | 1257 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); |
1276 root_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); | 1258 root_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); |
1277 | 1259 |
1278 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1260 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1279 root_pass_list.swap(root_frame_data->render_pass_list); | 1261 root_pass_list.swap(root_frame_data->render_pass_list); |
1280 | 1262 |
1281 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1263 CompositorFrame root_frame; |
1282 root_frame->delegated_frame_data = std::move(root_frame_data); | 1264 root_frame.delegated_frame_data = std::move(root_frame_data); |
1283 | 1265 |
1284 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1266 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1285 SurfaceFactory::DrawCallback()); | 1267 SurfaceFactory::DrawCallback()); |
1286 | 1268 |
1287 std::unique_ptr<CompositorFrame> aggregated_frame = | 1269 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1288 aggregator_.Aggregate(root_surface_id_); | |
1289 | 1270 |
1290 ASSERT_TRUE(aggregated_frame); | 1271 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1291 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1292 | 1272 |
1293 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1273 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
1294 | 1274 |
1295 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1275 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1296 | 1276 |
1297 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1277 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1298 | 1278 |
1299 // Damage rect for first aggregation should contain entire root surface. | 1279 // Damage rect for first aggregation should contain entire root surface. |
1300 EXPECT_TRUE( | 1280 EXPECT_TRUE( |
1301 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | 1281 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); |
1302 | 1282 |
1303 { | 1283 { |
1304 AddPasses(&child_pass_list, | 1284 AddPasses(&child_pass_list, |
1305 gfx::Rect(SurfaceSize()), | 1285 gfx::Rect(SurfaceSize()), |
1306 child_passes, | 1286 child_passes, |
1307 arraysize(child_passes)); | 1287 arraysize(child_passes)); |
1308 | 1288 |
1309 RenderPass* child_root_pass = child_pass_list[0].get(); | 1289 RenderPass* child_root_pass = child_pass_list[0].get(); |
1310 SharedQuadState* child_root_pass_sqs = | 1290 SharedQuadState* child_root_pass_sqs = |
1311 child_root_pass->shared_quad_state_list.front(); | 1291 child_root_pass->shared_quad_state_list.front(); |
1312 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1292 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1313 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 1293 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
1314 | 1294 |
1315 std::unique_ptr<DelegatedFrameData> child_frame_data( | 1295 std::unique_ptr<DelegatedFrameData> child_frame_data( |
1316 new DelegatedFrameData); | 1296 new DelegatedFrameData); |
1317 child_pass_list.swap(child_frame_data->render_pass_list); | 1297 child_pass_list.swap(child_frame_data->render_pass_list); |
1318 | 1298 |
1319 std::unique_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1299 CompositorFrame child_frame; |
1320 child_frame->delegated_frame_data = std::move(child_frame_data); | 1300 child_frame.delegated_frame_data = std::move(child_frame_data); |
1321 | 1301 |
1322 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 1302 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
1323 SurfaceFactory::DrawCallback()); | 1303 SurfaceFactory::DrawCallback()); |
1324 | 1304 |
1325 std::unique_ptr<CompositorFrame> aggregated_frame = | 1305 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1326 aggregator_.Aggregate(root_surface_id_); | |
1327 | 1306 |
1328 ASSERT_TRUE(aggregated_frame); | 1307 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1329 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1330 | 1308 |
1331 DelegatedFrameData* frame_data = | 1309 DelegatedFrameData* frame_data = |
1332 aggregated_frame->delegated_frame_data.get(); | 1310 aggregated_frame.delegated_frame_data.get(); |
1333 | 1311 |
1334 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1312 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1335 | 1313 |
1336 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1314 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1337 | 1315 |
1338 // Outer surface didn't change, so transformed inner damage rect should be | 1316 // Outer surface didn't change, so transformed inner damage rect should be |
1339 // used. | 1317 // used. |
1340 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), | 1318 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), |
1341 aggregated_pass_list[1]->damage_rect.ToString()); | 1319 aggregated_pass_list[1]->damage_rect.ToString()); |
1342 } | 1320 } |
1343 | 1321 |
1344 { | 1322 { |
1345 RenderPassList root_pass_list; | 1323 RenderPassList root_pass_list; |
1346 AddPasses(&root_pass_list, | 1324 AddPasses(&root_pass_list, |
1347 gfx::Rect(SurfaceSize()), | 1325 gfx::Rect(SurfaceSize()), |
1348 root_passes, | 1326 root_passes, |
1349 arraysize(root_passes)); | 1327 arraysize(root_passes)); |
1350 | 1328 |
1351 root_pass_list[0] | 1329 root_pass_list[0] |
1352 ->shared_quad_state_list.front() | 1330 ->shared_quad_state_list.front() |
1353 ->quad_to_target_transform.Translate(0, 10); | 1331 ->quad_to_target_transform.Translate(0, 10); |
1354 root_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); | 1332 root_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); |
1355 | 1333 |
1356 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1334 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1357 root_pass_list.swap(root_frame_data->render_pass_list); | 1335 root_pass_list.swap(root_frame_data->render_pass_list); |
1358 | 1336 |
1359 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1337 CompositorFrame root_frame; |
1360 root_frame->delegated_frame_data = std::move(root_frame_data); | 1338 root_frame.delegated_frame_data = std::move(root_frame_data); |
1361 | 1339 |
1362 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1340 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1363 SurfaceFactory::DrawCallback()); | 1341 SurfaceFactory::DrawCallback()); |
1364 } | 1342 } |
1365 | 1343 |
1366 { | 1344 { |
1367 RenderPassList root_pass_list; | 1345 RenderPassList root_pass_list; |
1368 AddPasses(&root_pass_list, | 1346 AddPasses(&root_pass_list, |
1369 gfx::Rect(SurfaceSize()), | 1347 gfx::Rect(SurfaceSize()), |
1370 root_passes, | 1348 root_passes, |
1371 arraysize(root_passes)); | 1349 arraysize(root_passes)); |
1372 | 1350 |
1373 root_pass_list[0] | 1351 root_pass_list[0] |
1374 ->shared_quad_state_list.front() | 1352 ->shared_quad_state_list.front() |
1375 ->quad_to_target_transform.Translate(0, 10); | 1353 ->quad_to_target_transform.Translate(0, 10); |
1376 root_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); | 1354 root_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); |
1377 | 1355 |
1378 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1356 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1379 root_pass_list.swap(root_frame_data->render_pass_list); | 1357 root_pass_list.swap(root_frame_data->render_pass_list); |
1380 | 1358 |
1381 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1359 CompositorFrame root_frame; |
1382 root_frame->delegated_frame_data = std::move(root_frame_data); | 1360 root_frame.delegated_frame_data = std::move(root_frame_data); |
1383 | 1361 |
1384 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1362 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1385 SurfaceFactory::DrawCallback()); | 1363 SurfaceFactory::DrawCallback()); |
1386 | 1364 |
1387 std::unique_ptr<CompositorFrame> aggregated_frame = | 1365 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1388 aggregator_.Aggregate(root_surface_id_); | |
1389 | 1366 |
1390 ASSERT_TRUE(aggregated_frame); | 1367 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1391 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1392 | 1368 |
1393 DelegatedFrameData* frame_data = | 1369 DelegatedFrameData* frame_data = |
1394 aggregated_frame->delegated_frame_data.get(); | 1370 aggregated_frame.delegated_frame_data.get(); |
1395 | 1371 |
1396 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1372 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1397 | 1373 |
1398 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1374 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1399 | 1375 |
1400 // The root surface was enqueued without being aggregated once, so it should | 1376 // The root surface was enqueued without being aggregated once, so it should |
1401 // be treated as completely damaged. | 1377 // be treated as completely damaged. |
1402 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1378 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1403 gfx::Rect(SurfaceSize()))); | 1379 gfx::Rect(SurfaceSize()))); |
1404 } | 1380 } |
1405 | 1381 |
1406 // No Surface changed, so no damage should be given. | 1382 // No Surface changed, so no damage should be given. |
1407 { | 1383 { |
1408 std::unique_ptr<CompositorFrame> aggregated_frame = | 1384 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1409 aggregator_.Aggregate(root_surface_id_); | |
1410 | 1385 |
1411 ASSERT_TRUE(aggregated_frame); | 1386 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1412 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1413 | 1387 |
1414 DelegatedFrameData* frame_data = | 1388 DelegatedFrameData* frame_data = |
1415 aggregated_frame->delegated_frame_data.get(); | 1389 aggregated_frame.delegated_frame_data.get(); |
1416 | 1390 |
1417 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1391 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1418 | 1392 |
1419 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1393 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1420 | 1394 |
1421 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1395 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
1422 } | 1396 } |
1423 | 1397 |
1424 // SetFullDamageRectForSurface should cause the entire output to be | 1398 // SetFullDamageRectForSurface should cause the entire output to be |
1425 // marked as damaged. | 1399 // marked as damaged. |
1426 { | 1400 { |
1427 aggregator_.SetFullDamageForSurface(root_surface_id_); | 1401 aggregator_.SetFullDamageForSurface(root_surface_id_); |
1428 std::unique_ptr<CompositorFrame> aggregated_frame = | 1402 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1429 aggregator_.Aggregate(root_surface_id_); | |
1430 | 1403 |
1431 ASSERT_TRUE(aggregated_frame); | 1404 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1432 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1433 | 1405 |
1434 DelegatedFrameData* frame_data = | 1406 DelegatedFrameData* frame_data = |
1435 aggregated_frame->delegated_frame_data.get(); | 1407 aggregated_frame.delegated_frame_data.get(); |
1436 | 1408 |
1437 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1409 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1438 | 1410 |
1439 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1411 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1440 | 1412 |
1441 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1413 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1442 gfx::Rect(SurfaceSize()))); | 1414 gfx::Rect(SurfaceSize()))); |
1443 } | 1415 } |
1444 | 1416 |
1445 factory_.Destroy(child_surface_id); | 1417 factory_.Destroy(child_surface_id); |
(...skipping 10 matching lines...) Expand all Loading... |
1456 | 1428 |
1457 RenderPassList root_pass_list; | 1429 RenderPassList root_pass_list; |
1458 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1430 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1459 arraysize(root_passes)); | 1431 arraysize(root_passes)); |
1460 | 1432 |
1461 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100); | 1433 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100); |
1462 | 1434 |
1463 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1435 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1464 root_pass_list.swap(root_frame_data->render_pass_list); | 1436 root_pass_list.swap(root_frame_data->render_pass_list); |
1465 | 1437 |
1466 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1438 CompositorFrame root_frame; |
1467 root_frame->delegated_frame_data = std::move(root_frame_data); | 1439 root_frame.delegated_frame_data = std::move(root_frame_data); |
1468 | 1440 |
1469 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1441 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1470 SurfaceFactory::DrawCallback()); | 1442 SurfaceFactory::DrawCallback()); |
1471 | 1443 |
1472 { | 1444 { |
1473 std::unique_ptr<CompositorFrame> aggregated_frame = | 1445 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1474 aggregator_.Aggregate(root_surface_id_); | |
1475 | 1446 |
1476 ASSERT_TRUE(aggregated_frame); | 1447 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1477 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1478 | 1448 |
1479 DelegatedFrameData* frame_data = | 1449 DelegatedFrameData* frame_data = |
1480 aggregated_frame->delegated_frame_data.get(); | 1450 aggregated_frame.delegated_frame_data.get(); |
1481 | 1451 |
1482 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1452 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1483 | 1453 |
1484 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1454 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1485 | 1455 |
1486 // Damage rect for first aggregation should contain entire root surface. | 1456 // Damage rect for first aggregation should contain entire root surface. |
1487 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains( | 1457 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains( |
1488 gfx::Rect(SurfaceSize()))); | 1458 gfx::Rect(SurfaceSize()))); |
1489 } | 1459 } |
1490 | 1460 |
1491 SurfaceId second_root_surface_id = allocator_.GenerateId(); | 1461 SurfaceId second_root_surface_id = allocator_.GenerateId(); |
1492 { | 1462 { |
1493 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1463 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
1494 | 1464 |
1495 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, | 1465 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, |
1496 arraysize(root_render_pass_quads), | 1466 arraysize(root_render_pass_quads), |
1497 RenderPassId(2, 1))}; | 1467 RenderPassId(2, 1))}; |
1498 | 1468 |
1499 RenderPassList root_pass_list; | 1469 RenderPassList root_pass_list; |
1500 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1470 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1501 arraysize(root_passes)); | 1471 arraysize(root_passes)); |
1502 | 1472 |
1503 root_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); | 1473 root_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); |
1504 | 1474 |
1505 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1475 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1506 root_pass_list.swap(root_frame_data->render_pass_list); | 1476 root_pass_list.swap(root_frame_data->render_pass_list); |
1507 | 1477 |
1508 std::unique_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1478 CompositorFrame root_frame; |
1509 root_frame->delegated_frame_data = std::move(root_frame_data); | 1479 root_frame.delegated_frame_data = std::move(root_frame_data); |
1510 | 1480 |
1511 factory_.Create(second_root_surface_id); | 1481 factory_.Create(second_root_surface_id); |
1512 factory_.SubmitCompositorFrame(second_root_surface_id, | 1482 factory_.SubmitCompositorFrame(second_root_surface_id, |
1513 std::move(root_frame), | 1483 std::move(root_frame), |
1514 SurfaceFactory::DrawCallback()); | 1484 SurfaceFactory::DrawCallback()); |
1515 factory_.SetPreviousFrameSurface(second_root_surface_id, root_surface_id_); | 1485 factory_.SetPreviousFrameSurface(second_root_surface_id, root_surface_id_); |
1516 } | 1486 } |
1517 { | 1487 { |
1518 std::unique_ptr<CompositorFrame> aggregated_frame = | 1488 CompositorFrame aggregated_frame = |
1519 aggregator_.Aggregate(second_root_surface_id); | 1489 aggregator_.Aggregate(second_root_surface_id); |
1520 | 1490 |
1521 ASSERT_TRUE(aggregated_frame); | 1491 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1522 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1523 | 1492 |
1524 DelegatedFrameData* frame_data = | 1493 DelegatedFrameData* frame_data = |
1525 aggregated_frame->delegated_frame_data.get(); | 1494 aggregated_frame.delegated_frame_data.get(); |
1526 | 1495 |
1527 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1496 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1528 | 1497 |
1529 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1498 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1530 | 1499 |
1531 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect | 1500 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect |
1532 // from new surface should be used. | 1501 // from new surface should be used. |
1533 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); | 1502 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); |
1534 } | 1503 } |
1535 { | 1504 { |
1536 std::unique_ptr<CompositorFrame> aggregated_frame = | 1505 CompositorFrame aggregated_frame = |
1537 aggregator_.Aggregate(second_root_surface_id); | 1506 aggregator_.Aggregate(second_root_surface_id); |
1538 | 1507 |
1539 ASSERT_TRUE(aggregated_frame); | 1508 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1540 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1541 | 1509 |
1542 DelegatedFrameData* frame_data = | 1510 DelegatedFrameData* frame_data = |
1543 aggregated_frame->delegated_frame_data.get(); | 1511 aggregated_frame.delegated_frame_data.get(); |
1544 | 1512 |
1545 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1513 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1546 | 1514 |
1547 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1515 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1548 | 1516 |
1549 // No new frame, so no new damage. | 1517 // No new frame, so no new damage. |
1550 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1518 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1551 } | 1519 } |
1552 factory_.Destroy(second_root_surface_id); | 1520 factory_.Destroy(second_root_surface_id); |
1553 } | 1521 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 arraysize(root_passes)); | 1580 arraysize(root_passes)); |
1613 | 1581 |
1614 RenderPass* root_pass = root_pass_list[0].get(); | 1582 RenderPass* root_pass = root_pass_list[0].get(); |
1615 root_pass->shared_quad_state_list.front() | 1583 root_pass->shared_quad_state_list.front() |
1616 ->quad_to_target_transform.Translate(10, 10); | 1584 ->quad_to_target_transform.Translate(10, 10); |
1617 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); | 1585 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); |
1618 | 1586 |
1619 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1587 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1620 } | 1588 } |
1621 | 1589 |
1622 std::unique_ptr<CompositorFrame> aggregated_frame = | 1590 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1623 aggregator_.Aggregate(root_surface_id_); | |
1624 | 1591 |
1625 ASSERT_TRUE(aggregated_frame); | 1592 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1626 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1627 | 1593 |
1628 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1594 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get(); |
1629 | 1595 |
1630 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1596 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1631 | 1597 |
1632 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1598 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1633 | 1599 |
1634 // Damage rect for first aggregation should contain entire root surface. | 1600 // Damage rect for first aggregation should contain entire root surface. |
1635 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); | 1601 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); |
1636 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1602 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
1637 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1603 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
1638 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | 1604 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
1639 | 1605 |
1640 // Create a root surface with a smaller damage rect. | 1606 // Create a root surface with a smaller damage rect. |
1641 { | 1607 { |
1642 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1608 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1643 | 1609 |
1644 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1610 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
1645 | 1611 |
1646 RenderPassList root_pass_list; | 1612 RenderPassList root_pass_list; |
1647 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1613 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1648 arraysize(root_passes)); | 1614 arraysize(root_passes)); |
1649 | 1615 |
1650 RenderPass* root_pass = root_pass_list[0].get(); | 1616 RenderPass* root_pass = root_pass_list[0].get(); |
1651 root_pass->shared_quad_state_list.front() | 1617 root_pass->shared_quad_state_list.front() |
1652 ->quad_to_target_transform.Translate(10, 10); | 1618 ->quad_to_target_transform.Translate(10, 10); |
1653 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1619 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1654 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1620 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1655 } | 1621 } |
1656 | 1622 |
1657 { | 1623 { |
1658 std::unique_ptr<CompositorFrame> aggregated_frame = | 1624 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1659 aggregator_.Aggregate(root_surface_id_); | |
1660 | 1625 |
1661 ASSERT_TRUE(aggregated_frame); | 1626 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1662 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1663 | 1627 |
1664 DelegatedFrameData* frame_data = | 1628 DelegatedFrameData* frame_data = |
1665 aggregated_frame->delegated_frame_data.get(); | 1629 aggregated_frame.delegated_frame_data.get(); |
1666 | 1630 |
1667 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1631 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1668 | 1632 |
1669 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1633 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1670 | 1634 |
1671 // Only first quad from surface is inside damage rect and should be | 1635 // Only first quad from surface is inside damage rect and should be |
1672 // included. | 1636 // included. |
1673 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | 1637 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); |
1674 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1638 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1675 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1639 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
(...skipping 28 matching lines...) Expand all Loading... |
1704 | 1668 |
1705 RenderPass* child_root_pass = child_pass_list[1].get(); | 1669 RenderPass* child_root_pass = child_pass_list[1].get(); |
1706 | 1670 |
1707 child_root_pass->copy_requests.push_back( | 1671 child_root_pass->copy_requests.push_back( |
1708 CopyOutputRequest::CreateEmptyRequest()); | 1672 CopyOutputRequest::CreateEmptyRequest()); |
1709 child_root_pass->damage_rect = gfx::Rect(); | 1673 child_root_pass->damage_rect = gfx::Rect(); |
1710 SubmitPassListAsFrame(child_surface_id, &child_pass_list); | 1674 SubmitPassListAsFrame(child_surface_id, &child_pass_list); |
1711 } | 1675 } |
1712 | 1676 |
1713 { | 1677 { |
1714 std::unique_ptr<CompositorFrame> aggregated_frame = | 1678 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1715 aggregator_.Aggregate(root_surface_id_); | |
1716 | 1679 |
1717 ASSERT_TRUE(aggregated_frame); | 1680 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1718 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1719 | 1681 |
1720 DelegatedFrameData* frame_data = | 1682 DelegatedFrameData* frame_data = |
1721 aggregated_frame->delegated_frame_data.get(); | 1683 aggregated_frame.delegated_frame_data.get(); |
1722 | 1684 |
1723 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1685 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1724 | 1686 |
1725 // Output frame should have no damage, but all quads included. | 1687 // Output frame should have no damage, but all quads included. |
1726 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1688 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1727 | 1689 |
1728 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); | 1690 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); |
1729 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1691 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
1730 EXPECT_TRUE(aggregated_pass_list[2]->damage_rect.IsEmpty()); | 1692 EXPECT_TRUE(aggregated_pass_list[2]->damage_rect.IsEmpty()); |
1731 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1693 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
1732 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1694 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
1733 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), | 1695 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), |
1734 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); | 1696 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); |
1735 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), | 1697 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), |
1736 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); | 1698 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); |
1737 ASSERT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); | 1699 ASSERT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
1738 } | 1700 } |
1739 | 1701 |
1740 { | 1702 { |
1741 std::unique_ptr<CompositorFrame> aggregated_frame = | 1703 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1742 aggregator_.Aggregate(root_surface_id_); | |
1743 | 1704 |
1744 ASSERT_TRUE(aggregated_frame); | 1705 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1745 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1746 | 1706 |
1747 DelegatedFrameData* frame_data = | 1707 DelegatedFrameData* frame_data = |
1748 aggregated_frame->delegated_frame_data.get(); | 1708 aggregated_frame.delegated_frame_data.get(); |
1749 | 1709 |
1750 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1710 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1751 // There were no changes since last aggregation, so output should be empty | 1711 // There were no changes since last aggregation, so output should be empty |
1752 // and have no damage. | 1712 // and have no damage. |
1753 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1713 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1754 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1714 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1755 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1715 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1756 } | 1716 } |
1757 | 1717 |
1758 // Root surface has smaller damage rect, but filter on render pass means all | 1718 // Root surface has smaller damage rect, but filter on render pass means all |
(...skipping 15 matching lines...) Expand all Loading... |
1774 10, 10); | 1734 10, 10); |
1775 RenderPass* root_pass = root_pass_list[1].get(); | 1735 RenderPass* root_pass = root_pass_list[1].get(); |
1776 RenderPassDrawQuad* quad = | 1736 RenderPassDrawQuad* quad = |
1777 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); | 1737 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); |
1778 quad->filters.Append(FilterOperation::CreateBlurFilter(2)); | 1738 quad->filters.Append(FilterOperation::CreateBlurFilter(2)); |
1779 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1739 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1780 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1740 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1781 } | 1741 } |
1782 | 1742 |
1783 { | 1743 { |
1784 std::unique_ptr<CompositorFrame> aggregated_frame = | 1744 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1785 aggregator_.Aggregate(root_surface_id_); | |
1786 | 1745 |
1787 ASSERT_TRUE(aggregated_frame); | 1746 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1788 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1789 | 1747 |
1790 DelegatedFrameData* frame_data = | 1748 DelegatedFrameData* frame_data = |
1791 aggregated_frame->delegated_frame_data.get(); | 1749 aggregated_frame.delegated_frame_data.get(); |
1792 | 1750 |
1793 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1751 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1794 | 1752 |
1795 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1753 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1796 | 1754 |
1797 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); | 1755 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); |
1798 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1756 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
1799 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | 1757 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); |
1800 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1758 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
1801 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1759 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
(...skipping 24 matching lines...) Expand all Loading... |
1826 root_pass->shared_quad_state_list.ElementAt(1) | 1784 root_pass->shared_quad_state_list.ElementAt(1) |
1827 ->quad_to_target_transform.Translate(10, 10); | 1785 ->quad_to_target_transform.Translate(10, 10); |
1828 RenderPassDrawQuad* quad = | 1786 RenderPassDrawQuad* quad = |
1829 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); | 1787 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); |
1830 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2)); | 1788 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2)); |
1831 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1789 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1832 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1790 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1833 } | 1791 } |
1834 | 1792 |
1835 { | 1793 { |
1836 std::unique_ptr<CompositorFrame> aggregated_frame = | 1794 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id_); |
1837 aggregator_.Aggregate(root_surface_id_); | |
1838 | 1795 |
1839 ASSERT_TRUE(aggregated_frame); | 1796 ASSERT_TRUE(aggregated_frame.delegated_frame_data); |
1840 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | |
1841 | 1797 |
1842 DelegatedFrameData* frame_data = | 1798 DelegatedFrameData* frame_data = |
1843 aggregated_frame->delegated_frame_data.get(); | 1799 aggregated_frame.delegated_frame_data.get(); |
1844 | 1800 |
1845 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1801 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1846 | 1802 |
1847 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1803 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1848 | 1804 |
1849 // Pass 0 is solid color quad from root, but outside damage rect. | 1805 // Pass 0 is solid color quad from root, but outside damage rect. |
1850 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[0]->damage_rect); | 1806 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[0]->damage_rect); |
1851 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1807 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1852 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1808 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
1853 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1809 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; | 1900 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; |
1945 bool flipped = false; | 1901 bool flipped = false; |
1946 bool nearest_neighbor = false; | 1902 bool nearest_neighbor = false; |
1947 bool secure_output_only = true; | 1903 bool secure_output_only = true; |
1948 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending, | 1904 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending, |
1949 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left, | 1905 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left, |
1950 uv_bottom_right, background_color, vertex_opacity, flipped, | 1906 uv_bottom_right, background_color, vertex_opacity, flipped, |
1951 nearest_neighbor, secure_output_only); | 1907 nearest_neighbor, secure_output_only); |
1952 } | 1908 } |
1953 frame_data->render_pass_list.push_back(std::move(pass)); | 1909 frame_data->render_pass_list.push_back(std::move(pass)); |
1954 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 1910 CompositorFrame frame; |
1955 frame->delegated_frame_data = std::move(frame_data); | 1911 frame.delegated_frame_data = std::move(frame_data); |
1956 factory->SubmitCompositorFrame(surface_id, std::move(frame), | 1912 factory->SubmitCompositorFrame(surface_id, std::move(frame), |
1957 SurfaceFactory::DrawCallback()); | 1913 SurfaceFactory::DrawCallback()); |
1958 } | 1914 } |
1959 | 1915 |
1960 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1916 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
1961 ResourceTrackingSurfaceFactoryClient client; | 1917 ResourceTrackingSurfaceFactoryClient client; |
1962 SurfaceFactory factory(&manager_, &client); | 1918 SurfaceFactory factory(&manager_, &client); |
1963 SurfaceId surface_id(0, 7u, 0); | 1919 SurfaceId surface_id(0, 7u, 0); |
1964 factory.Create(surface_id); | 1920 factory.Create(surface_id); |
1965 | 1921 |
1966 ResourceId ids[] = {11, 12, 13}; | 1922 ResourceId ids[] = {11, 12, 13}; |
1967 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1923 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1968 &factory, surface_id); | 1924 &factory, surface_id); |
1969 | 1925 |
1970 std::unique_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 1926 CompositorFrame frame = aggregator_->Aggregate(surface_id); |
1971 | 1927 |
1972 // Nothing should be available to be returned yet. | 1928 // Nothing should be available to be returned yet. |
1973 EXPECT_TRUE(client.returned_resources().empty()); | 1929 EXPECT_TRUE(client.returned_resources().empty()); |
1974 | 1930 |
1975 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1931 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
1976 surface_id); | 1932 surface_id); |
1977 | 1933 |
1978 frame = aggregator_->Aggregate(surface_id); | 1934 frame = aggregator_->Aggregate(surface_id); |
1979 | 1935 |
1980 ASSERT_EQ(3u, client.returned_resources().size()); | 1936 ASSERT_EQ(3u, client.returned_resources().size()); |
(...skipping 15 matching lines...) Expand all Loading... |
1996 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 1952 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
1997 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 1953 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
1998 pass->id = RenderPassId(1, 1); | 1954 pass->id = RenderPassId(1, 1); |
1999 TransferableResource resource; | 1955 TransferableResource resource; |
2000 resource.id = 11; | 1956 resource.id = 11; |
2001 // ResourceProvider is software but resource is not, so it should be | 1957 // ResourceProvider is software but resource is not, so it should be |
2002 // ignored. | 1958 // ignored. |
2003 resource.is_software = false; | 1959 resource.is_software = false; |
2004 frame_data->resource_list.push_back(resource); | 1960 frame_data->resource_list.push_back(resource); |
2005 frame_data->render_pass_list.push_back(std::move(pass)); | 1961 frame_data->render_pass_list.push_back(std::move(pass)); |
2006 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 1962 CompositorFrame frame; |
2007 frame->delegated_frame_data = std::move(frame_data); | 1963 frame.delegated_frame_data = std::move(frame_data); |
2008 factory.SubmitCompositorFrame(surface_id, std::move(frame), | 1964 factory.SubmitCompositorFrame(surface_id, std::move(frame), |
2009 SurfaceFactory::DrawCallback()); | 1965 SurfaceFactory::DrawCallback()); |
2010 | 1966 |
2011 std::unique_ptr<CompositorFrame> returned_frame = | 1967 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); |
2012 aggregator_->Aggregate(surface_id); | |
2013 | 1968 |
2014 // Nothing should be available to be returned yet. | 1969 // Nothing should be available to be returned yet. |
2015 EXPECT_TRUE(client.returned_resources().empty()); | 1970 EXPECT_TRUE(client.returned_resources().empty()); |
2016 | 1971 |
2017 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1972 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
2018 surface_id); | 1973 surface_id); |
2019 ASSERT_EQ(1u, client.returned_resources().size()); | 1974 ASSERT_EQ(1u, client.returned_resources().size()); |
2020 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1975 EXPECT_EQ(11u, client.returned_resources()[0].id); |
2021 | 1976 |
2022 factory.Destroy(surface_id); | 1977 factory.Destroy(surface_id); |
2023 } | 1978 } |
2024 | 1979 |
2025 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1980 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
2026 ResourceTrackingSurfaceFactoryClient client; | 1981 ResourceTrackingSurfaceFactoryClient client; |
2027 SurfaceFactory factory(&manager_, &client); | 1982 SurfaceFactory factory(&manager_, &client); |
2028 SurfaceId surface1_id(0, 7u, 0); | 1983 SurfaceId surface1_id(0, 7u, 0); |
2029 factory.Create(surface1_id); | 1984 factory.Create(surface1_id); |
2030 | 1985 |
2031 SurfaceId surface2_id(0, 8u, 0); | 1986 SurfaceId surface2_id(0, 8u, 0); |
2032 factory.Create(surface2_id); | 1987 factory.Create(surface2_id); |
2033 | 1988 |
2034 ResourceId ids[] = {11, 12, 13}; | 1989 ResourceId ids[] = {11, 12, 13}; |
2035 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1990 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
2036 &factory, surface1_id); | 1991 &factory, surface1_id); |
2037 ResourceId ids2[] = {14, 15, 16}; | 1992 ResourceId ids2[] = {14, 15, 16}; |
2038 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 1993 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
2039 &factory, surface2_id); | 1994 &factory, surface2_id); |
2040 | 1995 |
2041 std::unique_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id); | 1996 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
2042 | 1997 |
2043 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1998 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
2044 surface1_id); | 1999 surface1_id); |
2045 | 2000 |
2046 // Nothing should be available to be returned yet. | 2001 // Nothing should be available to be returned yet. |
2047 EXPECT_TRUE(client.returned_resources().empty()); | 2002 EXPECT_TRUE(client.returned_resources().empty()); |
2048 | 2003 |
2049 frame = aggregator_->Aggregate(surface2_id); | 2004 frame = aggregator_->Aggregate(surface2_id); |
2050 | 2005 |
2051 // surface1_id wasn't referenced, so its resources should be returned. | 2006 // surface1_id wasn't referenced, so its resources should be returned. |
(...skipping 28 matching lines...) Expand all Loading... |
2080 ResourceId ids2[] = {17, 18, 19}; | 2035 ResourceId ids2[] = {17, 18, 19}; |
2081 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 2036 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
2082 child_surface_id, &factory, | 2037 child_surface_id, &factory, |
2083 middle_surface_id); | 2038 middle_surface_id); |
2084 | 2039 |
2085 ResourceId ids3[] = {20, 21, 22}; | 2040 ResourceId ids3[] = {20, 21, 22}; |
2086 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 2041 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
2087 middle_surface_id, &factory, | 2042 middle_surface_id, &factory, |
2088 root_surface_id); | 2043 root_surface_id); |
2089 | 2044 |
2090 std::unique_ptr<CompositorFrame> frame; | 2045 CompositorFrame frame; |
2091 frame = aggregator_->Aggregate(root_surface_id); | 2046 frame = aggregator_->Aggregate(root_surface_id); |
2092 | 2047 |
2093 RenderPassList* pass_list = &frame->delegated_frame_data->render_pass_list; | 2048 RenderPassList* pass_list = &frame.delegated_frame_data->render_pass_list; |
2094 ASSERT_EQ(1u, pass_list->size()); | 2049 ASSERT_EQ(1u, pass_list->size()); |
2095 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 2050 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
2096 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 2051 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
2097 | 2052 |
2098 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 2053 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
2099 child_surface_id, &factory, | 2054 child_surface_id, &factory, |
2100 middle_surface_id); | 2055 middle_surface_id); |
2101 | 2056 |
2102 frame = aggregator_->Aggregate(root_surface_id); | 2057 frame = aggregator_->Aggregate(root_surface_id); |
2103 | 2058 |
2104 pass_list = &frame->delegated_frame_data->render_pass_list; | 2059 pass_list = &frame.delegated_frame_data->render_pass_list; |
2105 ASSERT_EQ(1u, pass_list->size()); | 2060 ASSERT_EQ(1u, pass_list->size()); |
2106 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 2061 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
2107 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 2062 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
2108 | 2063 |
2109 factory.Destroy(root_surface_id); | 2064 factory.Destroy(root_surface_id); |
2110 factory.Destroy(child_surface_id); | 2065 factory.Destroy(child_surface_id); |
2111 factory.Destroy(middle_surface_id); | 2066 factory.Destroy(middle_surface_id); |
2112 } | 2067 } |
2113 | 2068 |
2114 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 2069 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
2115 ResourceTrackingSurfaceFactoryClient client; | 2070 ResourceTrackingSurfaceFactoryClient client; |
2116 SurfaceFactory factory(&manager_, &client); | 2071 SurfaceFactory factory(&manager_, &client); |
2117 SurfaceId surface1_id(0, 7u, 0); | 2072 SurfaceId surface1_id(0, 7u, 0); |
2118 factory.Create(surface1_id); | 2073 factory.Create(surface1_id); |
2119 | 2074 |
2120 SurfaceId surface2_id(0, 8u, 0); | 2075 SurfaceId surface2_id(0, 8u, 0); |
2121 factory.Create(surface2_id); | 2076 factory.Create(surface2_id); |
2122 | 2077 |
2123 ResourceId ids[] = {11, 12, 13}; | 2078 ResourceId ids[] = {11, 12, 13}; |
2124 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 2079 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
2125 &factory, surface1_id); | 2080 &factory, surface1_id); |
2126 | 2081 |
2127 std::unique_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id); | 2082 CompositorFrame frame = aggregator_->Aggregate(surface1_id); |
2128 | 2083 |
2129 RenderPass* render_pass = | 2084 RenderPass* render_pass = |
2130 frame->delegated_frame_data->render_pass_list.back().get(); | 2085 frame.delegated_frame_data->render_pass_list.back().get(); |
2131 | 2086 |
2132 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); | 2087 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); |
2133 | 2088 |
2134 { | 2089 { |
2135 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 2090 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
2136 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 2091 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
2137 pass->id = RenderPassId(1, 1); | 2092 pass->id = RenderPassId(1, 1); |
2138 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 2093 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
2139 sqs->opacity = 1.f; | 2094 sqs->opacity = 1.f; |
2140 SurfaceDrawQuad* surface_quad = | 2095 SurfaceDrawQuad* surface_quad = |
2141 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 2096 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
2142 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), | 2097 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), |
2143 surface1_id); | 2098 surface1_id); |
2144 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 2099 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
2145 | 2100 |
2146 frame_data->render_pass_list.push_back(std::move(pass)); | 2101 frame_data->render_pass_list.push_back(std::move(pass)); |
2147 std::unique_ptr<CompositorFrame> frame(new CompositorFrame); | 2102 CompositorFrame frame; |
2148 frame->delegated_frame_data = std::move(frame_data); | 2103 frame.delegated_frame_data = std::move(frame_data); |
2149 factory.SubmitCompositorFrame(surface2_id, std::move(frame), | 2104 factory.SubmitCompositorFrame(surface2_id, std::move(frame), |
2150 SurfaceFactory::DrawCallback()); | 2105 SurfaceFactory::DrawCallback()); |
2151 } | 2106 } |
2152 | 2107 |
2153 frame = aggregator_->Aggregate(surface2_id); | 2108 frame = aggregator_->Aggregate(surface2_id); |
2154 EXPECT_EQ(1u, frame->delegated_frame_data->render_pass_list.size()); | 2109 EXPECT_EQ(1u, frame.delegated_frame_data->render_pass_list.size()); |
2155 render_pass = frame->delegated_frame_data->render_pass_list.front().get(); | 2110 render_pass = frame.delegated_frame_data->render_pass_list.front().get(); |
2156 | 2111 |
2157 // Parent has copy request, so texture should not be drawn. | 2112 // Parent has copy request, so texture should not be drawn. |
2158 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2113 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
2159 | 2114 |
2160 frame = aggregator_->Aggregate(surface2_id); | 2115 frame = aggregator_->Aggregate(surface2_id); |
2161 EXPECT_EQ(1u, frame->delegated_frame_data->render_pass_list.size()); | 2116 EXPECT_EQ(1u, frame.delegated_frame_data->render_pass_list.size()); |
2162 render_pass = frame->delegated_frame_data->render_pass_list.front().get(); | 2117 render_pass = frame.delegated_frame_data->render_pass_list.front().get(); |
2163 | 2118 |
2164 // Copy request has been executed earlier, so texture should be drawn. | 2119 // Copy request has been executed earlier, so texture should be drawn. |
2165 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, | 2120 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, |
2166 render_pass->quad_list.front()->material); | 2121 render_pass->quad_list.front()->material); |
2167 | 2122 |
2168 aggregator_->set_output_is_secure(false); | 2123 aggregator_->set_output_is_secure(false); |
2169 | 2124 |
2170 frame = aggregator_->Aggregate(surface2_id); | 2125 frame = aggregator_->Aggregate(surface2_id); |
2171 render_pass = frame->delegated_frame_data->render_pass_list.back().get(); | 2126 render_pass = frame.delegated_frame_data->render_pass_list.back().get(); |
2172 | 2127 |
2173 // Output is insecure, so texture should be drawn. | 2128 // Output is insecure, so texture should be drawn. |
2174 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2129 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
2175 | 2130 |
2176 factory.Destroy(surface1_id); | 2131 factory.Destroy(surface1_id); |
2177 factory.Destroy(surface2_id); | 2132 factory.Destroy(surface2_id); |
2178 } | 2133 } |
2179 | 2134 |
2180 } // namespace | 2135 } // namespace |
2181 } // namespace cc | 2136 } // namespace cc |
2182 | 2137 |
OLD | NEW |