| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 ResourceProvider* resource_provider, | 555 ResourceProvider* resource_provider, |
| 556 ResourceProviderContext* context) { | 556 ResourceProviderContext* context) { |
| 557 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type()); | 557 DCHECK_EQ(expected_default_type, resource_provider->default_resource_type()); |
| 558 | 558 |
| 559 gfx::Size size(1, 1); | 559 gfx::Size size(1, 1); |
| 560 ResourceFormat format = RGBA_8888; | 560 ResourceFormat format = RGBA_8888; |
| 561 size_t pixel_size = TextureSizeBytes(size, format); | 561 size_t pixel_size = TextureSizeBytes(size, format); |
| 562 ASSERT_EQ(4U, pixel_size); | 562 ASSERT_EQ(4U, pixel_size); |
| 563 | 563 |
| 564 ResourceId id = resource_provider->CreateResource( | 564 ResourceId id = resource_provider->CreateResource( |
| 565 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 565 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 566 gfx::ColorSpace()); |
| 566 EXPECT_EQ(1, static_cast<int>(resource_provider->num_resources())); | 567 EXPECT_EQ(1, static_cast<int>(resource_provider->num_resources())); |
| 567 if (expected_default_type == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 568 if (expected_default_type == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 568 EXPECT_EQ(0u, context->NumTextures()); | 569 EXPECT_EQ(0u, context->NumTextures()); |
| 569 | 570 |
| 570 uint8_t data[4] = { 1, 2, 3, 4 }; | 571 uint8_t data[4] = { 1, 2, 3, 4 }; |
| 571 resource_provider->CopyToResource(id, data, size); | 572 resource_provider->CopyToResource(id, data, size); |
| 572 if (expected_default_type == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 573 if (expected_default_type == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 573 EXPECT_EQ(1u, context->NumTextures()); | 574 EXPECT_EQ(1u, context->NumTextures()); |
| 574 | 575 |
| 575 uint8_t result[4] = { 0 }; | 576 uint8_t result[4] = { 0 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 586 CheckCreateResource(GetParam(), resource_provider_.get(), context()); | 587 CheckCreateResource(GetParam(), resource_provider_.get(), context()); |
| 587 } | 588 } |
| 588 | 589 |
| 589 TEST_P(ResourceProviderTest, SimpleUpload) { | 590 TEST_P(ResourceProviderTest, SimpleUpload) { |
| 590 gfx::Size size(2, 2); | 591 gfx::Size size(2, 2); |
| 591 ResourceFormat format = RGBA_8888; | 592 ResourceFormat format = RGBA_8888; |
| 592 size_t pixel_size = TextureSizeBytes(size, format); | 593 size_t pixel_size = TextureSizeBytes(size, format); |
| 593 ASSERT_EQ(16U, pixel_size); | 594 ASSERT_EQ(16U, pixel_size); |
| 594 | 595 |
| 595 ResourceId id = resource_provider_->CreateResource( | 596 ResourceId id = resource_provider_->CreateResource( |
| 596 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 597 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 598 gfx::ColorSpace()); |
| 597 | 599 |
| 598 uint8_t image[16] = {0}; | 600 uint8_t image[16] = {0}; |
| 599 resource_provider_->CopyToResource(id, image, size); | 601 resource_provider_->CopyToResource(id, image, size); |
| 600 { | 602 { |
| 601 uint8_t result[16] = {0}; | 603 uint8_t result[16] = {0}; |
| 602 uint8_t expected[16] = {0}; | 604 uint8_t expected[16] = {0}; |
| 603 GetResourcePixels(resource_provider_.get(), context(), id, size, format, | 605 GetResourcePixels(resource_provider_.get(), context(), id, size, format, |
| 604 result); | 606 result); |
| 605 EXPECT_EQ(0, memcmp(expected, result, pixel_size)); | 607 EXPECT_EQ(0, memcmp(expected, result, pixel_size)); |
| 606 } | 608 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 619 } | 621 } |
| 620 | 622 |
| 621 TEST_P(ResourceProviderTest, TransferGLResources) { | 623 TEST_P(ResourceProviderTest, TransferGLResources) { |
| 622 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 624 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 623 return; | 625 return; |
| 624 gfx::Size size(1, 1); | 626 gfx::Size size(1, 1); |
| 625 ResourceFormat format = RGBA_8888; | 627 ResourceFormat format = RGBA_8888; |
| 626 size_t pixel_size = TextureSizeBytes(size, format); | 628 size_t pixel_size = TextureSizeBytes(size, format); |
| 627 ASSERT_EQ(4U, pixel_size); | 629 ASSERT_EQ(4U, pixel_size); |
| 628 | 630 |
| 631 gfx::ColorSpace color_space1 = gfx::ColorSpace::CreateSRGB(); |
| 629 ResourceId id1 = child_resource_provider_->CreateResource( | 632 ResourceId id1 = child_resource_provider_->CreateResource( |
| 630 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 633 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, color_space1); |
| 631 uint8_t data1[4] = { 1, 2, 3, 4 }; | 634 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 632 child_resource_provider_->CopyToResource(id1, data1, size); | 635 child_resource_provider_->CopyToResource(id1, data1, size); |
| 633 | 636 |
| 634 ResourceId id2 = child_resource_provider_->CreateResource( | 637 ResourceId id2 = child_resource_provider_->CreateResource( |
| 635 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 638 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 639 gfx::ColorSpace()); |
| 636 uint8_t data2[4] = { 5, 5, 5, 5 }; | 640 uint8_t data2[4] = { 5, 5, 5, 5 }; |
| 637 child_resource_provider_->CopyToResource(id2, data2, size); | 641 child_resource_provider_->CopyToResource(id2, data2, size); |
| 638 | 642 |
| 639 ResourceId id3 = child_resource_provider_->CreateResource( | 643 ResourceId id3 = child_resource_provider_->CreateResource( |
| 640 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 644 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 645 gfx::ColorSpace()); |
| 641 { | 646 { |
| 642 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 647 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
| 643 child_resource_provider_.get(), id3); | 648 child_resource_provider_.get(), id3); |
| 644 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 649 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); |
| 645 } | 650 } |
| 646 | 651 |
| 647 GLuint external_texture_id = child_context_->createExternalTexture(); | 652 GLuint external_texture_id = child_context_->createExternalTexture(); |
| 648 | 653 |
| 649 gpu::Mailbox external_mailbox; | 654 gpu::Mailbox external_mailbox; |
| 650 child_context_->genMailboxCHROMIUM(external_mailbox.name); | 655 child_context_->genMailboxCHROMIUM(external_mailbox.name); |
| 651 child_context_->produceTextureDirectCHROMIUM( | 656 child_context_->produceTextureDirectCHROMIUM( |
| 652 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); | 657 external_texture_id, GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); |
| 653 gpu::SyncToken external_sync_token; | 658 gpu::SyncToken external_sync_token; |
| 654 child_context_->genSyncToken(child_context_->insertFenceSync(), | 659 child_context_->genSyncToken(child_context_->insertFenceSync(), |
| 655 external_sync_token.GetData()); | 660 external_sync_token.GetData()); |
| 656 EXPECT_TRUE(external_sync_token.HasData()); | 661 EXPECT_TRUE(external_sync_token.HasData()); |
| 657 | 662 |
| 658 gfx::ColorSpace id4_color_space = gfx::ColorSpace::CreateSRGB(); | 663 gfx::ColorSpace color_space4 = gfx::ColorSpace::CreateXYZD50(); |
| 659 TextureMailbox id4_mailbox(external_mailbox, external_sync_token, | 664 TextureMailbox id4_mailbox(external_mailbox, external_sync_token, |
| 660 GL_TEXTURE_EXTERNAL_OES); | 665 GL_TEXTURE_EXTERNAL_OES); |
| 661 id4_mailbox.set_color_space(id4_color_space); | 666 id4_mailbox.set_color_space(color_space4); |
| 662 ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( | 667 ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( |
| 663 id4_mailbox, | 668 id4_mailbox, |
| 664 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); | 669 SingleReleaseCallbackImpl::Create(base::Bind(&EmptyReleaseCallback))); |
| 665 | 670 |
| 666 ReturnedResourceArray returned_to_child; | 671 ReturnedResourceArray returned_to_child; |
| 667 int child_id = | 672 int child_id = |
| 668 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 673 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 669 | 674 |
| 670 { | 675 { |
| 671 // Transfer some resources to the parent. | 676 // Transfer some resources to the parent. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 GetResourcePixels( | 750 GetResourcePixels( |
| 746 resource_provider_.get(), context(), mapped_id2, size, format, result); | 751 resource_provider_.get(), context(), mapped_id2, size, format, result); |
| 747 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); | 752 EXPECT_EQ(0, memcmp(data2, result, pixel_size)); |
| 748 | 753 |
| 749 EXPECT_FALSE(resource_provider_->IsOverlayCandidate(mapped_id1)); | 754 EXPECT_FALSE(resource_provider_->IsOverlayCandidate(mapped_id1)); |
| 750 EXPECT_FALSE(resource_provider_->IsOverlayCandidate(mapped_id2)); | 755 EXPECT_FALSE(resource_provider_->IsOverlayCandidate(mapped_id2)); |
| 751 EXPECT_TRUE(resource_provider_->IsOverlayCandidate(mapped_id3)); | 756 EXPECT_TRUE(resource_provider_->IsOverlayCandidate(mapped_id3)); |
| 752 EXPECT_FALSE(resource_provider_->IsOverlayCandidate(mapped_id4)); | 757 EXPECT_FALSE(resource_provider_->IsOverlayCandidate(mapped_id4)); |
| 753 | 758 |
| 754 { | 759 { |
| 760 resource_provider_->WaitSyncTokenIfNeeded(mapped_id1); |
| 761 ResourceProvider::ScopedReadLockGL lock1(resource_provider_.get(), |
| 762 mapped_id1); |
| 763 EXPECT_TRUE(lock1.color_space() == color_space1); |
| 764 |
| 755 resource_provider_->WaitSyncTokenIfNeeded(mapped_id4); | 765 resource_provider_->WaitSyncTokenIfNeeded(mapped_id4); |
| 756 ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), | 766 ResourceProvider::ScopedReadLockGL lock4(resource_provider_.get(), |
| 757 mapped_id4); | 767 mapped_id4); |
| 758 EXPECT_TRUE(lock.color_space() == id4_color_space); | 768 EXPECT_TRUE(lock4.color_space() == color_space4); |
| 759 } | 769 } |
| 760 | 770 |
| 761 { | 771 { |
| 762 // Check that transfering again the same resource from the child to the | 772 // Check that transfering again the same resource from the child to the |
| 763 // parent works. | 773 // parent works. |
| 764 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 774 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 765 resource_ids_to_transfer.push_back(id1); | 775 resource_ids_to_transfer.push_back(id1); |
| 766 resource_ids_to_transfer.push_back(id2); | 776 resource_ids_to_transfer.push_back(id2); |
| 767 resource_ids_to_transfer.push_back(id3); | 777 resource_ids_to_transfer.push_back(id3); |
| 768 TransferableResourceArray list; | 778 TransferableResourceArray list; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 } | 905 } |
| 896 }; | 906 }; |
| 897 | 907 |
| 898 TEST_P(ResourceProviderTestNoSyncToken, TransferGLResources) { | 908 TEST_P(ResourceProviderTestNoSyncToken, TransferGLResources) { |
| 899 gfx::Size size(1, 1); | 909 gfx::Size size(1, 1); |
| 900 ResourceFormat format = RGBA_8888; | 910 ResourceFormat format = RGBA_8888; |
| 901 size_t pixel_size = TextureSizeBytes(size, format); | 911 size_t pixel_size = TextureSizeBytes(size, format); |
| 902 ASSERT_EQ(4U, pixel_size); | 912 ASSERT_EQ(4U, pixel_size); |
| 903 | 913 |
| 904 ResourceId id1 = child_resource_provider_->CreateResource( | 914 ResourceId id1 = child_resource_provider_->CreateResource( |
| 905 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 915 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 916 gfx::ColorSpace()); |
| 906 uint8_t data1[4] = {1, 2, 3, 4}; | 917 uint8_t data1[4] = {1, 2, 3, 4}; |
| 907 child_resource_provider_->CopyToResource(id1, data1, size); | 918 child_resource_provider_->CopyToResource(id1, data1, size); |
| 908 | 919 |
| 909 ResourceId id2 = child_resource_provider_->CreateResource( | 920 ResourceId id2 = child_resource_provider_->CreateResource( |
| 910 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 921 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 922 gfx::ColorSpace()); |
| 911 { | 923 { |
| 912 // Ensure locking the memory buffer doesn't create an unnecessary sync | 924 // Ensure locking the memory buffer doesn't create an unnecessary sync |
| 913 // point. | 925 // point. |
| 914 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( | 926 ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock( |
| 915 child_resource_provider_.get(), id2); | 927 child_resource_provider_.get(), id2); |
| 916 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); | 928 EXPECT_TRUE(lock.GetGpuMemoryBuffer()); |
| 917 } | 929 } |
| 918 | 930 |
| 919 GLuint external_texture_id = child_context_->createExternalTexture(); | 931 GLuint external_texture_id = child_context_->createExternalTexture(); |
| 920 | 932 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 ResourceProviderTestNoSyncToken, | 1012 ResourceProviderTestNoSyncToken, |
| 1001 ::testing::Values(ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)); | 1013 ::testing::Values(ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)); |
| 1002 | 1014 |
| 1003 TEST_P(ResourceProviderTest, ReadLockCountStopsReturnToChildOrDelete) { | 1015 TEST_P(ResourceProviderTest, ReadLockCountStopsReturnToChildOrDelete) { |
| 1004 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 1016 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 1005 return; | 1017 return; |
| 1006 gfx::Size size(1, 1); | 1018 gfx::Size size(1, 1); |
| 1007 ResourceFormat format = RGBA_8888; | 1019 ResourceFormat format = RGBA_8888; |
| 1008 | 1020 |
| 1009 ResourceId id1 = child_resource_provider_->CreateResource( | 1021 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1010 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1022 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1023 gfx::ColorSpace()); |
| 1011 uint8_t data1[4] = {1, 2, 3, 4}; | 1024 uint8_t data1[4] = {1, 2, 3, 4}; |
| 1012 child_resource_provider_->CopyToResource(id1, data1, size); | 1025 child_resource_provider_->CopyToResource(id1, data1, size); |
| 1013 | 1026 |
| 1014 ReturnedResourceArray returned_to_child; | 1027 ReturnedResourceArray returned_to_child; |
| 1015 int child_id = | 1028 int child_id = |
| 1016 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1029 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1017 { | 1030 { |
| 1018 // Transfer some resources to the parent. | 1031 // Transfer some resources to the parent. |
| 1019 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1032 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1020 resource_ids_to_transfer.push_back(id1); | 1033 resource_ids_to_transfer.push_back(id1); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 ~TestFence() override {} | 1082 ~TestFence() override {} |
| 1070 }; | 1083 }; |
| 1071 | 1084 |
| 1072 TEST_P(ResourceProviderTest, ReadLockFenceStopsReturnToChildOrDelete) { | 1085 TEST_P(ResourceProviderTest, ReadLockFenceStopsReturnToChildOrDelete) { |
| 1073 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 1086 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 1074 return; | 1087 return; |
| 1075 gfx::Size size(1, 1); | 1088 gfx::Size size(1, 1); |
| 1076 ResourceFormat format = RGBA_8888; | 1089 ResourceFormat format = RGBA_8888; |
| 1077 | 1090 |
| 1078 ResourceId id1 = child_resource_provider_->CreateResource( | 1091 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1079 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1092 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1093 gfx::ColorSpace()); |
| 1080 uint8_t data1[4] = {1, 2, 3, 4}; | 1094 uint8_t data1[4] = {1, 2, 3, 4}; |
| 1081 child_resource_provider_->CopyToResource(id1, data1, size); | 1095 child_resource_provider_->CopyToResource(id1, data1, size); |
| 1082 child_resource_provider_->EnableReadLockFencesForTesting(id1); | 1096 child_resource_provider_->EnableReadLockFencesForTesting(id1); |
| 1083 ReturnedResourceArray returned_to_child; | 1097 ReturnedResourceArray returned_to_child; |
| 1084 int child_id = | 1098 int child_id = |
| 1085 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1099 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1086 | 1100 |
| 1087 // Transfer some resources to the parent. | 1101 // Transfer some resources to the parent. |
| 1088 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1102 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1089 resource_ids_to_transfer.push_back(id1); | 1103 resource_ids_to_transfer.push_back(id1); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 EXPECT_EQ(0u, child_resource_provider_->num_resources()); | 1140 EXPECT_EQ(0u, child_resource_provider_->num_resources()); |
| 1127 } | 1141 } |
| 1128 | 1142 |
| 1129 TEST_P(ResourceProviderTest, ReadLockFenceDestroyChild) { | 1143 TEST_P(ResourceProviderTest, ReadLockFenceDestroyChild) { |
| 1130 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 1144 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 1131 return; | 1145 return; |
| 1132 gfx::Size size(1, 1); | 1146 gfx::Size size(1, 1); |
| 1133 ResourceFormat format = RGBA_8888; | 1147 ResourceFormat format = RGBA_8888; |
| 1134 | 1148 |
| 1135 ResourceId id1 = child_resource_provider_->CreateResource( | 1149 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1136 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1150 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1151 gfx::ColorSpace()); |
| 1137 uint8_t data[4] = {1, 2, 3, 4}; | 1152 uint8_t data[4] = {1, 2, 3, 4}; |
| 1138 child_resource_provider_->CopyToResource(id1, data, size); | 1153 child_resource_provider_->CopyToResource(id1, data, size); |
| 1139 child_resource_provider_->EnableReadLockFencesForTesting(id1); | 1154 child_resource_provider_->EnableReadLockFencesForTesting(id1); |
| 1140 | 1155 |
| 1141 ResourceId id2 = child_resource_provider_->CreateResource( | 1156 ResourceId id2 = child_resource_provider_->CreateResource( |
| 1142 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1157 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1158 gfx::ColorSpace()); |
| 1143 child_resource_provider_->CopyToResource(id2, data, size); | 1159 child_resource_provider_->CopyToResource(id2, data, size); |
| 1144 | 1160 |
| 1145 ReturnedResourceArray returned_to_child; | 1161 ReturnedResourceArray returned_to_child; |
| 1146 int child_id = | 1162 int child_id = |
| 1147 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1163 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1148 | 1164 |
| 1149 // Transfer resources to the parent. | 1165 // Transfer resources to the parent. |
| 1150 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1166 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1151 resource_ids_to_transfer.push_back(id1); | 1167 resource_ids_to_transfer.push_back(id1); |
| 1152 resource_ids_to_transfer.push_back(id2); | 1168 resource_ids_to_transfer.push_back(id2); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 EXPECT_EQ(0u, child_resource_provider_->num_resources()); | 1208 EXPECT_EQ(0u, child_resource_provider_->num_resources()); |
| 1193 } | 1209 } |
| 1194 | 1210 |
| 1195 TEST_P(ResourceProviderTest, ReadLockFenceContextLost) { | 1211 TEST_P(ResourceProviderTest, ReadLockFenceContextLost) { |
| 1196 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) | 1212 if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE) |
| 1197 return; | 1213 return; |
| 1198 gfx::Size size(1, 1); | 1214 gfx::Size size(1, 1); |
| 1199 ResourceFormat format = RGBA_8888; | 1215 ResourceFormat format = RGBA_8888; |
| 1200 | 1216 |
| 1201 ResourceId id1 = child_resource_provider_->CreateResource( | 1217 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1202 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1218 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1219 gfx::ColorSpace()); |
| 1203 uint8_t data[4] = {1, 2, 3, 4}; | 1220 uint8_t data[4] = {1, 2, 3, 4}; |
| 1204 child_resource_provider_->CopyToResource(id1, data, size); | 1221 child_resource_provider_->CopyToResource(id1, data, size); |
| 1205 child_resource_provider_->EnableReadLockFencesForTesting(id1); | 1222 child_resource_provider_->EnableReadLockFencesForTesting(id1); |
| 1206 | 1223 |
| 1207 ResourceId id2 = child_resource_provider_->CreateResource( | 1224 ResourceId id2 = child_resource_provider_->CreateResource( |
| 1208 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1225 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1226 gfx::ColorSpace()); |
| 1209 child_resource_provider_->CopyToResource(id2, data, size); | 1227 child_resource_provider_->CopyToResource(id2, data, size); |
| 1210 | 1228 |
| 1211 ReturnedResourceArray returned_to_child; | 1229 ReturnedResourceArray returned_to_child; |
| 1212 int child_id = | 1230 int child_id = |
| 1213 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1231 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1214 | 1232 |
| 1215 // Transfer resources to the parent. | 1233 // Transfer resources to the parent. |
| 1216 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1234 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1217 resource_ids_to_transfer.push_back(id1); | 1235 resource_ids_to_transfer.push_back(id1); |
| 1218 resource_ids_to_transfer.push_back(id2); | 1236 resource_ids_to_transfer.push_back(id2); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 TEST_P(ResourceProviderTest, TransferSoftwareResources) { | 1272 TEST_P(ResourceProviderTest, TransferSoftwareResources) { |
| 1255 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) | 1273 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) |
| 1256 return; | 1274 return; |
| 1257 | 1275 |
| 1258 gfx::Size size(1, 1); | 1276 gfx::Size size(1, 1); |
| 1259 ResourceFormat format = RGBA_8888; | 1277 ResourceFormat format = RGBA_8888; |
| 1260 size_t pixel_size = TextureSizeBytes(size, format); | 1278 size_t pixel_size = TextureSizeBytes(size, format); |
| 1261 ASSERT_EQ(4U, pixel_size); | 1279 ASSERT_EQ(4U, pixel_size); |
| 1262 | 1280 |
| 1263 ResourceId id1 = child_resource_provider_->CreateResource( | 1281 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1264 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1282 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1283 gfx::ColorSpace()); |
| 1265 uint8_t data1[4] = { 1, 2, 3, 4 }; | 1284 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 1266 child_resource_provider_->CopyToResource(id1, data1, size); | 1285 child_resource_provider_->CopyToResource(id1, data1, size); |
| 1267 | 1286 |
| 1268 ResourceId id2 = child_resource_provider_->CreateResource( | 1287 ResourceId id2 = child_resource_provider_->CreateResource( |
| 1269 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1288 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1289 gfx::ColorSpace()); |
| 1270 uint8_t data2[4] = { 5, 5, 5, 5 }; | 1290 uint8_t data2[4] = { 5, 5, 5, 5 }; |
| 1271 child_resource_provider_->CopyToResource(id2, data2, size); | 1291 child_resource_provider_->CopyToResource(id2, data2, size); |
| 1272 | 1292 |
| 1273 std::unique_ptr<SharedBitmap> shared_bitmap(CreateAndFillSharedBitmap( | 1293 std::unique_ptr<SharedBitmap> shared_bitmap(CreateAndFillSharedBitmap( |
| 1274 shared_bitmap_manager_.get(), gfx::Size(1, 1), 0)); | 1294 shared_bitmap_manager_.get(), gfx::Size(1, 1), 0)); |
| 1275 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); | 1295 SharedBitmap* shared_bitmap_ptr = shared_bitmap.get(); |
| 1276 ResourceId id3 = child_resource_provider_->CreateResourceFromTextureMailbox( | 1296 ResourceId id3 = child_resource_provider_->CreateResourceFromTextureMailbox( |
| 1277 TextureMailbox(shared_bitmap_ptr, gfx::Size(1, 1)), | 1297 TextureMailbox(shared_bitmap_ptr, gfx::Size(1, 1)), |
| 1278 SingleReleaseCallbackImpl::Create(base::Bind( | 1298 SingleReleaseCallbackImpl::Create(base::Bind( |
| 1279 &SharedBitmapReleaseCallback, base::Passed(&shared_bitmap)))); | 1299 &SharedBitmapReleaseCallback, base::Passed(&shared_bitmap)))); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 nullptr, 0, 1, kDelegatedSyncPointsRequired, | 1493 nullptr, 0, 1, kDelegatedSyncPointsRequired, |
| 1474 kUseGpuMemoryBufferResources, | 1494 kUseGpuMemoryBufferResources, |
| 1475 DefaultBufferToTextureTargetMapForTesting())); | 1495 DefaultBufferToTextureTargetMapForTesting())); |
| 1476 | 1496 |
| 1477 gfx::Size size(1, 1); | 1497 gfx::Size size(1, 1); |
| 1478 ResourceFormat format = RGBA_8888; | 1498 ResourceFormat format = RGBA_8888; |
| 1479 size_t pixel_size = TextureSizeBytes(size, format); | 1499 size_t pixel_size = TextureSizeBytes(size, format); |
| 1480 ASSERT_EQ(4U, pixel_size); | 1500 ASSERT_EQ(4U, pixel_size); |
| 1481 | 1501 |
| 1482 ResourceId id1 = child_resource_provider->CreateResource( | 1502 ResourceId id1 = child_resource_provider->CreateResource( |
| 1483 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1503 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1504 gfx::ColorSpace()); |
| 1484 uint8_t data1[4] = { 1, 2, 3, 4 }; | 1505 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 1485 child_resource_provider->CopyToResource(id1, data1, size); | 1506 child_resource_provider->CopyToResource(id1, data1, size); |
| 1486 child_resource_provider->GenerateSyncTokenForResource(id1); | 1507 child_resource_provider->GenerateSyncTokenForResource(id1); |
| 1487 | 1508 |
| 1488 ReturnedResourceArray returned_to_child; | 1509 ReturnedResourceArray returned_to_child; |
| 1489 int child_id = | 1510 int child_id = |
| 1490 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1511 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1491 { | 1512 { |
| 1492 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1513 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1493 resource_ids_to_transfer.push_back(id1); | 1514 resource_ids_to_transfer.push_back(id1); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1521 TEST_P(ResourceProviderTest, TransferInvalidSoftware) { | 1542 TEST_P(ResourceProviderTest, TransferInvalidSoftware) { |
| 1522 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) | 1543 if (GetParam() != ResourceProvider::RESOURCE_TYPE_BITMAP) |
| 1523 return; | 1544 return; |
| 1524 | 1545 |
| 1525 gfx::Size size(1, 1); | 1546 gfx::Size size(1, 1); |
| 1526 ResourceFormat format = RGBA_8888; | 1547 ResourceFormat format = RGBA_8888; |
| 1527 size_t pixel_size = TextureSizeBytes(size, format); | 1548 size_t pixel_size = TextureSizeBytes(size, format); |
| 1528 ASSERT_EQ(4U, pixel_size); | 1549 ASSERT_EQ(4U, pixel_size); |
| 1529 | 1550 |
| 1530 ResourceId id1 = child_resource_provider_->CreateResource( | 1551 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1531 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1552 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1553 gfx::ColorSpace()); |
| 1532 uint8_t data1[4] = { 1, 2, 3, 4 }; | 1554 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 1533 child_resource_provider_->CopyToResource(id1, data1, size); | 1555 child_resource_provider_->CopyToResource(id1, data1, size); |
| 1534 | 1556 |
| 1535 ReturnedResourceArray returned_to_child; | 1557 ReturnedResourceArray returned_to_child; |
| 1536 int child_id = | 1558 int child_id = |
| 1537 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1559 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1538 { | 1560 { |
| 1539 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1561 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1540 resource_ids_to_transfer.push_back(id1); | 1562 resource_ids_to_transfer.push_back(id1); |
| 1541 | 1563 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1572 EXPECT_FALSE(returned_to_child[0].lost); | 1594 EXPECT_FALSE(returned_to_child[0].lost); |
| 1573 } | 1595 } |
| 1574 | 1596 |
| 1575 TEST_P(ResourceProviderTest, DeleteExportedResources) { | 1597 TEST_P(ResourceProviderTest, DeleteExportedResources) { |
| 1576 gfx::Size size(1, 1); | 1598 gfx::Size size(1, 1); |
| 1577 ResourceFormat format = RGBA_8888; | 1599 ResourceFormat format = RGBA_8888; |
| 1578 size_t pixel_size = TextureSizeBytes(size, format); | 1600 size_t pixel_size = TextureSizeBytes(size, format); |
| 1579 ASSERT_EQ(4U, pixel_size); | 1601 ASSERT_EQ(4U, pixel_size); |
| 1580 | 1602 |
| 1581 ResourceId id1 = child_resource_provider_->CreateResource( | 1603 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1582 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1604 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1605 gfx::ColorSpace()); |
| 1583 uint8_t data1[4] = { 1, 2, 3, 4 }; | 1606 uint8_t data1[4] = { 1, 2, 3, 4 }; |
| 1584 child_resource_provider_->CopyToResource(id1, data1, size); | 1607 child_resource_provider_->CopyToResource(id1, data1, size); |
| 1585 | 1608 |
| 1586 ResourceId id2 = child_resource_provider_->CreateResource( | 1609 ResourceId id2 = child_resource_provider_->CreateResource( |
| 1587 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1610 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1611 gfx::ColorSpace()); |
| 1588 uint8_t data2[4] = {5, 5, 5, 5}; | 1612 uint8_t data2[4] = {5, 5, 5, 5}; |
| 1589 child_resource_provider_->CopyToResource(id2, data2, size); | 1613 child_resource_provider_->CopyToResource(id2, data2, size); |
| 1590 | 1614 |
| 1591 ReturnedResourceArray returned_to_child; | 1615 ReturnedResourceArray returned_to_child; |
| 1592 int child_id = | 1616 int child_id = |
| 1593 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1617 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1594 { | 1618 { |
| 1595 // Transfer some resources to the parent. | 1619 // Transfer some resources to the parent. |
| 1596 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1620 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1597 resource_ids_to_transfer.push_back(id1); | 1621 resource_ids_to_transfer.push_back(id1); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 } | 1700 } |
| 1677 } | 1701 } |
| 1678 | 1702 |
| 1679 TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { | 1703 TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { |
| 1680 gfx::Size size(1, 1); | 1704 gfx::Size size(1, 1); |
| 1681 ResourceFormat format = RGBA_8888; | 1705 ResourceFormat format = RGBA_8888; |
| 1682 size_t pixel_size = TextureSizeBytes(size, format); | 1706 size_t pixel_size = TextureSizeBytes(size, format); |
| 1683 ASSERT_EQ(4U, pixel_size); | 1707 ASSERT_EQ(4U, pixel_size); |
| 1684 | 1708 |
| 1685 ResourceId id1 = child_resource_provider_->CreateResource( | 1709 ResourceId id1 = child_resource_provider_->CreateResource( |
| 1686 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1710 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1711 gfx::ColorSpace()); |
| 1687 uint8_t data1[4] = {1, 2, 3, 4}; | 1712 uint8_t data1[4] = {1, 2, 3, 4}; |
| 1688 child_resource_provider_->CopyToResource(id1, data1, size); | 1713 child_resource_provider_->CopyToResource(id1, data1, size); |
| 1689 | 1714 |
| 1690 ResourceId id2 = child_resource_provider_->CreateResource( | 1715 ResourceId id2 = child_resource_provider_->CreateResource( |
| 1691 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1716 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1717 gfx::ColorSpace()); |
| 1692 uint8_t data2[4] = {5, 5, 5, 5}; | 1718 uint8_t data2[4] = {5, 5, 5, 5}; |
| 1693 child_resource_provider_->CopyToResource(id2, data2, size); | 1719 child_resource_provider_->CopyToResource(id2, data2, size); |
| 1694 | 1720 |
| 1695 ReturnedResourceArray returned_to_child; | 1721 ReturnedResourceArray returned_to_child; |
| 1696 int child_id = | 1722 int child_id = |
| 1697 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1723 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1698 { | 1724 { |
| 1699 // Transfer some resources to the parent. | 1725 // Transfer some resources to the parent. |
| 1700 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1726 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1701 resource_ids_to_transfer.push_back(id1); | 1727 resource_ids_to_transfer.push_back(id1); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 } | 1823 } |
| 1798 } | 1824 } |
| 1799 | 1825 |
| 1800 TEST_P(ResourceProviderTest, DeleteTransferredResources) { | 1826 TEST_P(ResourceProviderTest, DeleteTransferredResources) { |
| 1801 gfx::Size size(1, 1); | 1827 gfx::Size size(1, 1); |
| 1802 ResourceFormat format = RGBA_8888; | 1828 ResourceFormat format = RGBA_8888; |
| 1803 size_t pixel_size = TextureSizeBytes(size, format); | 1829 size_t pixel_size = TextureSizeBytes(size, format); |
| 1804 ASSERT_EQ(4U, pixel_size); | 1830 ASSERT_EQ(4U, pixel_size); |
| 1805 | 1831 |
| 1806 ResourceId id = child_resource_provider_->CreateResource( | 1832 ResourceId id = child_resource_provider_->CreateResource( |
| 1807 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1833 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1834 gfx::ColorSpace()); |
| 1808 uint8_t data[4] = { 1, 2, 3, 4 }; | 1835 uint8_t data[4] = { 1, 2, 3, 4 }; |
| 1809 child_resource_provider_->CopyToResource(id, data, size); | 1836 child_resource_provider_->CopyToResource(id, data, size); |
| 1810 | 1837 |
| 1811 ReturnedResourceArray returned_to_child; | 1838 ReturnedResourceArray returned_to_child; |
| 1812 int child_id = | 1839 int child_id = |
| 1813 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1840 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1814 { | 1841 { |
| 1815 // Transfer some resource to the parent. | 1842 // Transfer some resource to the parent. |
| 1816 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 1843 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 1817 resource_ids_to_transfer.push_back(id); | 1844 resource_ids_to_transfer.push_back(id); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 EXPECT_EQ(0u, child_resource_provider_->num_resources()); | 1879 EXPECT_EQ(0u, child_resource_provider_->num_resources()); |
| 1853 } | 1880 } |
| 1854 | 1881 |
| 1855 TEST_P(ResourceProviderTest, UnuseTransferredResources) { | 1882 TEST_P(ResourceProviderTest, UnuseTransferredResources) { |
| 1856 gfx::Size size(1, 1); | 1883 gfx::Size size(1, 1); |
| 1857 ResourceFormat format = RGBA_8888; | 1884 ResourceFormat format = RGBA_8888; |
| 1858 size_t pixel_size = TextureSizeBytes(size, format); | 1885 size_t pixel_size = TextureSizeBytes(size, format); |
| 1859 ASSERT_EQ(4U, pixel_size); | 1886 ASSERT_EQ(4U, pixel_size); |
| 1860 | 1887 |
| 1861 ResourceId id = child_resource_provider_->CreateResource( | 1888 ResourceId id = child_resource_provider_->CreateResource( |
| 1862 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 1889 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 1890 gfx::ColorSpace()); |
| 1863 uint8_t data[4] = {1, 2, 3, 4}; | 1891 uint8_t data[4] = {1, 2, 3, 4}; |
| 1864 child_resource_provider_->CopyToResource(id, data, size); | 1892 child_resource_provider_->CopyToResource(id, data, size); |
| 1865 | 1893 |
| 1866 ReturnedResourceArray returned_to_child; | 1894 ReturnedResourceArray returned_to_child; |
| 1867 int child_id = | 1895 int child_id = |
| 1868 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 1896 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 1869 const ResourceProvider::ResourceIdMap& map = | 1897 const ResourceProvider::ResourceIdMap& map = |
| 1870 resource_provider_->GetChildToParentMap(child_id); | 1898 resource_provider_->GetChildToParentMap(child_id); |
| 1871 { | 1899 { |
| 1872 // Transfer some resource to the parent. | 1900 // Transfer some resource to the parent. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 | 2036 |
| 2009 gfx::Size size(1, 1); | 2037 gfx::Size size(1, 1); |
| 2010 ResourceFormat format = RGBA_8888; | 2038 ResourceFormat format = RGBA_8888; |
| 2011 int child_texture_id = 1; | 2039 int child_texture_id = 1; |
| 2012 int parent_texture_id = 2; | 2040 int parent_texture_id = 2; |
| 2013 | 2041 |
| 2014 size_t pixel_size = TextureSizeBytes(size, format); | 2042 size_t pixel_size = TextureSizeBytes(size, format); |
| 2015 ASSERT_EQ(4U, pixel_size); | 2043 ASSERT_EQ(4U, pixel_size); |
| 2016 | 2044 |
| 2017 ResourceId id = child_resource_provider->CreateResource( | 2045 ResourceId id = child_resource_provider->CreateResource( |
| 2018 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2046 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 2047 gfx::ColorSpace()); |
| 2019 | 2048 |
| 2020 // The new texture is created with GL_LINEAR. | 2049 // The new texture is created with GL_LINEAR. |
| 2021 EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, child_texture_id)) | 2050 EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, child_texture_id)) |
| 2022 .Times(2); // Once to create and once to allocate. | 2051 .Times(2); // Once to create and once to allocate. |
| 2023 EXPECT_CALL(*child_context, | 2052 EXPECT_CALL(*child_context, |
| 2024 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2053 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 2025 EXPECT_CALL(*child_context, | 2054 EXPECT_CALL(*child_context, |
| 2026 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2055 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 2027 EXPECT_CALL( | 2056 EXPECT_CALL( |
| 2028 *child_context, | 2057 *child_context, |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 context()->waitSyncToken(release_sync_token.GetConstData()); | 2313 context()->waitSyncToken(release_sync_token.GetConstData()); |
| 2285 texture = | 2314 texture = |
| 2286 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 2315 context()->createAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 2287 context()->deleteTexture(texture); | 2316 context()->deleteTexture(texture); |
| 2288 } | 2317 } |
| 2289 | 2318 |
| 2290 TEST_P(ResourceProviderTest, LostResourceInParent) { | 2319 TEST_P(ResourceProviderTest, LostResourceInParent) { |
| 2291 gfx::Size size(1, 1); | 2320 gfx::Size size(1, 1); |
| 2292 ResourceFormat format = RGBA_8888; | 2321 ResourceFormat format = RGBA_8888; |
| 2293 ResourceId resource = child_resource_provider_->CreateResource( | 2322 ResourceId resource = child_resource_provider_->CreateResource( |
| 2294 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2323 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 2324 gfx::ColorSpace()); |
| 2295 child_resource_provider_->AllocateForTesting(resource); | 2325 child_resource_provider_->AllocateForTesting(resource); |
| 2296 // Expect a GL resource to be lost. | 2326 // Expect a GL resource to be lost. |
| 2297 bool should_lose_resource = | 2327 bool should_lose_resource = |
| 2298 GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE; | 2328 GetParam() == ResourceProvider::RESOURCE_TYPE_GL_TEXTURE; |
| 2299 | 2329 |
| 2300 ReturnedResourceArray returned_to_child; | 2330 ReturnedResourceArray returned_to_child; |
| 2301 int child_id = | 2331 int child_id = |
| 2302 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 2332 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 2303 { | 2333 { |
| 2304 // Transfer the resource to the parent. | 2334 // Transfer the resource to the parent. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 | 2369 |
| 2340 // Lost resources stay in use in the parent forever. | 2370 // Lost resources stay in use in the parent forever. |
| 2341 EXPECT_EQ(should_lose_resource, | 2371 EXPECT_EQ(should_lose_resource, |
| 2342 child_resource_provider_->InUseByConsumer(resource)); | 2372 child_resource_provider_->InUseByConsumer(resource)); |
| 2343 } | 2373 } |
| 2344 | 2374 |
| 2345 TEST_P(ResourceProviderTest, LostResourceInGrandParent) { | 2375 TEST_P(ResourceProviderTest, LostResourceInGrandParent) { |
| 2346 gfx::Size size(1, 1); | 2376 gfx::Size size(1, 1); |
| 2347 ResourceFormat format = RGBA_8888; | 2377 ResourceFormat format = RGBA_8888; |
| 2348 ResourceId resource = child_resource_provider_->CreateResource( | 2378 ResourceId resource = child_resource_provider_->CreateResource( |
| 2349 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2379 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 2380 gfx::ColorSpace()); |
| 2350 child_resource_provider_->AllocateForTesting(resource); | 2381 child_resource_provider_->AllocateForTesting(resource); |
| 2351 | 2382 |
| 2352 ReturnedResourceArray returned_to_child; | 2383 ReturnedResourceArray returned_to_child; |
| 2353 int child_id = | 2384 int child_id = |
| 2354 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); | 2385 resource_provider_->CreateChild(GetReturnCallback(&returned_to_child)); |
| 2355 { | 2386 { |
| 2356 // Transfer the resource to the parent. | 2387 // Transfer the resource to the parent. |
| 2357 ResourceProvider::ResourceIdArray resource_ids_to_transfer; | 2388 ResourceProvider::ResourceIdArray resource_ids_to_transfer; |
| 2358 resource_ids_to_transfer.push_back(resource); | 2389 resource_ids_to_transfer.push_back(resource); |
| 2359 TransferableResourceArray list; | 2390 TransferableResourceArray list; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 output_surface->context_provider(), shared_bitmap_manager_.get(), | 2672 output_surface->context_provider(), shared_bitmap_manager_.get(), |
| 2642 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2673 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2643 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2674 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2644 DefaultBufferToTextureTargetMapForTesting())); | 2675 DefaultBufferToTextureTargetMapForTesting())); |
| 2645 | 2676 |
| 2646 gfx::Size size(1, 1); | 2677 gfx::Size size(1, 1); |
| 2647 ResourceFormat format = RGBA_8888; | 2678 ResourceFormat format = RGBA_8888; |
| 2648 int texture_id = 1; | 2679 int texture_id = 1; |
| 2649 | 2680 |
| 2650 ResourceId id = resource_provider->CreateResource( | 2681 ResourceId id = resource_provider->CreateResource( |
| 2651 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2682 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 2683 gfx::ColorSpace()); |
| 2652 | 2684 |
| 2653 // Check that the texture gets created with the right sampler settings. | 2685 // Check that the texture gets created with the right sampler settings. |
| 2654 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) | 2686 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) |
| 2655 .Times(2); // Once to create and once to allocate. | 2687 .Times(2); // Once to create and once to allocate. |
| 2656 EXPECT_CALL(*context, | 2688 EXPECT_CALL(*context, |
| 2657 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2689 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 2658 EXPECT_CALL(*context, | 2690 EXPECT_CALL(*context, |
| 2659 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2691 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 2660 EXPECT_CALL( | 2692 EXPECT_CALL( |
| 2661 *context, | 2693 *context, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2723 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2755 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2724 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2756 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2725 DefaultBufferToTextureTargetMapForTesting())); | 2757 DefaultBufferToTextureTargetMapForTesting())); |
| 2726 | 2758 |
| 2727 gfx::Size size(1, 1); | 2759 gfx::Size size(1, 1); |
| 2728 ResourceFormat format = RGBA_8888; | 2760 ResourceFormat format = RGBA_8888; |
| 2729 int texture_id = 1; | 2761 int texture_id = 1; |
| 2730 | 2762 |
| 2731 // Check that the texture gets created with the right sampler settings. | 2763 // Check that the texture gets created with the right sampler settings. |
| 2732 ResourceId id = resource_provider->CreateResource( | 2764 ResourceId id = resource_provider->CreateResource( |
| 2733 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2765 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 2766 gfx::ColorSpace()); |
| 2734 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 2767 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 2735 EXPECT_CALL(*context, | 2768 EXPECT_CALL(*context, |
| 2736 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2769 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 2737 EXPECT_CALL(*context, | 2770 EXPECT_CALL(*context, |
| 2738 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2771 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 2739 EXPECT_CALL( | 2772 EXPECT_CALL( |
| 2740 *context, | 2773 *context, |
| 2741 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 2774 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 2742 EXPECT_CALL( | 2775 EXPECT_CALL( |
| 2743 *context, | 2776 *context, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2768 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 2801 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 2769 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 2802 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 2770 DefaultBufferToTextureTargetMapForTesting())); | 2803 DefaultBufferToTextureTargetMapForTesting())); |
| 2771 | 2804 |
| 2772 gfx::Size size(1, 1); | 2805 gfx::Size size(1, 1); |
| 2773 ResourceFormat format = RGBA_8888; | 2806 ResourceFormat format = RGBA_8888; |
| 2774 | 2807 |
| 2775 for (int texture_id = 1; texture_id <= 2; ++texture_id) { | 2808 for (int texture_id = 1; texture_id <= 2; ++texture_id) { |
| 2776 // Check that the texture gets created with the right sampler settings. | 2809 // Check that the texture gets created with the right sampler settings. |
| 2777 ResourceId id = resource_provider->CreateResource( | 2810 ResourceId id = resource_provider->CreateResource( |
| 2778 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 2811 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 2812 gfx::ColorSpace()); |
| 2779 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 2813 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 2780 EXPECT_CALL(*context, | 2814 EXPECT_CALL(*context, |
| 2781 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2815 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 2782 EXPECT_CALL(*context, | 2816 EXPECT_CALL(*context, |
| 2783 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2817 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 2784 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, | 2818 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, |
| 2785 GL_CLAMP_TO_EDGE)); | 2819 GL_CLAMP_TO_EDGE)); |
| 2786 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, | 2820 EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, |
| 2787 GL_CLAMP_TO_EDGE)); | 2821 GL_CLAMP_TO_EDGE)); |
| 2788 resource_provider->CreateForTesting(id); | 2822 resource_provider->CreateForTesting(id); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2819 ResourceFormat format = RGBA_8888; | 2853 ResourceFormat format = RGBA_8888; |
| 2820 | 2854 |
| 2821 const ResourceProvider::TextureHint hints[4] = { | 2855 const ResourceProvider::TextureHint hints[4] = { |
| 2822 ResourceProvider::TEXTURE_HINT_DEFAULT, | 2856 ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 2823 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 2857 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 2824 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, | 2858 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, |
| 2825 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, | 2859 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, |
| 2826 }; | 2860 }; |
| 2827 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { | 2861 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { |
| 2828 // Check that the texture gets created with the right sampler settings. | 2862 // Check that the texture gets created with the right sampler settings. |
| 2829 ResourceId id = | 2863 ResourceId id = resource_provider->CreateResource( |
| 2830 resource_provider->CreateResource(size, hints[texture_id - 1], format); | 2864 size, hints[texture_id - 1], format, gfx::ColorSpace()); |
| 2831 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 2865 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 2832 EXPECT_CALL(*context, | 2866 EXPECT_CALL(*context, |
| 2833 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 2867 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 2834 EXPECT_CALL(*context, | 2868 EXPECT_CALL(*context, |
| 2835 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 2869 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 2836 EXPECT_CALL( | 2870 EXPECT_CALL( |
| 2837 *context, | 2871 *context, |
| 2838 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 2872 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 2839 EXPECT_CALL( | 2873 EXPECT_CALL( |
| 2840 *context, | 2874 *context, |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3330 | 3364 |
| 3331 gfx::Size size(2, 2); | 3365 gfx::Size size(2, 2); |
| 3332 gfx::Vector2d offset(0, 0); | 3366 gfx::Vector2d offset(0, 0); |
| 3333 ResourceFormat format = RGBA_8888; | 3367 ResourceFormat format = RGBA_8888; |
| 3334 ResourceId id = 0; | 3368 ResourceId id = 0; |
| 3335 uint8_t pixels[16] = { 0 }; | 3369 uint8_t pixels[16] = { 0 }; |
| 3336 int texture_id = 123; | 3370 int texture_id = 123; |
| 3337 | 3371 |
| 3338 // Lazy allocation. Don't allocate when creating the resource. | 3372 // Lazy allocation. Don't allocate when creating the resource. |
| 3339 id = resource_provider->CreateResource( | 3373 id = resource_provider->CreateResource( |
| 3340 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3374 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3375 gfx::ColorSpace()); |
| 3341 | 3376 |
| 3342 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3377 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3343 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); | 3378 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); |
| 3344 resource_provider->CreateForTesting(id); | 3379 resource_provider->CreateForTesting(id); |
| 3345 | 3380 |
| 3346 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 3381 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
| 3347 resource_provider->DeleteResource(id); | 3382 resource_provider->DeleteResource(id); |
| 3348 | 3383 |
| 3349 Mock::VerifyAndClearExpectations(context); | 3384 Mock::VerifyAndClearExpectations(context); |
| 3350 | 3385 |
| 3351 // Do allocate when we set the pixels. | 3386 // Do allocate when we set the pixels. |
| 3352 id = resource_provider->CreateResource( | 3387 id = resource_provider->CreateResource( |
| 3353 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3388 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3389 gfx::ColorSpace()); |
| 3354 | 3390 |
| 3355 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3391 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3356 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 3392 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
| 3357 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); | 3393 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); |
| 3358 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); | 3394 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); |
| 3359 resource_provider->CopyToResource(id, pixels, size); | 3395 resource_provider->CopyToResource(id, pixels, size); |
| 3360 | 3396 |
| 3361 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 3397 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
| 3362 resource_provider->DeleteResource(id); | 3398 resource_provider->DeleteResource(id); |
| 3363 | 3399 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3392 const ResourceProvider::TextureHint hints[4] = { | 3428 const ResourceProvider::TextureHint hints[4] = { |
| 3393 ResourceProvider::TEXTURE_HINT_DEFAULT, | 3429 ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 3394 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 3430 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 3395 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, | 3431 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, |
| 3396 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, | 3432 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, |
| 3397 }; | 3433 }; |
| 3398 for (size_t i = 0; i < arraysize(formats); ++i) { | 3434 for (size_t i = 0; i < arraysize(formats); ++i) { |
| 3399 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { | 3435 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { |
| 3400 // Lazy allocation. Don't allocate when creating the resource. | 3436 // Lazy allocation. Don't allocate when creating the resource. |
| 3401 ResourceId id = resource_provider->CreateResource( | 3437 ResourceId id = resource_provider->CreateResource( |
| 3402 size, hints[texture_id - 1], formats[i]); | 3438 size, hints[texture_id - 1], formats[i], gfx::ColorSpace()); |
| 3403 | 3439 |
| 3404 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3440 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3405 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 3441 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 3406 bool is_immutable_hint = | 3442 bool is_immutable_hint = |
| 3407 hints[texture_id - 1] & ResourceProvider::TEXTURE_HINT_IMMUTABLE; | 3443 hints[texture_id - 1] & ResourceProvider::TEXTURE_HINT_IMMUTABLE; |
| 3408 bool support_immutable_texture = | 3444 bool support_immutable_texture = |
| 3409 is_immutable_hint && formats[i] == RGBA_8888; | 3445 is_immutable_hint && formats[i] == RGBA_8888; |
| 3410 EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) | 3446 EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) |
| 3411 .Times(support_immutable_texture ? 1 : 0); | 3447 .Times(support_immutable_texture ? 1 : 0); |
| 3412 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) | 3448 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3450 const ResourceProvider::TextureHint hints[4] = { | 3486 const ResourceProvider::TextureHint hints[4] = { |
| 3451 ResourceProvider::TEXTURE_HINT_DEFAULT, | 3487 ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 3452 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 3488 ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 3453 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, | 3489 ResourceProvider::TEXTURE_HINT_FRAMEBUFFER, |
| 3454 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, | 3490 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, |
| 3455 }; | 3491 }; |
| 3456 for (size_t i = 0; i < arraysize(formats); ++i) { | 3492 for (size_t i = 0; i < arraysize(formats); ++i) { |
| 3457 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { | 3493 for (GLuint texture_id = 1; texture_id <= arraysize(hints); ++texture_id) { |
| 3458 // Lazy allocation. Don't allocate when creating the resource. | 3494 // Lazy allocation. Don't allocate when creating the resource. |
| 3459 ResourceId id = resource_provider->CreateResource( | 3495 ResourceId id = resource_provider->CreateResource( |
| 3460 size, hints[texture_id - 1], formats[i]); | 3496 size, hints[texture_id - 1], formats[i], gfx::ColorSpace()); |
| 3461 | 3497 |
| 3462 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3498 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3463 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 3499 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 3464 bool is_immutable_hint = | 3500 bool is_immutable_hint = |
| 3465 hints[texture_id - 1] & ResourceProvider::TEXTURE_HINT_IMMUTABLE; | 3501 hints[texture_id - 1] & ResourceProvider::TEXTURE_HINT_IMMUTABLE; |
| 3466 EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) | 3502 EXPECT_CALL(*context, texStorage2DEXT(_, _, _, 2, 2)) |
| 3467 .Times(is_immutable_hint ? 1 : 0); | 3503 .Times(is_immutable_hint ? 1 : 0); |
| 3468 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) | 3504 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)) |
| 3469 .Times(is_immutable_hint ? 0 : 1); | 3505 .Times(is_immutable_hint ? 0 : 1); |
| 3470 resource_provider->AllocateForTesting(id); | 3506 resource_provider->AllocateForTesting(id); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3499 const unsigned kImageId = 234u; | 3535 const unsigned kImageId = 234u; |
| 3500 | 3536 |
| 3501 std::unique_ptr<ResourceProvider> resource_provider( | 3537 std::unique_ptr<ResourceProvider> resource_provider( |
| 3502 base::MakeUnique<ResourceProvider>( | 3538 base::MakeUnique<ResourceProvider>( |
| 3503 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3539 output_surface->context_provider(), shared_bitmap_manager_.get(), |
| 3504 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3540 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3505 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3541 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3506 DefaultBufferToTextureTargetMapForTesting())); | 3542 DefaultBufferToTextureTargetMapForTesting())); |
| 3507 | 3543 |
| 3508 id = resource_provider->CreateResource( | 3544 id = resource_provider->CreateResource( |
| 3509 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3545 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3546 gfx::ColorSpace()); |
| 3510 | 3547 |
| 3511 EXPECT_CALL(*context, NextTextureId()) | 3548 EXPECT_CALL(*context, NextTextureId()) |
| 3512 .WillOnce(Return(kTextureId)) | 3549 .WillOnce(Return(kTextureId)) |
| 3513 .RetiresOnSaturation(); | 3550 .RetiresOnSaturation(); |
| 3514 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) | 3551 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)) |
| 3515 .Times(3) | 3552 .Times(3) |
| 3516 .RetiresOnSaturation(); | 3553 .RetiresOnSaturation(); |
| 3517 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) | 3554 EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA)) |
| 3518 .WillOnce(Return(kImageId)) | 3555 .WillOnce(Return(kImageId)) |
| 3519 .RetiresOnSaturation(); | 3556 .RetiresOnSaturation(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3580 gfx::Size size(4, 4); | 3617 gfx::Size size(4, 4); |
| 3581 std::unique_ptr<ResourceProvider> resource_provider( | 3618 std::unique_ptr<ResourceProvider> resource_provider( |
| 3582 base::MakeUnique<ResourceProvider>( | 3619 base::MakeUnique<ResourceProvider>( |
| 3583 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3620 output_surface->context_provider(), shared_bitmap_manager_.get(), |
| 3584 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3621 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3585 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3622 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3586 DefaultBufferToTextureTargetMapForTesting())); | 3623 DefaultBufferToTextureTargetMapForTesting())); |
| 3587 int texture_id = 123; | 3624 int texture_id = 123; |
| 3588 | 3625 |
| 3589 ResourceId id = resource_provider->CreateResource( | 3626 ResourceId id = resource_provider->CreateResource( |
| 3590 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); | 3627 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); |
| 3591 EXPECT_NE(0u, id); | 3628 EXPECT_NE(0u, id); |
| 3592 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3629 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3593 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); | 3630 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2); |
| 3594 resource_provider->AllocateForTesting(id); | 3631 resource_provider->AllocateForTesting(id); |
| 3595 | 3632 |
| 3596 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 3633 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
| 3597 resource_provider->DeleteResource(id); | 3634 resource_provider->DeleteResource(id); |
| 3598 } | 3635 } |
| 3599 | 3636 |
| 3600 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { | 3637 TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3615 std::unique_ptr<ResourceProvider> resource_provider( | 3652 std::unique_ptr<ResourceProvider> resource_provider( |
| 3616 base::MakeUnique<ResourceProvider>( | 3653 base::MakeUnique<ResourceProvider>( |
| 3617 output_surface->context_provider(), shared_bitmap_manager_.get(), | 3654 output_surface->context_provider(), shared_bitmap_manager_.get(), |
| 3618 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, | 3655 gpu_memory_buffer_manager_.get(), nullptr, 0, 1, |
| 3619 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3656 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3620 DefaultBufferToTextureTargetMapForTesting())); | 3657 DefaultBufferToTextureTargetMapForTesting())); |
| 3621 int texture_id = 123; | 3658 int texture_id = 123; |
| 3622 uint8_t pixels[8]; | 3659 uint8_t pixels[8]; |
| 3623 | 3660 |
| 3624 ResourceId id = resource_provider->CreateResource( | 3661 ResourceId id = resource_provider->CreateResource( |
| 3625 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1); | 3662 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, ETC1, gfx::ColorSpace()); |
| 3626 EXPECT_NE(0u, id); | 3663 EXPECT_NE(0u, id); |
| 3627 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); | 3664 EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(texture_id)); |
| 3628 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 3665 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
| 3629 EXPECT_CALL(*context, | 3666 EXPECT_CALL(*context, |
| 3630 compressedTexImage2D( | 3667 compressedTexImage2D( |
| 3631 _, 0, _, size.width(), size.height(), _, _, _)).Times(1); | 3668 _, 0, _, size.width(), size.height(), _, _, _)).Times(1); |
| 3632 resource_provider->CopyToResource(id, pixels, size); | 3669 resource_provider->CopyToResource(id, pixels, size); |
| 3633 | 3670 |
| 3634 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); | 3671 EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); |
| 3635 resource_provider->DeleteResource(id); | 3672 resource_provider->DeleteResource(id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3672 { | 3709 { |
| 3673 size_t kTextureAllocationChunkSize = 1; | 3710 size_t kTextureAllocationChunkSize = 1; |
| 3674 std::unique_ptr<ResourceProvider> resource_provider( | 3711 std::unique_ptr<ResourceProvider> resource_provider( |
| 3675 base::MakeUnique<ResourceProvider>( | 3712 base::MakeUnique<ResourceProvider>( |
| 3676 output_surface->context_provider(), shared_bitmap_manager.get(), | 3713 output_surface->context_provider(), shared_bitmap_manager.get(), |
| 3677 nullptr, nullptr, 0, kTextureAllocationChunkSize, | 3714 nullptr, nullptr, 0, kTextureAllocationChunkSize, |
| 3678 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3715 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3679 DefaultBufferToTextureTargetMapForTesting())); | 3716 DefaultBufferToTextureTargetMapForTesting())); |
| 3680 | 3717 |
| 3681 ResourceId id = resource_provider->CreateResource( | 3718 ResourceId id = resource_provider->CreateResource( |
| 3682 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3719 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3720 gfx::ColorSpace()); |
| 3683 resource_provider->AllocateForTesting(id); | 3721 resource_provider->AllocateForTesting(id); |
| 3684 Mock::VerifyAndClearExpectations(context); | 3722 Mock::VerifyAndClearExpectations(context); |
| 3685 | 3723 |
| 3686 DCHECK_EQ(2u, context->PeekTextureId()); | 3724 DCHECK_EQ(2u, context->PeekTextureId()); |
| 3687 resource_provider->DeleteResource(id); | 3725 resource_provider->DeleteResource(id); |
| 3688 } | 3726 } |
| 3689 | 3727 |
| 3690 { | 3728 { |
| 3691 size_t kTextureAllocationChunkSize = 8; | 3729 size_t kTextureAllocationChunkSize = 8; |
| 3692 std::unique_ptr<ResourceProvider> resource_provider( | 3730 std::unique_ptr<ResourceProvider> resource_provider( |
| 3693 base::MakeUnique<ResourceProvider>( | 3731 base::MakeUnique<ResourceProvider>( |
| 3694 output_surface->context_provider(), shared_bitmap_manager.get(), | 3732 output_surface->context_provider(), shared_bitmap_manager.get(), |
| 3695 nullptr, nullptr, 0, kTextureAllocationChunkSize, | 3733 nullptr, nullptr, 0, kTextureAllocationChunkSize, |
| 3696 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, | 3734 kDelegatedSyncPointsRequired, kUseGpuMemoryBufferResources, |
| 3697 DefaultBufferToTextureTargetMapForTesting())); | 3735 DefaultBufferToTextureTargetMapForTesting())); |
| 3698 | 3736 |
| 3699 ResourceId id = resource_provider->CreateResource( | 3737 ResourceId id = resource_provider->CreateResource( |
| 3700 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format); | 3738 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format, |
| 3739 gfx::ColorSpace()); |
| 3701 resource_provider->AllocateForTesting(id); | 3740 resource_provider->AllocateForTesting(id); |
| 3702 Mock::VerifyAndClearExpectations(context); | 3741 Mock::VerifyAndClearExpectations(context); |
| 3703 | 3742 |
| 3704 DCHECK_EQ(10u, context->PeekTextureId()); | 3743 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3705 resource_provider->DeleteResource(id); | 3744 resource_provider->DeleteResource(id); |
| 3706 } | 3745 } |
| 3707 } | 3746 } |
| 3708 | 3747 |
| 3709 } // namespace | 3748 } // namespace |
| 3710 } // namespace cc | 3749 } // namespace cc |
| OLD | NEW |