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

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

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

Powered by Google App Engine
This is Rietveld 408576698