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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 ResourceId id2 = child_resource_provider_->CreateResource( | 658 ResourceId id2 = child_resource_provider_->CreateResource( |
659 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 659 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
660 uint8_t data2[4] = { 5, 5, 5, 5 }; | 660 uint8_t data2[4] = { 5, 5, 5, 5 }; |
661 child_resource_provider_->CopyToResource(id2, data2, size); | 661 child_resource_provider_->CopyToResource(id2, data2, size); |
662 | 662 |
663 ResourceId id3 = child_resource_provider_->CreateResource( | 663 ResourceId id3 = child_resource_provider_->CreateResource( |
664 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 664 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
665 { | 665 { |
666 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 666 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
667 child_resource_provider_.get(), id3); | 667 child_resource_provider_.get(), id3); |
668 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 668 EXPECT_TRUE(lock.AllocateGpuMemoryBuffer(false)); |
669 } | 669 } |
670 | 670 |
671 GLuint external_texture_id = child_context_->createExternalTexture(); | 671 GLuint external_texture_id = child_context_->createExternalTexture(); |
672 | 672 |
673 gpu::Mailbox external_mailbox; | 673 gpu::Mailbox external_mailbox; |
674 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 674 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
675 child_context_->produceTextureDirectCHROMIUM( | 675 child_context_->produceTextureDirectCHROMIUM( |
676 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); | 676 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); |
677 const GLuint external_sync_point = child_context_->insertSyncPoint(); | 677 const GLuint external_sync_point = child_context_->insertSyncPoint(); |
678 ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( | 678 ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 uint8_t data1[4] = {1, 2, 3, 4}; | 913 uint8_t data1[4] = {1, 2, 3, 4}; |
914 child_resource_provider_->CopyToResource(id1, data1, size); | 914 child_resource_provider_->CopyToResource(id1, data1, size); |
915 | 915 |
916 ResourceId id2 = child_resource_provider_->CreateResource( | 916 ResourceId id2 = child_resource_provider_->CreateResource( |
917 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 917 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
918 { | 918 { |
919 // Ensure locking the memory buffer doesn't create an unnecessary sync | 919 // Ensure locking the memory buffer doesn't create an unnecessary sync |
920 // point. | 920 // point. |
921 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 921 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
922 child_resource_provider_.get(), id2); | 922 child_resource_provider_.get(), id2); |
923 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 923 EXPECT_TRUE(lock.AllocateGpuMemoryBuffer(false)); |
924 } | 924 } |
925 | 925 |
926 GLuint external_texture_id = child_context_->createExternalTexture(); | 926 GLuint external_texture_id = child_context_->createExternalTexture(); |
927 | 927 |
928 // A sync point is specified directly and should be used. | 928 // A sync point is specified directly and should be used. |
929 gpu::Mailbox external_mailbox; | 929 gpu::Mailbox external_mailbox; |
930 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 930 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
931 child_context_->produceTextureDirectCHROMIUM( | 931 child_context_->produceTextureDirectCHROMIUM( |
932 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); | 932 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); |
933 const GLuint external_sync_point = child_context_->insertSyncPoint(); | 933 const GLuint external_sync_point = child_context_->insertSyncPoint(); |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3518 | 3518 |
3519 id = resource_provider->CreateResource( | 3519 id = resource_provider->CreateResource( |
3520 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3520 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
3521 | 3521 |
3522 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) | 3522 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) |
3523 .WillOnce(Return(kImageId)) | 3523 .WillOnce(Return(kImageId)) |
3524 .RetiresOnSaturation(); | 3524 .RetiresOnSaturation(); |
3525 { | 3525 { |
3526 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 3526 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
3527 resource_provider.get(), id); | 3527 resource_provider.get(), id); |
3528 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 3528 EXPECT_TRUE(lock.AllocateGpuMemoryBuffer(false)); |
3529 } | 3529 } |
3530 | 3530 |
3531 EXPECT_CALL(*context, NextTextureId()) | 3531 EXPECT_CALL(*context, NextTextureId()) |
3532 .WillOnce(Return(kTextureId)) | 3532 .WillOnce(Return(kTextureId)) |
3533 .RetiresOnSaturation(); | 3533 .RetiresOnSaturation(); |
3534 // Once in CreateTextureId and once in BindForSampling | 3534 // Once in CreateTextureId and once in BindForSampling |
3535 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) | 3535 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(2) |
3536 .RetiresOnSaturation(); | 3536 .RetiresOnSaturation(); |
3537 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3537 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
3538 .Times(1) | 3538 .Times(1) |
3539 .RetiresOnSaturation(); | 3539 .RetiresOnSaturation(); |
3540 { | 3540 { |
3541 ResourceProvider::ScopedSamplerGL lock_gl( | 3541 ResourceProvider::ScopedSamplerGL lock_gl( |
3542 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); | 3542 resource_provider.get(), id, GL_TEXTURE_2D, GL_LINEAR); |
3543 EXPECT_EQ(kTextureId, lock_gl.texture_id()); | 3543 EXPECT_EQ(kTextureId, lock_gl.texture_id()); |
3544 } | 3544 } |
3545 | 3545 |
3546 { | 3546 { |
3547 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 3547 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
3548 resource_provider.get(), id); | 3548 resource_provider.get(), id); |
3549 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 3549 EXPECT_TRUE(lock.gpu_memory_buffer()); |
3550 } | 3550 } |
3551 | 3551 |
3552 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) | 3552 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1) |
3553 .RetiresOnSaturation(); | 3553 .RetiresOnSaturation(); |
3554 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3554 EXPECT_CALL(*context, releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
3555 .Times(1) | 3555 .Times(1) |
3556 .RetiresOnSaturation(); | 3556 .RetiresOnSaturation(); |
3557 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) | 3557 EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId)) |
3558 .Times(1) | 3558 .Times(1) |
3559 .RetiresOnSaturation(); | 3559 .RetiresOnSaturation(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 | 3605 |
3606 source_id = resource_provider->CreateResource( | 3606 source_id = resource_provider->CreateResource( |
3607 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3607 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
3608 | 3608 |
3609 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) | 3609 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) |
3610 .WillOnce(Return(kImageId)) | 3610 .WillOnce(Return(kImageId)) |
3611 .RetiresOnSaturation(); | 3611 .RetiresOnSaturation(); |
3612 { | 3612 { |
3613 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 3613 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
3614 resource_provider.get(), source_id); | 3614 resource_provider.get(), source_id); |
3615 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 3615 EXPECT_TRUE(lock.AllocateGpuMemoryBuffer(false)); |
3616 } | 3616 } |
3617 Mock::VerifyAndClearExpectations(context); | 3617 Mock::VerifyAndClearExpectations(context); |
3618 | 3618 |
3619 dest_id = resource_provider->CreateResource( | 3619 dest_id = resource_provider->CreateResource( |
3620 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3620 size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); |
3621 | 3621 |
3622 EXPECT_CALL(*context, NextTextureId()) | 3622 EXPECT_CALL(*context, NextTextureId()) |
3623 .WillOnce(Return(kDestTextureId)) | 3623 .WillOnce(Return(kDestTextureId)) |
3624 .RetiresOnSaturation(); | 3624 .RetiresOnSaturation(); |
3625 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) | 3625 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId)) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3802 resource_provider->AllocateForTesting(id); | 3802 resource_provider->AllocateForTesting(id); |
3803 Mock::VerifyAndClearExpectations(context); | 3803 Mock::VerifyAndClearExpectations(context); |
3804 | 3804 |
3805 DCHECK_EQ(10u, context->PeekTextureId()); | 3805 DCHECK_EQ(10u, context->PeekTextureId()); |
3806 resource_provider->DeleteResource(id); | 3806 resource_provider->DeleteResource(id); |
3807 } | 3807 } |
3808 } | 3808 } |
3809 | 3809 |
3810 } // namespace | 3810 } // namespace |
3811 } // namespace cc | 3811 } // namespace cc |
OLD | NEW |