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