OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 GLuint last_waited_sync_point_; | 332 GLuint last_waited_sync_point_; |
333 PendingProduceTextureList pending_produce_textures_; | 333 PendingProduceTextureList pending_produce_textures_; |
334 }; | 334 }; |
335 | 335 |
336 void GetResourcePixels(ResourceProvider* resource_provider, | 336 void GetResourcePixels(ResourceProvider* resource_provider, |
337 ResourceProviderContext* context, | 337 ResourceProviderContext* context, |
338 ResourceProvider::ResourceId id, | 338 ResourceProvider::ResourceId id, |
339 const gfx::Size& size, | 339 const gfx::Size& size, |
340 ResourceFormat format, | 340 ResourceFormat format, |
341 uint8_t* pixels) { | 341 uint8_t* pixels) { |
| 342 resource_provider->WaitSyncPointIfNeeded(id); |
342 switch (resource_provider->default_resource_type()) { | 343 switch (resource_provider->default_resource_type()) { |
343 case ResourceProvider::GLTexture: { | 344 case ResourceProvider::GLTexture: { |
344 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); | 345 ResourceProvider::ScopedReadLockGL lock_gl(resource_provider, id); |
345 ASSERT_NE(0U, lock_gl.texture_id()); | 346 ASSERT_NE(0U, lock_gl.texture_id()); |
346 context->bindTexture(GL_TEXTURE_2D, lock_gl.texture_id()); | 347 context->bindTexture(GL_TEXTURE_2D, lock_gl.texture_id()); |
347 context->GetPixels(size, format, pixels); | 348 context->GetPixels(size, format, pixels); |
348 break; | 349 break; |
349 } | 350 } |
350 case ResourceProvider::Bitmap: { | 351 case ResourceProvider::Bitmap: { |
351 ResourceProvider::ScopedReadLockSoftware lock_software(resource_provider, | 352 ResourceProvider::ScopedReadLockSoftware lock_software(resource_provider, |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), | 658 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
658 list[3].mailbox_holder.texture_target); | 659 list[3].mailbox_holder.texture_target); |
659 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 660 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
660 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); | 661 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); |
661 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); | 662 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); |
662 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); | 663 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); |
663 resource_provider_->ReceiveFromChild(child_id, list); | 664 resource_provider_->ReceiveFromChild(child_id, list); |
664 EXPECT_NE(list[0].mailbox_holder.sync_point, | 665 EXPECT_NE(list[0].mailbox_holder.sync_point, |
665 context3d_->last_waited_sync_point()); | 666 context3d_->last_waited_sync_point()); |
666 { | 667 { |
| 668 resource_provider_->WaitSyncPointIfNeeded(list[0].id); |
667 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 669 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
668 list[0].id); | 670 list[0].id); |
669 } | 671 } |
670 EXPECT_EQ(list[0].mailbox_holder.sync_point, | 672 EXPECT_EQ(list[0].mailbox_holder.sync_point, |
671 context3d_->last_waited_sync_point()); | 673 context3d_->last_waited_sync_point()); |
672 resource_provider_->DeclareUsedResourcesFromChild(child_id, | 674 resource_provider_->DeclareUsedResourcesFromChild(child_id, |
673 resource_ids_to_transfer); | 675 resource_ids_to_transfer); |
674 } | 676 } |
675 | 677 |
676 EXPECT_EQ(4u, resource_provider_->num_resources()); | 678 EXPECT_EQ(4u, resource_provider_->num_resources()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 EXPECT_FALSE(returned_to_child[3].lost); | 748 EXPECT_FALSE(returned_to_child[3].lost); |
747 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 749 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
748 returned_to_child.clear(); | 750 returned_to_child.clear(); |
749 } | 751 } |
750 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id1)); | 752 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id1)); |
751 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id2)); | 753 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id2)); |
752 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id3)); | 754 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id3)); |
753 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id4)); | 755 EXPECT_FALSE(child_resource_provider_->InUseByConsumer(id4)); |
754 | 756 |
755 { | 757 { |
| 758 child_resource_provider_->WaitSyncPointIfNeeded(id1); |
756 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 759 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
757 id1); | 760 id1); |
758 ASSERT_NE(0U, lock.texture_id()); | 761 ASSERT_NE(0U, lock.texture_id()); |
759 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); | 762 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); |
760 child_context_->GetPixels(size, format, result); | 763 child_context_->GetPixels(size, format, result); |
761 EXPECT_EQ(0, memcmp(data1, result, pixel_size)); | 764 EXPECT_EQ(0, memcmp(data1, result, pixel_size)); |
762 } | 765 } |
763 { | 766 { |
| 767 child_resource_provider_->WaitSyncPointIfNeeded(id2); |
764 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 768 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
765 id2); | 769 id2); |
766 ASSERT_NE(0U, lock.texture_id()); | 770 ASSERT_NE(0U, lock.texture_id()); |
767 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); | 771 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); |
768 child_context_->GetPixels(size, format, result); | 772 child_context_->GetPixels(size, format, result); |
769 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); | 773 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); |
770 } | 774 } |
771 { | 775 { |
| 776 child_resource_provider_->WaitSyncPointIfNeeded(id3); |
772 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 777 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
773 id3); | 778 id3); |
774 ASSERT_NE(0U, lock.texture_id()); | 779 ASSERT_NE(0U, lock.texture_id()); |
775 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); | 780 child_context_->bindTexture(GL_TEXTURE_2D, lock.texture_id()); |
776 } | 781 } |
777 { | 782 { |
778 // Transfer resources to the parent again. | 783 // Transfer resources to the parent again. |
779 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 784 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
780 resource_ids_to_transfer.push_back(id1); | 785 resource_ids_to_transfer.push_back(id1); |
781 resource_ids_to_transfer.push_back(id2); | 786 resource_ids_to_transfer.push_back(id2); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 852 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
848 resource_ids_to_transfer.push_back(id1); | 853 resource_ids_to_transfer.push_back(id1); |
849 TransferableResourceArray list; | 854 TransferableResourceArray list; |
850 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, | 855 child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, |
851 &list); | 856 &list); |
852 ASSERT_EQ(1u, list.size()); | 857 ASSERT_EQ(1u, list.size()); |
853 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 858 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
854 | 859 |
855 resource_provider_->ReceiveFromChild(child_id, list); | 860 resource_provider_->ReceiveFromChild(child_id, list); |
856 | 861 |
| 862 resource_provider_->WaitSyncPointIfNeeded(list[0].id); |
857 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 863 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), |
858 list[0].id); | 864 list[0].id); |
859 | 865 |
860 resource_provider_->DeclareUsedResourcesFromChild( | 866 resource_provider_->DeclareUsedResourcesFromChild( |
861 child_id, ResourceProvider::ResourceIdArray()); | 867 child_id, ResourceProvider::ResourceIdArray()); |
862 EXPECT_EQ(0u, returned_to_child.size()); | 868 EXPECT_EQ(0u, returned_to_child.size()); |
863 } | 869 } |
864 | 870 |
865 EXPECT_EQ(1u, returned_to_child.size()); | 871 EXPECT_EQ(1u, returned_to_child.size()); |
866 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); | 872 child_resource_provider_->ReceiveReturnsFromParent(returned_to_child); |
867 | 873 |
868 { | 874 { |
| 875 child_resource_provider_->WaitSyncPointIfNeeded(id1); |
869 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), | 876 ResourceProvider::ScopedReadLockGL lock(child_resource_provider_.get(), |
870 id1); | 877 id1); |
871 child_resource_provider_->DeleteResource(id1); | 878 child_resource_provider_->DeleteResource(id1); |
872 EXPECT_EQ(1u, child_resource_provider_->num_resources()); | 879 EXPECT_EQ(1u, child_resource_provider_->num_resources()); |
873 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); | 880 EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); |
874 } | 881 } |
875 | 882 |
876 EXPECT_EQ(0u, child_resource_provider_->num_resources()); | 883 EXPECT_EQ(0u, child_resource_provider_->num_resources()); |
877 resource_provider_->DestroyChild(child_id); | 884 resource_provider_->DestroyChild(child_id); |
878 } | 885 } |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 Mock::VerifyAndClearExpectations(child_context); | 1742 Mock::VerifyAndClearExpectations(child_context); |
1736 | 1743 |
1737 ASSERT_EQ(1u, list.size()); | 1744 ASSERT_EQ(1u, list.size()); |
1738 EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter); | 1745 EXPECT_EQ(static_cast<unsigned>(child_filter), list[0].filter); |
1739 | 1746 |
1740 EXPECT_CALL(*parent_context, | 1747 EXPECT_CALL(*parent_context, |
1741 bindTexture(GL_TEXTURE_2D, parent_texture_id)); | 1748 bindTexture(GL_TEXTURE_2D, parent_texture_id)); |
1742 EXPECT_CALL(*parent_context, consumeTextureCHROMIUM(GL_TEXTURE_2D, _)); | 1749 EXPECT_CALL(*parent_context, consumeTextureCHROMIUM(GL_TEXTURE_2D, _)); |
1743 parent_resource_provider->ReceiveFromChild(child_id, list); | 1750 parent_resource_provider->ReceiveFromChild(child_id, list); |
1744 { | 1751 { |
| 1752 parent_resource_provider->WaitSyncPointIfNeeded(list[0].id); |
1745 ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(), | 1753 ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(), |
1746 list[0].id); | 1754 list[0].id); |
1747 } | 1755 } |
1748 Mock::VerifyAndClearExpectations(parent_context); | 1756 Mock::VerifyAndClearExpectations(parent_context); |
1749 | 1757 |
1750 parent_resource_provider->DeclareUsedResourcesFromChild( | 1758 parent_resource_provider->DeclareUsedResourcesFromChild( |
1751 child_id, resource_ids_to_transfer); | 1759 child_id, resource_ids_to_transfer); |
1752 Mock::VerifyAndClearExpectations(parent_context); | 1760 Mock::VerifyAndClearExpectations(parent_context); |
1753 } | 1761 } |
1754 ResourceProvider::ResourceIdMap resource_map = | 1762 ResourceProvider::ResourceIdMap resource_map = |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2511 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 2519 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
2512 | 2520 |
2513 ResourceProvider::ResourceId id = | 2521 ResourceProvider::ResourceId id = |
2514 resource_provider->CreateResourceFromTextureMailbox( | 2522 resource_provider->CreateResourceFromTextureMailbox( |
2515 mailbox, callback.Pass()); | 2523 mailbox, callback.Pass()); |
2516 EXPECT_NE(0u, id); | 2524 EXPECT_NE(0u, id); |
2517 | 2525 |
2518 Mock::VerifyAndClearExpectations(context); | 2526 Mock::VerifyAndClearExpectations(context); |
2519 | 2527 |
2520 { | 2528 { |
| 2529 // Mailbox sync point WaitSyncPoint before using the texture. |
| 2530 EXPECT_CALL(*context, waitSyncPoint(sync_point)); |
| 2531 resource_provider->WaitSyncPointIfNeeded(id); |
| 2532 Mock::VerifyAndClearExpectations(context); |
| 2533 |
2521 // Using the texture does a consume of the mailbox. | 2534 // Using the texture does a consume of the mailbox. |
2522 EXPECT_CALL(*context, bindTexture(target, texture_id)); | 2535 EXPECT_CALL(*context, bindTexture(target, texture_id)); |
2523 EXPECT_CALL(*context, waitSyncPoint(sync_point)); | |
2524 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _)); | 2536 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _)); |
2525 | 2537 |
2526 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2538 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2527 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2539 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2528 | 2540 |
2529 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); | 2541 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); |
2530 Mock::VerifyAndClearExpectations(context); | 2542 Mock::VerifyAndClearExpectations(context); |
2531 | 2543 |
2532 // When done with it, a sync point should be inserted, but no produce is | 2544 // When done with it, a sync point should be inserted, but no produce is |
2533 // necessary. | 2545 // necessary. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 TextureMailbox mailbox(gpu_mailbox, target, sync_point); | 2587 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
2576 | 2588 |
2577 ResourceProvider::ResourceId id = | 2589 ResourceProvider::ResourceId id = |
2578 resource_provider->CreateResourceFromTextureMailbox( | 2590 resource_provider->CreateResourceFromTextureMailbox( |
2579 mailbox, callback.Pass()); | 2591 mailbox, callback.Pass()); |
2580 EXPECT_NE(0u, id); | 2592 EXPECT_NE(0u, id); |
2581 | 2593 |
2582 Mock::VerifyAndClearExpectations(context); | 2594 Mock::VerifyAndClearExpectations(context); |
2583 | 2595 |
2584 { | 2596 { |
| 2597 // Mailbox sync point WaitSyncPoint before using the texture. |
| 2598 EXPECT_CALL(*context, waitSyncPoint(sync_point)); |
| 2599 resource_provider->WaitSyncPointIfNeeded(id); |
| 2600 Mock::VerifyAndClearExpectations(context); |
| 2601 |
2585 // Using the texture does a consume of the mailbox. | 2602 // Using the texture does a consume of the mailbox. |
2586 EXPECT_CALL(*context, bindTexture(target, texture_id)); | 2603 EXPECT_CALL(*context, bindTexture(target, texture_id)); |
2587 EXPECT_CALL(*context, waitSyncPoint(sync_point)); | |
2588 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _)); | 2604 EXPECT_CALL(*context, consumeTextureCHROMIUM(target, _)); |
2589 | 2605 |
2590 EXPECT_CALL(*context, insertSyncPoint()).Times(0); | 2606 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
2591 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2607 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2592 | 2608 |
2593 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); | 2609 ResourceProvider::ScopedReadLockGL lock(resource_provider.get(), id); |
2594 Mock::VerifyAndClearExpectations(context); | 2610 Mock::VerifyAndClearExpectations(context); |
2595 | 2611 |
2596 // When done with it, a sync point should be inserted, but no produce is | 2612 // When done with it, a sync point should be inserted, but no produce is |
2597 // necessary. | 2613 // necessary. |
2598 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2614 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2599 EXPECT_CALL(*context, insertSyncPoint()); | 2615 EXPECT_CALL(*context, insertSyncPoint()); |
2600 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); | 2616 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
2601 | 2617 |
2602 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); | 2618 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
2603 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); | 2619 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
2604 } | 2620 } |
2605 } | 2621 } |
2606 | 2622 |
| 2623 TEST_P(ResourceProviderTest, |
| 2624 TextureMailbox_WaitSyncPointIfNeeded_WithSyncPoint) { |
| 2625 // Mailboxing is only supported for GL textures. |
| 2626 if (GetParam() != ResourceProvider::GLTexture) |
| 2627 return; |
| 2628 |
| 2629 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2630 new TextureStateTrackingContext); |
| 2631 TextureStateTrackingContext* context = context_owned.get(); |
| 2632 |
| 2633 FakeOutputSurfaceClient output_surface_client; |
| 2634 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2635 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2636 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2637 |
| 2638 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2639 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 2640 |
| 2641 uint32 sync_point = 30; |
| 2642 unsigned target = GL_TEXTURE_2D; |
| 2643 |
| 2644 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2645 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2646 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2647 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2648 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| 2649 |
| 2650 gpu::Mailbox gpu_mailbox; |
| 2651 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
| 2652 scoped_ptr<SingleReleaseCallback> callback = |
| 2653 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); |
| 2654 |
| 2655 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
| 2656 |
| 2657 ResourceProvider::ResourceId id = |
| 2658 resource_provider->CreateResourceFromTextureMailbox(mailbox, |
| 2659 callback.Pass()); |
| 2660 EXPECT_NE(0u, id); |
| 2661 |
| 2662 Mock::VerifyAndClearExpectations(context); |
| 2663 |
| 2664 { |
| 2665 // First call to WaitSyncPointIfNeeded should call waitSyncPoint. |
| 2666 EXPECT_CALL(*context, waitSyncPoint(sync_point)); |
| 2667 resource_provider->WaitSyncPointIfNeeded(id); |
| 2668 Mock::VerifyAndClearExpectations(context); |
| 2669 |
| 2670 // Subsequent calls to WaitSyncPointIfNeeded shouldn't call waitSyncPoint. |
| 2671 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2672 resource_provider->WaitSyncPointIfNeeded(id); |
| 2673 Mock::VerifyAndClearExpectations(context); |
| 2674 } |
| 2675 } |
| 2676 |
| 2677 TEST_P(ResourceProviderTest, TextureMailbox_WaitSyncPointIfNeeded_NoSyncPoint) { |
| 2678 // Mailboxing is only supported for GL textures. |
| 2679 if (GetParam() != ResourceProvider::GLTexture) |
| 2680 return; |
| 2681 |
| 2682 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 2683 new TextureStateTrackingContext); |
| 2684 TextureStateTrackingContext* context = context_owned.get(); |
| 2685 |
| 2686 FakeOutputSurfaceClient output_surface_client; |
| 2687 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 2688 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 2689 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 2690 |
| 2691 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
| 2692 output_surface.get(), shared_bitmap_manager_.get(), 0, false, 1, false)); |
| 2693 |
| 2694 uint32 sync_point = 0; |
| 2695 unsigned target = GL_TEXTURE_2D; |
| 2696 |
| 2697 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
| 2698 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2699 EXPECT_CALL(*context, insertSyncPoint()).Times(0); |
| 2700 EXPECT_CALL(*context, produceTextureCHROMIUM(_, _)).Times(0); |
| 2701 EXPECT_CALL(*context, consumeTextureCHROMIUM(_, _)).Times(0); |
| 2702 |
| 2703 gpu::Mailbox gpu_mailbox; |
| 2704 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
| 2705 scoped_ptr<SingleReleaseCallback> callback = |
| 2706 SingleReleaseCallback::Create(base::Bind(&EmptyReleaseCallback)); |
| 2707 |
| 2708 TextureMailbox mailbox(gpu_mailbox, target, sync_point); |
| 2709 |
| 2710 ResourceProvider::ResourceId id = |
| 2711 resource_provider->CreateResourceFromTextureMailbox(mailbox, |
| 2712 callback.Pass()); |
| 2713 EXPECT_NE(0u, id); |
| 2714 |
| 2715 Mock::VerifyAndClearExpectations(context); |
| 2716 |
| 2717 { |
| 2718 // WaitSyncPointIfNeeded with sync_point == 0 shouldn't call waitSyncPoint. |
| 2719 EXPECT_CALL(*context, waitSyncPoint(_)).Times(0); |
| 2720 resource_provider->WaitSyncPointIfNeeded(id); |
| 2721 Mock::VerifyAndClearExpectations(context); |
| 2722 } |
| 2723 } |
| 2724 |
2607 class AllocationTrackingContext3D : public TestWebGraphicsContext3D { | 2725 class AllocationTrackingContext3D : public TestWebGraphicsContext3D { |
2608 public: | 2726 public: |
2609 MOCK_METHOD0(NextTextureId, GLuint()); | 2727 MOCK_METHOD0(NextTextureId, GLuint()); |
2610 MOCK_METHOD1(RetireTextureId, void(GLuint id)); | 2728 MOCK_METHOD1(RetireTextureId, void(GLuint id)); |
2611 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); | 2729 MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); |
2612 MOCK_METHOD5(texStorage2DEXT, | 2730 MOCK_METHOD5(texStorage2DEXT, |
2613 void(GLenum target, | 2731 void(GLenum target, |
2614 GLint levels, | 2732 GLint levels, |
2615 GLuint internalformat, | 2733 GLuint internalformat, |
2616 GLint width, | 2734 GLint width, |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3405 resource_provider->AllocateForTesting(id); | 3523 resource_provider->AllocateForTesting(id); |
3406 Mock::VerifyAndClearExpectations(context); | 3524 Mock::VerifyAndClearExpectations(context); |
3407 | 3525 |
3408 DCHECK_EQ(10u, context->PeekTextureId()); | 3526 DCHECK_EQ(10u, context->PeekTextureId()); |
3409 resource_provider->DeleteResource(id); | 3527 resource_provider->DeleteResource(id); |
3410 } | 3528 } |
3411 } | 3529 } |
3412 | 3530 |
3413 } // namespace | 3531 } // namespace |
3414 } // namespace cc | 3532 } // namespace cc |
OLD | NEW |