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

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

Issue 2831213004: cc: Reject CompositorFrames to old child surfaces (Closed)
Patch Set: Address Dana's comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/compositor_frame_sink_support.h" 5 #include "cc/surfaces/compositor_frame_sink_support.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" 9 #include "cc/surfaces/compositor_frame_sink_support_client.h"
10 #include "cc/surfaces/frame_sink_id.h" 10 #include "cc/surfaces/frame_sink_id.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 std::vector<SurfaceId> embedded_surfaces, 101 std::vector<SurfaceId> embedded_surfaces,
102 std::vector<SurfaceId> referenced_surfaces) { 102 std::vector<SurfaceId> referenced_surfaces) {
103 return MakeCompositorFrame(std::move(embedded_surfaces), 103 return MakeCompositorFrame(std::move(embedded_surfaces),
104 std::move(referenced_surfaces), 104 std::move(referenced_surfaces),
105 TransferableResourceArray()); 105 TransferableResourceArray());
106 } 106 }
107 107
108 CompositorFrame MakeCompositorFrameWithResources( 108 CompositorFrame MakeCompositorFrameWithResources(
109 std::vector<SurfaceId> embedded_surfaces, 109 std::vector<SurfaceId> embedded_surfaces,
110 TransferableResourceArray resource_list) { 110 TransferableResourceArray resource_list) {
111 return MakeCompositorFrame(embedded_surfaces, embedded_surfaces, 111 return MakeCompositorFrame(embedded_surfaces, empty_surface_ids(),
112 std::move(resource_list)); 112 std::move(resource_list));
113 } 113 }
114 114
115 TransferableResource MakeResource(ResourceId id, 115 TransferableResource MakeResource(ResourceId id,
116 ResourceFormat format, 116 ResourceFormat format,
117 uint32_t filter, 117 uint32_t filter,
118 const gfx::Size& size) { 118 const gfx::Size& size) {
119 TransferableResource resource; 119 TransferableResource resource;
120 resource.id = id; 120 resource.id = id;
121 resource.format = format; 121 resource.format = format;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 // The parent Surface is blocked on |child_id1| and |child_id2|. 285 // The parent Surface is blocked on |child_id1| and |child_id2|.
286 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) { 286 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) {
287 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 287 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
288 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 288 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
289 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 289 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
290 290
291 parent_support().SubmitCompositorFrame( 291 parent_support().SubmitCompositorFrame(
292 parent_id.local_surface_id(), 292 parent_id.local_surface_id(),
293 MakeCompositorFrame({child_id1, child_id2})); 293 MakeCompositorFrame({child_id1, child_id2}, empty_surface_ids()));
294 294
295 // parent_support is blocked on |child_id1| and |child_id2|. 295 // parent_support is blocked on |child_id1| and |child_id2|.
296 EXPECT_TRUE(dependency_tracker().has_deadline()); 296 EXPECT_TRUE(dependency_tracker().has_deadline());
297 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 297 EXPECT_FALSE(parent_surface()->HasActiveFrame());
298 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 298 EXPECT_TRUE(parent_surface()->HasPendingFrame());
299 EXPECT_THAT(parent_surface()->blocking_surfaces(), 299 EXPECT_THAT(parent_surface()->blocking_surfaces(),
300 UnorderedElementsAre(child_id1, child_id2)); 300 UnorderedElementsAre(child_id1, child_id2));
301 301
302 // Submit a CompositorFrame without any dependencies to |child_id1|. 302 // Submit a CompositorFrame without any dependencies to |child_id1|.
303 // parent_support should now only be blocked on |child_id2|. 303 // parent_support should now only be blocked on |child_id2|.
304 child_support1().SubmitCompositorFrame( 304 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(),
305 child_id1.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 305 MakeCompositorFrame());
306 306
307 EXPECT_TRUE(dependency_tracker().has_deadline()); 307 EXPECT_TRUE(dependency_tracker().has_deadline());
308 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 308 EXPECT_FALSE(parent_surface()->HasActiveFrame());
309 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 309 EXPECT_TRUE(parent_surface()->HasPendingFrame());
310 EXPECT_THAT(parent_surface()->blocking_surfaces(), 310 EXPECT_THAT(parent_surface()->blocking_surfaces(),
311 UnorderedElementsAre(child_id2)); 311 UnorderedElementsAre(child_id2));
312 312
313 // Submit a CompositorFrame without any dependencies to |child_id2|. 313 // Submit a CompositorFrame without any dependencies to |child_id2|.
314 // parent_support should be activated. 314 // parent_support should be activated.
315 child_support2().SubmitCompositorFrame( 315 child_support2().SubmitCompositorFrame(child_id2.local_surface_id(),
316 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 316 MakeCompositorFrame());
317 317
318 EXPECT_FALSE(dependency_tracker().has_deadline()); 318 EXPECT_FALSE(dependency_tracker().has_deadline());
319 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 319 EXPECT_TRUE(parent_surface()->HasActiveFrame());
320 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 320 EXPECT_FALSE(parent_surface()->HasPendingFrame());
321 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); 321 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
322 } 322 }
323 323
324 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. 324 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|.
325 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { 325 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) {
326 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 326 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
327 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 327 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
328 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 328 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
329 329
330 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 330 parent_support().SubmitCompositorFrame(
331 MakeCompositorFrame({child_id1})); 331 parent_id.local_surface_id(),
332 MakeCompositorFrame({child_id1}, empty_surface_ids()));
332 333
333 // parent_support is blocked on |child_id1|. 334 // parent_support is blocked on |child_id1|.
334 EXPECT_TRUE(dependency_tracker().has_deadline()); 335 EXPECT_TRUE(dependency_tracker().has_deadline());
335 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 336 EXPECT_FALSE(parent_surface()->HasActiveFrame());
336 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 337 EXPECT_TRUE(parent_surface()->HasPendingFrame());
337 EXPECT_THAT(parent_surface()->blocking_surfaces(), 338 EXPECT_THAT(parent_surface()->blocking_surfaces(),
338 UnorderedElementsAre(child_id1)); 339 UnorderedElementsAre(child_id1));
339 // The parent should not report damage until it activates. 340 // The parent should not report damage until it activates.
340 EXPECT_FALSE(IsSurfaceDamaged(parent_id)); 341 EXPECT_FALSE(IsSurfaceDamaged(parent_id));
341 342
342 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), 343 child_support1().SubmitCompositorFrame(
343 MakeCompositorFrame({child_id2})); 344 child_id1.local_surface_id(),
345 MakeCompositorFrame({child_id2}, empty_surface_ids()));
344 346
345 // child_support1 should now be blocked on |child_id2|. 347 // child_support1 should now be blocked on |child_id2|.
346 EXPECT_TRUE(dependency_tracker().has_deadline()); 348 EXPECT_TRUE(dependency_tracker().has_deadline());
347 EXPECT_FALSE(child_surface1()->HasActiveFrame()); 349 EXPECT_FALSE(child_surface1()->HasActiveFrame());
348 EXPECT_TRUE(child_surface1()->HasPendingFrame()); 350 EXPECT_TRUE(child_surface1()->HasPendingFrame());
349 EXPECT_THAT(child_surface1()->blocking_surfaces(), 351 EXPECT_THAT(child_surface1()->blocking_surfaces(),
350 UnorderedElementsAre(child_id2)); 352 UnorderedElementsAre(child_id2));
351 // The parent and child should not report damage until they activate. 353 // The parent and child should not report damage until they activate.
352 EXPECT_FALSE(IsSurfaceDamaged(parent_id)); 354 EXPECT_FALSE(IsSurfaceDamaged(parent_id));
353 EXPECT_FALSE(IsSurfaceDamaged(child_id1)); 355 EXPECT_FALSE(IsSurfaceDamaged(child_id1));
(...skipping 26 matching lines...) Expand all
380 EXPECT_TRUE(IsSurfaceDamaged(child_id2)); 382 EXPECT_TRUE(IsSurfaceDamaged(child_id2));
381 } 383 }
382 384
383 // parent_surface and child_surface1 are blocked on |child_id2|. 385 // parent_surface and child_surface1 are blocked on |child_id2|.
384 TEST_F(CompositorFrameSinkSupportTest, 386 TEST_F(CompositorFrameSinkSupportTest,
385 DisplayCompositorLockingTwoBlockedOnOne) { 387 DisplayCompositorLockingTwoBlockedOnOne) {
386 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 388 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
387 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 389 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
388 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 390 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
389 391
390 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 392 parent_support().SubmitCompositorFrame(
391 MakeCompositorFrame({child_id2})); 393 parent_id.local_surface_id(),
394 MakeCompositorFrame({child_id2}, empty_surface_ids()));
392 395
393 // parent_support is blocked on |child_id2|. 396 // parent_support is blocked on |child_id2|.
394 EXPECT_TRUE(dependency_tracker().has_deadline()); 397 EXPECT_TRUE(dependency_tracker().has_deadline());
395 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 398 EXPECT_FALSE(parent_surface()->HasActiveFrame());
396 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 399 EXPECT_TRUE(parent_surface()->HasPendingFrame());
397 EXPECT_THAT(parent_surface()->blocking_surfaces(), 400 EXPECT_THAT(parent_surface()->blocking_surfaces(),
398 UnorderedElementsAre(child_id2)); 401 UnorderedElementsAre(child_id2));
399 402
400 // child_support1 should now be blocked on |child_id2|. 403 // child_support1 should now be blocked on |child_id2|.
401 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), 404 child_support1().SubmitCompositorFrame(
402 MakeCompositorFrame({child_id2})); 405 child_id1.local_surface_id(),
406 MakeCompositorFrame({child_id2}, empty_surface_ids()));
403 407
404 EXPECT_TRUE(dependency_tracker().has_deadline()); 408 EXPECT_TRUE(dependency_tracker().has_deadline());
405 EXPECT_FALSE(child_surface1()->HasActiveFrame()); 409 EXPECT_FALSE(child_surface1()->HasActiveFrame());
406 EXPECT_TRUE(child_surface1()->HasPendingFrame()); 410 EXPECT_TRUE(child_surface1()->HasPendingFrame());
407 EXPECT_THAT(child_surface1()->blocking_surfaces(), 411 EXPECT_THAT(child_surface1()->blocking_surfaces(),
408 UnorderedElementsAre(child_id2)); 412 UnorderedElementsAre(child_id2));
409 413
410 // The parent should still be blocked on |child_id2|. 414 // The parent should still be blocked on |child_id2|.
411 EXPECT_THAT(parent_surface()->blocking_surfaces(), 415 EXPECT_THAT(parent_surface()->blocking_surfaces(),
412 UnorderedElementsAre(child_id2)); 416 UnorderedElementsAre(child_id2));
413 417
414 // Submit a CompositorFrame without any dependencies to |child_id2|. 418 // Submit a CompositorFrame without any dependencies to |child_id2|.
415 // parent_support should be activated. 419 // parent_support should be activated.
416 child_support2().SubmitCompositorFrame( 420 child_support2().SubmitCompositorFrame(child_id2.local_surface_id(),
417 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 421 MakeCompositorFrame());
418 422
419 EXPECT_FALSE(dependency_tracker().has_deadline()); 423 EXPECT_FALSE(dependency_tracker().has_deadline());
420 424
421 // child_surface1 should now be active. 425 // child_surface1 should now be active.
422 EXPECT_TRUE(child_surface1()->HasActiveFrame()); 426 EXPECT_TRUE(child_surface1()->HasActiveFrame());
423 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 427 EXPECT_FALSE(child_surface1()->HasPendingFrame());
424 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); 428 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty());
425 429
426 // parent_surface should now be active. 430 // parent_surface should now be active.
427 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 431 EXPECT_TRUE(parent_surface()->HasActiveFrame());
428 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 432 EXPECT_FALSE(parent_surface()->HasPendingFrame());
429 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); 433 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
430 } 434 }
431 435
432 // parent_surface is blocked on |child_id1|, and child_surface2 is blocked on 436 // parent_surface is blocked on |child_id1|, and child_surface2 is blocked on
433 // |child_id2| until the deadline hits. 437 // |child_id2| until the deadline hits.
434 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) { 438 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) {
435 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 439 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
436 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 440 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
437 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 441 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
438 442
439 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 443 parent_support().SubmitCompositorFrame(
440 MakeCompositorFrame({child_id1})); 444 parent_id.local_surface_id(),
445 MakeCompositorFrame({child_id1}, empty_surface_ids()));
441 446
442 // parent_support is blocked on |child_id1|. 447 // parent_support is blocked on |child_id1|.
443 EXPECT_TRUE(dependency_tracker().has_deadline()); 448 EXPECT_TRUE(dependency_tracker().has_deadline());
444 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 449 EXPECT_FALSE(parent_surface()->HasActiveFrame());
445 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 450 EXPECT_TRUE(parent_surface()->HasPendingFrame());
446 EXPECT_THAT(parent_surface()->blocking_surfaces(), 451 EXPECT_THAT(parent_surface()->blocking_surfaces(),
447 UnorderedElementsAre(child_id1)); 452 UnorderedElementsAre(child_id1));
448 453
449 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), 454 child_support1().SubmitCompositorFrame(
450 MakeCompositorFrame({child_id2})); 455 child_id1.local_surface_id(),
456 MakeCompositorFrame({child_id2}, empty_surface_ids()));
451 457
452 // child_support1 should now be blocked on |child_id2|. 458 // child_support1 should now be blocked on |child_id2|.
453 EXPECT_TRUE(dependency_tracker().has_deadline()); 459 EXPECT_TRUE(dependency_tracker().has_deadline());
454 EXPECT_FALSE(child_surface1()->HasActiveFrame()); 460 EXPECT_FALSE(child_surface1()->HasActiveFrame());
455 EXPECT_TRUE(child_surface1()->HasPendingFrame()); 461 EXPECT_TRUE(child_surface1()->HasPendingFrame());
456 EXPECT_THAT(child_surface1()->blocking_surfaces(), 462 EXPECT_THAT(child_surface1()->blocking_surfaces(),
457 UnorderedElementsAre(child_id2)); 463 UnorderedElementsAre(child_id2));
458 464
459 // The parent should still be blocked on |child_id1| because it's pending. 465 // The parent should still be blocked on |child_id1| because it's pending.
460 EXPECT_THAT(parent_surface()->blocking_surfaces(), 466 EXPECT_THAT(parent_surface()->blocking_surfaces(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 505
500 // Verifies that the deadline does not reset if we submit CompositorFrames 506 // Verifies that the deadline does not reset if we submit CompositorFrames
501 // to new Surfaces with unresolved dependencies. 507 // to new Surfaces with unresolved dependencies.
502 TEST_F(CompositorFrameSinkSupportTest, 508 TEST_F(CompositorFrameSinkSupportTest,
503 DisplayCompositorLockingFramesSubmittedAfterDeadlineSet) { 509 DisplayCompositorLockingFramesSubmittedAfterDeadlineSet) {
504 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); 510 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1);
505 BeginFrameArgs args = 511 BeginFrameArgs args =
506 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); 512 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
507 for (int i = 0; i < 3; ++i) { 513 for (int i = 0; i < 3; ++i) {
508 LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); 514 LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create());
509 support(i).SubmitCompositorFrame(local_surface_id, 515 support(i).SubmitCompositorFrame(
510 MakeCompositorFrame({arbitrary_id})); 516 local_surface_id,
517 MakeCompositorFrame({arbitrary_id}, empty_surface_ids()));
511 // The deadline has been set. 518 // The deadline has been set.
512 EXPECT_TRUE(dependency_tracker().has_deadline()); 519 EXPECT_TRUE(dependency_tracker().has_deadline());
513 520
514 // support(i) should be blocked on arbitrary_id. 521 // support(i) should be blocked on arbitrary_id.
515 EXPECT_FALSE(surface(i)->HasActiveFrame()); 522 EXPECT_FALSE(surface(i)->HasActiveFrame());
516 EXPECT_TRUE(surface(i)->HasPendingFrame()); 523 EXPECT_TRUE(surface(i)->HasPendingFrame());
517 EXPECT_THAT(surface(i)->blocking_surfaces(), 524 EXPECT_THAT(surface(i)->blocking_surfaces(),
518 UnorderedElementsAre(arbitrary_id)); 525 UnorderedElementsAre(arbitrary_id));
519 526
520 // Issue a BeginFrame to get closer to the deadline. 527 // Issue a BeginFrame to get closer to the deadline.
(...skipping 10 matching lines...) Expand all
531 } 538 }
532 539
533 // This test verifies at the Surface activates once a CompositorFrame is 540 // This test verifies at the Surface activates once a CompositorFrame is
534 // submitted that has no unresolved dependencies. 541 // submitted that has no unresolved dependencies.
535 TEST_F(CompositorFrameSinkSupportTest, 542 TEST_F(CompositorFrameSinkSupportTest,
536 DisplayCompositorLockingNewFrameOverridesOldDependencies) { 543 DisplayCompositorLockingNewFrameOverridesOldDependencies) {
537 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 544 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
538 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); 545 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1);
539 546
540 // Submit a CompositorFrame that depends on |arbitrary_id|. 547 // Submit a CompositorFrame that depends on |arbitrary_id|.
541 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 548 parent_support().SubmitCompositorFrame(
542 MakeCompositorFrame({arbitrary_id})); 549 parent_id.local_surface_id(),
550 MakeCompositorFrame({arbitrary_id}, empty_surface_ids()));
543 551
544 // Verify that the CompositorFrame is blocked on |arbitrary_id|. 552 // Verify that the CompositorFrame is blocked on |arbitrary_id|.
545 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 553 EXPECT_FALSE(parent_surface()->HasActiveFrame());
546 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 554 EXPECT_TRUE(parent_surface()->HasPendingFrame());
547 EXPECT_THAT(parent_surface()->blocking_surfaces(), 555 EXPECT_THAT(parent_surface()->blocking_surfaces(),
548 UnorderedElementsAre(arbitrary_id)); 556 UnorderedElementsAre(arbitrary_id));
549 557
550 // Submit a CompositorFrame that has no dependencies. 558 // Submit a CompositorFrame that has no dependencies.
551 parent_support().SubmitCompositorFrame( 559 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
552 parent_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 560 MakeCompositorFrame());
553 561
554 // Verify that the CompositorFrame has been activated. 562 // Verify that the CompositorFrame has been activated.
555 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 563 EXPECT_TRUE(parent_surface()->HasActiveFrame());
556 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 564 EXPECT_FALSE(parent_surface()->HasPendingFrame());
557 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); 565 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
558 } 566 }
559 567
560 // This test verifies that a pending CompositorFrame does not affect surface 568 // This test verifies that a pending CompositorFrame does not affect surface
561 // references. A new surface from a child will continue to exist as a temporary 569 // references. A new surface from a child will continue to exist as a temporary
562 // reference until the parent's frame activates. 570 // reference until the parent's frame activates.
(...skipping 19 matching lines...) Expand all
582 EXPECT_TRUE(HasTemporaryReference(child_id1)); 590 EXPECT_TRUE(HasTemporaryReference(child_id1));
583 591
584 // parent_support submits a CompositorFrame that depends on |child_id1| 592 // parent_support submits a CompositorFrame that depends on |child_id1|
585 // (which is already active) and |child_id2|. Thus, the parent should not 593 // (which is already active) and |child_id2|. Thus, the parent should not
586 // activate immediately. DidReceiveCompositorFrameAck should not be called 594 // activate immediately. DidReceiveCompositorFrameAck should not be called
587 // immediately because the parent CompositorFrame is also blocked on 595 // immediately because the parent CompositorFrame is also blocked on
588 // |child_id2|. 596 // |child_id2|.
589 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); 597 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0);
590 parent_support().SubmitCompositorFrame( 598 parent_support().SubmitCompositorFrame(
591 parent_id.local_surface_id(), 599 parent_id.local_surface_id(),
592 MakeCompositorFrame({child_id1, child_id2})); 600 MakeCompositorFrame({child_id2}, {child_id1}));
593 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 601 EXPECT_FALSE(parent_surface()->HasActiveFrame());
594 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 602 EXPECT_TRUE(parent_surface()->HasPendingFrame());
595 EXPECT_THAT(parent_surface()->blocking_surfaces(), 603 EXPECT_THAT(parent_surface()->blocking_surfaces(),
596 UnorderedElementsAre(child_id2)); 604 UnorderedElementsAre(child_id2));
597 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty()); 605 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty());
598 testing::Mock::VerifyAndClearExpectations(&support_client_); 606 testing::Mock::VerifyAndClearExpectations(&support_client_);
599 607
600 // Verify that there's a temporary reference for |child_id1| that still 608 // Verify that there's a temporary reference for |child_id1| that still
601 // exists. 609 // exists.
602 EXPECT_TRUE(HasTemporaryReference(child_id1)); 610 EXPECT_TRUE(HasTemporaryReference(child_id1));
(...skipping 10 matching lines...) Expand all
613 EXPECT_TRUE(child_surface1()->HasActiveFrame()); 621 EXPECT_TRUE(child_surface1()->HasActiveFrame());
614 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 622 EXPECT_FALSE(child_surface1()->HasPendingFrame());
615 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); 623 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty());
616 624
617 // Verify that the parent surface's CompositorFrame has activated and that the 625 // Verify that the parent surface's CompositorFrame has activated and that the
618 // temporary reference has been replaced by a permanent one. 626 // temporary reference has been replaced by a permanent one.
619 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 627 EXPECT_TRUE(parent_surface()->HasActiveFrame());
620 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 628 EXPECT_FALSE(parent_surface()->HasPendingFrame());
621 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); 629 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
622 EXPECT_FALSE(HasTemporaryReference(child_id1)); 630 EXPECT_FALSE(HasTemporaryReference(child_id1));
623 EXPECT_THAT(GetChildReferences(parent_id), 631 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1));
624 UnorderedElementsAre(child_id1, child_id2));
625 } 632 }
626 633
627 // This test verifies that we do not double count returned resources when a 634 // This test verifies that we do not double count returned resources when a
628 // CompositorFrame starts out as pending, then becomes active, and then is 635 // CompositorFrame starts out as pending, then becomes active, and then is
629 // replaced with another active CompositorFrame. 636 // replaced with another active CompositorFrame.
630 TEST_F(CompositorFrameSinkSupportTest, 637 TEST_F(CompositorFrameSinkSupportTest,
631 DisplayCompositorLockingResourcesOnlyReturnedOnce) { 638 DisplayCompositorLockingResourcesOnlyReturnedOnce) {
632 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 639 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
633 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); 640 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
634 641
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 684
678 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. 685 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|.
679 // child_support1 evicts its blocked Surface. The parent surface should 686 // child_support1 evicts its blocked Surface. The parent surface should
680 // activate. 687 // activate.
681 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { 688 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) {
682 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 689 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
683 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 690 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
684 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 691 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
685 692
686 // Submit a CompositorFrame that depends on |child_id1|. 693 // Submit a CompositorFrame that depends on |child_id1|.
687 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 694 parent_support().SubmitCompositorFrame(
688 MakeCompositorFrame({child_id1})); 695 parent_id1.local_surface_id(),
696 MakeCompositorFrame({child_id1}, empty_surface_ids()));
689 697
690 // Verify that the CompositorFrame is blocked on |child_id1|. 698 // Verify that the CompositorFrame is blocked on |child_id1|.
691 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 699 EXPECT_FALSE(parent_surface()->HasActiveFrame());
692 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 700 EXPECT_TRUE(parent_surface()->HasPendingFrame());
693 EXPECT_THAT(parent_surface()->blocking_surfaces(), 701 EXPECT_THAT(parent_surface()->blocking_surfaces(),
694 UnorderedElementsAre(child_id1)); 702 UnorderedElementsAre(child_id1));
695 703
696 // Submit a CompositorFrame that depends on |child_id2|. 704 // Submit a CompositorFrame that depends on |child_id2|.
697 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), 705 child_support1().SubmitCompositorFrame(
698 MakeCompositorFrame({child_id2})); 706 child_id1.local_surface_id(),
707 MakeCompositorFrame({child_id2}, empty_surface_ids()));
699 708
700 // Verify that the CompositorFrame is blocked on |child_id2|. 709 // Verify that the CompositorFrame is blocked on |child_id2|.
701 EXPECT_FALSE(child_surface1()->HasActiveFrame()); 710 EXPECT_FALSE(child_surface1()->HasActiveFrame());
702 EXPECT_TRUE(child_surface1()->HasPendingFrame()); 711 EXPECT_TRUE(child_surface1()->HasPendingFrame());
703 EXPECT_THAT(child_surface1()->blocking_surfaces(), 712 EXPECT_THAT(child_surface1()->blocking_surfaces(),
704 UnorderedElementsAre(child_id2)); 713 UnorderedElementsAre(child_id2));
705 714
706 // Evict child_support1's current Surface. 715 // Evict child_support1's current Surface.
707 // TODO(fsamuel): EvictFrame => EvictCurrentSurface. 716 // TODO(fsamuel): EvictFrame => EvictCurrentSurface.
708 child_support1().EvictFrame(); 717 child_support1().EvictFrame();
(...skipping 11 matching lines...) Expand all
720 // updated allowing garbage collection of surfaces that are no longer 729 // updated allowing garbage collection of surfaces that are no longer
721 // referenced. 730 // referenced.
722 TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { 731 TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) {
723 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 732 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
724 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 733 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
725 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 734 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
726 735
727 // The parent submits a CompositorFrame that depends on |child_id1| before the 736 // The parent submits a CompositorFrame that depends on |child_id1| before the
728 // child submits a CompositorFrame. 737 // child submits a CompositorFrame.
729 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); 738 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0);
730 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 739 parent_support().SubmitCompositorFrame(
731 MakeCompositorFrame({child_id1})); 740 parent_id.local_surface_id(),
741 MakeCompositorFrame({child_id1}, empty_surface_ids()));
732 742
733 // Verify that the CompositorFrame is blocked on |child_id|. 743 // Verify that the CompositorFrame is blocked on |child_id|.
734 EXPECT_FALSE(parent_surface()->HasActiveFrame()); 744 EXPECT_FALSE(parent_surface()->HasActiveFrame());
735 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 745 EXPECT_TRUE(parent_surface()->HasPendingFrame());
736 EXPECT_THAT(parent_surface()->blocking_surfaces(), 746 EXPECT_THAT(parent_surface()->blocking_surfaces(),
737 UnorderedElementsAre(child_id1)); 747 UnorderedElementsAre(child_id1));
738 testing::Mock::VerifyAndClearExpectations(&support_client_); 748 testing::Mock::VerifyAndClearExpectations(&support_client_);
739 749
740 // Verify that no references are added while the CompositorFrame is pending. 750 // Verify that no references are added while the CompositorFrame is pending.
741 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty()); 751 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty());
742 752
743 // DidReceiveCompositorFrameAck should get called twice: once for the child 753 // DidReceiveCompositorFrameAck should get called twice: once for the child
744 // and once for the now active parent CompositorFrame. 754 // and once for the now active parent CompositorFrame.
745 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(2); 755 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(2);
746 child_support1().SubmitCompositorFrame( 756 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(),
747 child_id1.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 757 MakeCompositorFrame());
748 testing::Mock::VerifyAndClearExpectations(&support_client_); 758 testing::Mock::VerifyAndClearExpectations(&support_client_);
749 759
750 // Verify that the child CompositorFrame activates immediately. 760 // Verify that the child CompositorFrame activates immediately.
751 EXPECT_TRUE(child_surface1()->HasActiveFrame()); 761 EXPECT_TRUE(child_surface1()->HasActiveFrame());
752 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 762 EXPECT_FALSE(child_surface1()->HasPendingFrame());
753 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); 763 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty());
754 764
755 // Verify that the parent Surface has activated. 765 // Verify that the parent Surface has activated.
756 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 766 EXPECT_TRUE(parent_surface()->HasActiveFrame());
757 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 767 EXPECT_FALSE(parent_surface()->HasPendingFrame());
758 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); 768 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
759 769
770 // Submit a new parent CompositorFrame to add a reference.
771 parent_support().SubmitCompositorFrame(
772 parent_id.local_surface_id(),
773 MakeCompositorFrame(empty_surface_ids(), {child_id1}));
774
775 // Verify that the parent Surface has activated.
776 EXPECT_TRUE(parent_surface()->HasActiveFrame());
777 EXPECT_FALSE(parent_surface()->HasPendingFrame());
778 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
779
760 // Verify that there is no temporary reference for the child and that 780 // Verify that there is no temporary reference for the child and that
761 // the reference from the parent to the child still exists. 781 // the reference from the parent to the child still exists.
762 EXPECT_FALSE(HasTemporaryReference(child_id1)); 782 EXPECT_FALSE(HasTemporaryReference(child_id1));
763 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); 783 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1));
764 784
765 // The parent submits another CompositorFrame that depends on |child_id2|. 785 // The parent submits another CompositorFrame that depends on |child_id2|.
766 // Submitting a pending CompositorFrame will not trigger a CompositorFrameAck. 786 // Submitting a pending CompositorFrame will not trigger a CompositorFrameAck.
767 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); 787 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0);
768 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 788 parent_support().SubmitCompositorFrame(
769 MakeCompositorFrame({child_id2})); 789 parent_id.local_surface_id(),
790 MakeCompositorFrame({child_id2}, empty_surface_ids()));
770 testing::Mock::VerifyAndClearExpectations(&support_client_); 791 testing::Mock::VerifyAndClearExpectations(&support_client_);
771 792
772 // The parent surface should now have both a pending and activate 793 // The parent surface should now have both a pending and activate
773 // CompositorFrame. Verify that the set of child references from 794 // CompositorFrame. Verify that the set of child references from
774 // |parent_id| are only from the active CompositorFrame. 795 // |parent_id| are only from the active CompositorFrame.
775 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 796 EXPECT_TRUE(parent_surface()->HasActiveFrame());
776 EXPECT_TRUE(parent_surface()->HasPendingFrame()); 797 EXPECT_TRUE(parent_surface()->HasPendingFrame());
777 EXPECT_THAT(parent_surface()->blocking_surfaces(), 798 EXPECT_THAT(parent_surface()->blocking_surfaces(),
778 UnorderedElementsAre(child_id2)); 799 UnorderedElementsAre(child_id2));
779 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); 800 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1));
780 801
781 child_support2().SubmitCompositorFrame( 802 child_support2().SubmitCompositorFrame(child_id2.local_surface_id(),
782 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 803 MakeCompositorFrame());
783 804
784 // Verify that the parent Surface has activated and no longer has a pending 805 // Verify that the parent Surface has activated and no longer has a pending
785 // CompositorFrame. Also verify that |child_id1| is no longer a child 806 // CompositorFrame. Also verify that |child_id1| is no longer a child
786 // reference of |parent_id|. 807 // reference of |parent_id|.
787 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 808 EXPECT_TRUE(parent_surface()->HasActiveFrame());
788 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 809 EXPECT_FALSE(parent_surface()->HasPendingFrame());
789 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); 810 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty());
790 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); 811 // The parent will not immediately refer to the child until it submits a new
812 // CompositorFrame with the reference.
813 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty());
791 } 814 }
792 815
793 // Checks whether the latency info are moved to the new surface from the old 816 // Checks whether the latency info are moved to the new surface from the old
794 // one when LocalSurfaceId changes. No frame has unresolved dependencies. 817 // one when LocalSurfaceId changes. No frame has unresolved dependencies.
795 TEST_F(CompositorFrameSinkSupportTest, 818 TEST_F(CompositorFrameSinkSupportTest,
796 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { 819 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) {
797 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 820 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
798 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 821 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
799 const ui::LatencyComponentType latency_type1 = 822 const ui::LatencyComponentType latency_type1 =
800 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; 823 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 CompositorFrame frame = MakeCompositorFrame(); 906 CompositorFrame frame = MakeCompositorFrame();
884 frame.metadata.latency_info.push_back(info); 907 frame.metadata.latency_info.push_back(info);
885 908
886 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 909 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
887 std::move(frame)); 910 std::move(frame));
888 911
889 // Submit a frame with unresolved dependencies. 912 // Submit a frame with unresolved dependencies.
890 ui::LatencyInfo info2; 913 ui::LatencyInfo info2;
891 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 914 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
892 915
893 CompositorFrame frame2 = MakeCompositorFrame({child_id}); 916 CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids());
894 frame2.metadata.latency_info.push_back(info2); 917 frame2.metadata.latency_info.push_back(info2);
895 918
896 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 919 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
897 std::move(frame2)); 920 std::move(frame2));
898 921
899 // Verify that the old surface has both an active and a pending frame. 922 // Verify that the old surface has both an active and a pending frame.
900 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 923 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
901 ASSERT_NE(nullptr, old_surface); 924 ASSERT_NE(nullptr, old_surface);
902 EXPECT_TRUE(old_surface->HasActiveFrame()); 925 EXPECT_TRUE(old_surface->HasActiveFrame());
903 EXPECT_TRUE(old_surface->HasPendingFrame()); 926 EXPECT_TRUE(old_surface->HasPendingFrame());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 989 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
967 ASSERT_NE(nullptr, old_surface); 990 ASSERT_NE(nullptr, old_surface);
968 EXPECT_TRUE(old_surface->HasActiveFrame()); 991 EXPECT_TRUE(old_surface->HasActiveFrame());
969 EXPECT_FALSE(old_surface->HasPendingFrame()); 992 EXPECT_FALSE(old_surface->HasPendingFrame());
970 993
971 // Submit a frame with a new local surface id and with unresolved 994 // Submit a frame with a new local surface id and with unresolved
972 // dependencies. 995 // dependencies.
973 ui::LatencyInfo info2; 996 ui::LatencyInfo info2;
974 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 997 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
975 998
976 CompositorFrame frame2 = MakeCompositorFrame({child_id}); 999 CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids());
977 frame2.metadata.latency_info.push_back(info2); 1000 frame2.metadata.latency_info.push_back(info2);
978 1001
979 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 1002 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
980 std::move(frame2)); 1003 std::move(frame2));
981 1004
982 // Verify that the new surface has a pending frame and no active frame. 1005 // Verify that the new surface has a pending frame and no active frame.
983 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); 1006 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
984 ASSERT_NE(nullptr, surface); 1007 ASSERT_NE(nullptr, surface);
985 EXPECT_TRUE(surface->HasPendingFrame()); 1008 EXPECT_TRUE(surface->HasPendingFrame());
986 EXPECT_FALSE(surface->HasActiveFrame()); 1009 EXPECT_FALSE(surface->HasActiveFrame());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 1085 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1063 MakeCompositorFrame()); 1086 MakeCompositorFrame());
1064 } 1087 }
1065 1088
1066 // Verifies that if a surface is marked destroyed and a new frame arrives for 1089 // Verifies that if a surface is marked destroyed and a new frame arrives for
1067 // it, it will be recovered. 1090 // it, it will be recovered.
1068 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { 1091 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) {
1069 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 1092 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1070 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); 1093 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
1071 1094
1072 // Add a reference from the parent to the child.
1073 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1074 MakeCompositorFrame({child_id}));
1075
1076 // Create the child surface by submitting a frame to it. 1095 // Create the child surface by submitting a frame to it.
1077 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); 1096 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id));
1078 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1097 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1079 MakeCompositorFrame()); 1098 MakeCompositorFrame());
1080 1099
1081 // Verify that the child surface is created. 1100 // Verify that the child surface is created.
1082 Surface* surface = surface_manager().GetSurfaceForId(child_id); 1101 Surface* surface = surface_manager().GetSurfaceForId(child_id);
1083 EXPECT_NE(nullptr, surface); 1102 EXPECT_NE(nullptr, surface);
1084 1103
1104 // Add a reference from the parent to the child.
1105 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1106 MakeCompositorFrame({child_id}));
1107
1085 // Attempt to destroy the child surface. The surface must still exist since 1108 // Attempt to destroy the child surface. The surface must still exist since
1086 // the parent needs it but it will be marked as destroyed. 1109 // the parent needs it but it will be marked as destroyed.
1087 child_support1().EvictFrame(); 1110 child_support1().EvictFrame();
1088 surface = surface_manager().GetSurfaceForId(child_id); 1111 surface = surface_manager().GetSurfaceForId(child_id);
1089 EXPECT_NE(nullptr, surface); 1112 EXPECT_NE(nullptr, surface);
1090 EXPECT_TRUE(surface->destroyed()); 1113 EXPECT_TRUE(surface->destroyed());
1091 1114
1092 // Child submits another frame to the same local surface id that is marked 1115 // Child submits another frame to the same local surface id that is marked
1093 // destroyed. 1116 // destroyed.
1094 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1117 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1095 MakeCompositorFrame()); 1118 MakeCompositorFrame());
1096 1119
1097 // Verify that the surface that was marked destroyed is recovered and is being 1120 // Verify that the surface that was marked destroyed is recovered and is being
1098 // used again. 1121 // used again.
1099 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); 1122 Surface* surface2 = surface_manager().GetSurfaceForId(child_id);
1100 EXPECT_EQ(surface, surface2); 1123 EXPECT_EQ(surface, surface2);
1101 EXPECT_FALSE(surface2->destroyed()); 1124 EXPECT_FALSE(surface2->destroyed());
1102 } 1125 }
1103 1126
1104 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist 1127 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist
1105 // anymore, it can still be reused for new surfaces. 1128 // anymore, it can still be reused for new surfaces.
1106 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { 1129 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) {
1107 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 1130 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1108 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); 1131 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
1109 1132
1110 // Add a reference from parent.
1111 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1112 MakeCompositorFrame({child_id}));
1113
1114 // Submit the first frame. Creates the surface. 1133 // Submit the first frame. Creates the surface.
1115 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1134 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1116 MakeCompositorFrame()); 1135 MakeCompositorFrame());
1117 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); 1136 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id));
1118 1137
1138 // Add a reference from parent.
1139 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1140 MakeCompositorFrame({child_id}));
1141
1119 // Remove the reference from parant. This allows us to destroy the surface. 1142 // Remove the reference from parant. This allows us to destroy the surface.
1120 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 1143 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1121 MakeCompositorFrame()); 1144 MakeCompositorFrame());
1122 1145
1123 // Destroy the surface. 1146 // Destroy the surface.
1124 child_support1().EvictFrame(); 1147 child_support1().EvictFrame();
1125 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); 1148 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id));
1126 1149
1127 // Submit another frame with the same local surface id. This should work fine 1150 // Submit another frame with the same local surface id. This should work fine
1128 // and a new surface must be created. 1151 // and a new surface must be created.
1129 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1152 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1130 MakeCompositorFrame()); 1153 MakeCompositorFrame());
1131 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); 1154 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id));
1132 } 1155 }
1133 1156
1134 // This test verifies that a crash does not occur if garbage collection is 1157 // This test verifies that a crash does not occur if garbage collection is
1135 // triggered during surface dependency resolution. This test triggers garbage 1158 // triggered during surface dependency resolution. This test triggers garbage
1136 // collection during surface resolution, by causing an activation to remove 1159 // collection during surface resolution, by causing an activation to remove
1137 // a surface subtree from the root. Both the old subtree and the new 1160 // a surface subtree from the root. Both the old subtree and the new
1138 // activated subtree refer to the same dependency. The old subtree was activated 1161 // activated subtree refer to the same dependency. The old subtree was activated
1139 // by deadline, and the new subtree was activated by a dependency finally 1162 // by deadline, and the new subtree was activated by a dependency finally
1140 // resolving. 1163 // resolving.
1141 TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { 1164 TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) {
1142 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); 1165 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1);
1143 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 1166 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
1144 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 1167 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
1145 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); 1168 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
1146 1169
1147 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 1170 parent_support().SubmitCompositorFrame(
1148 MakeCompositorFrame({child_id})); 1171 parent_id1.local_surface_id(),
1149 display_support().SubmitCompositorFrame(display_id.local_surface_id(), 1172 MakeCompositorFrame({child_id}, empty_surface_ids()));
1150 MakeCompositorFrame({parent_id1})); 1173 display_support().SubmitCompositorFrame(
1174 display_id.local_surface_id(),
1175 MakeCompositorFrame({parent_id1}, empty_surface_ids()));
1151 1176
1152 EXPECT_TRUE(dependency_tracker().has_deadline()); 1177 EXPECT_TRUE(dependency_tracker().has_deadline());
1153 1178
1154 BeginFrameArgs args = 1179 BeginFrameArgs args =
1155 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); 1180 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
1156 1181
1157 // Advance BeginFrames to trigger a deadline. 1182 // Advance BeginFrames to trigger a deadline.
1158 for (int i = 0; i < 3; ++i) { 1183 for (int i = 0; i < 3; ++i) {
1159 begin_frame_source()->TestOnBeginFrame(args); 1184 begin_frame_source()->TestOnBeginFrame(args);
1160 EXPECT_TRUE(dependency_tracker().has_deadline()); 1185 EXPECT_TRUE(dependency_tracker().has_deadline());
1161 } 1186 }
1162 begin_frame_source()->TestOnBeginFrame(args); 1187 begin_frame_source()->TestOnBeginFrame(args);
1163 EXPECT_FALSE(dependency_tracker().has_deadline()); 1188 EXPECT_FALSE(dependency_tracker().has_deadline());
1164 1189
1165 EXPECT_TRUE(display_surface()->HasActiveFrame()); 1190 EXPECT_TRUE(display_surface()->HasActiveFrame());
1166 EXPECT_FALSE(display_surface()->HasPendingFrame()); 1191 EXPECT_FALSE(display_surface()->HasPendingFrame());
1167 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 1192 EXPECT_TRUE(parent_surface()->HasActiveFrame());
1168 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 1193 EXPECT_FALSE(parent_surface()->HasPendingFrame());
1169 1194
1170 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 1195 parent_support().SubmitCompositorFrame(
1171 MakeCompositorFrame({child_id})); 1196 parent_id2.local_surface_id(),
1172 display_support().SubmitCompositorFrame(display_id.local_surface_id(), 1197 MakeCompositorFrame({child_id}, empty_surface_ids()));
1173 MakeCompositorFrame({parent_id2})); 1198 display_support().SubmitCompositorFrame(
1199 display_id.local_surface_id(),
1200 MakeCompositorFrame({parent_id2}, empty_surface_ids()));
1174 1201
1175 // The display surface now has two CompositorFrames. One that is pending, 1202 // The display surface now has two CompositorFrames. One that is pending,
1176 // indirectly blocked on child_id and one that is active, also indirectly 1203 // indirectly blocked on child_id and one that is active, also indirectly
1177 // referring to child_id, but activated due to the deadline above. 1204 // referring to child_id, but activated due to the deadline above.
1178 EXPECT_TRUE(display_surface()->HasActiveFrame()); 1205 EXPECT_TRUE(display_surface()->HasActiveFrame());
1179 EXPECT_TRUE(display_surface()->HasPendingFrame()); 1206 EXPECT_TRUE(display_surface()->HasPendingFrame());
1180 1207
1181 // Submitting a CompositorFrame will trigger garbage collection of the 1208 // Submitting a CompositorFrame will trigger garbage collection of the
1182 // |parent_id1| subtree. This should not crash. 1209 // |parent_id1| subtree. This should not crash.
1183 child_support1().SubmitCompositorFrame( 1210 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1184 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 1211 MakeCompositorFrame());
1185 } 1212 }
1186 1213
1187 // This test verifies that a crash does not occur if garbage collection is 1214 // This test verifies that a crash does not occur if garbage collection is
1188 // triggered when a deadline forces frame activation. This test triggers garbage 1215 // triggered when a deadline forces frame activation. This test triggers garbage
1189 // collection during deadline activation by causing the activation of a display 1216 // collection during deadline activation by causing the activation of a display
1190 // frame to replace a previously activated display frame that was referring to 1217 // frame to replace a previously activated display frame that was referring to
1191 // a now-unreachable surface subtree. That subtree gets garbage collected during 1218 // a now-unreachable surface subtree. That subtree gets garbage collected during
1192 // deadline activation. SurfaceDependencyTracker is also tracking a surface 1219 // deadline activation. SurfaceDependencyTracker is also tracking a surface
1193 // from that subtree due to an unresolved dependency. This test verifies that 1220 // from that subtree due to an unresolved dependency. This test verifies that
1194 // this dependency resolution does not crash. 1221 // this dependency resolution does not crash.
1195 TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { 1222 TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) {
1196 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); 1223 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1);
1197 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 1224 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
1198 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 1225 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
1199 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); 1226 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
1200 1227
1228 // |parent_id1| is blocked on |child_id|.
1229 parent_support().SubmitCompositorFrame(
1230 parent_id1.local_surface_id(),
1231 MakeCompositorFrame({child_id}, empty_surface_ids()));
1232
1201 display_support().SubmitCompositorFrame(display_id.local_surface_id(), 1233 display_support().SubmitCompositorFrame(display_id.local_surface_id(),
1202 MakeCompositorFrame({parent_id1})); 1234 MakeCompositorFrame({parent_id1}));
1203 1235
1236 EXPECT_TRUE(dependency_tracker().has_deadline());
1204 EXPECT_TRUE(display_surface()->HasPendingFrame()); 1237 EXPECT_TRUE(display_surface()->HasPendingFrame());
1205 EXPECT_TRUE(dependency_tracker().has_deadline());
1206 EXPECT_FALSE(display_surface()->HasActiveFrame()); 1238 EXPECT_FALSE(display_surface()->HasActiveFrame());
1207 1239
1208 // Advance BeginFrames to trigger a deadline. This activates the 1240 // Advance BeginFrames to trigger a deadline. This activates the
1209 // CompositorFrame submitted above. 1241 // CompositorFrame submitted above.
1210 BeginFrameArgs args = 1242 BeginFrameArgs args =
1211 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); 1243 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
1212 for (int i = 0; i < 3; ++i) { 1244 for (int i = 0; i < 3; ++i) {
1213 begin_frame_source()->TestOnBeginFrame(args); 1245 begin_frame_source()->TestOnBeginFrame(args);
1214 EXPECT_TRUE(dependency_tracker().has_deadline()); 1246 EXPECT_TRUE(dependency_tracker().has_deadline());
1215 } 1247 }
1216 begin_frame_source()->TestOnBeginFrame(args); 1248 begin_frame_source()->TestOnBeginFrame(args);
1217 EXPECT_FALSE(dependency_tracker().has_deadline()); 1249 EXPECT_FALSE(dependency_tracker().has_deadline());
1218 EXPECT_FALSE(display_surface()->HasPendingFrame()); 1250 EXPECT_FALSE(display_surface()->HasPendingFrame());
1219 EXPECT_TRUE(display_surface()->HasActiveFrame()); 1251 EXPECT_TRUE(display_surface()->HasActiveFrame());
1220 1252
1221 // |parent_id1| is blocked on |child_id|, but |display_id|'s CompositorFrame
1222 // has activated due to a deadline. |parent_id1| will be tracked by the
1223 // SurfaceDependencyTracker.
1224 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
1225 MakeCompositorFrame({child_id}));
1226
1227 // By submitting a display CompositorFrame, and replacing the parent's 1253 // By submitting a display CompositorFrame, and replacing the parent's
1228 // CompositorFrame with another surface ID, parent_id1 becomes unreachable and 1254 // CompositorFrame with another surface ID, parent_id1 becomes unreachable and
1229 // a candidate for garbage collection. 1255 // a candidate for garbage collection.
1230 display_support().SubmitCompositorFrame(display_id.local_surface_id(), 1256 display_support().SubmitCompositorFrame(
1231 MakeCompositorFrame({parent_id2})); 1257 display_id.local_surface_id(),
1258 MakeCompositorFrame({parent_id2}, empty_surface_ids()));
1232 1259
1233 // Now |parent_id1| is only kept alive by the active |display_id| frame. 1260 // Now |parent_id1| is only kept alive by the active |display_id| frame.
1234 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 1261 parent_support().SubmitCompositorFrame(
1235 MakeCompositorFrame({child_id})); 1262 parent_id2.local_surface_id(),
1263 MakeCompositorFrame({child_id}, empty_surface_ids()));
1236 1264
1237 // SurfaceDependencyTracker should now be tracking |display_id|, |parent_id1| 1265 // SurfaceDependencyTracker should now be tracking |display_id|, |parent_id1|
1238 // and |parent_id2|. By activating the pending |display_id| frame by deadline, 1266 // and |parent_id2|. By activating the pending |display_id| frame by deadline,
1239 // |parent_id1| becomes unreachable and is garbage collected while 1267 // |parent_id1| becomes unreachable and is garbage collected while
1240 // SurfaceDependencyTracker is in the process of activating surfaces. This 1268 // SurfaceDependencyTracker is in the process of activating surfaces. This
1241 // should not cause a crash or use-after-free. 1269 // should not cause a crash or use-after-free.
1242 for (int i = 0; i < 3; ++i) { 1270 for (int i = 0; i < 3; ++i) {
1243 begin_frame_source()->TestOnBeginFrame(args); 1271 begin_frame_source()->TestOnBeginFrame(args);
1244 EXPECT_TRUE(dependency_tracker().has_deadline()); 1272 EXPECT_TRUE(dependency_tracker().has_deadline());
1245 } 1273 }
1246 begin_frame_source()->TestOnBeginFrame(args); 1274 begin_frame_source()->TestOnBeginFrame(args);
1247 EXPECT_FALSE(dependency_tracker().has_deadline()); 1275 EXPECT_FALSE(dependency_tracker().has_deadline());
1248 } 1276 }
1249 1277
1250 // This test verifies that a CompositorFrame will only blocked on embedded 1278 // This test verifies that a CompositorFrame will only blocked on embedded
1251 // surfaces but not on other retained surface IDs in the CompositorFrame. 1279 // surfaces but not on other retained surface IDs in the CompositorFrame.
1252 TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) { 1280 TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) {
1253 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); 1281 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1);
1254 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 1282 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
1255 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); 1283 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2);
1256 1284
1285 // Submitting a CompositorFrame with |parent_id2| so that the display
1286 // CompositorFrame can hold a reference to it.
1287 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
1288 MakeCompositorFrame());
1289
1257 display_support().SubmitCompositorFrame( 1290 display_support().SubmitCompositorFrame(
1258 display_id.local_surface_id(), 1291 display_id.local_surface_id(),
1259 MakeCompositorFrame({parent_id1}, {parent_id1, parent_id2})); 1292 MakeCompositorFrame({parent_id1}, {parent_id2}));
1260 1293
1261 EXPECT_TRUE(display_surface()->HasPendingFrame()); 1294 EXPECT_TRUE(display_surface()->HasPendingFrame());
1262 EXPECT_FALSE(display_surface()->HasActiveFrame()); 1295 EXPECT_FALSE(display_surface()->HasActiveFrame());
1263 EXPECT_TRUE(dependency_tracker().has_deadline()); 1296 EXPECT_TRUE(dependency_tracker().has_deadline());
1264 1297
1265 // Verify that the display CompositorFrame will only block on |parent_id1| but 1298 // Verify that the display CompositorFrame will only block on |parent_id1| but
1266 // not |parent_id2|. 1299 // not |parent_id2|.
1267 EXPECT_THAT(display_surface()->blocking_surfaces(), 1300 EXPECT_THAT(display_surface()->blocking_surfaces(),
1268 UnorderedElementsAre(parent_id1)); 1301 UnorderedElementsAre(parent_id1));
1269 // Verify that the display surface holds no references while its 1302 // Verify that the display surface holds no references while its
1270 // CompositorFrame is pending. 1303 // CompositorFrame is pending.
1271 EXPECT_THAT(GetChildReferences(display_id), IsEmpty()); 1304 EXPECT_THAT(GetChildReferences(display_id), IsEmpty());
1272 1305
1273 // Submitting a CompositorFrame with |parent_id1| should unblock the display 1306 // Submitting a CompositorFrame with |parent_id1| should unblock the display
1274 // CompositorFrame. 1307 // CompositorFrame.
1275 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 1308 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
1276 MakeCompositorFrame()); 1309 MakeCompositorFrame());
1277 1310
1278 EXPECT_FALSE(dependency_tracker().has_deadline()); 1311 EXPECT_FALSE(dependency_tracker().has_deadline());
1279 EXPECT_FALSE(display_surface()->HasPendingFrame()); 1312 EXPECT_FALSE(display_surface()->HasPendingFrame());
1280 EXPECT_TRUE(display_surface()->HasActiveFrame()); 1313 EXPECT_TRUE(display_surface()->HasActiveFrame());
1281 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); 1314 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty());
1282
1283 // Only a reference to |parent_id1| is added because |parent_id2| does not
1284 // exist.
1285 EXPECT_THAT(GetChildReferences(display_id), UnorderedElementsAre(parent_id1));
1286 } 1315 }
1287 1316
1288 // This test verifies that a late arriving CompositorFrame activates immediately 1317 // This test verifies that a late arriving CompositorFrame activates immediately
1289 // and does not trigger a new deadline. 1318 // and does not trigger a new deadline.
1290 TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { 1319 TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) {
1291 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); 1320 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1);
1292 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 1321 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
1293 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 1322 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
1294 1323
1295 display_support().SubmitCompositorFrame(display_id.local_surface_id(), 1324 display_support().SubmitCompositorFrame(
1296 MakeCompositorFrame({parent_id1})); 1325 display_id.local_surface_id(),
1326 MakeCompositorFrame({parent_id1}, empty_surface_ids()));
1297 1327
1298 EXPECT_TRUE(display_surface()->HasPendingFrame()); 1328 EXPECT_TRUE(display_surface()->HasPendingFrame());
1299 EXPECT_FALSE(display_surface()->HasActiveFrame()); 1329 EXPECT_FALSE(display_surface()->HasActiveFrame());
1300 EXPECT_TRUE(dependency_tracker().has_deadline()); 1330 EXPECT_TRUE(dependency_tracker().has_deadline());
1301 1331
1302 // Advance BeginFrames to trigger a deadline. This activates the 1332 // Advance BeginFrames to trigger a deadline. This activates the
1303 // CompositorFrame submitted above. 1333 // CompositorFrame submitted above.
1304 BeginFrameArgs args = 1334 BeginFrameArgs args =
1305 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); 1335 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
1306 for (int i = 0; i < 3; ++i) { 1336 for (int i = 0; i < 3; ++i) {
1307 begin_frame_source()->TestOnBeginFrame(args); 1337 begin_frame_source()->TestOnBeginFrame(args);
1308 EXPECT_TRUE(dependency_tracker().has_deadline()); 1338 EXPECT_TRUE(dependency_tracker().has_deadline());
1309 } 1339 }
1310 begin_frame_source()->TestOnBeginFrame(args); 1340 begin_frame_source()->TestOnBeginFrame(args);
1311 EXPECT_FALSE(dependency_tracker().has_deadline()); 1341 EXPECT_FALSE(dependency_tracker().has_deadline());
1312 EXPECT_FALSE(display_surface()->HasPendingFrame()); 1342 EXPECT_FALSE(display_surface()->HasPendingFrame());
1313 EXPECT_TRUE(display_surface()->HasActiveFrame()); 1343 EXPECT_TRUE(display_surface()->HasActiveFrame());
1314 1344
1315 // A late arriving CompositorFrame should activate immediately without 1345 // A late arriving CompositorFrame should activate immediately without
1316 // scheduling a deadline and without waiting for dependencies to resolve. 1346 // scheduling a deadline and without waiting for dependencies to resolve.
1317 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 1347 parent_support().SubmitCompositorFrame(
1318 MakeCompositorFrame({child_id1})); 1348 parent_id1.local_surface_id(),
1349 MakeCompositorFrame({child_id1}, empty_surface_ids()));
1319 EXPECT_FALSE(dependency_tracker().has_deadline()); 1350 EXPECT_FALSE(dependency_tracker().has_deadline());
1320 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 1351 EXPECT_FALSE(parent_surface()->HasPendingFrame());
1321 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 1352 EXPECT_TRUE(parent_surface()->HasActiveFrame());
1322 } 1353 }
1323 1354
1355 // This test verifies CompositorFrames to a surface referenced by a parent
danakj 2017/05/04 21:39:13 submitted to a surface? tbh this sentence got me a
Fady Samuel 2017/05/04 22:44:03 Fixed comment.
1356 // client will be rejected until the parent's CompositorFrame activates.
1357 TEST_F(CompositorFrameSinkSupportTest,
1358 ReferencedSurfacesBlockedWhenParentPending) {
1359 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
1360 // This is the fallback child surface that the parent holds a reference to.
1361 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
1362 // This is the primary child surface that the parent wants to block on.
1363 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink1, 2);
1364
1365 // child_support1 submits a CompositorFrame without any dependencies.
1366 // DidReceiveCompositorFrameAck should call on immediate activation.
1367 // However, resources will not be returned because this frame is a candidate
1368 // for display.
1369 TransferableResource resource =
1370 MakeResource(1337 /* id */, ALPHA_8 /* format */, 1234 /* filter */,
1371 gfx::Size(1234, 5678));
1372 ReturnedResourceArray returned_resources;
1373 TransferableResource::ReturnResources({resource}, &returned_resources);
1374
1375 EXPECT_CALL(support_client_,
1376 DidReceiveCompositorFrameAck(Eq(ReturnedResourceArray())));
1377 child_support1().SubmitCompositorFrame(
1378 child_id1.local_surface_id(),
1379 MakeCompositorFrameWithResources(empty_surface_ids(), {resource}));
1380 testing::Mock::VerifyAndClearExpectations(&support_client_);
1381
1382 // The parent is blocked on |child_id2| and references |child_id1|. The
1383 // surface corresponding to |child_id1| will not accept new CompositorFrames
1384 // while the parent CompositorFrame is blocked.
1385 parent_support().SubmitCompositorFrame(
1386 parent_id1.local_surface_id(),
1387 MakeCompositorFrame({child_id2}, {child_id1}));
1388 EXPECT_TRUE(dependency_tracker().has_deadline());
1389 EXPECT_TRUE(parent_surface()->HasPendingFrame());
1390 EXPECT_FALSE(parent_surface()->HasActiveFrame());
1391
1392 // Resources will be returned immediately because |child_id2|'s surface is
danakj 2017/05/04 21:39:13 did u mean child_id1?
Fady Samuel 2017/05/04 22:44:03 Done.
1393 // closed.
1394 TransferableResource resource2 =
1395 MakeResource(1246 /* id */, ALPHA_8 /* format */, 1357 /* filter */,
1396 gfx::Size(8765, 4321));
1397 ReturnedResourceArray returned_resources2;
1398 TransferableResource::ReturnResources({resource2}, &returned_resources2);
1399 EXPECT_CALL(support_client_,
1400 DidReceiveCompositorFrameAck(Eq(returned_resources2)));
1401 child_support1().SubmitCompositorFrame(
1402 child_id1.local_surface_id(),
1403 MakeCompositorFrameWithResources(empty_surface_ids(), {resource2}));
1404 testing::Mock::VerifyAndClearExpectations(&support_client_);
1405
1406 // Advance BeginFrames to trigger a deadline. This activates the
1407 // CompositorFrame submitted to the parent.
1408 BeginFrameArgs args =
1409 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
1410 for (int i = 0; i < 3; ++i) {
1411 begin_frame_source()->TestOnBeginFrame(args);
1412 EXPECT_TRUE(dependency_tracker().has_deadline());
1413 }
1414 begin_frame_source()->TestOnBeginFrame(args);
1415 EXPECT_FALSE(dependency_tracker().has_deadline());
1416 EXPECT_FALSE(parent_surface()->HasPendingFrame());
1417 EXPECT_TRUE(parent_surface()->HasActiveFrame());
1418
1419 // Resources will be returned immediately because |child_id2|'s surface is
danakj 2017/05/04 21:39:13 did you mean child_id1 here too?
Fady Samuel 2017/05/04 22:44:03 Done.
1420 // closed forever.
1421 EXPECT_CALL(support_client_,
1422 DidReceiveCompositorFrameAck(Eq(returned_resources2)));
1423 child_support1().SubmitCompositorFrame(
1424 child_id1.local_surface_id(),
1425 MakeCompositorFrameWithResources(empty_surface_ids(), {resource2}));
1426 testing::Mock::VerifyAndClearExpectations(&support_client_);
1427 }
1428
1324 } // namespace test 1429 } // namespace test
1325 } // namespace cc 1430 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/compositor_frame.cc ('k') | cc/surfaces/surface.h » ('j') | cc/surfaces/surface.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698