OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/surfaces/surface_factory.h" | 5 #include "cc/surfaces/surface_factory.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 class SurfaceFactoryTest : public testing::Test, public SurfaceObserver { | 69 class SurfaceFactoryTest : public testing::Test, public SurfaceObserver { |
70 public: | 70 public: |
71 SurfaceFactoryTest() | 71 SurfaceFactoryTest() |
72 : factory_( | 72 : factory_( |
73 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)), | 73 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)), |
74 local_frame_id_(3, kArbitraryToken), | 74 local_frame_id_(3, kArbitraryToken), |
75 frame_sync_token_(GenTestSyncToken(4)), | 75 frame_sync_token_(GenTestSyncToken(4)), |
76 consumer_sync_token_(GenTestSyncToken(5)) { | 76 consumer_sync_token_(GenTestSyncToken(5)) { |
77 manager_.AddObserver(this); | 77 manager_.AddObserver(this); |
78 factory_->Create(local_frame_id_); | |
79 } | 78 } |
80 | 79 |
81 const SurfaceId& last_created_surface_id() const { | 80 const SurfaceId& last_created_surface_id() const { |
82 return last_created_surface_id_; | 81 return last_created_surface_id_; |
83 } | 82 } |
84 | 83 |
85 // SurfaceObserver implementation. | 84 // SurfaceObserver implementation. |
86 void OnSurfaceCreated(const SurfaceId& surface_id, | 85 void OnSurfaceCreated(const SurfaceId& surface_id, |
87 const gfx::Size& frame, | 86 const gfx::Size& frame, |
88 float device_scale_factor) override { | 87 float device_scale_factor) override { |
89 EXPECT_EQ(kArbitraryFrameSinkId, surface_id.frame_sink_id()); | 88 EXPECT_EQ(kArbitraryFrameSinkId, surface_id.frame_sink_id()); |
90 last_created_surface_id_ = surface_id; | 89 last_created_surface_id_ = surface_id; |
91 } | 90 } |
92 | 91 |
93 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { | 92 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { |
94 *changed = true; | 93 *changed = true; |
95 } | 94 } |
96 | 95 |
97 ~SurfaceFactoryTest() override { | 96 ~SurfaceFactoryTest() override { |
98 if (local_frame_id_.is_valid()) | |
99 factory_->Destroy(local_frame_id_); | |
100 manager_.RemoveObserver(this); | 97 manager_.RemoveObserver(this); |
| 98 factory_->EvictSurface(); |
101 } | 99 } |
102 | 100 |
103 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, | 101 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, |
104 size_t num_resource_ids) { | 102 size_t num_resource_ids) { |
105 CompositorFrame frame; | 103 CompositorFrame frame; |
106 for (size_t i = 0u; i < num_resource_ids; ++i) { | 104 for (size_t i = 0u; i < num_resource_ids; ++i) { |
107 TransferableResource resource; | 105 TransferableResource resource; |
108 resource.id = resource_ids[i]; | 106 resource.id = resource_ids[i]; |
109 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 107 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
110 resource.mailbox_holder.sync_token = frame_sync_token_; | 108 resource.mailbox_holder.sync_token = frame_sync_token_; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 int expected_returned_counts[] = {2, 2}; | 428 int expected_returned_counts[] = {2, 2}; |
431 CheckReturnedResourcesMatchExpected( | 429 CheckReturnedResourcesMatchExpected( |
432 expected_returned_ids, expected_returned_counts, | 430 expected_returned_ids, expected_returned_counts, |
433 arraysize(expected_returned_counts), consumer_sync_token_); | 431 arraysize(expected_returned_counts), consumer_sync_token_); |
434 } | 432 } |
435 } | 433 } |
436 | 434 |
437 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) { | 435 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) { |
438 LocalFrameId local_frame_id(6, kArbitraryToken); | 436 LocalFrameId local_frame_id(6, kArbitraryToken); |
439 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); | 437 SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); |
440 factory_->Create(local_frame_id); | 438 factory_->SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
| 439 SurfaceFactory::DrawCallback()); |
441 Surface* surface = manager_.GetSurfaceForId(surface_id); | 440 Surface* surface = manager_.GetSurfaceForId(surface_id); |
442 ASSERT_NE(nullptr, surface); | 441 ASSERT_NE(nullptr, surface); |
443 EXPECT_EQ(2, surface->frame_index()); | 442 EXPECT_EQ(2, surface->frame_index()); |
444 | |
445 factory_->SubmitCompositorFrame(local_frame_id, CompositorFrame(), | |
446 SurfaceFactory::DrawCallback()); | |
447 EXPECT_EQ(2, surface->frame_index()); | |
448 EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id); | 443 EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id); |
449 factory_->Destroy(local_frame_id); | |
450 } | 444 } |
451 | 445 |
452 void CreateSurfaceDrawCallback(SurfaceFactory* factory, | 446 void CreateSurfaceDrawCallback(SurfaceFactory* factory, |
453 uint32_t* execute_count) { | 447 uint32_t* execute_count) { |
454 LocalFrameId new_id(7, base::UnguessableToken::Create()); | 448 LocalFrameId new_id(7, base::UnguessableToken::Create()); |
455 factory->Create(new_id); | 449 factory->SubmitCompositorFrame(new_id, CompositorFrame(), |
456 factory->Destroy(new_id); | 450 SurfaceFactory::DrawCallback()); |
| 451 factory->EvictSurface(); |
457 *execute_count += 1; | 452 *execute_count += 1; |
458 } | 453 } |
459 | 454 |
460 TEST_F(SurfaceFactoryTest, AddDuringDestroy) { | 455 TEST_F(SurfaceFactoryTest, AddDuringEviction) { |
461 LocalFrameId local_frame_id(6, kArbitraryToken); | 456 LocalFrameId local_frame_id(6, kArbitraryToken); |
462 factory_->Create(local_frame_id); | |
463 | 457 |
464 uint32_t execute_count = 0; | 458 uint32_t execute_count = 0; |
465 factory_->SubmitCompositorFrame( | 459 factory_->SubmitCompositorFrame( |
466 local_frame_id, CompositorFrame(), | 460 local_frame_id, CompositorFrame(), |
467 base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()), | 461 base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()), |
468 &execute_count)); | 462 &execute_count)); |
469 EXPECT_EQ(0u, execute_count); | 463 EXPECT_EQ(0u, execute_count); |
470 factory_->Destroy(local_frame_id); | 464 factory_->EvictSurface(); |
471 EXPECT_EQ(1u, execute_count); | 465 EXPECT_EQ(1u, execute_count); |
472 } | 466 } |
473 | 467 |
474 void DrawCallback(uint32_t* execute_count) { | 468 void DrawCallback(uint32_t* execute_count) { |
475 *execute_count += 1; | 469 *execute_count += 1; |
476 } | 470 } |
477 | 471 |
478 // Tests doing a DestroyAll before shutting down the factory; | 472 // Tests doing an EvictSurface before shutting down the factory. |
479 TEST_F(SurfaceFactoryTest, DestroyAll) { | 473 TEST_F(SurfaceFactoryTest, EvictSurface) { |
480 LocalFrameId id(7, kArbitraryToken); | 474 LocalFrameId id(7, kArbitraryToken); |
481 factory_->Create(id); | |
482 | 475 |
483 TransferableResource resource; | 476 TransferableResource resource; |
484 resource.id = 1; | 477 resource.id = 1; |
485 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 478 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
486 CompositorFrame frame; | 479 CompositorFrame frame; |
487 frame.resource_list.push_back(resource); | 480 frame.resource_list.push_back(resource); |
488 uint32_t execute_count = 0; | 481 uint32_t execute_count = 0; |
489 factory_->SubmitCompositorFrame(id, std::move(frame), | 482 factory_->SubmitCompositorFrame(id, std::move(frame), |
490 base::Bind(&DrawCallback, &execute_count)); | 483 base::Bind(&DrawCallback, &execute_count)); |
491 EXPECT_EQ(last_created_surface_id().local_frame_id(), id); | 484 EXPECT_EQ(last_created_surface_id().local_frame_id(), id); |
492 local_frame_id_ = LocalFrameId(); | 485 local_frame_id_ = LocalFrameId(); |
493 factory_->DestroyAll(); | 486 factory_->EvictSurface(); |
494 EXPECT_EQ(1u, execute_count); | 487 EXPECT_EQ(1u, execute_count); |
495 } | 488 } |
496 | 489 |
497 // Tests that SurfaceFactory doesn't return resources after Reset(). | 490 // Tests that SurfaceFactory doesn't return resources after Reset(). |
498 TEST_F(SurfaceFactoryTest, Reset) { | 491 TEST_F(SurfaceFactoryTest, Reset) { |
499 LocalFrameId id(7, kArbitraryToken); | 492 LocalFrameId id(7, kArbitraryToken); |
500 factory_->Create(id); | |
501 | 493 |
502 TransferableResource resource; | 494 TransferableResource resource; |
503 resource.id = 1; | 495 resource.id = 1; |
504 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 496 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
505 CompositorFrame frame; | 497 CompositorFrame frame; |
506 frame.resource_list.push_back(resource); | 498 frame.resource_list.push_back(resource); |
507 uint32_t execute_count = 0; | |
508 factory_->SubmitCompositorFrame(id, std::move(frame), | 499 factory_->SubmitCompositorFrame(id, std::move(frame), |
509 base::Bind(&DrawCallback, &execute_count)); | 500 SurfaceFactory::DrawCallback()); |
510 EXPECT_EQ(last_created_surface_id().local_frame_id(), id); | 501 EXPECT_EQ(last_created_surface_id().local_frame_id(), id); |
511 | 502 |
512 SurfaceId surface_id(kArbitraryFrameSinkId, id); | 503 SurfaceId surface_id(kArbitraryFrameSinkId, id); |
513 manager_.AddSurfaceReference(manager_.GetRootSurfaceId(), surface_id); | 504 manager_.AddSurfaceReference(manager_.GetRootSurfaceId(), surface_id); |
514 factory_->Reset(); | 505 factory_->Reset(); |
515 EXPECT_TRUE(client_.returned_resources().empty()); | 506 EXPECT_TRUE(client_.returned_resources().empty()); |
516 manager_.RemoveSurfaceReference(manager_.GetRootSurfaceId(), surface_id); | 507 manager_.RemoveSurfaceReference(manager_.GetRootSurfaceId(), surface_id); |
517 EXPECT_TRUE(client_.returned_resources().empty()); | 508 EXPECT_TRUE(client_.returned_resources().empty()); |
518 local_frame_id_ = LocalFrameId(); | 509 local_frame_id_ = LocalFrameId(); |
519 } | 510 } |
520 | 511 |
521 TEST_F(SurfaceFactoryTest, DestroySequence) { | 512 TEST_F(SurfaceFactoryTest, DestroySequence) { |
522 LocalFrameId local_frame_id2(5, kArbitraryToken); | 513 LocalFrameId local_frame_id2(5, kArbitraryToken); |
| 514 std::unique_ptr<SurfaceFactory> factory2( |
| 515 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); |
523 SurfaceId id2(kArbitraryFrameSinkId, local_frame_id2); | 516 SurfaceId id2(kArbitraryFrameSinkId, local_frame_id2); |
524 factory_->Create(local_frame_id2); | 517 factory2->SubmitCompositorFrame(local_frame_id2, CompositorFrame(), |
| 518 SurfaceFactory::DrawCallback()); |
525 | 519 |
526 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); | 520 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); |
527 | 521 |
528 // Check that waiting before the sequence is satisfied works. | 522 // Check that waiting before the sequence is satisfied works. |
529 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 523 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
530 SurfaceSequence(kArbitraryFrameSinkId, 4)); | 524 SurfaceSequence(kArbitraryFrameSinkId, 4)); |
531 factory_->Destroy(local_frame_id2); | 525 factory2->EvictSurface(); |
532 | 526 |
533 CompositorFrame frame; | 527 CompositorFrame frame; |
534 frame.metadata.satisfies_sequences.push_back(6); | 528 frame.metadata.satisfies_sequences.push_back(6); |
535 frame.metadata.satisfies_sequences.push_back(4); | 529 frame.metadata.satisfies_sequences.push_back(4); |
536 DCHECK(manager_.GetSurfaceForId(id2)); | 530 DCHECK(manager_.GetSurfaceForId(id2)); |
537 factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), | 531 factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), |
538 SurfaceFactory::DrawCallback()); | 532 SurfaceFactory::DrawCallback()); |
539 EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id_); | |
540 DCHECK(!manager_.GetSurfaceForId(id2)); | 533 DCHECK(!manager_.GetSurfaceForId(id2)); |
541 | 534 |
542 // Check that waiting after the sequence is satisfied works. | 535 // Check that waiting after the sequence is satisfied works. |
543 factory_->Create(local_frame_id2); | 536 factory2->SubmitCompositorFrame(local_frame_id2, CompositorFrame(), |
| 537 SurfaceFactory::DrawCallback()); |
544 DCHECK(manager_.GetSurfaceForId(id2)); | 538 DCHECK(manager_.GetSurfaceForId(id2)); |
545 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 539 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
546 SurfaceSequence(kAnotherArbitraryFrameSinkId, 6)); | 540 SurfaceSequence(kAnotherArbitraryFrameSinkId, 6)); |
547 factory_->Destroy(local_frame_id2); | 541 factory2->EvictSurface(); |
548 DCHECK(!manager_.GetSurfaceForId(id2)); | 542 DCHECK(!manager_.GetSurfaceForId(id2)); |
549 } | 543 } |
550 | 544 |
551 // Tests that Surface ID namespace invalidation correctly allows | 545 // Tests that Surface ID namespace invalidation correctly allows |
552 // Sequences to be ignored. | 546 // Sequences to be ignored. |
553 TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { | 547 TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { |
554 FrameSinkId frame_sink_id(1234, 5678); | 548 FrameSinkId frame_sink_id(1234, 5678); |
555 | 549 |
556 LocalFrameId local_frame_id(5, kArbitraryToken); | 550 LocalFrameId local_frame_id(5, kArbitraryToken); |
557 SurfaceId id(factory_->frame_sink_id(), local_frame_id); | 551 SurfaceId id(factory_->frame_sink_id(), local_frame_id); |
558 factory_->Create(local_frame_id); | 552 factory_->SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
| 553 SurfaceFactory::DrawCallback()); |
559 | 554 |
560 manager_.RegisterFrameSinkId(frame_sink_id); | 555 manager_.RegisterFrameSinkId(frame_sink_id); |
561 manager_.GetSurfaceForId(id)->AddDestructionDependency( | 556 manager_.GetSurfaceForId(id)->AddDestructionDependency( |
562 SurfaceSequence(frame_sink_id, 4)); | 557 SurfaceSequence(frame_sink_id, 4)); |
563 factory_->Destroy(local_frame_id); | 558 |
| 559 factory_->EvictSurface(); |
564 | 560 |
565 // Verify the dependency has prevented the surface from getting destroyed. | 561 // Verify the dependency has prevented the surface from getting destroyed. |
566 EXPECT_TRUE(manager_.GetSurfaceForId(id)); | 562 EXPECT_TRUE(manager_.GetSurfaceForId(id)); |
567 | 563 |
568 manager_.InvalidateFrameSinkId(frame_sink_id); | 564 manager_.InvalidateFrameSinkId(frame_sink_id); |
569 | 565 |
570 // Verify that the invalidated namespace caused the unsatisfied sequence | 566 // Verify that the invalidated namespace caused the unsatisfied sequence |
571 // to be ignored. | 567 // to be ignored. |
572 EXPECT_FALSE(manager_.GetSurfaceForId(id)); | 568 EXPECT_FALSE(manager_.GetSurfaceForId(id)); |
573 } | 569 } |
574 | 570 |
575 TEST_F(SurfaceFactoryTest, DestroyCycle) { | 571 TEST_F(SurfaceFactoryTest, DestroyCycle) { |
576 LocalFrameId local_frame_id2(5, kArbitraryToken); | 572 LocalFrameId local_frame_id2(5, kArbitraryToken); |
577 SurfaceId id2(kArbitraryFrameSinkId, local_frame_id2); | 573 SurfaceId id2(kArbitraryFrameSinkId, local_frame_id2); |
578 factory_->Create(local_frame_id2); | 574 std::unique_ptr<SurfaceFactory> factory2( |
579 | 575 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); |
580 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); | 576 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); |
581 | |
582 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | |
583 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | |
584 | |
585 // Give id2 a frame that references local_frame_id_. | 577 // Give id2 a frame that references local_frame_id_. |
586 { | 578 { |
587 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | 579 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); |
588 CompositorFrame frame; | 580 CompositorFrame frame; |
589 frame.render_pass_list.push_back(std::move(render_pass)); | 581 frame.render_pass_list.push_back(std::move(render_pass)); |
590 frame.metadata.referenced_surfaces.push_back( | 582 frame.metadata.referenced_surfaces.push_back( |
591 SurfaceId(factory_->frame_sink_id(), local_frame_id_)); | 583 SurfaceId(factory_->frame_sink_id(), local_frame_id_)); |
592 factory_->SubmitCompositorFrame(local_frame_id2, std::move(frame), | 584 factory2->SubmitCompositorFrame(local_frame_id2, std::move(frame), |
593 SurfaceFactory::DrawCallback()); | 585 SurfaceFactory::DrawCallback()); |
594 EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id2); | 586 EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id2); |
595 } | 587 } |
596 factory_->Destroy(local_frame_id2); | 588 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
597 | 589 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 590 factory2->EvictSurface(); |
598 // Give local_frame_id_ a frame that references id2. | 591 // Give local_frame_id_ a frame that references id2. |
599 { | 592 { |
600 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | 593 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); |
601 CompositorFrame frame; | 594 CompositorFrame frame; |
602 frame.render_pass_list.push_back(std::move(render_pass)); | 595 frame.render_pass_list.push_back(std::move(render_pass)); |
603 frame.metadata.referenced_surfaces.push_back(id2); | 596 frame.metadata.referenced_surfaces.push_back(id2); |
604 factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), | 597 factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), |
605 SurfaceFactory::DrawCallback()); | 598 SurfaceFactory::DrawCallback()); |
606 EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id_); | |
607 } | 599 } |
608 factory_->Destroy(local_frame_id_); | 600 factory_->EvictSurface(); |
609 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); | 601 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); |
610 // local_frame_id_ should be retained by reference from id2. | 602 // local_frame_id_ should be retained by reference from id2. |
611 EXPECT_TRUE(manager_.GetSurfaceForId( | 603 EXPECT_TRUE(manager_.GetSurfaceForId( |
612 SurfaceId(factory_->frame_sink_id(), local_frame_id_))); | 604 SurfaceId(factory_->frame_sink_id(), local_frame_id_))); |
613 | 605 |
614 // Satisfy last destruction dependency for id2. | 606 // Satisfy last destruction dependency for id2. |
615 std::vector<uint32_t> to_satisfy; | 607 std::vector<uint32_t> to_satisfy; |
616 to_satisfy.push_back(4); | 608 to_satisfy.push_back(4); |
617 manager_.DidSatisfySequences(kAnotherArbitraryFrameSinkId, &to_satisfy); | 609 manager_.DidSatisfySequences(kAnotherArbitraryFrameSinkId, &to_satisfy); |
618 | 610 |
(...skipping 24 matching lines...) Expand all Loading... |
643 } | 635 } |
644 void* source1 = &source1; | 636 void* source1 = &source1; |
645 void* source2 = &source2; | 637 void* source2 = &source2; |
646 | 638 |
647 bool called1 = false; | 639 bool called1 = false; |
648 std::unique_ptr<CopyOutputRequest> request; | 640 std::unique_ptr<CopyOutputRequest> request; |
649 request = CopyOutputRequest::CreateRequest( | 641 request = CopyOutputRequest::CreateRequest( |
650 base::Bind(&CopyRequestTestCallback, &called1)); | 642 base::Bind(&CopyRequestTestCallback, &called1)); |
651 request->set_source(source1); | 643 request->set_source(source1); |
652 | 644 |
653 factory_->RequestCopyOfSurface(local_frame_id_, std::move(request)); | 645 factory_->RequestCopyOfSurface(std::move(request)); |
654 EXPECT_FALSE(called1); | 646 EXPECT_FALSE(called1); |
655 | 647 |
656 bool called2 = false; | 648 bool called2 = false; |
657 request = CopyOutputRequest::CreateRequest( | 649 request = CopyOutputRequest::CreateRequest( |
658 base::Bind(&CopyRequestTestCallback, &called2)); | 650 base::Bind(&CopyRequestTestCallback, &called2)); |
659 request->set_source(source2); | 651 request->set_source(source2); |
660 | 652 |
661 factory_->RequestCopyOfSurface(local_frame_id_, std::move(request)); | 653 factory_->RequestCopyOfSurface(std::move(request)); |
662 // Callbacks have different sources so neither should be called. | 654 // Callbacks have different sources so neither should be called. |
663 EXPECT_FALSE(called1); | 655 EXPECT_FALSE(called1); |
664 EXPECT_FALSE(called2); | 656 EXPECT_FALSE(called2); |
665 | 657 |
666 bool called3 = false; | 658 bool called3 = false; |
667 request = CopyOutputRequest::CreateRequest( | 659 request = CopyOutputRequest::CreateRequest( |
668 base::Bind(&CopyRequestTestCallback, &called3)); | 660 base::Bind(&CopyRequestTestCallback, &called3)); |
669 request->set_source(source1); | 661 request->set_source(source1); |
670 | 662 |
671 factory_->RequestCopyOfSurface(local_frame_id_, std::move(request)); | 663 factory_->RequestCopyOfSurface(std::move(request)); |
672 // Two callbacks are from source1, so the first should be called. | 664 // Two callbacks are from source1, so the first should be called. |
673 EXPECT_TRUE(called1); | 665 EXPECT_TRUE(called1); |
674 EXPECT_FALSE(called2); | 666 EXPECT_FALSE(called2); |
675 EXPECT_FALSE(called3); | 667 EXPECT_FALSE(called3); |
676 | 668 |
677 factory_->Destroy(local_frame_id_); | 669 factory_->EvictSurface(); |
678 local_frame_id_ = LocalFrameId(); | 670 local_frame_id_ = LocalFrameId(); |
679 EXPECT_TRUE(called1); | 671 EXPECT_TRUE(called1); |
680 EXPECT_TRUE(called2); | 672 EXPECT_TRUE(called2); |
681 EXPECT_TRUE(called3); | 673 EXPECT_TRUE(called3); |
682 } | 674 } |
683 | 675 |
684 } // namespace | 676 } // namespace |
685 } // namespace cc | 677 } // namespace cc |
OLD | NEW |