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

Side by Side Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: IsEmpty + rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
15 #include "cc/output/delegated_frame_data.h"
16 #include "cc/quads/render_pass.h" 15 #include "cc/quads/render_pass.h"
17 #include "cc/quads/render_pass_draw_quad.h" 16 #include "cc/quads/render_pass_draw_quad.h"
18 #include "cc/quads/solid_color_draw_quad.h" 17 #include "cc/quads/solid_color_draw_quad.h"
19 #include "cc/quads/surface_draw_quad.h" 18 #include "cc/quads/surface_draw_quad.h"
20 #include "cc/quads/texture_draw_quad.h" 19 #include "cc/quads/texture_draw_quad.h"
21 #include "cc/resources/shared_bitmap_manager.h" 20 #include "cc/resources/shared_bitmap_manager.h"
22 #include "cc/surfaces/surface.h" 21 #include "cc/surfaces/surface.h"
23 #include "cc/surfaces/surface_factory.h" 22 #include "cc/surfaces/surface_factory.h"
24 #include "cc/surfaces/surface_factory_client.h" 23 #include "cc/surfaces/surface_factory_client.h"
25 #include "cc/surfaces/surface_id_allocator.h" 24 #include "cc/surfaces/surface_id_allocator.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 SurfaceFactory factory_; 77 SurfaceFactory factory_;
79 SurfaceAggregator aggregator_; 78 SurfaceAggregator aggregator_;
80 }; 79 };
81 80
82 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { 81 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
83 LocalFrameId local_frame_id(7, 0); 82 LocalFrameId local_frame_id(7, 0);
84 SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id); 83 SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id);
85 factory_.Create(local_frame_id); 84 factory_.Create(local_frame_id);
86 85
87 CompositorFrame frame = aggregator_.Aggregate(one_id); 86 CompositorFrame frame = aggregator_.Aggregate(one_id);
88 EXPECT_FALSE(frame.delegated_frame_data);
89 87
90 factory_.Destroy(local_frame_id); 88 factory_.Destroy(local_frame_id);
91 } 89 }
92 90
93 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { 91 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
94 public: 92 public:
95 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) 93 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect)
96 : SurfaceAggregatorTest(use_damage_rect), 94 : SurfaceAggregatorTest(use_damage_rect),
97 child_factory_(kArbitraryChildFrameSinkId, 95 child_factory_(kArbitraryChildFrameSinkId,
98 &manager_, 96 &manager_,
(...skipping 14 matching lines...) Expand all
113 SurfaceAggregatorTest::TearDown(); 111 SurfaceAggregatorTest::TearDown();
114 } 112 }
115 113
116 void AggregateAndVerify(test::Pass* expected_passes, 114 void AggregateAndVerify(test::Pass* expected_passes,
117 size_t expected_pass_count, 115 size_t expected_pass_count,
118 SurfaceId* surface_ids, 116 SurfaceId* surface_ids,
119 size_t expected_surface_count) { 117 size_t expected_surface_count) {
120 CompositorFrame aggregated_frame = aggregator_.Aggregate( 118 CompositorFrame aggregated_frame = aggregator_.Aggregate(
121 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_)); 119 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_));
122 120
123 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 121 TestPassesMatchExpectations(expected_passes, expected_pass_count,
124 122 &aggregated_frame.render_pass_list);
125 DelegatedFrameData* frame_data =
126 aggregated_frame.delegated_frame_data.get();
127
128 TestPassesMatchExpectations(
129 expected_passes, expected_pass_count, &frame_data->render_pass_list);
130 123
131 // Ensure no duplicate pass ids output. 124 // Ensure no duplicate pass ids output.
132 std::set<RenderPassId> used_passes; 125 std::set<RenderPassId> used_passes;
133 for (const auto& pass : frame_data->render_pass_list) { 126 for (const auto& pass : aggregated_frame.render_pass_list) {
134 EXPECT_TRUE(used_passes.insert(pass->id).second); 127 EXPECT_TRUE(used_passes.insert(pass->id).second);
135 } 128 }
136 129
137 EXPECT_EQ(expected_surface_count, 130 EXPECT_EQ(expected_surface_count,
138 aggregator_.previous_contained_surfaces().size()); 131 aggregator_.previous_contained_surfaces().size());
139 for (size_t i = 0; i < expected_surface_count; i++) { 132 for (size_t i = 0; i < expected_surface_count; i++) {
140 EXPECT_TRUE( 133 EXPECT_TRUE(
141 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != 134 aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
142 aggregator_.previous_contained_surfaces().end()); 135 aggregator_.previous_contained_surfaces().end());
143 } 136 }
144 } 137 }
145 138
146 void SubmitPassListAsFrame(SurfaceFactory* factory, 139 void SubmitPassListAsFrame(SurfaceFactory* factory,
147 const LocalFrameId& local_frame_id, 140 const LocalFrameId& local_frame_id,
148 RenderPassList* pass_list) { 141 RenderPassList* pass_list) {
149 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
150 pass_list->swap(frame_data->render_pass_list);
151
152 CompositorFrame frame; 142 CompositorFrame frame;
153 frame.delegated_frame_data = std::move(frame_data); 143 pass_list->swap(frame.render_pass_list);
154 144
155 factory->SubmitCompositorFrame(local_frame_id, std::move(frame), 145 factory->SubmitCompositorFrame(local_frame_id, std::move(frame),
156 SurfaceFactory::DrawCallback()); 146 SurfaceFactory::DrawCallback());
157 } 147 }
158 148
159 void SubmitCompositorFrame(SurfaceFactory* factory, 149 void SubmitCompositorFrame(SurfaceFactory* factory,
160 test::Pass* passes, 150 test::Pass* passes,
161 size_t pass_count, 151 size_t pass_count,
162 const LocalFrameId& local_frame_id) { 152 const LocalFrameId& local_frame_id) {
163 RenderPassList pass_list; 153 RenderPassList pass_list;
164 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); 154 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count);
165 SubmitPassListAsFrame(factory, local_frame_id, &pass_list); 155 SubmitPassListAsFrame(factory, local_frame_id, &pass_list);
166 } 156 }
167 157
168 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, 158 void QueuePassAsFrame(std::unique_ptr<RenderPass> pass,
169 const LocalFrameId& local_frame_id) { 159 const LocalFrameId& local_frame_id) {
170 std::unique_ptr<DelegatedFrameData> delegated_frame_data(
171 new DelegatedFrameData);
172 delegated_frame_data->render_pass_list.push_back(std::move(pass));
173
174 CompositorFrame child_frame; 160 CompositorFrame child_frame;
175 child_frame.delegated_frame_data = std::move(delegated_frame_data); 161 child_frame.render_pass_list.push_back(std::move(pass));
176 162
177 factory_.SubmitCompositorFrame(local_frame_id, std::move(child_frame), 163 factory_.SubmitCompositorFrame(local_frame_id, std::move(child_frame),
178 SurfaceFactory::DrawCallback()); 164 SurfaceFactory::DrawCallback());
179 } 165 }
180 166
181 protected: 167 protected:
182 LocalFrameId root_local_frame_id_; 168 LocalFrameId root_local_frame_id_;
183 Surface* root_surface_; 169 Surface* root_surface_;
184 SurfaceIdAllocator allocator_; 170 SurfaceIdAllocator allocator_;
185 EmptySurfaceFactoryClient empty_child_client_; 171 EmptySurfaceFactoryClient empty_child_client_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 209
224 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; 210 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)};
225 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; 211 test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
226 212
227 SubmitCompositorFrame(&factory_, passes, arraysize(passes), 213 SubmitCompositorFrame(&factory_, passes, arraysize(passes),
228 root_local_frame_id_); 214 root_local_frame_id_);
229 215
230 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 216 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
231 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 217 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
232 218
233 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 219 RenderPassList& render_pass_list(aggregated_frame.render_pass_list);
234
235 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
236
237 RenderPassList& render_pass_list(frame_data->render_pass_list);
238 ASSERT_EQ(2u, render_pass_list.size()); 220 ASSERT_EQ(2u, render_pass_list.size());
239 SharedQuadStateList& shared_quad_state_list( 221 SharedQuadStateList& shared_quad_state_list(
240 render_pass_list[0]->shared_quad_state_list); 222 render_pass_list[0]->shared_quad_state_list);
241 ASSERT_EQ(2u, shared_quad_state_list.size()); 223 ASSERT_EQ(2u, shared_quad_state_list.size());
242 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); 224 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity);
243 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); 225 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity);
244 226
245 SharedQuadStateList& shared_quad_state_list2( 227 SharedQuadStateList& shared_quad_state_list2(
246 render_pass_list[1]->shared_quad_state_list); 228 render_pass_list[1]->shared_quad_state_list);
247 ASSERT_EQ(1u, shared_quad_state_list2.size()); 229 ASSERT_EQ(1u, shared_quad_state_list2.size());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), 310 test::Quad::SurfaceQuad(embedded_surface_id, 1.f),
329 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 311 test::Quad::SolidColorQuad(SK_ColorBLACK)};
330 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 312 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
331 313
332 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), 314 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
333 root_local_frame_id_); 315 root_local_frame_id_);
334 316
335 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 317 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
336 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 318 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
337 319
338 ASSERT_TRUE(aggregated_frame.delegated_frame_data);
339
340 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
341
342 test::Quad expected_quads[] = { 320 test::Quad expected_quads[] = {
343 test::Quad::SolidColorQuad(SK_ColorWHITE), 321 test::Quad::SolidColorQuad(SK_ColorWHITE),
344 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), 322 test::Quad::RenderPassQuad(aggregated_frame.render_pass_list[0]->id),
345 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 323 test::Quad::SolidColorQuad(SK_ColorBLACK)};
346 test::Pass expected_passes[] = { 324 test::Pass expected_passes[] = {
347 test::Pass(embedded_quads, arraysize(embedded_quads)), 325 test::Pass(embedded_quads, arraysize(embedded_quads)),
348 test::Pass(expected_quads, arraysize(expected_quads))}; 326 test::Pass(expected_quads, arraysize(expected_quads))};
349 TestPassesMatchExpectations(expected_passes, 327 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes),
350 arraysize(expected_passes), 328 &aggregated_frame.render_pass_list);
351 &frame_data->render_pass_list); 329 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size());
352 ASSERT_EQ(2u, frame_data->render_pass_list.size()); 330 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size());
353 ASSERT_EQ(1u, frame_data->render_pass_list[0]->copy_requests.size());
354 DCHECK_EQ(copy_request_ptr, 331 DCHECK_EQ(copy_request_ptr,
355 frame_data->render_pass_list[0]->copy_requests[0].get()); 332 aggregated_frame.render_pass_list[0]->copy_requests[0].get());
356 333
357 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; 334 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id};
358 EXPECT_EQ(arraysize(surface_ids), 335 EXPECT_EQ(arraysize(surface_ids),
359 aggregator_.previous_contained_surfaces().size()); 336 aggregator_.previous_contained_surfaces().size());
360 for (size_t i = 0; i < arraysize(surface_ids); i++) { 337 for (size_t i = 0; i < arraysize(surface_ids); i++) {
361 EXPECT_TRUE( 338 EXPECT_TRUE(
362 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != 339 aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
363 aggregator_.previous_contained_surfaces().end()); 340 aggregator_.previous_contained_surfaces().end());
364 } 341 }
365 342
(...skipping 29 matching lines...) Expand all
395 test::Pass(root_quads2, arraysize(root_quads2), RenderPassId(1, 2))}; 372 test::Pass(root_quads2, arraysize(root_quads2), RenderPassId(1, 2))};
396 { 373 {
397 RenderPassList pass_list; 374 RenderPassList pass_list;
398 AddPasses(&pass_list, 375 AddPasses(&pass_list,
399 gfx::Rect(SurfaceSize()), 376 gfx::Rect(SurfaceSize()),
400 root_passes, 377 root_passes,
401 arraysize(root_passes)); 378 arraysize(root_passes));
402 pass_list[0]->copy_requests.push_back(std::move(copy_request)); 379 pass_list[0]->copy_requests.push_back(std::move(copy_request));
403 pass_list[1]->copy_requests.push_back(std::move(copy_request2)); 380 pass_list[1]->copy_requests.push_back(std::move(copy_request2));
404 381
405 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
406 pass_list.swap(frame_data->render_pass_list);
407
408 CompositorFrame frame; 382 CompositorFrame frame;
409 frame.delegated_frame_data = std::move(frame_data); 383 pass_list.swap(frame.render_pass_list);
410 384
411 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(frame), 385 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(frame),
412 SurfaceFactory::DrawCallback()); 386 SurfaceFactory::DrawCallback());
413 } 387 }
414 388
415 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 389 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
416 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 390 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
417 391
418 ASSERT_TRUE(aggregated_frame.delegated_frame_data);
419
420 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
421
422 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), 392 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
423 test::Quad::SolidColorQuad(SK_ColorGREEN), 393 test::Quad::SolidColorQuad(SK_ColorGREEN),
424 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 394 test::Quad::SolidColorQuad(SK_ColorBLACK)};
425 test::Pass expected_passes[] = { 395 test::Pass expected_passes[] = {
426 test::Pass(expected_quads, arraysize(expected_quads)), 396 test::Pass(expected_quads, arraysize(expected_quads)),
427 test::Pass(root_quads2, arraysize(root_quads2))}; 397 test::Pass(root_quads2, arraysize(root_quads2))};
428 TestPassesMatchExpectations(expected_passes, 398 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes),
429 arraysize(expected_passes), 399 &aggregated_frame.render_pass_list);
430 &frame_data->render_pass_list); 400 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size());
431 ASSERT_EQ(2u, frame_data->render_pass_list.size()); 401 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size());
432 ASSERT_EQ(1u, frame_data->render_pass_list[0]->copy_requests.size());
433 DCHECK_EQ(copy_request_ptr, 402 DCHECK_EQ(copy_request_ptr,
434 frame_data->render_pass_list[0]->copy_requests[0].get()); 403 aggregated_frame.render_pass_list[0]->copy_requests[0].get());
435 ASSERT_EQ(1u, frame_data->render_pass_list[1]->copy_requests.size()); 404 ASSERT_EQ(1u, aggregated_frame.render_pass_list[1]->copy_requests.size());
436 DCHECK_EQ(copy_request2_ptr, 405 DCHECK_EQ(copy_request2_ptr,
437 frame_data->render_pass_list[1]->copy_requests[0].get()); 406 aggregated_frame.render_pass_list[1]->copy_requests[0].get());
438 407
439 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; 408 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id};
440 EXPECT_EQ(arraysize(surface_ids), 409 EXPECT_EQ(arraysize(surface_ids),
441 aggregator_.previous_contained_surfaces().size()); 410 aggregator_.previous_contained_surfaces().size());
442 for (size_t i = 0; i < arraysize(surface_ids); i++) { 411 for (size_t i = 0; i < arraysize(surface_ids); i++) {
443 EXPECT_TRUE( 412 EXPECT_TRUE(
444 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != 413 aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
445 aggregator_.previous_contained_surfaces().end()); 414 aggregator_.previous_contained_surfaces().end());
446 } 415 }
447 416
448 // Ensure copy requests have been removed from root surface. 417 // Ensure copy requests have been removed from root surface.
449 const CompositorFrame& original_frame = 418 const CompositorFrame& original_frame =
450 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame(); 419 manager_.GetSurfaceForId(root_surface_id)->GetEligibleFrame();
451 RenderPassList& original_pass_list = 420 const RenderPassList& original_pass_list = original_frame.render_pass_list;
452 original_frame.delegated_frame_data->render_pass_list;
453 ASSERT_EQ(2u, original_pass_list.size()); 421 ASSERT_EQ(2u, original_pass_list.size());
454 DCHECK(original_pass_list[0]->copy_requests.empty()); 422 DCHECK(original_pass_list[0]->copy_requests.empty());
455 DCHECK(original_pass_list[1]->copy_requests.empty()); 423 DCHECK(original_pass_list[1]->copy_requests.empty());
456 424
457 factory_.Destroy(embedded_local_frame_id); 425 factory_.Destroy(embedded_local_frame_id);
458 } 426 }
459 427
460 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { 428 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
461 LocalFrameId embedded_local_frame_id = allocator_.GenerateId(); 429 LocalFrameId embedded_local_frame_id = allocator_.GenerateId();
462 SurfaceId embedded_surface_id(factory_.frame_sink_id(), 430 SurfaceId embedded_surface_id(factory_.frame_sink_id(),
(...skipping 19 matching lines...) Expand all
482 factory_.Create(parent_local_frame_id); 450 factory_.Create(parent_local_frame_id);
483 451
484 test::Quad parent_quads[] = { 452 test::Quad parent_quads[] = {
485 test::Quad::SolidColorQuad(SK_ColorWHITE), 453 test::Quad::SolidColorQuad(SK_ColorWHITE),
486 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), 454 test::Quad::SurfaceQuad(embedded_surface_id, 1.f),
487 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 455 test::Quad::SolidColorQuad(SK_ColorBLACK)};
488 test::Pass parent_passes[] = { 456 test::Pass parent_passes[] = {
489 test::Pass(parent_quads, arraysize(parent_quads))}; 457 test::Pass(parent_quads, arraysize(parent_quads))};
490 458
491 { 459 {
492 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 460 CompositorFrame frame;
493 AddPasses(&frame_data->render_pass_list, gfx::Rect(SurfaceSize()),
494 parent_passes, arraysize(parent_passes));
495 461
496 CompositorFrame frame; 462 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes,
497 frame.delegated_frame_data = std::move(frame_data); 463 arraysize(parent_passes));
464
498 frame.metadata.referenced_surfaces.push_back(embedded_surface_id); 465 frame.metadata.referenced_surfaces.push_back(embedded_surface_id);
499 466
500 factory_.SubmitCompositorFrame(parent_local_frame_id, std::move(frame), 467 factory_.SubmitCompositorFrame(parent_local_frame_id, std::move(frame),
501 SurfaceFactory::DrawCallback()); 468 SurfaceFactory::DrawCallback());
502 } 469 }
503 470
504 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), 471 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
505 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 472 test::Quad::SolidColorQuad(SK_ColorBLACK)};
506 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 473 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
507 474
508 { 475 {
509 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 476 CompositorFrame frame;
510 AddPasses(&frame_data->render_pass_list, gfx::Rect(SurfaceSize()), 477 AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
511 root_passes, arraysize(root_passes)); 478 arraysize(root_passes));
512 479
513 CompositorFrame frame;
514 frame.delegated_frame_data = std::move(frame_data);
515 frame.metadata.referenced_surfaces.push_back(parent_surface_id); 480 frame.metadata.referenced_surfaces.push_back(parent_surface_id);
516 // Reference to Surface ID of a Surface that doesn't exist should be 481 // Reference to Surface ID of a Surface that doesn't exist should be
517 // included in previous_contained_surfaces, but otherwise ignored. 482 // included in previous_contained_surfaces, but otherwise ignored.
518 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id); 483 frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id);
519 484
520 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(frame), 485 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(frame),
521 SurfaceFactory::DrawCallback()); 486 SurfaceFactory::DrawCallback());
522 } 487 }
523 488
524 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 489 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
525 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 490 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
526 491
527 ASSERT_TRUE(aggregated_frame.delegated_frame_data);
528
529 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
530
531 // First pass should come from surface that had a copy request but was not 492 // First pass should come from surface that had a copy request but was not
532 // referenced directly. The second pass comes from the root surface. 493 // referenced directly. The second pass comes from the root surface.
533 // parent_quad should be ignored because it is neither referenced through a 494 // parent_quad should be ignored because it is neither referenced through a
534 // SurfaceDrawQuad nor has a copy request on it. 495 // SurfaceDrawQuad nor has a copy request on it.
535 test::Pass expected_passes[] = { 496 test::Pass expected_passes[] = {
536 test::Pass(embedded_quads, arraysize(embedded_quads)), 497 test::Pass(embedded_quads, arraysize(embedded_quads)),
537 test::Pass(root_quads, arraysize(root_quads))}; 498 test::Pass(root_quads, arraysize(root_quads))};
538 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes), 499 TestPassesMatchExpectations(expected_passes, arraysize(expected_passes),
539 &frame_data->render_pass_list); 500 &aggregated_frame.render_pass_list);
540 ASSERT_EQ(2u, frame_data->render_pass_list.size()); 501 ASSERT_EQ(2u, aggregated_frame.render_pass_list.size());
541 ASSERT_EQ(1u, frame_data->render_pass_list[0]->copy_requests.size()); 502 ASSERT_EQ(1u, aggregated_frame.render_pass_list[0]->copy_requests.size());
542 DCHECK_EQ(copy_request_ptr, 503 DCHECK_EQ(copy_request_ptr,
543 frame_data->render_pass_list[0]->copy_requests[0].get()); 504 aggregated_frame.render_pass_list[0]->copy_requests[0].get());
544 505
545 SurfaceId surface_ids[] = { 506 SurfaceId surface_ids[] = {
546 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_), 507 SurfaceId(factory_.frame_sink_id(), root_local_frame_id_),
547 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; 508 parent_surface_id, embedded_surface_id, nonexistent_surface_id};
548 EXPECT_EQ(arraysize(surface_ids), 509 EXPECT_EQ(arraysize(surface_ids),
549 aggregator_.previous_contained_surfaces().size()); 510 aggregator_.previous_contained_surfaces().size());
550 for (size_t i = 0; i < arraysize(surface_ids); i++) { 511 for (size_t i = 0; i < arraysize(surface_ids); i++) {
551 EXPECT_TRUE( 512 EXPECT_TRUE(
552 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != 513 aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
553 aggregator_.previous_contained_surfaces().end()); 514 aggregator_.previous_contained_surfaces().end());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), 549 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]),
589 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), 550 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]),
590 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; 551 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])};
591 552
592 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes), 553 SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
593 root_local_frame_id_); 554 root_local_frame_id_);
594 555
595 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 556 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
596 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 557 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
597 558
598 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 559 const RenderPassList& aggregated_pass_list =
599 560 aggregated_frame.render_pass_list;
600 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
601
602 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
603 561
604 ASSERT_EQ(5u, aggregated_pass_list.size()); 562 ASSERT_EQ(5u, aggregated_pass_list.size());
605 RenderPassId actual_pass_ids[] = { 563 RenderPassId actual_pass_ids[] = {
606 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, 564 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id,
607 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id, 565 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id,
608 aggregated_pass_list[4]->id}; 566 aggregated_pass_list[4]->id};
609 for (size_t i = 0; i < 5; ++i) { 567 for (size_t i = 0; i < 5; ++i) {
610 for (size_t j = 0; j < i; ++j) { 568 for (size_t j = 0; j < i; ++j) {
611 EXPECT_NE(actual_pass_ids[i], actual_pass_ids[j]); 569 EXPECT_NE(actual_pass_ids[i], actual_pass_ids[j]);
612 } 570 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 test::Pass parent_passes[] = { 792 test::Pass parent_passes[] = {
835 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), 793 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]),
836 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; 794 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])};
837 795
838 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes), 796 SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes),
839 root_local_frame_id_); 797 root_local_frame_id_);
840 798
841 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 799 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
842 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 800 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
843 801
844 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 802 const RenderPassList& aggregated_pass_list =
845 803 aggregated_frame.render_pass_list;
846 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
847
848 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
849 804
850 ASSERT_EQ(3u, aggregated_pass_list.size()); 805 ASSERT_EQ(3u, aggregated_pass_list.size());
851 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, 806 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id,
852 aggregated_pass_list[1]->id, 807 aggregated_pass_list[1]->id,
853 aggregated_pass_list[2]->id}; 808 aggregated_pass_list[2]->id};
854 // Make sure the aggregated frame's pass IDs are all unique. 809 // Make sure the aggregated frame's pass IDs are all unique.
855 for (size_t i = 0; i < 3; ++i) { 810 for (size_t i = 0; i < 3; ++i) {
856 for (size_t j = 0; j < i; ++j) { 811 for (size_t j = 0; j < i; ++j) {
857 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i 812 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i
858 << " and " << j; 813 << " and " << j;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 gfx::Rect(SurfaceSize()), 957 gfx::Rect(SurfaceSize()),
1003 child_two_surface_id); 958 child_two_surface_id);
1004 AddSolidColorQuadWithBlendMode( 959 AddSolidColorQuadWithBlendMode(
1005 SurfaceSize(), root_pass.get(), blend_modes[6]); 960 SurfaceSize(), root_pass.get(), blend_modes[6]);
1006 961
1007 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_); 962 QueuePassAsFrame(std::move(root_pass), root_local_frame_id_);
1008 963
1009 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 964 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1010 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 965 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1011 966
1012 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 967 const RenderPassList& aggregated_pass_list =
1013 968 aggregated_frame.render_pass_list;
1014 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
1015
1016 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1017 969
1018 ASSERT_EQ(1u, aggregated_pass_list.size()); 970 ASSERT_EQ(1u, aggregated_pass_list.size());
1019 971
1020 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; 972 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list;
1021 973
1022 ASSERT_EQ(7u, aggregated_quad_list.size()); 974 ASSERT_EQ(7u, aggregated_quad_list.size());
1023 975
1024 for (auto iter = aggregated_quad_list.cbegin(); 976 for (auto iter = aggregated_quad_list.cbegin();
1025 iter != aggregated_quad_list.cend(); 977 iter != aggregated_quad_list.cend();
1026 ++iter) { 978 ++iter) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 child_nonroot_pass->shared_quad_state_list.front(); 1028 child_nonroot_pass->shared_quad_state_list.front();
1077 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0); 1029 child_nonroot_pass_sqs->quad_to_target_transform.Translate(5, 0);
1078 1030
1079 RenderPass* child_root_pass = child_pass_list[1].get(); 1031 RenderPass* child_root_pass = child_pass_list[1].get();
1080 SharedQuadState* child_root_pass_sqs = 1032 SharedQuadState* child_root_pass_sqs =
1081 child_root_pass->shared_quad_state_list.front(); 1033 child_root_pass->shared_quad_state_list.front();
1082 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); 1034 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
1083 child_root_pass_sqs->is_clipped = true; 1035 child_root_pass_sqs->is_clipped = true;
1084 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); 1036 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5);
1085 1037
1086 std::unique_ptr<DelegatedFrameData> child_frame_data(
1087 new DelegatedFrameData);
1088 child_pass_list.swap(child_frame_data->render_pass_list);
1089
1090 CompositorFrame child_frame; 1038 CompositorFrame child_frame;
1091 child_frame.delegated_frame_data = std::move(child_frame_data); 1039 child_pass_list.swap(child_frame.render_pass_list);
danakj 2016/10/27 23:06:56 Can you maybe instead define child_frame earlier a
Saman Sami 2016/10/28 16:47:35 Done.
1092 1040
1093 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), 1041 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
1094 SurfaceFactory::DrawCallback()); 1042 SurfaceFactory::DrawCallback());
1095 } 1043 }
1096 1044
1097 // Middle child surface. 1045 // Middle child surface.
1098 LocalFrameId middle_local_frame_id = allocator_.GenerateId(); 1046 LocalFrameId middle_local_frame_id = allocator_.GenerateId();
1099 SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id); 1047 SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id);
1100 factory_.Create(middle_local_frame_id); 1048 factory_.Create(middle_local_frame_id);
1101 { 1049 {
1102 test::Quad middle_quads[] = { 1050 test::Quad middle_quads[] = {
1103 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; 1051 test::Quad::SurfaceQuad(child_surface_id, 1.f)};
1104 test::Pass middle_passes[] = { 1052 test::Pass middle_passes[] = {
1105 test::Pass(middle_quads, arraysize(middle_quads)), 1053 test::Pass(middle_quads, arraysize(middle_quads)),
1106 }; 1054 };
1107 1055
1108 RenderPassList middle_pass_list; 1056 RenderPassList middle_pass_list;
1109 AddPasses(&middle_pass_list, gfx::Rect(SurfaceSize()), middle_passes, 1057 AddPasses(&middle_pass_list, gfx::Rect(SurfaceSize()), middle_passes,
1110 arraysize(middle_passes)); 1058 arraysize(middle_passes));
1111 1059
1112 RenderPass* middle_root_pass = middle_pass_list[0].get(); 1060 RenderPass* middle_root_pass = middle_pass_list[0].get();
1113 middle_root_pass->quad_list.ElementAt(0)->visible_rect = 1061 middle_root_pass->quad_list.ElementAt(0)->visible_rect =
1114 gfx::Rect(0, 1, 100, 7); 1062 gfx::Rect(0, 1, 100, 7);
1115 SharedQuadState* middle_root_pass_sqs = 1063 SharedQuadState* middle_root_pass_sqs =
1116 middle_root_pass->shared_quad_state_list.front(); 1064 middle_root_pass->shared_quad_state_list.front();
1117 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3); 1065 middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3);
1118 1066
1119 std::unique_ptr<DelegatedFrameData> middle_frame_data(
1120 new DelegatedFrameData);
1121 middle_pass_list.swap(middle_frame_data->render_pass_list);
1122
1123 CompositorFrame middle_frame; 1067 CompositorFrame middle_frame;
danakj 2016/10/27 23:06:56 same
1124 middle_frame.delegated_frame_data = std::move(middle_frame_data); 1068 middle_pass_list.swap(middle_frame.render_pass_list);
1125 1069
1126 factory_.SubmitCompositorFrame(middle_local_frame_id, 1070 factory_.SubmitCompositorFrame(middle_local_frame_id,
1127 std::move(middle_frame), 1071 std::move(middle_frame),
1128 SurfaceFactory::DrawCallback()); 1072 SurfaceFactory::DrawCallback());
1129 } 1073 }
1130 1074
1131 // Root surface. 1075 // Root surface.
1132 test::Quad secondary_quads[] = { 1076 test::Quad secondary_quads[] = {
1133 test::Quad::SolidColorQuad(1), 1077 test::Quad::SolidColorQuad(1),
1134 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; 1078 test::Quad::SurfaceQuad(middle_surface_id, 1.f)};
(...skipping 12 matching lines...) Expand all
1147 ->shared_quad_state_list.front() 1091 ->shared_quad_state_list.front()
1148 ->quad_to_target_transform.Translate(0, 7); 1092 ->quad_to_target_transform.Translate(0, 7);
1149 root_pass_list[0] 1093 root_pass_list[0]
1150 ->shared_quad_state_list.ElementAt(1) 1094 ->shared_quad_state_list.ElementAt(1)
1151 ->quad_to_target_transform.Translate(0, 10); 1095 ->quad_to_target_transform.Translate(0, 10);
1152 root_pass_list[0]->quad_list.ElementAt(1)->visible_rect = 1096 root_pass_list[0]->quad_list.ElementAt(1)->visible_rect =
1153 gfx::Rect(0, 0, 8, 100); 1097 gfx::Rect(0, 0, 8, 100);
1154 1098
1155 root_pass_list[0]->transform_to_root_target.Translate(10, 5); 1099 root_pass_list[0]->transform_to_root_target.Translate(10, 5);
1156 1100
1157 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1158 root_pass_list.swap(root_frame_data->render_pass_list);
1159
1160 CompositorFrame root_frame; 1101 CompositorFrame root_frame;
danakj 2016/10/27 23:06:56 same
1161 root_frame.delegated_frame_data = std::move(root_frame_data); 1102 root_pass_list.swap(root_frame.render_pass_list);
1162 1103
1163 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame), 1104 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame),
1164 SurfaceFactory::DrawCallback()); 1105 SurfaceFactory::DrawCallback());
1165 1106
1166 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1107 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1167 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1108 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1168 1109
1169 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1110 const RenderPassList& aggregated_pass_list =
1170 1111 aggregated_frame.render_pass_list;
1171 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
1172
1173 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1174 1112
1175 ASSERT_EQ(3u, aggregated_pass_list.size()); 1113 ASSERT_EQ(3u, aggregated_pass_list.size());
1176 1114
1177 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); 1115 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size());
1178 1116
1179 // The first pass should have one shared quad state for the one solid color 1117 // The first pass should have one shared quad state for the one solid color
1180 // quad. 1118 // quad.
1181 EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); 1119 EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size());
1182 // The second pass should have just two shared quad states. We'll 1120 // The second pass should have just two shared quad states. We'll
1183 // verify the properties through the quads. 1121 // verify the properties through the quads.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 AddPasses(&child_pass_list, 1191 AddPasses(&child_pass_list,
1254 gfx::Rect(SurfaceSize()), 1192 gfx::Rect(SurfaceSize()),
1255 child_passes, 1193 child_passes,
1256 arraysize(child_passes)); 1194 arraysize(child_passes));
1257 1195
1258 RenderPass* child_root_pass = child_pass_list[0].get(); 1196 RenderPass* child_root_pass = child_pass_list[0].get();
1259 SharedQuadState* child_root_pass_sqs = 1197 SharedQuadState* child_root_pass_sqs =
1260 child_root_pass->shared_quad_state_list.front(); 1198 child_root_pass->shared_quad_state_list.front();
1261 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); 1199 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
1262 1200
1263 std::unique_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
1264 child_pass_list.swap(child_frame_data->render_pass_list);
1265
1266 CompositorFrame child_frame; 1201 CompositorFrame child_frame;
danakj 2016/10/27 23:06:56 same
1267 child_frame.delegated_frame_data = std::move(child_frame_data); 1202 child_pass_list.swap(child_frame.render_pass_list);
1268 1203
1269 LocalFrameId child_local_frame_id = allocator_.GenerateId(); 1204 LocalFrameId child_local_frame_id = allocator_.GenerateId();
1270 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id); 1205 SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
1271 factory_.Create(child_local_frame_id); 1206 factory_.Create(child_local_frame_id);
1272 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), 1207 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
1273 SurfaceFactory::DrawCallback()); 1208 SurfaceFactory::DrawCallback());
1274 1209
1275 test::Quad parent_surface_quads[] = { 1210 test::Quad parent_surface_quads[] = {
1276 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; 1211 test::Quad::SurfaceQuad(child_surface_id, 1.f)};
1277 test::Pass parent_surface_passes[] = { 1212 test::Pass parent_surface_passes[] = {
1278 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), 1213 test::Pass(parent_surface_quads, arraysize(parent_surface_quads),
1279 RenderPassId(1, 1))}; 1214 RenderPassId(1, 1))};
1280 1215
1281 RenderPassList parent_surface_pass_list; 1216 RenderPassList parent_surface_pass_list;
1282 AddPasses(&parent_surface_pass_list, 1217 AddPasses(&parent_surface_pass_list,
1283 gfx::Rect(SurfaceSize()), 1218 gfx::Rect(SurfaceSize()),
1284 parent_surface_passes, 1219 parent_surface_passes,
1285 arraysize(parent_surface_passes)); 1220 arraysize(parent_surface_passes));
1286 1221
1287 // Parent surface is only used to test if the transform is applied correctly 1222 // Parent surface is only used to test if the transform is applied correctly
1288 // to the child surface's damage. 1223 // to the child surface's damage.
1289 std::unique_ptr<DelegatedFrameData> parent_surface_frame_data(
1290 new DelegatedFrameData);
1291 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list);
1292
1293 CompositorFrame parent_surface_frame; 1224 CompositorFrame parent_surface_frame;
danakj 2016/10/27 23:06:56 same
1294 parent_surface_frame.delegated_frame_data = 1225 parent_surface_pass_list.swap(parent_surface_frame.render_pass_list);
1295 std::move(parent_surface_frame_data);
1296 1226
1297 LocalFrameId parent_local_frame_id = allocator_.GenerateId(); 1227 LocalFrameId parent_local_frame_id = allocator_.GenerateId();
1298 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id); 1228 SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id);
1299 factory_.Create(parent_local_frame_id); 1229 factory_.Create(parent_local_frame_id);
1300 factory_.SubmitCompositorFrame(parent_local_frame_id, 1230 factory_.SubmitCompositorFrame(parent_local_frame_id,
1301 std::move(parent_surface_frame), 1231 std::move(parent_surface_frame),
1302 SurfaceFactory::DrawCallback()); 1232 SurfaceFactory::DrawCallback());
1303 1233
1304 test::Quad root_surface_quads[] = { 1234 test::Quad root_surface_quads[] = {
1305 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; 1235 test::Quad::SurfaceQuad(parent_surface_id, 1.f)};
(...skipping 11 matching lines...) Expand all
1317 gfx::Rect(SurfaceSize()), 1247 gfx::Rect(SurfaceSize()),
1318 root_passes, 1248 root_passes,
1319 arraysize(root_passes)); 1249 arraysize(root_passes));
1320 1250
1321 root_pass_list[0] 1251 root_pass_list[0]
1322 ->shared_quad_state_list.front() 1252 ->shared_quad_state_list.front()
1323 ->quad_to_target_transform.Translate(0, 10); 1253 ->quad_to_target_transform.Translate(0, 10);
1324 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); 1254 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10);
1325 root_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); 1255 root_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100);
1326 1256
1327 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1328 root_pass_list.swap(root_frame_data->render_pass_list);
1329
1330 CompositorFrame root_frame; 1257 CompositorFrame root_frame;
danakj 2016/10/27 23:06:56 same.. ok u get the idea lol
1331 root_frame.delegated_frame_data = std::move(root_frame_data); 1258 root_pass_list.swap(root_frame.render_pass_list);
1332 1259
1333 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame), 1260 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame),
1334 SurfaceFactory::DrawCallback()); 1261 SurfaceFactory::DrawCallback());
1335 1262
1336 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1263 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1337 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1264 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1338 1265
1339 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1266 const RenderPassList& aggregated_pass_list =
1340 1267 aggregated_frame.render_pass_list;
1341 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
1342
1343 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1344 1268
1345 ASSERT_EQ(2u, aggregated_pass_list.size()); 1269 ASSERT_EQ(2u, aggregated_pass_list.size());
1346 1270
1347 // Damage rect for first aggregation should contain entire root surface. 1271 // Damage rect for first aggregation should contain entire root surface.
1348 EXPECT_TRUE( 1272 EXPECT_TRUE(
1349 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); 1273 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
1350 1274
1351 { 1275 {
1352 AddPasses(&child_pass_list, 1276 AddPasses(&child_pass_list,
1353 gfx::Rect(SurfaceSize()), 1277 gfx::Rect(SurfaceSize()),
1354 child_passes, 1278 child_passes,
1355 arraysize(child_passes)); 1279 arraysize(child_passes));
1356 1280
1357 RenderPass* child_root_pass = child_pass_list[0].get(); 1281 RenderPass* child_root_pass = child_pass_list[0].get();
1358 SharedQuadState* child_root_pass_sqs = 1282 SharedQuadState* child_root_pass_sqs =
1359 child_root_pass->shared_quad_state_list.front(); 1283 child_root_pass->shared_quad_state_list.front();
1360 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); 1284 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
1361 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); 1285 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10);
1362 1286
1363 std::unique_ptr<DelegatedFrameData> child_frame_data(
1364 new DelegatedFrameData);
1365 child_pass_list.swap(child_frame_data->render_pass_list);
1366
1367 CompositorFrame child_frame; 1287 CompositorFrame child_frame;
1368 child_frame.delegated_frame_data = std::move(child_frame_data); 1288 child_pass_list.swap(child_frame.render_pass_list);
1369 1289
1370 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame), 1290 factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
1371 SurfaceFactory::DrawCallback()); 1291 SurfaceFactory::DrawCallback());
1372 1292
1373 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1293 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1374 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1294 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1375 1295
1376 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1296 const RenderPassList& aggregated_pass_list =
1377 1297 aggregated_frame.render_pass_list;
1378 DelegatedFrameData* frame_data =
1379 aggregated_frame.delegated_frame_data.get();
1380
1381 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1382 1298
1383 ASSERT_EQ(2u, aggregated_pass_list.size()); 1299 ASSERT_EQ(2u, aggregated_pass_list.size());
1384 1300
1385 // Outer surface didn't change, so transformed inner damage rect should be 1301 // Outer surface didn't change, so transformed inner damage rect should be
1386 // used. 1302 // used.
1387 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), 1303 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(),
1388 aggregated_pass_list[1]->damage_rect.ToString()); 1304 aggregated_pass_list[1]->damage_rect.ToString());
1389 } 1305 }
1390 1306
1391 { 1307 {
1392 RenderPassList root_pass_list; 1308 RenderPassList root_pass_list;
1393 AddPasses(&root_pass_list, 1309 AddPasses(&root_pass_list,
1394 gfx::Rect(SurfaceSize()), 1310 gfx::Rect(SurfaceSize()),
1395 root_passes, 1311 root_passes,
1396 arraysize(root_passes)); 1312 arraysize(root_passes));
1397 1313
1398 root_pass_list[0] 1314 root_pass_list[0]
1399 ->shared_quad_state_list.front() 1315 ->shared_quad_state_list.front()
1400 ->quad_to_target_transform.Translate(0, 10); 1316 ->quad_to_target_transform.Translate(0, 10);
1401 root_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); 1317 root_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1);
1402 1318
1403 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1404 root_pass_list.swap(root_frame_data->render_pass_list);
1405
1406 CompositorFrame root_frame; 1319 CompositorFrame root_frame;
1407 root_frame.delegated_frame_data = std::move(root_frame_data); 1320 root_pass_list.swap(root_frame.render_pass_list);
1408 1321
1409 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame), 1322 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame),
1410 SurfaceFactory::DrawCallback()); 1323 SurfaceFactory::DrawCallback());
1411 } 1324 }
1412 1325
1413 { 1326 {
1414 RenderPassList root_pass_list; 1327 RenderPassList root_pass_list;
1415 AddPasses(&root_pass_list, 1328 AddPasses(&root_pass_list,
1416 gfx::Rect(SurfaceSize()), 1329 gfx::Rect(SurfaceSize()),
1417 root_passes, 1330 root_passes,
1418 arraysize(root_passes)); 1331 arraysize(root_passes));
1419 1332
1420 root_pass_list[0] 1333 root_pass_list[0]
1421 ->shared_quad_state_list.front() 1334 ->shared_quad_state_list.front()
1422 ->quad_to_target_transform.Translate(0, 10); 1335 ->quad_to_target_transform.Translate(0, 10);
1423 root_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); 1336 root_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1);
1424 1337
1425 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1426 root_pass_list.swap(root_frame_data->render_pass_list);
1427
1428 CompositorFrame root_frame; 1338 CompositorFrame root_frame;
1429 root_frame.delegated_frame_data = std::move(root_frame_data); 1339 root_pass_list.swap(root_frame.render_pass_list);
1430 1340
1431 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame), 1341 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame),
1432 SurfaceFactory::DrawCallback()); 1342 SurfaceFactory::DrawCallback());
1433 1343
1434 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1344 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1435 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1345 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1436 1346
1437 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1347 const RenderPassList& aggregated_pass_list =
1438 1348 aggregated_frame.render_pass_list;
1439 DelegatedFrameData* frame_data =
1440 aggregated_frame.delegated_frame_data.get();
1441
1442 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1443 1349
1444 ASSERT_EQ(2u, aggregated_pass_list.size()); 1350 ASSERT_EQ(2u, aggregated_pass_list.size());
1445 1351
1446 // The root surface was enqueued without being aggregated once, so it should 1352 // The root surface was enqueued without being aggregated once, so it should
1447 // be treated as completely damaged. 1353 // be treated as completely damaged.
1448 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( 1354 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains(
1449 gfx::Rect(SurfaceSize()))); 1355 gfx::Rect(SurfaceSize())));
1450 } 1356 }
1451 1357
1452 // No Surface changed, so no damage should be given. 1358 // No Surface changed, so no damage should be given.
1453 { 1359 {
1454 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1360 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1455 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1361 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1456 1362
1457 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1363 const RenderPassList& aggregated_pass_list =
1458 1364 aggregated_frame.render_pass_list;
1459 DelegatedFrameData* frame_data =
1460 aggregated_frame.delegated_frame_data.get();
1461
1462 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1463 1365
1464 ASSERT_EQ(2u, aggregated_pass_list.size()); 1366 ASSERT_EQ(2u, aggregated_pass_list.size());
1465 1367
1466 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); 1368 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty());
1467 } 1369 }
1468 1370
1469 // SetFullDamageRectForSurface should cause the entire output to be 1371 // SetFullDamageRectForSurface should cause the entire output to be
1470 // marked as damaged. 1372 // marked as damaged.
1471 { 1373 {
1472 aggregator_.SetFullDamageForSurface(root_surface_id); 1374 aggregator_.SetFullDamageForSurface(root_surface_id);
1473 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1375 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1474 1376
1475 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1377 const RenderPassList& aggregated_pass_list =
1476 1378 aggregated_frame.render_pass_list;
1477 DelegatedFrameData* frame_data =
1478 aggregated_frame.delegated_frame_data.get();
1479
1480 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1481 1379
1482 ASSERT_EQ(2u, aggregated_pass_list.size()); 1380 ASSERT_EQ(2u, aggregated_pass_list.size());
1483 1381
1484 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( 1382 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains(
1485 gfx::Rect(SurfaceSize()))); 1383 gfx::Rect(SurfaceSize())));
1486 } 1384 }
1487 1385
1488 factory_.Destroy(child_local_frame_id); 1386 factory_.Destroy(child_local_frame_id);
1489 } 1387 }
1490 1388
1491 // Check that damage is correctly calculated for surfaces with 1389 // Check that damage is correctly calculated for surfaces with
1492 // SetPreviousFrameSurface. 1390 // SetPreviousFrameSurface.
1493 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { 1391 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
1494 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; 1392 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
1495 1393
1496 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, 1394 test::Pass root_passes[] = {test::Pass(root_render_pass_quads,
1497 arraysize(root_render_pass_quads), 1395 arraysize(root_render_pass_quads),
1498 RenderPassId(2, 1))}; 1396 RenderPassId(2, 1))};
1499 1397
1500 RenderPassList root_pass_list; 1398 RenderPassList root_pass_list;
1501 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, 1399 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1502 arraysize(root_passes)); 1400 arraysize(root_passes));
1503 1401
1504 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100); 1402 root_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100);
1505 1403
1506 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1507 root_pass_list.swap(root_frame_data->render_pass_list);
1508
1509 CompositorFrame root_frame; 1404 CompositorFrame root_frame;
1510 root_frame.delegated_frame_data = std::move(root_frame_data); 1405 root_pass_list.swap(root_frame.render_pass_list);
1511 1406
1512 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame), 1407 factory_.SubmitCompositorFrame(root_local_frame_id_, std::move(root_frame),
1513 SurfaceFactory::DrawCallback()); 1408 SurfaceFactory::DrawCallback());
1514 1409
1515 { 1410 {
1516 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1411 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1517 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1412 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1518 1413
1519 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1414 const RenderPassList& aggregated_pass_list =
1520 1415 aggregated_frame.render_pass_list;
1521 DelegatedFrameData* frame_data =
1522 aggregated_frame.delegated_frame_data.get();
1523
1524 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1525 1416
1526 ASSERT_EQ(1u, aggregated_pass_list.size()); 1417 ASSERT_EQ(1u, aggregated_pass_list.size());
1527 1418
1528 // Damage rect for first aggregation should contain entire root surface. 1419 // Damage rect for first aggregation should contain entire root surface.
1529 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains( 1420 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains(
1530 gfx::Rect(SurfaceSize()))); 1421 gfx::Rect(SurfaceSize())));
1531 } 1422 }
1532 1423
1533 LocalFrameId second_root_local_frame_id = allocator_.GenerateId(); 1424 LocalFrameId second_root_local_frame_id = allocator_.GenerateId();
1534 SurfaceId second_root_surface_id(factory_.frame_sink_id(), 1425 SurfaceId second_root_surface_id(factory_.frame_sink_id(),
1535 second_root_local_frame_id); 1426 second_root_local_frame_id);
1536 { 1427 {
1537 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; 1428 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
1538 1429
1539 test::Pass root_passes[] = {test::Pass(root_render_pass_quads, 1430 test::Pass root_passes[] = {test::Pass(root_render_pass_quads,
1540 arraysize(root_render_pass_quads), 1431 arraysize(root_render_pass_quads),
1541 RenderPassId(2, 1))}; 1432 RenderPassId(2, 1))};
1542 1433
1543 RenderPassList root_pass_list; 1434 RenderPassList root_pass_list;
1544 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, 1435 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1545 arraysize(root_passes)); 1436 arraysize(root_passes));
1546 1437
1547 root_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4); 1438 root_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4);
1548 1439
1549 std::unique_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1550 root_pass_list.swap(root_frame_data->render_pass_list);
1551
1552 CompositorFrame root_frame; 1440 CompositorFrame root_frame;
1553 root_frame.delegated_frame_data = std::move(root_frame_data); 1441 root_pass_list.swap(root_frame.render_pass_list);
1554 1442
1555 factory_.Create(second_root_local_frame_id); 1443 factory_.Create(second_root_local_frame_id);
1556 factory_.SubmitCompositorFrame(second_root_local_frame_id, 1444 factory_.SubmitCompositorFrame(second_root_local_frame_id,
1557 std::move(root_frame), 1445 std::move(root_frame),
1558 SurfaceFactory::DrawCallback()); 1446 SurfaceFactory::DrawCallback());
1559 factory_.SetPreviousFrameSurface(second_root_local_frame_id, 1447 factory_.SetPreviousFrameSurface(second_root_local_frame_id,
1560 root_local_frame_id_); 1448 root_local_frame_id_);
1561 } 1449 }
1562 { 1450 {
1563 CompositorFrame aggregated_frame = 1451 CompositorFrame aggregated_frame =
1564 aggregator_.Aggregate(second_root_surface_id); 1452 aggregator_.Aggregate(second_root_surface_id);
1565 1453
1566 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1454 const RenderPassList& aggregated_pass_list =
1567 1455 aggregated_frame.render_pass_list;
1568 DelegatedFrameData* frame_data =
1569 aggregated_frame.delegated_frame_data.get();
1570
1571 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1572 1456
1573 ASSERT_EQ(1u, aggregated_pass_list.size()); 1457 ASSERT_EQ(1u, aggregated_pass_list.size());
1574 1458
1575 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect 1459 // Frame from SetPreviousFrameSurface was aggregated last, so damage rect
1576 // from new surface should be used. 1460 // from new surface should be used.
1577 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect); 1461 EXPECT_EQ(gfx::Rect(1, 2, 3, 4), aggregated_pass_list[0]->damage_rect);
1578 } 1462 }
1579 { 1463 {
1580 CompositorFrame aggregated_frame = 1464 CompositorFrame aggregated_frame =
1581 aggregator_.Aggregate(second_root_surface_id); 1465 aggregator_.Aggregate(second_root_surface_id);
1582 1466
1583 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1467 const RenderPassList& aggregated_pass_list =
1584 1468 aggregated_frame.render_pass_list;
1585 DelegatedFrameData* frame_data =
1586 aggregated_frame.delegated_frame_data.get();
1587
1588 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1589 1469
1590 ASSERT_EQ(1u, aggregated_pass_list.size()); 1470 ASSERT_EQ(1u, aggregated_pass_list.size());
1591 1471
1592 // No new frame, so no new damage. 1472 // No new frame, so no new damage.
1593 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); 1473 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty());
1594 } 1474 }
1595 factory_.Destroy(second_root_local_frame_id); 1475 factory_.Destroy(second_root_local_frame_id);
1596 } 1476 }
1597 1477
1598 class SurfaceAggregatorPartialSwapTest 1478 class SurfaceAggregatorPartialSwapTest
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 root_pass->shared_quad_state_list.front() 1539 root_pass->shared_quad_state_list.front()
1660 ->quad_to_target_transform.Translate(10, 10); 1540 ->quad_to_target_transform.Translate(10, 10);
1661 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); 1541 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1);
1662 1542
1663 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); 1543 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list);
1664 } 1544 }
1665 1545
1666 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_); 1546 SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
1667 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1547 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1668 1548
1669 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1549 const RenderPassList& aggregated_pass_list =
1670 1550 aggregated_frame.render_pass_list;
1671 DelegatedFrameData* frame_data = aggregated_frame.delegated_frame_data.get();
1672
1673 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1674 1551
1675 ASSERT_EQ(3u, aggregated_pass_list.size()); 1552 ASSERT_EQ(3u, aggregated_pass_list.size());
1676 1553
1677 // Damage rect for first aggregation should contain entire root surface. 1554 // Damage rect for first aggregation should contain entire root surface.
1678 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); 1555 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect);
1679 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); 1556 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
1680 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1557 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1681 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); 1558 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
1682 1559
1683 // Create a root surface with a smaller damage rect. 1560 // Create a root surface with a smaller damage rect.
1684 { 1561 {
1685 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; 1562 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)};
1686 1563
1687 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 1564 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
1688 1565
1689 RenderPassList root_pass_list; 1566 RenderPassList root_pass_list;
1690 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, 1567 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1691 arraysize(root_passes)); 1568 arraysize(root_passes));
1692 1569
1693 RenderPass* root_pass = root_pass_list[0].get(); 1570 RenderPass* root_pass = root_pass_list[0].get();
1694 root_pass->shared_quad_state_list.front() 1571 root_pass->shared_quad_state_list.front()
1695 ->quad_to_target_transform.Translate(10, 10); 1572 ->quad_to_target_transform.Translate(10, 10);
1696 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); 1573 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
1697 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); 1574 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list);
1698 } 1575 }
1699 1576
1700 { 1577 {
1701 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1578 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1702 1579
1703 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1580 const RenderPassList& aggregated_pass_list =
1704 1581 aggregated_frame.render_pass_list;
1705 DelegatedFrameData* frame_data =
1706 aggregated_frame.delegated_frame_data.get();
1707
1708 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1709 1582
1710 ASSERT_EQ(3u, aggregated_pass_list.size()); 1583 ASSERT_EQ(3u, aggregated_pass_list.size());
1711 1584
1712 // Only first quad from surface is inside damage rect and should be 1585 // Only first quad from surface is inside damage rect and should be
1713 // included. 1586 // included.
1714 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); 1587 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect);
1715 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); 1588 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size());
1716 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1589 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1717 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), 1590 EXPECT_EQ(gfx::Rect(0, 0, 2, 2),
1718 aggregated_pass_list[1]->quad_list.back()->visible_rect); 1591 aggregated_pass_list[1]->quad_list.back()->visible_rect);
(...skipping 28 matching lines...) Expand all
1747 1620
1748 child_root_pass->copy_requests.push_back( 1621 child_root_pass->copy_requests.push_back(
1749 CopyOutputRequest::CreateEmptyRequest()); 1622 CopyOutputRequest::CreateEmptyRequest());
1750 child_root_pass->damage_rect = gfx::Rect(); 1623 child_root_pass->damage_rect = gfx::Rect();
1751 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list); 1624 SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list);
1752 } 1625 }
1753 1626
1754 { 1627 {
1755 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1628 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1756 1629
1757 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1630 const RenderPassList& aggregated_pass_list =
1758 1631 aggregated_frame.render_pass_list;
1759 DelegatedFrameData* frame_data =
1760 aggregated_frame.delegated_frame_data.get();
1761
1762 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1763 1632
1764 // Output frame should have no damage, but all quads included. 1633 // Output frame should have no damage, but all quads included.
1765 ASSERT_EQ(3u, aggregated_pass_list.size()); 1634 ASSERT_EQ(3u, aggregated_pass_list.size());
1766 1635
1767 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); 1636 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect);
1768 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); 1637 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
1769 EXPECT_TRUE(aggregated_pass_list[2]->damage_rect.IsEmpty()); 1638 EXPECT_TRUE(aggregated_pass_list[2]->damage_rect.IsEmpty());
1770 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); 1639 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
1771 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1640 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1772 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), 1641 EXPECT_EQ(gfx::Rect(1, 1, 2, 2),
1773 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); 1642 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect);
1774 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), 1643 EXPECT_EQ(gfx::Rect(0, 0, 2, 2),
1775 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); 1644 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect);
1776 ASSERT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); 1645 ASSERT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
1777 } 1646 }
1778 1647
1779 { 1648 {
1780 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1649 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1781 1650
1782 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1651 const RenderPassList& aggregated_pass_list =
1783 1652 aggregated_frame.render_pass_list;
1784 DelegatedFrameData* frame_data =
1785 aggregated_frame.delegated_frame_data.get();
1786
1787 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1788 // There were no changes since last aggregation, so output should be empty 1653 // There were no changes since last aggregation, so output should be empty
1789 // and have no damage. 1654 // and have no damage.
1790 ASSERT_EQ(1u, aggregated_pass_list.size()); 1655 ASSERT_EQ(1u, aggregated_pass_list.size());
1791 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); 1656 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty());
1792 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); 1657 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size());
1793 } 1658 }
1794 1659
1795 // Root surface has smaller damage rect, but filter on render pass means all 1660 // Root surface has smaller damage rect, but filter on render pass means all
1796 // of it should be aggregated. 1661 // of it should be aggregated.
1797 { 1662 {
(...skipping 15 matching lines...) Expand all
1813 RenderPassDrawQuad* quad = 1678 RenderPassDrawQuad* quad =
1814 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); 1679 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front());
1815 quad->filters.Append(FilterOperation::CreateBlurFilter(2)); 1680 quad->filters.Append(FilterOperation::CreateBlurFilter(2));
1816 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); 1681 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
1817 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); 1682 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list);
1818 } 1683 }
1819 1684
1820 { 1685 {
1821 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1686 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1822 1687
1823 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1688 const RenderPassList& aggregated_pass_list =
1824 1689 aggregated_frame.render_pass_list;
1825 DelegatedFrameData* frame_data =
1826 aggregated_frame.delegated_frame_data.get();
1827
1828 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1829 1690
1830 ASSERT_EQ(3u, aggregated_pass_list.size()); 1691 ASSERT_EQ(3u, aggregated_pass_list.size());
1831 1692
1832 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); 1693 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect);
1833 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); 1694 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
1834 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); 1695 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect);
1835 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); 1696 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
1836 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1697 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1837 // First render pass draw quad is outside damage rect, so shouldn't be 1698 // First render pass draw quad is outside damage rect, so shouldn't be
1838 // drawn. 1699 // drawn.
(...skipping 24 matching lines...) Expand all
1863 RenderPassDrawQuad* quad = 1724 RenderPassDrawQuad* quad =
1864 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); 1725 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front());
1865 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2)); 1726 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2));
1866 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); 1727 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
1867 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); 1728 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list);
1868 } 1729 }
1869 1730
1870 { 1731 {
1871 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); 1732 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
1872 1733
1873 ASSERT_TRUE(aggregated_frame.delegated_frame_data); 1734 const RenderPassList& aggregated_pass_list =
1874 1735 aggregated_frame.render_pass_list;
1875 DelegatedFrameData* frame_data =
1876 aggregated_frame.delegated_frame_data.get();
1877
1878 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1879 1736
1880 ASSERT_EQ(3u, aggregated_pass_list.size()); 1737 ASSERT_EQ(3u, aggregated_pass_list.size());
1881 1738
1882 // Pass 0 is solid color quad from root, but outside damage rect. 1739 // Pass 0 is solid color quad from root, but outside damage rect.
1883 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[0]->damage_rect); 1740 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[0]->damage_rect);
1884 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); 1741 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size());
1885 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); 1742 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
1886 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1743 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1887 1744
1888 // First render pass draw quad is outside damage rect, so shouldn't be 1745 // First render pass draw quad is outside damage rect, so shouldn't be
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 1791
1935 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); 1792 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient);
1936 }; 1793 };
1937 1794
1938 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, 1795 void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
1939 size_t num_resource_ids, 1796 size_t num_resource_ids,
1940 bool valid, 1797 bool valid,
1941 SurfaceId child_id, 1798 SurfaceId child_id,
1942 SurfaceFactory* factory, 1799 SurfaceFactory* factory,
1943 SurfaceId surface_id) { 1800 SurfaceId surface_id) {
1944 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 1801 CompositorFrame frame;
1945 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 1802 std::unique_ptr<RenderPass> pass = RenderPass::Create();
1946 pass->id = RenderPassId(1, 1); 1803 pass->id = RenderPassId(1, 1);
1947 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 1804 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
1948 sqs->opacity = 1.f; 1805 sqs->opacity = 1.f;
1949 if (!child_id.is_null()) { 1806 if (!child_id.is_null()) {
1950 SurfaceDrawQuad* surface_quad = 1807 SurfaceDrawQuad* surface_quad =
1951 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 1808 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
1952 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 1809 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
1953 child_id); 1810 child_id);
1954 } 1811 }
1955 1812
1956 for (size_t i = 0u; i < num_resource_ids; ++i) { 1813 for (size_t i = 0u; i < num_resource_ids; ++i) {
1957 TransferableResource resource; 1814 TransferableResource resource;
1958 resource.id = resource_ids[i]; 1815 resource.id = resource_ids[i];
1959 // ResourceProvider is software, so only software resources are valid. 1816 // ResourceProvider is software, so only software resources are valid.
1960 resource.is_software = valid; 1817 resource.is_software = valid;
1961 frame_data->resource_list.push_back(resource); 1818 frame.resource_list.push_back(resource);
1962 TextureDrawQuad* quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 1819 TextureDrawQuad* quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
1963 const gfx::Rect rect; 1820 const gfx::Rect rect;
1964 const gfx::Rect opaque_rect; 1821 const gfx::Rect opaque_rect;
1965 const gfx::Rect visible_rect; 1822 const gfx::Rect visible_rect;
1966 bool needs_blending = false; 1823 bool needs_blending = false;
1967 bool premultiplied_alpha = false; 1824 bool premultiplied_alpha = false;
1968 const gfx::PointF uv_top_left; 1825 const gfx::PointF uv_top_left;
1969 const gfx::PointF uv_bottom_right; 1826 const gfx::PointF uv_bottom_right;
1970 SkColor background_color = SK_ColorGREEN; 1827 SkColor background_color = SK_ColorGREEN;
1971 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; 1828 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f};
1972 bool flipped = false; 1829 bool flipped = false;
1973 bool nearest_neighbor = false; 1830 bool nearest_neighbor = false;
1974 bool secure_output_only = true; 1831 bool secure_output_only = true;
1975 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending, 1832 quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending,
1976 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left, 1833 resource_ids[i], gfx::Size(), premultiplied_alpha, uv_top_left,
1977 uv_bottom_right, background_color, vertex_opacity, flipped, 1834 uv_bottom_right, background_color, vertex_opacity, flipped,
1978 nearest_neighbor, secure_output_only); 1835 nearest_neighbor, secure_output_only);
1979 } 1836 }
1980 frame_data->render_pass_list.push_back(std::move(pass)); 1837 frame.render_pass_list.push_back(std::move(pass));
1981 CompositorFrame frame;
1982 frame.delegated_frame_data = std::move(frame_data);
1983 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame), 1838 factory->SubmitCompositorFrame(surface_id.local_frame_id(), std::move(frame),
1984 SurfaceFactory::DrawCallback()); 1839 SurfaceFactory::DrawCallback());
1985 } 1840 }
1986 1841
1987 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { 1842 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
1988 ResourceTrackingSurfaceFactoryClient client; 1843 ResourceTrackingSurfaceFactoryClient client;
1989 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); 1844 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
1990 LocalFrameId local_frame_id(7u, 0); 1845 LocalFrameId local_frame_id(7u, 0);
1991 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); 1846 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id);
1992 factory.Create(local_frame_id); 1847 factory.Create(local_frame_id);
(...skipping 22 matching lines...) Expand all
2015 factory.Destroy(local_frame_id); 1870 factory.Destroy(local_frame_id);
2016 } 1871 }
2017 1872
2018 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { 1873 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
2019 ResourceTrackingSurfaceFactoryClient client; 1874 ResourceTrackingSurfaceFactoryClient client;
2020 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); 1875 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
2021 LocalFrameId local_frame_id(7u, 0); 1876 LocalFrameId local_frame_id(7u, 0);
2022 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); 1877 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id);
2023 factory.Create(local_frame_id); 1878 factory.Create(local_frame_id);
2024 1879
2025 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 1880 CompositorFrame frame;
2026 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 1881 std::unique_ptr<RenderPass> pass = RenderPass::Create();
2027 pass->id = RenderPassId(1, 1); 1882 pass->id = RenderPassId(1, 1);
2028 TransferableResource resource; 1883 TransferableResource resource;
2029 resource.id = 11; 1884 resource.id = 11;
2030 // ResourceProvider is software but resource is not, so it should be 1885 // ResourceProvider is software but resource is not, so it should be
2031 // ignored. 1886 // ignored.
2032 resource.is_software = false; 1887 resource.is_software = false;
2033 frame_data->resource_list.push_back(resource); 1888 frame.resource_list.push_back(resource);
2034 frame_data->render_pass_list.push_back(std::move(pass)); 1889 frame.render_pass_list.push_back(std::move(pass));
2035 CompositorFrame frame;
2036 frame.delegated_frame_data = std::move(frame_data);
2037 factory.SubmitCompositorFrame(local_frame_id, std::move(frame), 1890 factory.SubmitCompositorFrame(local_frame_id, std::move(frame),
2038 SurfaceFactory::DrawCallback()); 1891 SurfaceFactory::DrawCallback());
2039 1892
2040 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); 1893 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id);
2041 1894
2042 // Nothing should be available to be returned yet. 1895 // Nothing should be available to be returned yet.
2043 EXPECT_TRUE(client.returned_resources().empty()); 1896 EXPECT_TRUE(client.returned_resources().empty());
2044 1897
2045 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, 1898 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory,
2046 surface_id); 1899 surface_id);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 middle_surface_id); 1969 middle_surface_id);
2117 1970
2118 ResourceId ids3[] = {20, 21, 22}; 1971 ResourceId ids3[] = {20, 21, 22};
2119 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, 1972 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true,
2120 middle_surface_id, &factory, 1973 middle_surface_id, &factory,
2121 root_surface_id); 1974 root_surface_id);
2122 1975
2123 CompositorFrame frame; 1976 CompositorFrame frame;
2124 frame = aggregator_->Aggregate(root_surface_id); 1977 frame = aggregator_->Aggregate(root_surface_id);
2125 1978
2126 RenderPassList* pass_list = &frame.delegated_frame_data->render_pass_list; 1979 RenderPassList* pass_list = &frame.render_pass_list;
2127 ASSERT_EQ(1u, pass_list->size()); 1980 ASSERT_EQ(1u, pass_list->size());
2128 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); 1981 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size());
2129 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); 1982 EXPECT_EQ(3u, pass_list->back()->quad_list.size());
2130 1983
2131 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, 1984 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true,
2132 child_surface_id, &factory, 1985 child_surface_id, &factory,
2133 middle_surface_id); 1986 middle_surface_id);
2134 1987
2135 frame = aggregator_->Aggregate(root_surface_id); 1988 frame = aggregator_->Aggregate(root_surface_id);
2136 1989
2137 pass_list = &frame.delegated_frame_data->render_pass_list; 1990 pass_list = &frame.render_pass_list;
2138 ASSERT_EQ(1u, pass_list->size()); 1991 ASSERT_EQ(1u, pass_list->size());
2139 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); 1992 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size());
2140 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); 1993 EXPECT_EQ(9u, pass_list->back()->quad_list.size());
2141 1994
2142 factory.Destroy(root_local_frame_id); 1995 factory.Destroy(root_local_frame_id);
2143 factory.Destroy(child_local_frame_id); 1996 factory.Destroy(child_local_frame_id);
2144 factory.Destroy(middle_local_frame_id); 1997 factory.Destroy(middle_local_frame_id);
2145 } 1998 }
2146 1999
2147 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { 2000 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
2148 ResourceTrackingSurfaceFactoryClient client; 2001 ResourceTrackingSurfaceFactoryClient client;
2149 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client); 2002 SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
2150 LocalFrameId local_frame1_id(7u, 0); 2003 LocalFrameId local_frame1_id(7u, 0);
2151 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id); 2004 SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id);
2152 factory.Create(local_frame1_id); 2005 factory.Create(local_frame1_id);
2153 2006
2154 LocalFrameId local_frame2_id(8u, 0); 2007 LocalFrameId local_frame2_id(8u, 0);
2155 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id); 2008 SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id);
2156 factory.Create(local_frame2_id); 2009 factory.Create(local_frame2_id);
2157 2010
2158 ResourceId ids[] = {11, 12, 13}; 2011 ResourceId ids[] = {11, 12, 13};
2159 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), 2012 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
2160 &factory, surface1_id); 2013 &factory, surface1_id);
2161 2014
2162 CompositorFrame frame = aggregator_->Aggregate(surface1_id); 2015 CompositorFrame frame = aggregator_->Aggregate(surface1_id);
2163 2016
2164 RenderPass* render_pass = 2017 RenderPass* render_pass = frame.render_pass_list.back().get();
2165 frame.delegated_frame_data->render_pass_list.back().get();
2166 2018
2167 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material); 2019 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, render_pass->quad_list.back()->material);
2168 2020
2169 { 2021 {
2170 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
2171 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 2022 std::unique_ptr<RenderPass> pass = RenderPass::Create();
2172 pass->id = RenderPassId(1, 1); 2023 pass->id = RenderPassId(1, 1);
2173 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 2024 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
2174 sqs->opacity = 1.f; 2025 sqs->opacity = 1.f;
2175 SurfaceDrawQuad* surface_quad = 2026 SurfaceDrawQuad* surface_quad =
2176 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 2027 pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
2177 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 2028 surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
2178 surface1_id); 2029 surface1_id);
2179 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 2030 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
2180 2031
2181 frame_data->render_pass_list.push_back(std::move(pass));
2182 CompositorFrame frame; 2032 CompositorFrame frame;
2183 frame.delegated_frame_data = std::move(frame_data); 2033 frame.render_pass_list.push_back(std::move(pass));
2034
2184 factory.SubmitCompositorFrame(local_frame2_id, std::move(frame), 2035 factory.SubmitCompositorFrame(local_frame2_id, std::move(frame),
2185 SurfaceFactory::DrawCallback()); 2036 SurfaceFactory::DrawCallback());
2186 } 2037 }
2187 2038
2188 frame = aggregator_->Aggregate(surface2_id); 2039 frame = aggregator_->Aggregate(surface2_id);
2189 EXPECT_EQ(1u, frame.delegated_frame_data->render_pass_list.size()); 2040 EXPECT_EQ(1u, frame.render_pass_list.size());
2190 render_pass = frame.delegated_frame_data->render_pass_list.front().get(); 2041 render_pass = frame.render_pass_list.front().get();
2191 2042
2192 // Parent has copy request, so texture should not be drawn. 2043 // Parent has copy request, so texture should not be drawn.
2193 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); 2044 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material);
2194 2045
2195 frame = aggregator_->Aggregate(surface2_id); 2046 frame = aggregator_->Aggregate(surface2_id);
2196 EXPECT_EQ(1u, frame.delegated_frame_data->render_pass_list.size()); 2047 EXPECT_EQ(1u, frame.render_pass_list.size());
2197 render_pass = frame.delegated_frame_data->render_pass_list.front().get(); 2048 render_pass = frame.render_pass_list.front().get();
2198 2049
2199 // Copy request has been executed earlier, so texture should be drawn. 2050 // Copy request has been executed earlier, so texture should be drawn.
2200 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, 2051 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT,
2201 render_pass->quad_list.front()->material); 2052 render_pass->quad_list.front()->material);
2202 2053
2203 aggregator_->set_output_is_secure(false); 2054 aggregator_->set_output_is_secure(false);
2204 2055
2205 frame = aggregator_->Aggregate(surface2_id); 2056 frame = aggregator_->Aggregate(surface2_id);
2206 render_pass = frame.delegated_frame_data->render_pass_list.back().get(); 2057 render_pass = frame.render_pass_list.back().get();
2207 2058
2208 // Output is insecure, so texture should be drawn. 2059 // Output is insecure, so texture should be drawn.
2209 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); 2060 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material);
2210 2061
2211 factory.Destroy(local_frame1_id); 2062 factory.Destroy(local_frame1_id);
2212 factory.Destroy(local_frame2_id); 2063 factory.Destroy(local_frame2_id);
2213 } 2064 }
2214 2065
2215 } // namespace 2066 } // namespace
2216 } // namespace cc 2067 } // namespace cc
2217 2068
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698