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

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

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

Powered by Google App Engine
This is Rietveld 408576698