OLD | NEW |
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> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { | 50 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { |
51 public: | 51 public: |
52 void ReturnResources(const ReturnedResourceArray& resources) override {} | 52 void ReturnResources(const ReturnedResourceArray& resources) override {} |
53 | 53 |
54 void WillDrawSurface(SurfaceId id, const gfx::Rect& damage_rect) override { | 54 void WillDrawSurface(SurfaceId id, const gfx::Rect& damage_rect) override { |
55 last_surface_id_ = id; | 55 last_surface_id_ = id; |
56 last_damage_rect_ = damage_rect; | 56 last_damage_rect_ = damage_rect; |
57 } | 57 } |
58 | 58 |
59 void SetBeginFrameSource(SurfaceId surface_id, | 59 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
60 BeginFrameSource* begin_frame_source) override {} | |
61 | 60 |
62 gfx::Rect last_damage_rect_; | 61 gfx::Rect last_damage_rect_; |
63 SurfaceId last_surface_id_; | 62 SurfaceId last_surface_id_; |
64 }; | 63 }; |
65 | 64 |
66 class FakeSurfaceAggregatorClient : public SurfaceAggregatorClient { | |
67 public: | |
68 void AddSurface(Surface* surface) override { | |
69 EXPECT_FALSE(HasSurface(surface)); | |
70 surfaces_.insert(surface); | |
71 } | |
72 | |
73 void RemoveSurface(Surface* surface) override { | |
74 EXPECT_TRUE(HasSurface(surface)); | |
75 surfaces_.erase(surface); | |
76 } | |
77 | |
78 bool HasSurface(Surface* surface) const { | |
79 return surfaces_.count(surface) != 0; | |
80 } | |
81 | |
82 private: | |
83 std::set<Surface*> surfaces_; | |
84 }; | |
85 | |
86 class SurfaceAggregatorTest : public testing::Test { | 65 class SurfaceAggregatorTest : public testing::Test { |
87 public: | 66 public: |
88 explicit SurfaceAggregatorTest(bool use_damage_rect) | 67 explicit SurfaceAggregatorTest(bool use_damage_rect) |
89 : factory_(&manager_, &empty_client_), | 68 : factory_(&manager_, &empty_client_), |
90 aggregator_(&surface_aggregator_client_, | 69 aggregator_(&manager_, NULL, use_damage_rect) {} |
91 &manager_, | |
92 NULL, | |
93 use_damage_rect) {} | |
94 | 70 |
95 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 71 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
96 | 72 |
97 protected: | 73 protected: |
98 SurfaceManager manager_; | 74 SurfaceManager manager_; |
99 EmptySurfaceFactoryClient empty_client_; | 75 EmptySurfaceFactoryClient empty_client_; |
100 SurfaceFactory factory_; | 76 SurfaceFactory factory_; |
101 FakeSurfaceAggregatorClient surface_aggregator_client_; | |
102 SurfaceAggregator aggregator_; | 77 SurfaceAggregator aggregator_; |
103 }; | 78 }; |
104 | 79 |
105 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 80 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
106 SurfaceId one_id(7); | 81 SurfaceId one_id(7); |
107 factory_.Create(one_id); | 82 factory_.Create(one_id); |
108 Surface* surface = manager_.GetSurfaceForId(one_id); | |
109 | 83 |
110 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
111 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); | 84 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); |
112 EXPECT_FALSE(frame); | 85 EXPECT_FALSE(frame); |
113 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
114 | 86 |
115 factory_.Destroy(one_id); | 87 factory_.Destroy(one_id); |
116 } | 88 } |
117 | 89 |
118 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 90 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
119 public: | 91 public: |
120 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) | 92 explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) |
121 : SurfaceAggregatorTest(use_damage_rect), | 93 : SurfaceAggregatorTest(use_damage_rect), |
122 allocator_(1u), | 94 allocator_(1u), |
123 child_allocator_(2u) {} | 95 child_allocator_(2u) {} |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // through the aggregator correctly. | 180 // through the aggregator correctly. |
209 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { | 181 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { |
210 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), | 182 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), |
211 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 183 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
212 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 184 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
213 | 185 |
214 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 186 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
215 | 187 |
216 SurfaceId ids[] = {root_surface_id_}; | 188 SurfaceId ids[] = {root_surface_id_}; |
217 | 189 |
218 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
219 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 190 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
220 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
221 | 191 |
222 // Check that WillDrawSurface was called. | 192 // Check that WillDrawSurface was called. |
223 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); | 193 EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_); |
224 EXPECT_EQ(root_surface_id_, empty_client_.last_surface_id_); | 194 EXPECT_EQ(root_surface_id_, empty_client_.last_surface_id_); |
225 } | 195 } |
226 | 196 |
227 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { | 197 TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) { |
228 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 198 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
229 factory_.Create(embedded_surface_id); | 199 factory_.Create(embedded_surface_id); |
230 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
231 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
232 | 200 |
233 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 201 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
234 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 202 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
235 test::Pass embedded_passes[] = { | 203 test::Pass embedded_passes[] = { |
236 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 204 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
237 | 205 |
238 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 206 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
239 embedded_surface_id); | 207 embedded_surface_id); |
240 | 208 |
241 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; | 209 test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)}; |
242 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 210 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
243 | 211 |
244 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 212 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
245 | 213 |
246 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
247 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
248 | |
249 scoped_ptr<CompositorFrame> aggregated_frame = | 214 scoped_ptr<CompositorFrame> aggregated_frame = |
250 aggregator_.Aggregate(root_surface_id_); | 215 aggregator_.Aggregate(root_surface_id_); |
251 | 216 |
252 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
253 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
254 | |
255 ASSERT_TRUE(aggregated_frame); | 217 ASSERT_TRUE(aggregated_frame); |
256 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 218 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
257 | 219 |
258 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 220 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
259 | 221 |
260 RenderPassList& render_pass_list(frame_data->render_pass_list); | 222 RenderPassList& render_pass_list(frame_data->render_pass_list); |
261 ASSERT_EQ(2u, render_pass_list.size()); | 223 ASSERT_EQ(2u, render_pass_list.size()); |
262 SharedQuadStateList& shared_quad_state_list( | 224 SharedQuadStateList& shared_quad_state_list( |
263 render_pass_list[0]->shared_quad_state_list); | 225 render_pass_list[0]->shared_quad_state_list); |
264 ASSERT_EQ(2u, shared_quad_state_list.size()); | 226 ASSERT_EQ(2u, shared_quad_state_list.size()); |
(...skipping 14 matching lines...) Expand all Loading... |
279 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 241 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
280 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 242 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
281 test::Pass passes[] = { | 243 test::Pass passes[] = { |
282 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), | 244 test::Pass(quads[0], arraysize(quads[0]), RenderPassId(1, 1)), |
283 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; | 245 test::Pass(quads[1], arraysize(quads[1]), RenderPassId(1, 2))}; |
284 | 246 |
285 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 247 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
286 | 248 |
287 SurfaceId ids[] = {root_surface_id_}; | 249 SurfaceId ids[] = {root_surface_id_}; |
288 | 250 |
289 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
290 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); | 251 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
291 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
292 } | 252 } |
293 | 253 |
294 // This tests very simple embedding. root_surface has a frame containing a few | 254 // This tests very simple embedding. root_surface has a frame containing a few |
295 // solid color quads and a surface quad referencing embedded_surface. | 255 // solid color quads and a surface quad referencing embedded_surface. |
296 // embedded_surface has a frame containing only a solid color quad. The solid | 256 // embedded_surface has a frame containing only a solid color quad. The solid |
297 // color quad should be aggregated into the final frame. | 257 // color quad should be aggregated into the final frame. |
298 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 258 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
299 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 259 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
300 factory_.Create(embedded_surface_id); | 260 factory_.Create(embedded_surface_id); |
301 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
302 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
303 | 261 |
304 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 262 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
305 test::Pass embedded_passes[] = { | 263 test::Pass embedded_passes[] = { |
306 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 264 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
307 | 265 |
308 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 266 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
309 embedded_surface_id); | 267 embedded_surface_id); |
310 | 268 |
311 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 269 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
312 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 270 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
313 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 271 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
314 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 272 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
315 | 273 |
316 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 274 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
317 | 275 |
318 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
319 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
320 | |
321 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 276 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
322 test::Quad::SolidColorQuad(SK_ColorGREEN), | 277 test::Quad::SolidColorQuad(SK_ColorGREEN), |
323 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 278 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
324 test::Pass expected_passes[] = { | 279 test::Pass expected_passes[] = { |
325 test::Pass(expected_quads, arraysize(expected_quads))}; | 280 test::Pass(expected_quads, arraysize(expected_quads))}; |
326 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; | 281 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; |
327 AggregateAndVerify( | 282 AggregateAndVerify( |
328 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 283 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
329 | 284 |
330 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
331 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
332 | |
333 factory_.Destroy(embedded_surface_id); | 285 factory_.Destroy(embedded_surface_id); |
334 } | 286 } |
335 | 287 |
336 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 288 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
337 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 289 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
338 factory_.Create(embedded_surface_id); | 290 factory_.Create(embedded_surface_id); |
339 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
340 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
341 | 291 |
342 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 292 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
343 test::Pass embedded_passes[] = { | 293 test::Pass embedded_passes[] = { |
344 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 294 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
345 | 295 |
346 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 296 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
347 embedded_surface_id); | 297 embedded_surface_id); |
348 scoped_ptr<CopyOutputRequest> copy_request( | 298 scoped_ptr<CopyOutputRequest> copy_request( |
349 CopyOutputRequest::CreateEmptyRequest()); | 299 CopyOutputRequest::CreateEmptyRequest()); |
350 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 300 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
351 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); | 301 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); |
352 | 302 |
353 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 303 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
354 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 304 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
355 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 305 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
356 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 306 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
357 | 307 |
358 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 308 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
359 | 309 |
360 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
361 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
362 | |
363 scoped_ptr<CompositorFrame> aggregated_frame = | 310 scoped_ptr<CompositorFrame> aggregated_frame = |
364 aggregator_.Aggregate(root_surface_id_); | 311 aggregator_.Aggregate(root_surface_id_); |
365 | 312 |
366 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
367 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
368 | |
369 ASSERT_TRUE(aggregated_frame); | 313 ASSERT_TRUE(aggregated_frame); |
370 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 314 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
371 | 315 |
372 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 316 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
373 | 317 |
374 test::Quad expected_quads[] = { | 318 test::Quad expected_quads[] = { |
375 test::Quad::SolidColorQuad(SK_ColorWHITE), | 319 test::Quad::SolidColorQuad(SK_ColorWHITE), |
376 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), | 320 test::Quad::RenderPassQuad(frame_data->render_pass_list[0]->id), |
377 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 321 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
378 test::Pass expected_passes[] = { | 322 test::Pass expected_passes[] = { |
(...skipping 16 matching lines...) Expand all Loading... |
395 aggregator_.previous_contained_surfaces().end()); | 339 aggregator_.previous_contained_surfaces().end()); |
396 } | 340 } |
397 | 341 |
398 factory_.Destroy(embedded_surface_id); | 342 factory_.Destroy(embedded_surface_id); |
399 } | 343 } |
400 | 344 |
401 // Root surface may contain copy requests. | 345 // Root surface may contain copy requests. |
402 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 346 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
403 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 347 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
404 factory_.Create(embedded_surface_id); | 348 factory_.Create(embedded_surface_id); |
405 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
406 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
407 | 349 |
408 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 350 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
409 test::Pass embedded_passes[] = { | 351 test::Pass embedded_passes[] = { |
410 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 352 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
411 | 353 |
412 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 354 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
413 embedded_surface_id); | 355 embedded_surface_id); |
414 scoped_ptr<CopyOutputRequest> copy_request( | 356 scoped_ptr<CopyOutputRequest> copy_request( |
415 CopyOutputRequest::CreateEmptyRequest()); | 357 CopyOutputRequest::CreateEmptyRequest()); |
416 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 358 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
(...skipping 20 matching lines...) Expand all Loading... |
437 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 379 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
438 pass_list.swap(frame_data->render_pass_list); | 380 pass_list.swap(frame_data->render_pass_list); |
439 | 381 |
440 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 382 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
441 frame->delegated_frame_data = std::move(frame_data); | 383 frame->delegated_frame_data = std::move(frame_data); |
442 | 384 |
443 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), | 385 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), |
444 SurfaceFactory::DrawCallback()); | 386 SurfaceFactory::DrawCallback()); |
445 } | 387 } |
446 | 388 |
447 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
448 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
449 | |
450 scoped_ptr<CompositorFrame> aggregated_frame = | 389 scoped_ptr<CompositorFrame> aggregated_frame = |
451 aggregator_.Aggregate(root_surface_id_); | 390 aggregator_.Aggregate(root_surface_id_); |
452 | 391 |
453 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
454 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
455 | |
456 ASSERT_TRUE(aggregated_frame); | 392 ASSERT_TRUE(aggregated_frame); |
457 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 393 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
458 | 394 |
459 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 395 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
460 | 396 |
461 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 397 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
462 test::Quad::SolidColorQuad(SK_ColorGREEN), | 398 test::Quad::SolidColorQuad(SK_ColorGREEN), |
463 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 399 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
464 test::Pass expected_passes[] = { | 400 test::Pass expected_passes[] = { |
465 test::Pass(expected_quads, arraysize(expected_quads)), | 401 test::Pass(expected_quads, arraysize(expected_quads)), |
(...skipping 27 matching lines...) Expand all Loading... |
493 DCHECK(original_pass_list[0]->copy_requests.empty()); | 429 DCHECK(original_pass_list[0]->copy_requests.empty()); |
494 DCHECK(original_pass_list[1]->copy_requests.empty()); | 430 DCHECK(original_pass_list[1]->copy_requests.empty()); |
495 | 431 |
496 factory_.Destroy(embedded_surface_id); | 432 factory_.Destroy(embedded_surface_id); |
497 } | 433 } |
498 | 434 |
499 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 435 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
500 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 436 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
501 SurfaceId nonexistent_surface_id = allocator_.GenerateId(); | 437 SurfaceId nonexistent_surface_id = allocator_.GenerateId(); |
502 factory_.Create(embedded_surface_id); | 438 factory_.Create(embedded_surface_id); |
503 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
504 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
505 | 439 |
506 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 440 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
507 test::Pass embedded_passes[] = { | 441 test::Pass embedded_passes[] = { |
508 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 442 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
509 | 443 |
510 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 444 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
511 embedded_surface_id); | 445 embedded_surface_id); |
512 scoped_ptr<CopyOutputRequest> copy_request( | 446 scoped_ptr<CopyOutputRequest> copy_request( |
513 CopyOutputRequest::CreateEmptyRequest()); | 447 CopyOutputRequest::CreateEmptyRequest()); |
514 CopyOutputRequest* copy_request_ptr = copy_request.get(); | 448 CopyOutputRequest* copy_request_ptr = copy_request.get(); |
515 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); | 449 factory_.RequestCopyOfSurface(embedded_surface_id, std::move(copy_request)); |
516 | 450 |
517 SurfaceId parent_surface_id = allocator_.GenerateId(); | 451 SurfaceId parent_surface_id = allocator_.GenerateId(); |
518 factory_.Create(parent_surface_id); | 452 factory_.Create(parent_surface_id); |
519 Surface* parent_surface = manager_.GetSurfaceForId(parent_surface_id); | |
520 | 453 |
521 test::Quad parent_quads[] = { | 454 test::Quad parent_quads[] = { |
522 test::Quad::SolidColorQuad(SK_ColorWHITE), | 455 test::Quad::SolidColorQuad(SK_ColorWHITE), |
523 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 456 test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
524 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 457 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
525 test::Pass parent_passes[] = { | 458 test::Pass parent_passes[] = { |
526 test::Pass(parent_quads, arraysize(parent_quads))}; | 459 test::Pass(parent_quads, arraysize(parent_quads))}; |
527 | 460 |
528 { | 461 { |
529 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 462 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
(...skipping 21 matching lines...) Expand all Loading... |
551 frame->delegated_frame_data = std::move(frame_data); | 484 frame->delegated_frame_data = std::move(frame_data); |
552 frame->metadata.referenced_surfaces.push_back(parent_surface_id); | 485 frame->metadata.referenced_surfaces.push_back(parent_surface_id); |
553 // Reference to Surface ID of a Surface that doesn't exist should be | 486 // Reference to Surface ID of a Surface that doesn't exist should be |
554 // included in previous_contained_surfaces, but otherwise ignored. | 487 // included in previous_contained_surfaces, but otherwise ignored. |
555 frame->metadata.referenced_surfaces.push_back(nonexistent_surface_id); | 488 frame->metadata.referenced_surfaces.push_back(nonexistent_surface_id); |
556 | 489 |
557 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), | 490 factory_.SubmitCompositorFrame(root_surface_id_, std::move(frame), |
558 SurfaceFactory::DrawCallback()); | 491 SurfaceFactory::DrawCallback()); |
559 } | 492 } |
560 | 493 |
561 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
562 EXPECT_FALSE(surface_aggregator_client_.HasSurface(parent_surface)); | |
563 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
564 | |
565 scoped_ptr<CompositorFrame> aggregated_frame = | 494 scoped_ptr<CompositorFrame> aggregated_frame = |
566 aggregator_.Aggregate(root_surface_id_); | 495 aggregator_.Aggregate(root_surface_id_); |
567 | 496 |
568 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
569 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
570 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
571 | |
572 ASSERT_TRUE(aggregated_frame); | 497 ASSERT_TRUE(aggregated_frame); |
573 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 498 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
574 | 499 |
575 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 500 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
576 | 501 |
577 // First pass should come from surface that had a copy request but was not | 502 // First pass should come from surface that had a copy request but was not |
578 // referenced directly. The second pass comes from the root surface. | 503 // referenced directly. The second pass comes from the root surface. |
579 // parent_quad should be ignored because it is neither referenced through a | 504 // parent_quad should be ignored because it is neither referenced through a |
580 // SurfaceDrawQuad nor has a copy request on it. | 505 // SurfaceDrawQuad nor has a copy request on it. |
581 test::Pass expected_passes[] = { | 506 test::Pass expected_passes[] = { |
(...skipping 17 matching lines...) Expand all Loading... |
599 } | 524 } |
600 | 525 |
601 factory_.Destroy(parent_surface_id); | 526 factory_.Destroy(parent_surface_id); |
602 factory_.Destroy(embedded_surface_id); | 527 factory_.Destroy(embedded_surface_id); |
603 } | 528 } |
604 | 529 |
605 // This tests referencing a surface that has multiple render passes. | 530 // This tests referencing a surface that has multiple render passes. |
606 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 531 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
607 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); | 532 SurfaceId embedded_surface_id = child_allocator_.GenerateId(); |
608 factory_.Create(embedded_surface_id); | 533 factory_.Create(embedded_surface_id); |
609 Surface* embedded_surface = manager_.GetSurfaceForId(embedded_surface_id); | |
610 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
611 | 534 |
612 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), | 535 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2), |
613 RenderPassId(1, 3)}; | 536 RenderPassId(1, 3)}; |
614 | 537 |
615 test::Quad embedded_quads[][2] = { | 538 test::Quad embedded_quads[][2] = { |
616 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, | 539 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, |
617 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, | 540 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, |
618 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; | 541 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; |
619 test::Pass embedded_passes[] = { | 542 test::Pass embedded_passes[] = { |
620 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), | 543 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), |
621 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), | 544 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), |
622 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; | 545 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; |
623 | 546 |
624 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), | 547 SubmitCompositorFrame(embedded_passes, arraysize(embedded_passes), |
625 embedded_surface_id); | 548 embedded_surface_id); |
626 | 549 |
627 test::Quad root_quads[][2] = { | 550 test::Quad root_quads[][2] = { |
628 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, | 551 {test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)}, |
629 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), | 552 {test::Quad::SurfaceQuad(embedded_surface_id, 1.f), |
630 test::Quad::RenderPassQuad(pass_ids[0])}, | 553 test::Quad::RenderPassQuad(pass_ids[0])}, |
631 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; | 554 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; |
632 test::Pass root_passes[] = { | 555 test::Pass root_passes[] = { |
633 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), | 556 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), |
634 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), | 557 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), |
635 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; | 558 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; |
636 | 559 |
637 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); | 560 SubmitCompositorFrame(root_passes, arraysize(root_passes), root_surface_id_); |
638 | 561 |
639 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
640 EXPECT_FALSE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
641 | |
642 scoped_ptr<CompositorFrame> aggregated_frame = | 562 scoped_ptr<CompositorFrame> aggregated_frame = |
643 aggregator_.Aggregate(root_surface_id_); | 563 aggregator_.Aggregate(root_surface_id_); |
644 | 564 |
645 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
646 EXPECT_TRUE(surface_aggregator_client_.HasSurface(embedded_surface)); | |
647 | |
648 ASSERT_TRUE(aggregated_frame); | 565 ASSERT_TRUE(aggregated_frame); |
649 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 566 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
650 | 567 |
651 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 568 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
652 | 569 |
653 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 570 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
654 | 571 |
655 ASSERT_EQ(5u, aggregated_pass_list.size()); | 572 ASSERT_EQ(5u, aggregated_pass_list.size()); |
656 RenderPassId actual_pass_ids[] = { | 573 RenderPassId actual_pass_ids[] = { |
657 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, | 574 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 676 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
760 | 677 |
761 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 678 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
762 | 679 |
763 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 680 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
764 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 681 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
765 test::Pass expected_passes[] = { | 682 test::Pass expected_passes[] = { |
766 test::Pass(expected_quads, arraysize(expected_quads))}; | 683 test::Pass(expected_quads, arraysize(expected_quads))}; |
767 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; | 684 SurfaceId ids[] = {root_surface_id_, InvalidSurfaceId()}; |
768 | 685 |
769 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
770 AggregateAndVerify( | 686 AggregateAndVerify( |
771 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 687 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
772 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
773 } | 688 } |
774 | 689 |
775 // Tests a reference to a valid surface with no submitted frame. This quad | 690 // Tests a reference to a valid surface with no submitted frame. This quad |
776 // should also just be dropped. | 691 // should also just be dropped. |
777 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 692 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
778 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); | 693 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); |
779 factory_.Create(surface_with_no_frame_id); | 694 factory_.Create(surface_with_no_frame_id); |
780 Surface* surface_with_no_frame = | |
781 manager_.GetSurfaceForId(surface_with_no_frame_id); | |
782 | 695 |
783 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 696 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
784 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), | 697 test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f), |
785 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 698 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
786 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 699 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
787 | 700 |
788 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 701 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
789 | 702 |
790 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 703 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
791 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 704 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
792 test::Pass expected_passes[] = { | 705 test::Pass expected_passes[] = { |
793 test::Pass(expected_quads, arraysize(expected_quads))}; | 706 test::Pass(expected_quads, arraysize(expected_quads))}; |
794 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; | 707 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; |
795 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
796 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface_with_no_frame)); | |
797 AggregateAndVerify( | 708 AggregateAndVerify( |
798 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 709 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
799 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
800 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface_with_no_frame)); | |
801 factory_.Destroy(surface_with_no_frame_id); | 710 factory_.Destroy(surface_with_no_frame_id); |
802 } | 711 } |
803 | 712 |
804 // Tests a surface quad referencing itself, generating a trivial cycle. | 713 // Tests a surface quad referencing itself, generating a trivial cycle. |
805 // The quad creating the cycle should be dropped from the final frame. | 714 // The quad creating the cycle should be dropped from the final frame. |
806 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 715 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
807 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_, 1.f), | 716 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_, 1.f), |
808 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 717 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
809 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 718 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
810 | 719 |
811 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); | 720 SubmitCompositorFrame(passes, arraysize(passes), root_surface_id_); |
812 | 721 |
813 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 722 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
814 test::Pass expected_passes[] = { | 723 test::Pass expected_passes[] = { |
815 test::Pass(expected_quads, arraysize(expected_quads))}; | 724 test::Pass(expected_quads, arraysize(expected_quads))}; |
816 SurfaceId ids[] = {root_surface_id_}; | 725 SurfaceId ids[] = {root_surface_id_}; |
817 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
818 AggregateAndVerify( | 726 AggregateAndVerify( |
819 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 727 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
820 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
821 } | 728 } |
822 | 729 |
823 // Tests a more complex cycle with one intermediate surface. | 730 // Tests a more complex cycle with one intermediate surface. |
824 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 731 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
825 SurfaceId child_surface_id = allocator_.GenerateId(); | 732 SurfaceId child_surface_id = allocator_.GenerateId(); |
826 factory_.Create(child_surface_id); | 733 factory_.Create(child_surface_id); |
827 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
828 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
829 | 734 |
830 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 735 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
831 test::Quad::SurfaceQuad(child_surface_id, 1.f), | 736 test::Quad::SurfaceQuad(child_surface_id, 1.f), |
832 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 737 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
833 test::Pass parent_passes[] = { | 738 test::Pass parent_passes[] = { |
834 test::Pass(parent_quads, arraysize(parent_quads))}; | 739 test::Pass(parent_quads, arraysize(parent_quads))}; |
835 | 740 |
836 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 741 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), |
837 root_surface_id_); | 742 root_surface_id_); |
838 | 743 |
(...skipping 11 matching lines...) Expand all Loading... |
850 // SK_ColorGREEN from the child | 755 // SK_ColorGREEN from the child |
851 // SK_ColorMAGENTA from the child | 756 // SK_ColorMAGENTA from the child |
852 // SK_ColorCYAN from the parent | 757 // SK_ColorCYAN from the parent |
853 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 758 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
854 test::Quad::SolidColorQuad(SK_ColorGREEN), | 759 test::Quad::SolidColorQuad(SK_ColorGREEN), |
855 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 760 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
856 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 761 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
857 test::Pass expected_passes[] = { | 762 test::Pass expected_passes[] = { |
858 test::Pass(expected_quads, arraysize(expected_quads))}; | 763 test::Pass(expected_quads, arraysize(expected_quads))}; |
859 SurfaceId ids[] = {root_surface_id_, child_surface_id}; | 764 SurfaceId ids[] = {root_surface_id_, child_surface_id}; |
860 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
861 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
862 AggregateAndVerify( | 765 AggregateAndVerify( |
863 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 766 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
864 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
865 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
866 factory_.Destroy(child_surface_id); | 767 factory_.Destroy(child_surface_id); |
867 } | 768 } |
868 | 769 |
869 // Tests that we map render pass IDs from different surfaces into a unified | 770 // Tests that we map render pass IDs from different surfaces into a unified |
870 // namespace and update RenderPassDrawQuad's id references to match. | 771 // namespace and update RenderPassDrawQuad's id references to match. |
871 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 772 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
872 SurfaceId child_surface_id = allocator_.GenerateId(); | 773 SurfaceId child_surface_id = allocator_.GenerateId(); |
873 factory_.Create(child_surface_id); | 774 factory_.Create(child_surface_id); |
874 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
875 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
876 | 775 |
877 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 776 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
878 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 777 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
879 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 778 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
880 test::Pass surface_passes[] = { | 779 test::Pass surface_passes[] = { |
881 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 780 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
882 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 781 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
883 | 782 |
884 SubmitCompositorFrame(surface_passes, arraysize(surface_passes), | 783 SubmitCompositorFrame(surface_passes, arraysize(surface_passes), |
885 child_surface_id); | 784 child_surface_id); |
886 | 785 |
887 // Pass IDs from the parent surface may collide with ones from the child. | 786 // Pass IDs from the parent surface may collide with ones from the child. |
888 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; | 787 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)}; |
889 test::Quad parent_quad[][1] = { | 788 test::Quad parent_quad[][1] = { |
890 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, | 789 {test::Quad::SurfaceQuad(child_surface_id, 1.f)}, |
891 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 790 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
892 test::Pass parent_passes[] = { | 791 test::Pass parent_passes[] = { |
893 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 792 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
894 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 793 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
895 | 794 |
896 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), | 795 SubmitCompositorFrame(parent_passes, arraysize(parent_passes), |
897 root_surface_id_); | 796 root_surface_id_); |
898 | 797 |
899 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
900 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
901 | |
902 scoped_ptr<CompositorFrame> aggregated_frame = | 798 scoped_ptr<CompositorFrame> aggregated_frame = |
903 aggregator_.Aggregate(root_surface_id_); | 799 aggregator_.Aggregate(root_surface_id_); |
904 | 800 |
905 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
906 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
907 | |
908 ASSERT_TRUE(aggregated_frame); | 801 ASSERT_TRUE(aggregated_frame); |
909 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 802 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
910 | 803 |
911 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 804 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
912 | 805 |
913 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 806 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
914 | 807 |
915 ASSERT_EQ(3u, aggregated_pass_list.size()); | 808 ASSERT_EQ(3u, aggregated_pass_list.size()); |
916 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, | 809 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id, |
917 aggregated_pass_list[1]->id, | 810 aggregated_pass_list[1]->id, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 SkXfermode::kDst_Mode, // 2 | 888 SkXfermode::kDst_Mode, // 2 |
996 SkXfermode::kSrcOver_Mode, // 3 | 889 SkXfermode::kSrcOver_Mode, // 3 |
997 SkXfermode::kDstOver_Mode, // 4 | 890 SkXfermode::kDstOver_Mode, // 4 |
998 SkXfermode::kSrcIn_Mode, // 5 | 891 SkXfermode::kSrcIn_Mode, // 5 |
999 SkXfermode::kDstIn_Mode, // 6 | 892 SkXfermode::kDstIn_Mode, // 6 |
1000 }; | 893 }; |
1001 | 894 |
1002 RenderPassId pass_id(1, 1); | 895 RenderPassId pass_id(1, 1); |
1003 SurfaceId grandchild_surface_id = allocator_.GenerateId(); | 896 SurfaceId grandchild_surface_id = allocator_.GenerateId(); |
1004 factory_.Create(grandchild_surface_id); | 897 factory_.Create(grandchild_surface_id); |
1005 Surface* grandchild_surface = manager_.GetSurfaceForId(grandchild_surface_id); | |
1006 EXPECT_FALSE(surface_aggregator_client_.HasSurface(grandchild_surface)); | |
1007 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 898 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
1008 gfx::Rect output_rect(SurfaceSize()); | 899 gfx::Rect output_rect(SurfaceSize()); |
1009 gfx::Rect damage_rect(SurfaceSize()); | 900 gfx::Rect damage_rect(SurfaceSize()); |
1010 gfx::Transform transform_to_root_target; | 901 gfx::Transform transform_to_root_target; |
1011 grandchild_pass->SetNew( | 902 grandchild_pass->SetNew( |
1012 pass_id, output_rect, damage_rect, transform_to_root_target); | 903 pass_id, output_rect, damage_rect, transform_to_root_target); |
1013 AddSolidColorQuadWithBlendMode( | 904 AddSolidColorQuadWithBlendMode( |
1014 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 905 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
1015 QueuePassAsFrame(std::move(grandchild_pass), grandchild_surface_id); | 906 QueuePassAsFrame(std::move(grandchild_pass), grandchild_surface_id); |
1016 | 907 |
1017 SurfaceId child_one_surface_id = allocator_.GenerateId(); | 908 SurfaceId child_one_surface_id = allocator_.GenerateId(); |
1018 factory_.Create(child_one_surface_id); | 909 factory_.Create(child_one_surface_id); |
1019 Surface* child_one_surface = manager_.GetSurfaceForId(child_one_surface_id); | |
1020 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_one_surface)); | |
1021 | 910 |
1022 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 911 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
1023 child_one_pass->SetNew( | 912 child_one_pass->SetNew( |
1024 pass_id, output_rect, damage_rect, transform_to_root_target); | 913 pass_id, output_rect, damage_rect, transform_to_root_target); |
1025 AddSolidColorQuadWithBlendMode( | 914 AddSolidColorQuadWithBlendMode( |
1026 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 915 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
1027 SurfaceDrawQuad* grandchild_surface_quad = | 916 SurfaceDrawQuad* grandchild_surface_quad = |
1028 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 917 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
1029 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 918 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
1030 gfx::Rect(SurfaceSize()), | 919 gfx::Rect(SurfaceSize()), |
1031 gfx::Rect(SurfaceSize()), | 920 gfx::Rect(SurfaceSize()), |
1032 grandchild_surface_id); | 921 grandchild_surface_id); |
1033 AddSolidColorQuadWithBlendMode( | 922 AddSolidColorQuadWithBlendMode( |
1034 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 923 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
1035 QueuePassAsFrame(std::move(child_one_pass), child_one_surface_id); | 924 QueuePassAsFrame(std::move(child_one_pass), child_one_surface_id); |
1036 | 925 |
1037 SurfaceId child_two_surface_id = allocator_.GenerateId(); | 926 SurfaceId child_two_surface_id = allocator_.GenerateId(); |
1038 factory_.Create(child_two_surface_id); | 927 factory_.Create(child_two_surface_id); |
1039 Surface* child_two_surface = manager_.GetSurfaceForId(child_two_surface_id); | |
1040 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_two_surface)); | |
1041 | 928 |
1042 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 929 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
1043 child_two_pass->SetNew( | 930 child_two_pass->SetNew( |
1044 pass_id, output_rect, damage_rect, transform_to_root_target); | 931 pass_id, output_rect, damage_rect, transform_to_root_target); |
1045 AddSolidColorQuadWithBlendMode( | 932 AddSolidColorQuadWithBlendMode( |
1046 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 933 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
1047 QueuePassAsFrame(std::move(child_two_pass), child_two_surface_id); | 934 QueuePassAsFrame(std::move(child_two_pass), child_two_surface_id); |
1048 | 935 |
1049 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); | 936 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); |
1050 root_pass->SetNew( | 937 root_pass->SetNew( |
(...skipping 13 matching lines...) Expand all Loading... |
1064 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 951 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
1065 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 952 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
1066 gfx::Rect(SurfaceSize()), | 953 gfx::Rect(SurfaceSize()), |
1067 gfx::Rect(SurfaceSize()), | 954 gfx::Rect(SurfaceSize()), |
1068 child_two_surface_id); | 955 child_two_surface_id); |
1069 AddSolidColorQuadWithBlendMode( | 956 AddSolidColorQuadWithBlendMode( |
1070 SurfaceSize(), root_pass.get(), blend_modes[6]); | 957 SurfaceSize(), root_pass.get(), blend_modes[6]); |
1071 | 958 |
1072 QueuePassAsFrame(std::move(root_pass), root_surface_id_); | 959 QueuePassAsFrame(std::move(root_pass), root_surface_id_); |
1073 | 960 |
1074 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1075 EXPECT_FALSE(surface_aggregator_client_.HasSurface(grandchild_surface)); | |
1076 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_one_surface)); | |
1077 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_two_surface)); | |
1078 | |
1079 scoped_ptr<CompositorFrame> aggregated_frame = | 961 scoped_ptr<CompositorFrame> aggregated_frame = |
1080 aggregator_.Aggregate(root_surface_id_); | 962 aggregator_.Aggregate(root_surface_id_); |
1081 | 963 |
1082 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1083 EXPECT_TRUE(surface_aggregator_client_.HasSurface(grandchild_surface)); | |
1084 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_one_surface)); | |
1085 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_two_surface)); | |
1086 | |
1087 ASSERT_TRUE(aggregated_frame); | 964 ASSERT_TRUE(aggregated_frame); |
1088 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 965 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1089 | 966 |
1090 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 967 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1091 | 968 |
1092 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 969 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1093 | 970 |
1094 ASSERT_EQ(1u, aggregated_pass_list.size()); | 971 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1095 | 972 |
1096 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 973 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
(...skipping 26 matching lines...) Expand all Loading... |
1123 // pass id and a transform of +8 in the x direction. | 1000 // pass id and a transform of +8 in the x direction. |
1124 // | 1001 // |
1125 // After aggregation, the child surface's root pass quad should have all | 1002 // After aggregation, the child surface's root pass quad should have all |
1126 // transforms concatenated for a total transform of +23 x, +10 y. The | 1003 // transforms concatenated for a total transform of +23 x, +10 y. The |
1127 // contributing render pass' transform in the aggregate frame should not be | 1004 // contributing render pass' transform in the aggregate frame should not be |
1128 // affected. | 1005 // affected. |
1129 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { | 1006 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { |
1130 // Innermost child surface. | 1007 // Innermost child surface. |
1131 SurfaceId child_surface_id = allocator_.GenerateId(); | 1008 SurfaceId child_surface_id = allocator_.GenerateId(); |
1132 factory_.Create(child_surface_id); | 1009 factory_.Create(child_surface_id); |
1133 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1134 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1135 { | 1010 { |
1136 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; | 1011 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; |
1137 test::Quad child_quads[][1] = { | 1012 test::Quad child_quads[][1] = { |
1138 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 1013 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
1139 {test::Quad::RenderPassQuad(child_pass_id[0])}, | 1014 {test::Quad::RenderPassQuad(child_pass_id[0])}, |
1140 }; | 1015 }; |
1141 test::Pass child_passes[] = { | 1016 test::Pass child_passes[] = { |
1142 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), | 1017 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), |
1143 test::Pass(child_quads[1], arraysize(child_quads[1]), | 1018 test::Pass(child_quads[1], arraysize(child_quads[1]), |
1144 child_pass_id[1])}; | 1019 child_pass_id[1])}; |
(...skipping 21 matching lines...) Expand all Loading... |
1166 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1041 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
1167 child_frame->delegated_frame_data = std::move(child_frame_data); | 1042 child_frame->delegated_frame_data = std::move(child_frame_data); |
1168 | 1043 |
1169 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 1044 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
1170 SurfaceFactory::DrawCallback()); | 1045 SurfaceFactory::DrawCallback()); |
1171 } | 1046 } |
1172 | 1047 |
1173 // Middle child surface. | 1048 // Middle child surface. |
1174 SurfaceId middle_surface_id = allocator_.GenerateId(); | 1049 SurfaceId middle_surface_id = allocator_.GenerateId(); |
1175 factory_.Create(middle_surface_id); | 1050 factory_.Create(middle_surface_id); |
1176 Surface* middle_surface = manager_.GetSurfaceForId(middle_surface_id); | |
1177 EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1178 { | 1051 { |
1179 test::Quad middle_quads[] = { | 1052 test::Quad middle_quads[] = { |
1180 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1053 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1181 test::Pass middle_passes[] = { | 1054 test::Pass middle_passes[] = { |
1182 test::Pass(middle_quads, arraysize(middle_quads)), | 1055 test::Pass(middle_quads, arraysize(middle_quads)), |
1183 }; | 1056 }; |
1184 | 1057 |
1185 RenderPassList middle_pass_list; | 1058 RenderPassList middle_pass_list; |
1186 AddPasses(&middle_pass_list, gfx::Rect(SurfaceSize()), middle_passes, | 1059 AddPasses(&middle_pass_list, gfx::Rect(SurfaceSize()), middle_passes, |
1187 arraysize(middle_passes)); | 1060 arraysize(middle_passes)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 | 1104 |
1232 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1105 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1233 root_pass_list.swap(root_frame_data->render_pass_list); | 1106 root_pass_list.swap(root_frame_data->render_pass_list); |
1234 | 1107 |
1235 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1108 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1236 root_frame->delegated_frame_data = std::move(root_frame_data); | 1109 root_frame->delegated_frame_data = std::move(root_frame_data); |
1237 | 1110 |
1238 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1111 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1239 SurfaceFactory::DrawCallback()); | 1112 SurfaceFactory::DrawCallback()); |
1240 | 1113 |
1241 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1242 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1243 EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1244 | |
1245 scoped_ptr<CompositorFrame> aggregated_frame = | 1114 scoped_ptr<CompositorFrame> aggregated_frame = |
1246 aggregator_.Aggregate(root_surface_id_); | 1115 aggregator_.Aggregate(root_surface_id_); |
1247 | 1116 |
1248 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1249 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1250 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
1251 | |
1252 ASSERT_TRUE(aggregated_frame); | 1117 ASSERT_TRUE(aggregated_frame); |
1253 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1118 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1254 | 1119 |
1255 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1120 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1256 | 1121 |
1257 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1122 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1258 | 1123 |
1259 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1124 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1260 | 1125 |
1261 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 1126 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1210 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
1346 | 1211 |
1347 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 1212 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
1348 child_pass_list.swap(child_frame_data->render_pass_list); | 1213 child_pass_list.swap(child_frame_data->render_pass_list); |
1349 | 1214 |
1350 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1215 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
1351 child_frame->delegated_frame_data = std::move(child_frame_data); | 1216 child_frame->delegated_frame_data = std::move(child_frame_data); |
1352 | 1217 |
1353 SurfaceId child_surface_id = allocator_.GenerateId(); | 1218 SurfaceId child_surface_id = allocator_.GenerateId(); |
1354 factory_.Create(child_surface_id); | 1219 factory_.Create(child_surface_id); |
1355 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1356 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 1220 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
1357 SurfaceFactory::DrawCallback()); | 1221 SurfaceFactory::DrawCallback()); |
1358 | 1222 |
1359 test::Quad parent_surface_quads[] = { | 1223 test::Quad parent_surface_quads[] = { |
1360 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1224 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1361 test::Pass parent_surface_passes[] = { | 1225 test::Pass parent_surface_passes[] = { |
1362 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), | 1226 test::Pass(parent_surface_quads, arraysize(parent_surface_quads), |
1363 RenderPassId(1, 1))}; | 1227 RenderPassId(1, 1))}; |
1364 | 1228 |
1365 RenderPassList parent_surface_pass_list; | 1229 RenderPassList parent_surface_pass_list; |
1366 AddPasses(&parent_surface_pass_list, | 1230 AddPasses(&parent_surface_pass_list, |
1367 gfx::Rect(SurfaceSize()), | 1231 gfx::Rect(SurfaceSize()), |
1368 parent_surface_passes, | 1232 parent_surface_passes, |
1369 arraysize(parent_surface_passes)); | 1233 arraysize(parent_surface_passes)); |
1370 | 1234 |
1371 // Parent surface is only used to test if the transform is applied correctly | 1235 // Parent surface is only used to test if the transform is applied correctly |
1372 // to the child surface's damage. | 1236 // to the child surface's damage. |
1373 scoped_ptr<DelegatedFrameData> parent_surface_frame_data( | 1237 scoped_ptr<DelegatedFrameData> parent_surface_frame_data( |
1374 new DelegatedFrameData); | 1238 new DelegatedFrameData); |
1375 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list); | 1239 parent_surface_pass_list.swap(parent_surface_frame_data->render_pass_list); |
1376 | 1240 |
1377 scoped_ptr<CompositorFrame> parent_surface_frame(new CompositorFrame); | 1241 scoped_ptr<CompositorFrame> parent_surface_frame(new CompositorFrame); |
1378 parent_surface_frame->delegated_frame_data = | 1242 parent_surface_frame->delegated_frame_data = |
1379 std::move(parent_surface_frame_data); | 1243 std::move(parent_surface_frame_data); |
1380 | 1244 |
1381 SurfaceId parent_surface_id = allocator_.GenerateId(); | 1245 SurfaceId parent_surface_id = allocator_.GenerateId(); |
1382 factory_.Create(parent_surface_id); | 1246 factory_.Create(parent_surface_id); |
1383 Surface* parent_surface = manager_.GetSurfaceForId(parent_surface_id); | |
1384 factory_.SubmitCompositorFrame(parent_surface_id, | 1247 factory_.SubmitCompositorFrame(parent_surface_id, |
1385 std::move(parent_surface_frame), | 1248 std::move(parent_surface_frame), |
1386 SurfaceFactory::DrawCallback()); | 1249 SurfaceFactory::DrawCallback()); |
1387 | 1250 |
1388 test::Quad root_surface_quads[] = { | 1251 test::Quad root_surface_quads[] = { |
1389 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; | 1252 test::Quad::SurfaceQuad(parent_surface_id, 1.f)}; |
1390 test::Quad root_render_pass_quads[] = { | 1253 test::Quad root_render_pass_quads[] = { |
1391 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; | 1254 test::Quad::RenderPassQuad(RenderPassId(1, 1))}; |
1392 | 1255 |
1393 test::Pass root_passes[] = { | 1256 test::Pass root_passes[] = { |
(...skipping 16 matching lines...) Expand all Loading... |
1410 | 1273 |
1411 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1274 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1412 root_pass_list.swap(root_frame_data->render_pass_list); | 1275 root_pass_list.swap(root_frame_data->render_pass_list); |
1413 | 1276 |
1414 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1277 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1415 root_frame->delegated_frame_data = std::move(root_frame_data); | 1278 root_frame->delegated_frame_data = std::move(root_frame_data); |
1416 | 1279 |
1417 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1280 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1418 SurfaceFactory::DrawCallback()); | 1281 SurfaceFactory::DrawCallback()); |
1419 | 1282 |
1420 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1421 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1422 EXPECT_FALSE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1423 | |
1424 scoped_ptr<CompositorFrame> aggregated_frame = | 1283 scoped_ptr<CompositorFrame> aggregated_frame = |
1425 aggregator_.Aggregate(root_surface_id_); | 1284 aggregator_.Aggregate(root_surface_id_); |
1426 | 1285 |
1427 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1428 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1429 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1430 | |
1431 ASSERT_TRUE(aggregated_frame); | 1286 ASSERT_TRUE(aggregated_frame); |
1432 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1287 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1433 | 1288 |
1434 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1289 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1435 | 1290 |
1436 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1291 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1437 | 1292 |
1438 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1293 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1439 | 1294 |
1440 // Damage rect for first aggregation should contain entire root surface. | 1295 // Damage rect for first aggregation should contain entire root surface. |
(...skipping 14 matching lines...) Expand all Loading... |
1455 | 1310 |
1456 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 1311 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
1457 child_pass_list.swap(child_frame_data->render_pass_list); | 1312 child_pass_list.swap(child_frame_data->render_pass_list); |
1458 | 1313 |
1459 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1314 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
1460 child_frame->delegated_frame_data = std::move(child_frame_data); | 1315 child_frame->delegated_frame_data = std::move(child_frame_data); |
1461 | 1316 |
1462 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), | 1317 factory_.SubmitCompositorFrame(child_surface_id, std::move(child_frame), |
1463 SurfaceFactory::DrawCallback()); | 1318 SurfaceFactory::DrawCallback()); |
1464 | 1319 |
1465 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1466 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1467 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1468 | |
1469 scoped_ptr<CompositorFrame> aggregated_frame = | 1320 scoped_ptr<CompositorFrame> aggregated_frame = |
1470 aggregator_.Aggregate(root_surface_id_); | 1321 aggregator_.Aggregate(root_surface_id_); |
1471 | 1322 |
1472 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1473 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1474 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1475 | |
1476 ASSERT_TRUE(aggregated_frame); | 1323 ASSERT_TRUE(aggregated_frame); |
1477 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1324 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1478 | 1325 |
1479 DelegatedFrameData* frame_data = | 1326 DelegatedFrameData* frame_data = |
1480 aggregated_frame->delegated_frame_data.get(); | 1327 aggregated_frame->delegated_frame_data.get(); |
1481 | 1328 |
1482 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1329 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1483 | 1330 |
1484 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1331 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1485 | 1332 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 | 1372 |
1526 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1373 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1527 root_pass_list.swap(root_frame_data->render_pass_list); | 1374 root_pass_list.swap(root_frame_data->render_pass_list); |
1528 | 1375 |
1529 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1376 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1530 root_frame->delegated_frame_data = std::move(root_frame_data); | 1377 root_frame->delegated_frame_data = std::move(root_frame_data); |
1531 | 1378 |
1532 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), | 1379 factory_.SubmitCompositorFrame(root_surface_id_, std::move(root_frame), |
1533 SurfaceFactory::DrawCallback()); | 1380 SurfaceFactory::DrawCallback()); |
1534 | 1381 |
1535 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1536 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1537 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1538 | |
1539 scoped_ptr<CompositorFrame> aggregated_frame = | 1382 scoped_ptr<CompositorFrame> aggregated_frame = |
1540 aggregator_.Aggregate(root_surface_id_); | 1383 aggregator_.Aggregate(root_surface_id_); |
1541 | 1384 |
1542 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1543 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1544 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1545 | |
1546 ASSERT_TRUE(aggregated_frame); | 1385 ASSERT_TRUE(aggregated_frame); |
1547 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1386 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1548 | 1387 |
1549 DelegatedFrameData* frame_data = | 1388 DelegatedFrameData* frame_data = |
1550 aggregated_frame->delegated_frame_data.get(); | 1389 aggregated_frame->delegated_frame_data.get(); |
1551 | 1390 |
1552 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1391 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1553 | 1392 |
1554 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1393 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1555 | 1394 |
1556 // The root surface was enqueued without being aggregated once, so it should | 1395 // The root surface was enqueued without being aggregated once, so it should |
1557 // be treated as completely damaged. | 1396 // be treated as completely damaged. |
1558 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1397 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1559 gfx::Rect(SurfaceSize()))); | 1398 gfx::Rect(SurfaceSize()))); |
1560 } | 1399 } |
1561 | 1400 |
1562 // No Surface changed, so no damage should be given. | 1401 // No Surface changed, so no damage should be given. |
1563 { | 1402 { |
1564 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1565 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1566 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1567 | |
1568 scoped_ptr<CompositorFrame> aggregated_frame = | 1403 scoped_ptr<CompositorFrame> aggregated_frame = |
1569 aggregator_.Aggregate(root_surface_id_); | 1404 aggregator_.Aggregate(root_surface_id_); |
1570 | 1405 |
1571 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1572 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1573 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1574 | |
1575 ASSERT_TRUE(aggregated_frame); | 1406 ASSERT_TRUE(aggregated_frame); |
1576 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1407 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1577 | 1408 |
1578 DelegatedFrameData* frame_data = | 1409 DelegatedFrameData* frame_data = |
1579 aggregated_frame->delegated_frame_data.get(); | 1410 aggregated_frame->delegated_frame_data.get(); |
1580 | 1411 |
1581 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1412 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1582 | 1413 |
1583 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1414 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1584 | 1415 |
1585 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1416 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
1586 } | 1417 } |
1587 | 1418 |
1588 // SetFullDamageRectForSurface should cause the entire output to be | 1419 // SetFullDamageRectForSurface should cause the entire output to be |
1589 // marked as damaged. | 1420 // marked as damaged. |
1590 { | 1421 { |
1591 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1592 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1593 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1594 | |
1595 aggregator_.SetFullDamageForSurface(root_surface_id_); | 1422 aggregator_.SetFullDamageForSurface(root_surface_id_); |
1596 scoped_ptr<CompositorFrame> aggregated_frame = | 1423 scoped_ptr<CompositorFrame> aggregated_frame = |
1597 aggregator_.Aggregate(root_surface_id_); | 1424 aggregator_.Aggregate(root_surface_id_); |
1598 | 1425 |
1599 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1600 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1601 EXPECT_TRUE(surface_aggregator_client_.HasSurface(parent_surface)); | |
1602 | |
1603 ASSERT_TRUE(aggregated_frame); | 1426 ASSERT_TRUE(aggregated_frame); |
1604 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1427 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1605 | 1428 |
1606 DelegatedFrameData* frame_data = | 1429 DelegatedFrameData* frame_data = |
1607 aggregated_frame->delegated_frame_data.get(); | 1430 aggregated_frame->delegated_frame_data.get(); |
1608 | 1431 |
1609 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1432 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1610 | 1433 |
1611 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1434 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1612 | 1435 |
1613 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1436 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1614 gfx::Rect(SurfaceSize()))); | 1437 gfx::Rect(SurfaceSize()))); |
1615 } | 1438 } |
1616 | 1439 |
1617 factory_.Destroy(child_surface_id); | 1440 factory_.Destroy(child_surface_id); |
1618 } | 1441 } |
1619 | 1442 |
1620 class SurfaceAggregatorPartialSwapTest | 1443 class SurfaceAggregatorPartialSwapTest |
1621 : public SurfaceAggregatorValidSurfaceTest { | 1444 : public SurfaceAggregatorValidSurfaceTest { |
1622 public: | 1445 public: |
1623 SurfaceAggregatorPartialSwapTest() | 1446 SurfaceAggregatorPartialSwapTest() |
1624 : SurfaceAggregatorValidSurfaceTest(true) {} | 1447 : SurfaceAggregatorValidSurfaceTest(true) {} |
1625 }; | 1448 }; |
1626 | 1449 |
1627 // Tests that quads outside the damage rect are ignored. | 1450 // Tests that quads outside the damage rect are ignored. |
1628 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { | 1451 TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) { |
1629 SurfaceId child_surface_id = allocator_.GenerateId(); | 1452 SurfaceId child_surface_id = allocator_.GenerateId(); |
1630 factory_.Create(child_surface_id); | 1453 factory_.Create(child_surface_id); |
1631 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
1632 // The child surface has two quads, one with a visible rect of 13,13 4x4 and | 1454 // The child surface has two quads, one with a visible rect of 13,13 4x4 and |
1633 // the other other with a visible rect of 10,10 2x2 (relative to root target | 1455 // the other other with a visible rect of 10,10 2x2 (relative to root target |
1634 // space). | 1456 // space). |
1635 { | 1457 { |
1636 RenderPassId child_pass_id = RenderPassId(1, 1); | 1458 RenderPassId child_pass_id = RenderPassId(1, 1); |
1637 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1459 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1638 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 1460 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
1639 test::Pass child_passes[] = { | 1461 test::Pass child_passes[] = { |
1640 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), | 1462 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id), |
1641 test::Pass(child_quads2, arraysize(child_quads2), child_pass_id)}; | 1463 test::Pass(child_quads2, arraysize(child_quads2), child_pass_id)}; |
(...skipping 25 matching lines...) Expand all Loading... |
1667 arraysize(root_passes)); | 1489 arraysize(root_passes)); |
1668 | 1490 |
1669 RenderPass* root_pass = root_pass_list[0].get(); | 1491 RenderPass* root_pass = root_pass_list[0].get(); |
1670 root_pass->shared_quad_state_list.front() | 1492 root_pass->shared_quad_state_list.front() |
1671 ->quad_to_target_transform.Translate(10, 10); | 1493 ->quad_to_target_transform.Translate(10, 10); |
1672 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); | 1494 root_pass->damage_rect = gfx::Rect(0, 0, 1, 1); |
1673 | 1495 |
1674 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1496 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1675 } | 1497 } |
1676 | 1498 |
1677 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1678 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
1679 | |
1680 scoped_ptr<CompositorFrame> aggregated_frame = | 1499 scoped_ptr<CompositorFrame> aggregated_frame = |
1681 aggregator_.Aggregate(root_surface_id_); | 1500 aggregator_.Aggregate(root_surface_id_); |
1682 | 1501 |
1683 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1684 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1685 | |
1686 ASSERT_TRUE(aggregated_frame); | 1502 ASSERT_TRUE(aggregated_frame); |
1687 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1503 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1688 | 1504 |
1689 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1505 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1690 | 1506 |
1691 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1507 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1692 | 1508 |
1693 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1509 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1694 | 1510 |
1695 // Damage rect for first aggregation should contain entire root surface. | 1511 // Damage rect for first aggregation should contain entire root surface. |
(...skipping 12 matching lines...) Expand all Loading... |
1708 arraysize(root_passes)); | 1524 arraysize(root_passes)); |
1709 | 1525 |
1710 RenderPass* root_pass = root_pass_list[0].get(); | 1526 RenderPass* root_pass = root_pass_list[0].get(); |
1711 root_pass->shared_quad_state_list.front() | 1527 root_pass->shared_quad_state_list.front() |
1712 ->quad_to_target_transform.Translate(10, 10); | 1528 ->quad_to_target_transform.Translate(10, 10); |
1713 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1529 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1714 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); | 1530 SubmitPassListAsFrame(root_surface_id_, &root_pass_list); |
1715 } | 1531 } |
1716 | 1532 |
1717 { | 1533 { |
1718 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1719 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1720 | |
1721 scoped_ptr<CompositorFrame> aggregated_frame = | 1534 scoped_ptr<CompositorFrame> aggregated_frame = |
1722 aggregator_.Aggregate(root_surface_id_); | 1535 aggregator_.Aggregate(root_surface_id_); |
1723 | 1536 |
1724 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1725 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1726 | |
1727 ASSERT_TRUE(aggregated_frame); | 1537 ASSERT_TRUE(aggregated_frame); |
1728 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1538 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1729 | 1539 |
1730 DelegatedFrameData* frame_data = | 1540 DelegatedFrameData* frame_data = |
1731 aggregated_frame->delegated_frame_data.get(); | 1541 aggregated_frame->delegated_frame_data.get(); |
1732 | 1542 |
1733 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1543 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1734 | 1544 |
1735 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1545 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1736 | 1546 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1769 | 1579 |
1770 RenderPass* child_root_pass = child_pass_list[1].get(); | 1580 RenderPass* child_root_pass = child_pass_list[1].get(); |
1771 | 1581 |
1772 child_root_pass->copy_requests.push_back( | 1582 child_root_pass->copy_requests.push_back( |
1773 CopyOutputRequest::CreateEmptyRequest()); | 1583 CopyOutputRequest::CreateEmptyRequest()); |
1774 child_root_pass->damage_rect = gfx::Rect(); | 1584 child_root_pass->damage_rect = gfx::Rect(); |
1775 SubmitPassListAsFrame(child_surface_id, &child_pass_list); | 1585 SubmitPassListAsFrame(child_surface_id, &child_pass_list); |
1776 } | 1586 } |
1777 | 1587 |
1778 { | 1588 { |
1779 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1780 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1781 | |
1782 scoped_ptr<CompositorFrame> aggregated_frame = | 1589 scoped_ptr<CompositorFrame> aggregated_frame = |
1783 aggregator_.Aggregate(root_surface_id_); | 1590 aggregator_.Aggregate(root_surface_id_); |
1784 | 1591 |
1785 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1786 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1787 | |
1788 ASSERT_TRUE(aggregated_frame); | 1592 ASSERT_TRUE(aggregated_frame); |
1789 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1593 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1790 | 1594 |
1791 DelegatedFrameData* frame_data = | 1595 DelegatedFrameData* frame_data = |
1792 aggregated_frame->delegated_frame_data.get(); | 1596 aggregated_frame->delegated_frame_data.get(); |
1793 | 1597 |
1794 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1598 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1795 | 1599 |
1796 // Output frame should have no damage, but all quads included. | 1600 // Output frame should have no damage, but all quads included. |
1797 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1601 ASSERT_EQ(3u, aggregated_pass_list.size()); |
1798 | 1602 |
1799 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1603 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
1800 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1604 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
1801 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1605 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
1802 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), | 1606 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), |
1803 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); | 1607 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); |
1804 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), | 1608 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), |
1805 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); | 1609 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); |
1806 } | 1610 } |
1807 | 1611 |
1808 { | 1612 { |
1809 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1810 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1811 | |
1812 scoped_ptr<CompositorFrame> aggregated_frame = | 1613 scoped_ptr<CompositorFrame> aggregated_frame = |
1813 aggregator_.Aggregate(root_surface_id_); | 1614 aggregator_.Aggregate(root_surface_id_); |
1814 | 1615 |
1815 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface_)); | |
1816 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
1817 | |
1818 ASSERT_TRUE(aggregated_frame); | 1616 ASSERT_TRUE(aggregated_frame); |
1819 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1617 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1820 | 1618 |
1821 DelegatedFrameData* frame_data = | 1619 DelegatedFrameData* frame_data = |
1822 aggregated_frame->delegated_frame_data.get(); | 1620 aggregated_frame->delegated_frame_data.get(); |
1823 | 1621 |
1824 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1622 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1825 // There were no changes since last aggregation, so output should be empty | 1623 // There were no changes since last aggregation, so output should be empty |
1826 // and have no damage. | 1624 // and have no damage. |
1827 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1625 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1828 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1626 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1829 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1627 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1830 } | 1628 } |
1831 | 1629 |
1832 factory_.Destroy(child_surface_id); | 1630 factory_.Destroy(child_surface_id); |
1833 } | 1631 } |
1834 | 1632 |
1835 class SurfaceAggregatorWithResourcesTest : public testing::Test { | 1633 class SurfaceAggregatorWithResourcesTest : public testing::Test { |
1836 public: | 1634 public: |
1837 void SetUp() override { | 1635 void SetUp() override { |
1838 output_surface_ = FakeOutputSurface::CreateSoftware( | 1636 output_surface_ = FakeOutputSurface::CreateSoftware( |
1839 make_scoped_ptr(new SoftwareOutputDevice)); | 1637 make_scoped_ptr(new SoftwareOutputDevice)); |
1840 output_surface_->BindToClient(&output_surface_client_); | 1638 output_surface_->BindToClient(&output_surface_client_); |
1841 shared_bitmap_manager_.reset(new TestSharedBitmapManager); | 1639 shared_bitmap_manager_.reset(new TestSharedBitmapManager); |
1842 | 1640 |
1843 resource_provider_ = FakeResourceProvider::Create( | 1641 resource_provider_ = FakeResourceProvider::Create( |
1844 output_surface_.get(), shared_bitmap_manager_.get()); | 1642 output_surface_.get(), shared_bitmap_manager_.get()); |
1845 | 1643 |
1846 aggregator_.reset(new SurfaceAggregator(&surface_aggregator_client_, | 1644 aggregator_.reset( |
1847 &manager_, resource_provider_.get(), | 1645 new SurfaceAggregator(&manager_, resource_provider_.get(), false)); |
1848 false)); | |
1849 } | 1646 } |
1850 | 1647 |
1851 protected: | 1648 protected: |
1852 SurfaceManager manager_; | 1649 SurfaceManager manager_; |
1853 FakeOutputSurfaceClient output_surface_client_; | 1650 FakeOutputSurfaceClient output_surface_client_; |
1854 scoped_ptr<OutputSurface> output_surface_; | 1651 scoped_ptr<OutputSurface> output_surface_; |
1855 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 1652 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
1856 scoped_ptr<ResourceProvider> resource_provider_; | 1653 scoped_ptr<ResourceProvider> resource_provider_; |
1857 scoped_ptr<SurfaceAggregator> aggregator_; | 1654 scoped_ptr<SurfaceAggregator> aggregator_; |
1858 FakeSurfaceAggregatorClient surface_aggregator_client_; | |
1859 }; | 1655 }; |
1860 | 1656 |
1861 class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient { | 1657 class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient { |
1862 public: | 1658 public: |
1863 ResourceTrackingSurfaceFactoryClient() {} | 1659 ResourceTrackingSurfaceFactoryClient() {} |
1864 ~ResourceTrackingSurfaceFactoryClient() override {} | 1660 ~ResourceTrackingSurfaceFactoryClient() override {} |
1865 | 1661 |
1866 void ReturnResources(const ReturnedResourceArray& resources) override { | 1662 void ReturnResources(const ReturnedResourceArray& resources) override { |
1867 returned_resources_ = resources; | 1663 returned_resources_ = resources; |
1868 } | 1664 } |
1869 | 1665 |
1870 ReturnedResourceArray returned_resources() const { | 1666 ReturnedResourceArray returned_resources() const { |
1871 return returned_resources_; | 1667 return returned_resources_; |
1872 } | 1668 } |
1873 | 1669 |
1874 void SetBeginFrameSource(SurfaceId surface_id, | 1670 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {} |
1875 BeginFrameSource* begin_frame_source) override {} | |
1876 | 1671 |
1877 private: | 1672 private: |
1878 ReturnedResourceArray returned_resources_; | 1673 ReturnedResourceArray returned_resources_; |
1879 | 1674 |
1880 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); | 1675 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); |
1881 }; | 1676 }; |
1882 | 1677 |
1883 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, | 1678 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, |
1884 size_t num_resource_ids, | 1679 size_t num_resource_ids, |
1885 bool valid, | 1680 bool valid, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 frame->delegated_frame_data = std::move(frame_data); | 1721 frame->delegated_frame_data = std::move(frame_data); |
1927 factory->SubmitCompositorFrame(surface_id, std::move(frame), | 1722 factory->SubmitCompositorFrame(surface_id, std::move(frame), |
1928 SurfaceFactory::DrawCallback()); | 1723 SurfaceFactory::DrawCallback()); |
1929 } | 1724 } |
1930 | 1725 |
1931 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 1726 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
1932 ResourceTrackingSurfaceFactoryClient client; | 1727 ResourceTrackingSurfaceFactoryClient client; |
1933 SurfaceFactory factory(&manager_, &client); | 1728 SurfaceFactory factory(&manager_, &client); |
1934 SurfaceId surface_id(7u); | 1729 SurfaceId surface_id(7u); |
1935 factory.Create(surface_id); | 1730 factory.Create(surface_id); |
1936 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
1937 | 1731 |
1938 ResourceId ids[] = {11, 12, 13}; | 1732 ResourceId ids[] = {11, 12, 13}; |
1939 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1733 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
1940 &factory, surface_id); | 1734 &factory, surface_id); |
1941 | 1735 |
1942 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
1943 | |
1944 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 1736 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); |
1945 | 1737 |
1946 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1947 | |
1948 // Nothing should be available to be returned yet. | 1738 // Nothing should be available to be returned yet. |
1949 EXPECT_TRUE(client.returned_resources().empty()); | 1739 EXPECT_TRUE(client.returned_resources().empty()); |
1950 | 1740 |
1951 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, | 1741 SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory, |
1952 surface_id); | 1742 surface_id); |
1953 | 1743 |
1954 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1955 | |
1956 frame = aggregator_->Aggregate(surface_id); | 1744 frame = aggregator_->Aggregate(surface_id); |
1957 | 1745 |
1958 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1959 | |
1960 ASSERT_EQ(3u, client.returned_resources().size()); | 1746 ASSERT_EQ(3u, client.returned_resources().size()); |
1961 ResourceId returned_ids[3]; | 1747 ResourceId returned_ids[3]; |
1962 for (size_t i = 0; i < 3; ++i) { | 1748 for (size_t i = 0; i < 3; ++i) { |
1963 returned_ids[i] = client.returned_resources()[i].id; | 1749 returned_ids[i] = client.returned_resources()[i].id; |
1964 } | 1750 } |
1965 EXPECT_THAT(returned_ids, | 1751 EXPECT_THAT(returned_ids, |
1966 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1752 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1967 factory.Destroy(surface_id); | 1753 factory.Destroy(surface_id); |
1968 } | 1754 } |
1969 | 1755 |
1970 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 1756 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
1971 ResourceTrackingSurfaceFactoryClient client; | 1757 ResourceTrackingSurfaceFactoryClient client; |
1972 SurfaceFactory factory(&manager_, &client); | 1758 SurfaceFactory factory(&manager_, &client); |
1973 SurfaceId surface_id(7u); | 1759 SurfaceId surface_id(7u); |
1974 factory.Create(surface_id); | 1760 factory.Create(surface_id); |
1975 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
1976 | 1761 |
1977 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 1762 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
1978 scoped_ptr<RenderPass> pass = RenderPass::Create(); | 1763 scoped_ptr<RenderPass> pass = RenderPass::Create(); |
1979 pass->id = RenderPassId(1, 1); | 1764 pass->id = RenderPassId(1, 1); |
1980 TransferableResource resource; | 1765 TransferableResource resource; |
1981 resource.id = 11; | 1766 resource.id = 11; |
1982 // ResourceProvider is software but resource is not, so it should be | 1767 // ResourceProvider is software but resource is not, so it should be |
1983 // ignored. | 1768 // ignored. |
1984 resource.is_software = false; | 1769 resource.is_software = false; |
1985 frame_data->resource_list.push_back(resource); | 1770 frame_data->resource_list.push_back(resource); |
1986 frame_data->render_pass_list.push_back(std::move(pass)); | 1771 frame_data->render_pass_list.push_back(std::move(pass)); |
1987 scoped_ptr<CompositorFrame> frame(new CompositorFrame); | 1772 scoped_ptr<CompositorFrame> frame(new CompositorFrame); |
1988 frame->delegated_frame_data = std::move(frame_data); | 1773 frame->delegated_frame_data = std::move(frame_data); |
1989 factory.SubmitCompositorFrame(surface_id, std::move(frame), | 1774 factory.SubmitCompositorFrame(surface_id, std::move(frame), |
1990 SurfaceFactory::DrawCallback()); | 1775 SurfaceFactory::DrawCallback()); |
1991 | 1776 |
1992 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface)); | |
1993 | |
1994 scoped_ptr<CompositorFrame> returned_frame = | 1777 scoped_ptr<CompositorFrame> returned_frame = |
1995 aggregator_->Aggregate(surface_id); | 1778 aggregator_->Aggregate(surface_id); |
1996 | 1779 |
1997 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface)); | |
1998 | |
1999 // Nothing should be available to be returned yet. | 1780 // Nothing should be available to be returned yet. |
2000 EXPECT_TRUE(client.returned_resources().empty()); | 1781 EXPECT_TRUE(client.returned_resources().empty()); |
2001 | 1782 |
2002 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1783 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
2003 surface_id); | 1784 surface_id); |
2004 ASSERT_EQ(1u, client.returned_resources().size()); | 1785 ASSERT_EQ(1u, client.returned_resources().size()); |
2005 EXPECT_EQ(11u, client.returned_resources()[0].id); | 1786 EXPECT_EQ(11u, client.returned_resources()[0].id); |
2006 | 1787 |
2007 factory.Destroy(surface_id); | 1788 factory.Destroy(surface_id); |
2008 } | 1789 } |
2009 | 1790 |
2010 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 1791 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
2011 ResourceTrackingSurfaceFactoryClient client; | 1792 ResourceTrackingSurfaceFactoryClient client; |
2012 SurfaceFactory factory(&manager_, &client); | 1793 SurfaceFactory factory(&manager_, &client); |
2013 SurfaceId surface1_id(7u); | 1794 SurfaceId surface1_id(7u); |
2014 factory.Create(surface1_id); | 1795 factory.Create(surface1_id); |
2015 Surface* surface1 = manager_.GetSurfaceForId(surface1_id); | |
2016 | 1796 |
2017 SurfaceId surface2_id(8u); | 1797 SurfaceId surface2_id(8u); |
2018 factory.Create(surface2_id); | 1798 factory.Create(surface2_id); |
2019 Surface* surface2 = manager_.GetSurfaceForId(surface2_id); | |
2020 | 1799 |
2021 ResourceId ids[] = {11, 12, 13}; | 1800 ResourceId ids[] = {11, 12, 13}; |
2022 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1801 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
2023 &factory, surface1_id); | 1802 &factory, surface1_id); |
2024 ResourceId ids2[] = {14, 15, 16}; | 1803 ResourceId ids2[] = {14, 15, 16}; |
2025 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), | 1804 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(), |
2026 &factory, surface2_id); | 1805 &factory, surface2_id); |
2027 | 1806 |
2028 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface1)); | |
2029 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2)); | |
2030 | |
2031 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id); | 1807 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface1_id); |
2032 | 1808 |
2033 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface1)); | |
2034 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2)); | |
2035 | |
2036 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, | 1809 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory, |
2037 surface1_id); | 1810 surface1_id); |
2038 | 1811 |
2039 // Nothing should be available to be returned yet. | 1812 // Nothing should be available to be returned yet. |
2040 EXPECT_TRUE(client.returned_resources().empty()); | 1813 EXPECT_TRUE(client.returned_resources().empty()); |
2041 | 1814 |
2042 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface1)); | |
2043 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface2)); | |
2044 | |
2045 frame = aggregator_->Aggregate(surface2_id); | 1815 frame = aggregator_->Aggregate(surface2_id); |
2046 | 1816 |
2047 EXPECT_FALSE(surface_aggregator_client_.HasSurface(surface1)); | |
2048 EXPECT_TRUE(surface_aggregator_client_.HasSurface(surface2)); | |
2049 | |
2050 // surface1_id wasn't referenced, so its resources should be returned. | 1817 // surface1_id wasn't referenced, so its resources should be returned. |
2051 ASSERT_EQ(3u, client.returned_resources().size()); | 1818 ASSERT_EQ(3u, client.returned_resources().size()); |
2052 ResourceId returned_ids[3]; | 1819 ResourceId returned_ids[3]; |
2053 for (size_t i = 0; i < 3; ++i) { | 1820 for (size_t i = 0; i < 3; ++i) { |
2054 returned_ids[i] = client.returned_resources()[i].id; | 1821 returned_ids[i] = client.returned_resources()[i].id; |
2055 } | 1822 } |
2056 EXPECT_THAT(returned_ids, | 1823 EXPECT_THAT(returned_ids, |
2057 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1824 testing::WhenSorted(testing::ElementsAreArray(ids))); |
2058 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1825 EXPECT_EQ(3u, resource_provider_->num_resources()); |
2059 factory.Destroy(surface1_id); | 1826 factory.Destroy(surface1_id); |
2060 factory.Destroy(surface2_id); | 1827 factory.Destroy(surface2_id); |
2061 } | 1828 } |
2062 | 1829 |
2063 // Ensure that aggregator completely ignores Surfaces that reference invalid | 1830 // Ensure that aggregator completely ignores Surfaces that reference invalid |
2064 // resources. | 1831 // resources. |
2065 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 1832 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
2066 ResourceTrackingSurfaceFactoryClient client; | 1833 ResourceTrackingSurfaceFactoryClient client; |
2067 SurfaceFactory factory(&manager_, &client); | 1834 SurfaceFactory factory(&manager_, &client); |
2068 SurfaceId root_surface_id(7u); | 1835 SurfaceId root_surface_id(7u); |
2069 factory.Create(root_surface_id); | 1836 factory.Create(root_surface_id); |
2070 Surface* root_surface = manager_.GetSurfaceForId(root_surface_id); | |
2071 SurfaceId middle_surface_id(8u); | 1837 SurfaceId middle_surface_id(8u); |
2072 factory.Create(middle_surface_id); | 1838 factory.Create(middle_surface_id); |
2073 Surface* middle_surface = manager_.GetSurfaceForId(middle_surface_id); | |
2074 SurfaceId child_surface_id(9u); | 1839 SurfaceId child_surface_id(9u); |
2075 factory.Create(child_surface_id); | 1840 factory.Create(child_surface_id); |
2076 Surface* child_surface = manager_.GetSurfaceForId(child_surface_id); | |
2077 | 1841 |
2078 ResourceId ids[] = {14, 15, 16}; | 1842 ResourceId ids[] = {14, 15, 16}; |
2079 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), | 1843 SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(), |
2080 &factory, child_surface_id); | 1844 &factory, child_surface_id); |
2081 | 1845 |
2082 ResourceId ids2[] = {17, 18, 19}; | 1846 ResourceId ids2[] = {17, 18, 19}; |
2083 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, | 1847 SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false, |
2084 child_surface_id, &factory, | 1848 child_surface_id, &factory, |
2085 middle_surface_id); | 1849 middle_surface_id); |
2086 | 1850 |
2087 ResourceId ids3[] = {20, 21, 22}; | 1851 ResourceId ids3[] = {20, 21, 22}; |
2088 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, | 1852 SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true, |
2089 middle_surface_id, &factory, | 1853 middle_surface_id, &factory, |
2090 root_surface_id); | 1854 root_surface_id); |
2091 | 1855 |
2092 EXPECT_FALSE(surface_aggregator_client_.HasSurface(root_surface)); | |
2093 EXPECT_FALSE(surface_aggregator_client_.HasSurface(middle_surface)); | |
2094 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
2095 | |
2096 scoped_ptr<CompositorFrame> frame; | 1856 scoped_ptr<CompositorFrame> frame; |
2097 frame = aggregator_->Aggregate(root_surface_id); | 1857 frame = aggregator_->Aggregate(root_surface_id); |
2098 | 1858 |
2099 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface)); | |
2100 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
2101 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
2102 | |
2103 RenderPassList* pass_list = &frame->delegated_frame_data->render_pass_list; | 1859 RenderPassList* pass_list = &frame->delegated_frame_data->render_pass_list; |
2104 ASSERT_EQ(1u, pass_list->size()); | 1860 ASSERT_EQ(1u, pass_list->size()); |
2105 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); | 1861 EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size()); |
2106 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); | 1862 EXPECT_EQ(3u, pass_list->back()->quad_list.size()); |
2107 | 1863 |
2108 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, | 1864 SubmitCompositorFrameWithResources(ids2, arraysize(ids), true, |
2109 child_surface_id, &factory, | 1865 child_surface_id, &factory, |
2110 middle_surface_id); | 1866 middle_surface_id); |
2111 | 1867 |
2112 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface)); | |
2113 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
2114 EXPECT_FALSE(surface_aggregator_client_.HasSurface(child_surface)); | |
2115 | |
2116 frame = aggregator_->Aggregate(root_surface_id); | 1868 frame = aggregator_->Aggregate(root_surface_id); |
2117 | 1869 |
2118 EXPECT_TRUE(surface_aggregator_client_.HasSurface(root_surface)); | |
2119 EXPECT_TRUE(surface_aggregator_client_.HasSurface(middle_surface)); | |
2120 EXPECT_TRUE(surface_aggregator_client_.HasSurface(child_surface)); | |
2121 | |
2122 pass_list = &frame->delegated_frame_data->render_pass_list; | 1870 pass_list = &frame->delegated_frame_data->render_pass_list; |
2123 ASSERT_EQ(1u, pass_list->size()); | 1871 ASSERT_EQ(1u, pass_list->size()); |
2124 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 1872 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
2125 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 1873 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
2126 | 1874 |
2127 factory.Destroy(root_surface_id); | 1875 factory.Destroy(root_surface_id); |
2128 factory.Destroy(child_surface_id); | 1876 factory.Destroy(child_surface_id); |
2129 factory.Destroy(middle_surface_id); | 1877 factory.Destroy(middle_surface_id); |
2130 } | 1878 } |
2131 | 1879 |
2132 } // namespace | 1880 } // namespace |
2133 } // namespace cc | 1881 } // namespace cc |
2134 | 1882 |
OLD | NEW |