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