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

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

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

Powered by Google App Engine
This is Rietveld 408576698