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

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

Issue 432093003: Enqueuing new frames in a Surface should cause Displays to reaggregate it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/surfaces/surface_aggregator.cc ('k') | cc/surfaces/surface_damage_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/compositor_frame.h" 5 #include "cc/output/compositor_frame.h"
6 #include "cc/output/delegated_frame_data.h" 6 #include "cc/output/delegated_frame_data.h"
7 #include "cc/quads/render_pass.h" 7 #include "cc/quads/render_pass.h"
8 #include "cc/quads/render_pass_draw_quad.h" 8 #include "cc/quads/render_pass_draw_quad.h"
9 #include "cc/quads/solid_color_draw_quad.h" 9 #include "cc/quads/solid_color_draw_quad.h"
10 #include "cc/quads/surface_draw_quad.h" 10 #include "cc/quads/surface_draw_quad.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 protected: 54 protected:
55 SurfaceManager manager_; 55 SurfaceManager manager_;
56 EmptySurfaceFactoryClient empty_client_; 56 EmptySurfaceFactoryClient empty_client_;
57 SurfaceFactory factory_; 57 SurfaceFactory factory_;
58 SurfaceAggregator aggregator_; 58 SurfaceAggregator aggregator_;
59 }; 59 };
60 60
61 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { 61 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
62 SurfaceId one_id(7); 62 SurfaceId one_id(7);
63 factory_.Create(one_id, SurfaceSize()); 63 factory_.Create(one_id, SurfaceSize());
64 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); 64 std::set<SurfaceId> surface_set;
65 scoped_ptr<CompositorFrame> frame =
66 aggregator_.Aggregate(one_id, &surface_set);
65 EXPECT_FALSE(frame); 67 EXPECT_FALSE(frame);
66 factory_.Destroy(one_id); 68 factory_.Destroy(one_id);
67 } 69 }
68 70
69 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { 71 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
70 public: 72 public:
71 SurfaceAggregatorValidSurfaceTest() : allocator_(1u) {} 73 SurfaceAggregatorValidSurfaceTest() : allocator_(1u) {}
72 74
73 virtual void SetUp() { 75 virtual void SetUp() {
74 SurfaceAggregatorTest::SetUp(); 76 SurfaceAggregatorTest::SetUp();
75 root_surface_id_ = allocator_.GenerateId(); 77 root_surface_id_ = allocator_.GenerateId();
76 factory_.Create(root_surface_id_, SurfaceSize()); 78 factory_.Create(root_surface_id_, SurfaceSize());
77 } 79 }
78 80
79 virtual void TearDown() { 81 virtual void TearDown() {
80 factory_.Destroy(root_surface_id_); 82 factory_.Destroy(root_surface_id_);
81 SurfaceAggregatorTest::TearDown(); 83 SurfaceAggregatorTest::TearDown();
82 } 84 }
83 85
84 void AggregateAndVerify(test::Pass* expected_passes, 86 void AggregateAndVerify(test::Pass* expected_passes,
85 size_t expected_pass_count) { 87 size_t expected_pass_count,
88 SurfaceId* surface_ids,
89 size_t expected_surface_count) {
90 std::set<SurfaceId> surface_set;
86 scoped_ptr<CompositorFrame> aggregated_frame = 91 scoped_ptr<CompositorFrame> aggregated_frame =
87 aggregator_.Aggregate(root_surface_id_); 92 aggregator_.Aggregate(root_surface_id_, &surface_set);
88 93
89 ASSERT_TRUE(aggregated_frame); 94 ASSERT_TRUE(aggregated_frame);
90 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 95 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
91 96
92 DelegatedFrameData* frame_data = 97 DelegatedFrameData* frame_data =
93 aggregated_frame->delegated_frame_data.get(); 98 aggregated_frame->delegated_frame_data.get();
94 99
95 TestPassesMatchExpectations( 100 TestPassesMatchExpectations(
96 expected_passes, expected_pass_count, &frame_data->render_pass_list); 101 expected_passes, expected_pass_count, &frame_data->render_pass_list);
102
103 EXPECT_EQ(expected_surface_count, surface_set.size());
104 for (size_t i = 0; i < expected_surface_count; i++) {
105 EXPECT_TRUE(surface_set.find(surface_ids[i]) != surface_set.end());
106 }
97 } 107 }
98 108
99 void SubmitFrame(test::Pass* passes, 109 void SubmitFrame(test::Pass* passes,
100 size_t pass_count, 110 size_t pass_count,
101 SurfaceId surface_id) { 111 SurfaceId surface_id) {
102 RenderPassList pass_list; 112 RenderPassList pass_list;
103 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); 113 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count);
104 114
105 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 115 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
106 pass_list.swap(frame_data->render_pass_list); 116 pass_list.swap(frame_data->render_pass_list);
(...skipping 21 matching lines...) Expand all
128 138
129 // Tests that a very simple frame containing only two solid color quads makes it 139 // Tests that a very simple frame containing only two solid color quads makes it
130 // through the aggregator correctly. 140 // through the aggregator correctly.
131 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { 141 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) {
132 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), 142 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED),
133 test::Quad::SolidColorQuad(SK_ColorBLUE)}; 143 test::Quad::SolidColorQuad(SK_ColorBLUE)};
134 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; 144 test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
135 145
136 SubmitFrame(passes, arraysize(passes), root_surface_id_); 146 SubmitFrame(passes, arraysize(passes), root_surface_id_);
137 147
138 AggregateAndVerify(passes, arraysize(passes)); 148 SurfaceId ids[] = {root_surface_id_};
149 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids));
139 } 150 }
140 151
141 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { 152 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
142 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), 153 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE),
143 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, 154 test::Quad::SolidColorQuad(SK_ColorLTGRAY)},
144 {test::Quad::SolidColorQuad(SK_ColorGRAY), 155 {test::Quad::SolidColorQuad(SK_ColorGRAY),
145 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; 156 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}};
146 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0])), 157 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0])),
147 test::Pass(quads[1], arraysize(quads[1]))}; 158 test::Pass(quads[1], arraysize(quads[1]))};
148 159
149 SubmitFrame(passes, arraysize(passes), root_surface_id_); 160 SubmitFrame(passes, arraysize(passes), root_surface_id_);
150 161
151 AggregateAndVerify(passes, arraysize(passes)); 162 SurfaceId ids[] = {root_surface_id_};
163 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids));
152 } 164 }
153 165
154 // This tests very simple embedding. root_surface has a frame containing a few 166 // This tests very simple embedding. root_surface has a frame containing a few
155 // solid color quads and a surface quad referencing embedded_surface. 167 // solid color quads and a surface quad referencing embedded_surface.
156 // embedded_surface has a frame containing only a solid color quad. The solid 168 // embedded_surface has a frame containing only a solid color quad. The solid
157 // color quad should be aggregated into the final frame. 169 // color quad should be aggregated into the final frame.
158 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { 170 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
159 SurfaceId embedded_surface_id = allocator_.GenerateId(); 171 SurfaceId embedded_surface_id = allocator_.GenerateId();
160 factory_.Create(embedded_surface_id, SurfaceSize()); 172 factory_.Create(embedded_surface_id, SurfaceSize());
161 173
162 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; 174 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
163 test::Pass embedded_passes[] = { 175 test::Pass embedded_passes[] = {
164 test::Pass(embedded_quads, arraysize(embedded_quads))}; 176 test::Pass(embedded_quads, arraysize(embedded_quads))};
165 177
166 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); 178 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id);
167 179
168 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), 180 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
169 test::Quad::SurfaceQuad(embedded_surface_id), 181 test::Quad::SurfaceQuad(embedded_surface_id),
170 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 182 test::Quad::SolidColorQuad(SK_ColorBLACK)};
171 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 183 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
172 184
173 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); 185 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_);
174 186
175 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), 187 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
176 test::Quad::SolidColorQuad(SK_ColorGREEN), 188 test::Quad::SolidColorQuad(SK_ColorGREEN),
177 test::Quad::SolidColorQuad(SK_ColorBLACK)}; 189 test::Quad::SolidColorQuad(SK_ColorBLACK)};
178 test::Pass expected_passes[] = { 190 test::Pass expected_passes[] = {
179 test::Pass(expected_quads, arraysize(expected_quads))}; 191 test::Pass(expected_quads, arraysize(expected_quads))};
180 AggregateAndVerify(expected_passes, arraysize(expected_passes)); 192 SurfaceId ids[] = {root_surface_id_, embedded_surface_id};
193 AggregateAndVerify(
194 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
181 195
182 factory_.Destroy(embedded_surface_id); 196 factory_.Destroy(embedded_surface_id);
183 } 197 }
184 198
185 // This tests referencing a surface that has multiple render passes. 199 // This tests referencing a surface that has multiple render passes.
186 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { 200 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
187 SurfaceId embedded_surface_id = allocator_.GenerateId(); 201 SurfaceId embedded_surface_id = allocator_.GenerateId();
188 factory_.Create(embedded_surface_id, SurfaceSize()); 202 factory_.Create(embedded_surface_id, SurfaceSize());
189 203
190 RenderPass::Id pass_ids[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2), 204 RenderPass::Id pass_ids[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2),
(...skipping 15 matching lines...) Expand all
206 {test::Quad::SurfaceQuad(embedded_surface_id), 220 {test::Quad::SurfaceQuad(embedded_surface_id),
207 test::Quad::RenderPassQuad(pass_ids[0])}, 221 test::Quad::RenderPassQuad(pass_ids[0])},
208 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; 222 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}};
209 test::Pass root_passes[] = { 223 test::Pass root_passes[] = {
210 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), 224 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]),
211 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), 225 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]),
212 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; 226 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])};
213 227
214 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); 228 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_);
215 229
230 std::set<SurfaceId> surface_set;
216 scoped_ptr<CompositorFrame> aggregated_frame = 231 scoped_ptr<CompositorFrame> aggregated_frame =
217 aggregator_.Aggregate(root_surface_id_); 232 aggregator_.Aggregate(root_surface_id_, &surface_set);
218 233
219 ASSERT_TRUE(aggregated_frame); 234 ASSERT_TRUE(aggregated_frame);
220 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 235 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
221 236
222 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 237 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
223 238
224 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 239 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
225 240
226 ASSERT_EQ(5u, aggregated_pass_list.size()); 241 ASSERT_EQ(5u, aggregated_pass_list.size());
227 RenderPass::Id actual_pass_ids[] = { 242 RenderPass::Id actual_pass_ids[] = {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 test::Quad::SurfaceQuad(InvalidSurfaceId()), 337 test::Quad::SurfaceQuad(InvalidSurfaceId()),
323 test::Quad::SolidColorQuad(SK_ColorBLUE)}; 338 test::Quad::SolidColorQuad(SK_ColorBLUE)};
324 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; 339 test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
325 340
326 SubmitFrame(passes, arraysize(passes), root_surface_id_); 341 SubmitFrame(passes, arraysize(passes), root_surface_id_);
327 342
328 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), 343 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
329 test::Quad::SolidColorQuad(SK_ColorBLUE)}; 344 test::Quad::SolidColorQuad(SK_ColorBLUE)};
330 test::Pass expected_passes[] = { 345 test::Pass expected_passes[] = {
331 test::Pass(expected_quads, arraysize(expected_quads))}; 346 test::Pass(expected_quads, arraysize(expected_quads))};
332 AggregateAndVerify(expected_passes, arraysize(expected_passes)); 347 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()};
348 AggregateAndVerify(
349 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
333 } 350 }
334 351
335 // Tests a reference to a valid surface with no submitted frame. This quad 352 // Tests a reference to a valid surface with no submitted frame. This quad
336 // should also just be dropped. 353 // should also just be dropped.
337 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { 354 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
338 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); 355 SurfaceId surface_with_no_frame_id = allocator_.GenerateId();
339 factory_.Create(surface_with_no_frame_id, gfx::Size(5, 5)); 356 factory_.Create(surface_with_no_frame_id, gfx::Size(5, 5));
340 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), 357 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
341 test::Quad::SurfaceQuad(surface_with_no_frame_id), 358 test::Quad::SurfaceQuad(surface_with_no_frame_id),
342 test::Quad::SolidColorQuad(SK_ColorBLUE)}; 359 test::Quad::SolidColorQuad(SK_ColorBLUE)};
343 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; 360 test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
344 361
345 SubmitFrame(passes, arraysize(passes), root_surface_id_); 362 SubmitFrame(passes, arraysize(passes), root_surface_id_);
346 363
347 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), 364 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
348 test::Quad::SolidColorQuad(SK_ColorBLUE)}; 365 test::Quad::SolidColorQuad(SK_ColorBLUE)};
349 test::Pass expected_passes[] = { 366 test::Pass expected_passes[] = {
350 test::Pass(expected_quads, arraysize(expected_quads))}; 367 test::Pass(expected_quads, arraysize(expected_quads))};
351 AggregateAndVerify(expected_passes, arraysize(expected_passes)); 368 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id};
369 AggregateAndVerify(
370 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
352 factory_.Destroy(surface_with_no_frame_id); 371 factory_.Destroy(surface_with_no_frame_id);
353 } 372 }
354 373
355 // Tests a surface quad referencing itself, generating a trivial cycle. 374 // Tests a surface quad referencing itself, generating a trivial cycle.
356 // The quad creating the cycle should be dropped from the final frame. 375 // The quad creating the cycle should be dropped from the final frame.
357 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { 376 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) {
358 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_), 377 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_),
359 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; 378 test::Quad::SolidColorQuad(SK_ColorYELLOW)};
360 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; 379 test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
361 380
362 SubmitFrame(passes, arraysize(passes), root_surface_id_); 381 SubmitFrame(passes, arraysize(passes), root_surface_id_);
363 382
364 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; 383 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)};
365 test::Pass expected_passes[] = { 384 test::Pass expected_passes[] = {
366 test::Pass(expected_quads, arraysize(expected_quads))}; 385 test::Pass(expected_quads, arraysize(expected_quads))};
367 AggregateAndVerify(expected_passes, arraysize(expected_passes)); 386 SurfaceId ids[] = {root_surface_id_};
387 AggregateAndVerify(
388 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
368 } 389 }
369 390
370 // Tests a more complex cycle with one intermediate surface. 391 // Tests a more complex cycle with one intermediate surface.
371 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { 392 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
372 SurfaceId child_surface_id = allocator_.GenerateId(); 393 SurfaceId child_surface_id = allocator_.GenerateId();
373 factory_.Create(child_surface_id, SurfaceSize()); 394 factory_.Create(child_surface_id, SurfaceSize());
374 395
375 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), 396 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE),
376 test::Quad::SurfaceQuad(child_surface_id), 397 test::Quad::SurfaceQuad(child_surface_id),
377 test::Quad::SolidColorQuad(SK_ColorCYAN)}; 398 test::Quad::SolidColorQuad(SK_ColorCYAN)};
(...skipping 14 matching lines...) Expand all
392 // SK_ColorBLUE from the parent 413 // SK_ColorBLUE from the parent
393 // SK_ColorGREEN from the child 414 // SK_ColorGREEN from the child
394 // SK_ColorMAGENTA from the child 415 // SK_ColorMAGENTA from the child
395 // SK_ColorCYAN from the parent 416 // SK_ColorCYAN from the parent
396 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), 417 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE),
397 test::Quad::SolidColorQuad(SK_ColorGREEN), 418 test::Quad::SolidColorQuad(SK_ColorGREEN),
398 test::Quad::SolidColorQuad(SK_ColorMAGENTA), 419 test::Quad::SolidColorQuad(SK_ColorMAGENTA),
399 test::Quad::SolidColorQuad(SK_ColorCYAN)}; 420 test::Quad::SolidColorQuad(SK_ColorCYAN)};
400 test::Pass expected_passes[] = { 421 test::Pass expected_passes[] = {
401 test::Pass(expected_quads, arraysize(expected_quads))}; 422 test::Pass(expected_quads, arraysize(expected_quads))};
402 AggregateAndVerify(expected_passes, arraysize(expected_passes)); 423 SurfaceId ids[] = {root_surface_id_, child_surface_id};
424 AggregateAndVerify(
425 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
403 factory_.Destroy(child_surface_id); 426 factory_.Destroy(child_surface_id);
404 } 427 }
405 428
406 // Tests that we map render pass IDs from different surfaces into a unified 429 // Tests that we map render pass IDs from different surfaces into a unified
407 // namespace and update RenderPassDrawQuad's id references to match. 430 // namespace and update RenderPassDrawQuad's id references to match.
408 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { 431 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
409 SurfaceId child_surface_id = allocator_.GenerateId(); 432 SurfaceId child_surface_id = allocator_.GenerateId();
410 factory_.Create(child_surface_id, SurfaceSize()); 433 factory_.Create(child_surface_id, SurfaceSize());
411 434
412 RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)}; 435 RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)};
413 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, 436 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)},
414 {test::Quad::RenderPassQuad(child_pass_id[0])}}; 437 {test::Quad::RenderPassQuad(child_pass_id[0])}};
415 test::Pass surface_passes[] = { 438 test::Pass surface_passes[] = {
416 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), 439 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]),
417 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; 440 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])};
418 441
419 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id); 442 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id);
420 443
421 // Pass IDs from the parent surface may collide with ones from the child. 444 // Pass IDs from the parent surface may collide with ones from the child.
422 RenderPass::Id parent_pass_id[] = {RenderPass::Id(2, 1), 445 RenderPass::Id parent_pass_id[] = {RenderPass::Id(2, 1),
423 RenderPass::Id(1, 2)}; 446 RenderPass::Id(1, 2)};
424 test::Quad parent_quad[][1] = { 447 test::Quad parent_quad[][1] = {
425 {test::Quad::SurfaceQuad(child_surface_id)}, 448 {test::Quad::SurfaceQuad(child_surface_id)},
426 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; 449 {test::Quad::RenderPassQuad(parent_pass_id[0])}};
427 test::Pass parent_passes[] = { 450 test::Pass parent_passes[] = {
428 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), 451 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]),
429 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; 452 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])};
430 453
431 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); 454 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_);
455 std::set<SurfaceId> surface_set;
432 scoped_ptr<CompositorFrame> aggregated_frame = 456 scoped_ptr<CompositorFrame> aggregated_frame =
433 aggregator_.Aggregate(root_surface_id_); 457 aggregator_.Aggregate(root_surface_id_, &surface_set);
434 458
435 ASSERT_TRUE(aggregated_frame); 459 ASSERT_TRUE(aggregated_frame);
436 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 460 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
437 461
438 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 462 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
439 463
440 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 464 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
441 465
442 ASSERT_EQ(3u, aggregated_pass_list.size()); 466 ASSERT_EQ(3u, aggregated_pass_list.size());
443 RenderPass::Id actual_pass_ids[] = {aggregated_pass_list[0]->id, 467 RenderPass::Id actual_pass_ids[] = {aggregated_pass_list[0]->id,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); 617 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
594 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), 618 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(),
595 gfx::Rect(SurfaceSize()), 619 gfx::Rect(SurfaceSize()),
596 gfx::Rect(SurfaceSize()), 620 gfx::Rect(SurfaceSize()),
597 child_two_surface_id); 621 child_two_surface_id);
598 AddSolidColorQuadWithBlendMode( 622 AddSolidColorQuadWithBlendMode(
599 SurfaceSize(), root_pass.get(), blend_modes[6]); 623 SurfaceSize(), root_pass.get(), blend_modes[6]);
600 624
601 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); 625 QueuePassAsFrame(root_pass.Pass(), root_surface_id_);
602 626
627 std::set<SurfaceId> surface_set;
603 scoped_ptr<CompositorFrame> aggregated_frame = 628 scoped_ptr<CompositorFrame> aggregated_frame =
604 aggregator_.Aggregate(root_surface_id_); 629 aggregator_.Aggregate(root_surface_id_, &surface_set);
605 630
606 ASSERT_TRUE(aggregated_frame); 631 ASSERT_TRUE(aggregated_frame);
607 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 632 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
608 633
609 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 634 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
610 635
611 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 636 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
612 637
613 ASSERT_EQ(1u, aggregated_pass_list.size()); 638 ASSERT_EQ(1u, aggregated_pass_list.size());
614 639
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 ->content_to_target_transform.Translate(0, 10); 719 ->content_to_target_transform.Translate(0, 10);
695 720
696 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); 721 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
697 root_pass_list.swap(root_frame_data->render_pass_list); 722 root_pass_list.swap(root_frame_data->render_pass_list);
698 723
699 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); 724 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
700 root_frame->delegated_frame_data = root_frame_data.Pass(); 725 root_frame->delegated_frame_data = root_frame_data.Pass();
701 726
702 factory_.SubmitFrame(root_surface_id_, root_frame.Pass()); 727 factory_.SubmitFrame(root_surface_id_, root_frame.Pass());
703 728
729 std::set<SurfaceId> surface_set;
704 scoped_ptr<CompositorFrame> aggregated_frame = 730 scoped_ptr<CompositorFrame> aggregated_frame =
705 aggregator_.Aggregate(root_surface_id_); 731 aggregator_.Aggregate(root_surface_id_, &surface_set);
706 732
707 ASSERT_TRUE(aggregated_frame); 733 ASSERT_TRUE(aggregated_frame);
708 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 734 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
709 735
710 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 736 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
711 737
712 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 738 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
713 739
714 ASSERT_EQ(2u, aggregated_pass_list.size()); 740 ASSERT_EQ(2u, aggregated_pass_list.size());
715 741
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 881
856 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { 882 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
857 ResourceTrackingSurfaceFactoryClient client; 883 ResourceTrackingSurfaceFactoryClient client;
858 SurfaceFactory factory(&manager_, &client); 884 SurfaceFactory factory(&manager_, &client);
859 SurfaceId surface_id(7u); 885 SurfaceId surface_id(7u);
860 factory.Create(surface_id, SurfaceSize()); 886 factory.Create(surface_id, SurfaceSize());
861 887
862 ResourceProvider::ResourceId ids[] = {11, 12, 13}; 888 ResourceProvider::ResourceId ids[] = {11, 12, 13};
863 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); 889 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id);
864 890
865 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); 891 std::set<SurfaceId> surface_set;
892 scoped_ptr<CompositorFrame> frame =
893 aggregator_->Aggregate(surface_id, &surface_set);
866 894
867 // Nothing should be available to be returned yet. 895 // Nothing should be available to be returned yet.
868 EXPECT_TRUE(client.returned_resources().empty()); 896 EXPECT_TRUE(client.returned_resources().empty());
869 897
870 SubmitFrameWithResources(NULL, 0u, &factory, surface_id); 898 SubmitFrameWithResources(NULL, 0u, &factory, surface_id);
871 899
872 frame = aggregator_->Aggregate(surface_id); 900 surface_set.clear();
901 frame = aggregator_->Aggregate(surface_id, &surface_set);
873 902
874 ASSERT_EQ(3u, client.returned_resources().size()); 903 ASSERT_EQ(3u, client.returned_resources().size());
875 ResourceProvider::ResourceId returned_ids[3]; 904 ResourceProvider::ResourceId returned_ids[3];
876 for (size_t i = 0; i < 3; ++i) { 905 for (size_t i = 0; i < 3; ++i) {
877 returned_ids[i] = client.returned_resources()[i].id; 906 returned_ids[i] = client.returned_resources()[i].id;
878 } 907 }
879 EXPECT_THAT(returned_ids, 908 EXPECT_THAT(returned_ids,
880 testing::WhenSorted(testing::ElementsAreArray(ids))); 909 testing::WhenSorted(testing::ElementsAreArray(ids)));
881 factory.Destroy(surface_id); 910 factory.Destroy(surface_id);
882 } 911 }
883 912
884 } // namespace 913 } // namespace
885 } // namespace cc 914 } // namespace cc
886 915
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.cc ('k') | cc/surfaces/surface_damage_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698