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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/base/scoped_ptr_deque.h" | 9 #include "cc/base/scoped_ptr_deque.h" |
10 #include "cc/base/scoped_ptr_hash_map.h" | 10 #include "cc/base/scoped_ptr_hash_map.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 scoped_ptr<Texture> ConsumeTexture(const WGC3Dbyte* mailbox_name, | 82 scoped_ptr<Texture> ConsumeTexture(const WGC3Dbyte* mailbox_name, |
83 unsigned sync_point) { | 83 unsigned sync_point) { |
84 unsigned mailbox = 0; | 84 unsigned mailbox = 0; |
85 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); | 85 memcpy(&mailbox, mailbox_name, sizeof(mailbox)); |
86 DCHECK(mailbox && mailbox < next_mailbox_); | 86 DCHECK(mailbox && mailbox < next_mailbox_); |
87 | 87 |
88 // If the latest sync point the context has waited on is before the sync | 88 // If the latest sync point the context has waited on is before the sync |
89 // point for when the mailbox was set, pretend we never saw that | 89 // point for when the mailbox was set, pretend we never saw that |
90 // produceTexture. | 90 // ProduceTexture. |
91 if (sync_point_for_mailbox_[mailbox] > sync_point) { | 91 if (sync_point_for_mailbox_[mailbox] > sync_point) { |
92 NOTREACHED(); | 92 NOTREACHED(); |
93 return scoped_ptr<Texture>(); | 93 return scoped_ptr<Texture>(); |
94 } | 94 } |
95 return textures_.take(mailbox); | 95 return textures_.take(mailbox); |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} | 99 ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} |
100 | 100 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) OVERRIDE { | 226 virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox) OVERRIDE { |
227 return shared_data_->GenMailbox(mailbox); | 227 return shared_data_->GenMailbox(mailbox); |
228 } | 228 } |
229 | 229 |
230 virtual void produceTextureCHROMIUM(WGC3Denum target, | 230 virtual void produceTextureCHROMIUM(WGC3Denum target, |
231 const WGC3Dbyte* mailbox) OVERRIDE { | 231 const WGC3Dbyte* mailbox) OVERRIDE { |
232 ASSERT_TRUE(current_texture_); | 232 ASSERT_TRUE(current_texture_); |
233 ASSERT_EQ(target, GL_TEXTURE_2D); | 233 ASSERT_EQ(target, GL_TEXTURE_2D); |
234 | 234 |
235 // Delay moving the texture into the mailbox until the next | 235 // Delay moving the texture into the mailbox until the next |
236 // insertSyncPoint, so that it is not visible to other contexts that | 236 // InsertSyncPoint, so that it is not visible to other contexts that |
237 // haven't waited on that sync point. | 237 // haven't waited on that sync point. |
238 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); | 238 scoped_ptr<PendingProduceTexture> pending(new PendingProduceTexture); |
239 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); | 239 memcpy(pending->mailbox, mailbox, sizeof(pending->mailbox)); |
240 pending->texture = textures_.take(current_texture_); | 240 pending->texture = textures_.take(current_texture_); |
241 textures_.set(current_texture_, scoped_ptr<Texture>()); | 241 textures_.set(current_texture_, scoped_ptr<Texture>()); |
242 pending_produce_textures_.push_back(pending.Pass()); | 242 pending_produce_textures_.push_back(pending.Pass()); |
243 } | 243 } |
244 | 244 |
245 virtual void consumeTextureCHROMIUM(WGC3Denum target, | 245 virtual void consumeTextureCHROMIUM(WGC3Denum target, |
246 const WGC3Dbyte* mailbox) OVERRIDE { | 246 const WGC3Dbyte* mailbox) OVERRIDE { |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 | 833 |
834 // Force all textures to be "1" so we can test for them. | 834 // Force all textures to be "1" so we can test for them. |
835 virtual WebKit::WebGLId NextTextureId() OVERRIDE { return 1; } | 835 virtual WebKit::WebGLId NextTextureId() OVERRIDE { return 1; } |
836 }; | 836 }; |
837 | 837 |
838 TEST_P(ResourceProviderTest, ScopedSampler) { | 838 TEST_P(ResourceProviderTest, ScopedSampler) { |
839 // Sampling is only supported for GL textures. | 839 // Sampling is only supported for GL textures. |
840 if (GetParam() != ResourceProvider::GLTexture) | 840 if (GetParam() != ResourceProvider::GLTexture) |
841 return; | 841 return; |
842 | 842 |
843 scoped_ptr<OutputSurface> outputSurface( | 843 scoped_ptr<OutputSurface> output_surface( |
844 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 844 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
845 new TextureStateTrackingContext))); | 845 new TextureStateTrackingContext))); |
846 TextureStateTrackingContext* context = | 846 TextureStateTrackingContext* context = |
847 static_cast<TextureStateTrackingContext*>(outputSurface->context3d()); | 847 static_cast<TextureStateTrackingContext*>(output_surface->context3d()); |
848 scoped_ptr<ResourceProvider> resource_provider( | 848 scoped_ptr<ResourceProvider> resource_provider( |
849 ResourceProvider::Create(outputSurface.get())); | 849 ResourceProvider::Create(output_surface.get())); |
850 | 850 |
851 gfx::Size size(1, 1); | 851 gfx::Size size(1, 1); |
852 WGC3Denum format = GL_RGBA; | 852 WGC3Denum format = GL_RGBA; |
853 int texture_id = 1; | 853 int texture_id = 1; |
854 | 854 |
855 // Check that the texture gets created with the right sampler settings. | 855 // Check that the texture gets created with the right sampler settings. |
856 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) | 856 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)) |
857 .Times(2); // Once to create and once to allocate. | 857 .Times(2); // Once to create and once to allocate. |
858 EXPECT_CALL(*context, | 858 EXPECT_CALL(*context, |
859 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 859 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 } | 906 } |
907 | 907 |
908 Mock::VerifyAndClearExpectations(context); | 908 Mock::VerifyAndClearExpectations(context); |
909 } | 909 } |
910 | 910 |
911 TEST_P(ResourceProviderTest, ManagedResource) { | 911 TEST_P(ResourceProviderTest, ManagedResource) { |
912 // Sampling is only supported for GL textures. | 912 // Sampling is only supported for GL textures. |
913 if (GetParam() != ResourceProvider::GLTexture) | 913 if (GetParam() != ResourceProvider::GLTexture) |
914 return; | 914 return; |
915 | 915 |
916 scoped_ptr<OutputSurface> outputSurface( | 916 scoped_ptr<OutputSurface> output_surface( |
917 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 917 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( |
918 new TextureStateTrackingContext))); | 918 new TextureStateTrackingContext))); |
919 TextureStateTrackingContext* context = | 919 TextureStateTrackingContext* context = |
920 static_cast<TextureStateTrackingContext*>(outputSurface->context3d()); | 920 static_cast<TextureStateTrackingContext*>(output_surface->context3d()); |
921 scoped_ptr<ResourceProvider> resource_provider( | 921 scoped_ptr<ResourceProvider> resource_provider( |
922 ResourceProvider::Create(outputSurface.get())); | 922 ResourceProvider::Create(output_surface.get())); |
923 | 923 |
924 gfx::Size size(1, 1); | 924 gfx::Size size(1, 1); |
925 WGC3Denum format = GL_RGBA; | 925 WGC3Denum format = GL_RGBA; |
926 int texture_id = 1; | 926 int texture_id = 1; |
927 | 927 |
928 // Check that the texture gets created with the right sampler settings. | 928 // Check that the texture gets created with the right sampler settings. |
929 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | 929 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
930 EXPECT_CALL(*context, | 930 EXPECT_CALL(*context, |
931 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 931 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
932 EXPECT_CALL(*context, | 932 EXPECT_CALL(*context, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum target)); | 995 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum target)); |
996 }; | 996 }; |
997 | 997 |
998 TEST_P(ResourceProviderTest, TextureAllocation) { | 998 TEST_P(ResourceProviderTest, TextureAllocation) { |
999 // Only for GL textures. | 999 // Only for GL textures. |
1000 if (GetParam() != ResourceProvider::GLTexture) | 1000 if (GetParam() != ResourceProvider::GLTexture) |
1001 return; | 1001 return; |
1002 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( | 1002 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( |
1003 static_cast<WebKit::WebGraphicsContext3D*>( | 1003 static_cast<WebKit::WebGraphicsContext3D*>( |
1004 new NiceMock<AllocationTrackingContext3D>)); | 1004 new NiceMock<AllocationTrackingContext3D>)); |
1005 scoped_ptr<OutputSurface> outputSurface( | 1005 scoped_ptr<OutputSurface> output_surface( |
1006 FakeOutputSurface::Create3d(mock_context.Pass())); | 1006 FakeOutputSurface::Create3d(mock_context.Pass())); |
1007 | 1007 |
1008 gfx::Size size(2, 2); | 1008 gfx::Size size(2, 2); |
1009 gfx::Vector2d offset(0, 0); | 1009 gfx::Vector2d offset(0, 0); |
1010 gfx::Rect rect(0, 0, 2, 2); | 1010 gfx::Rect rect(0, 0, 2, 2); |
1011 WGC3Denum format = GL_RGBA; | 1011 WGC3Denum format = GL_RGBA; |
1012 ResourceProvider::ResourceId id = 0; | 1012 ResourceProvider::ResourceId id = 0; |
1013 uint8_t pixels[16] = { 0 }; | 1013 uint8_t pixels[16] = { 0 }; |
1014 int texture_id = 123; | 1014 int texture_id = 123; |
1015 | 1015 |
1016 AllocationTrackingContext3D* context = | 1016 AllocationTrackingContext3D* context = |
1017 static_cast<AllocationTrackingContext3D*>(outputSurface->context3d()); | 1017 static_cast<AllocationTrackingContext3D*>(output_surface->context3d()); |
1018 scoped_ptr<ResourceProvider> resource_provider( | 1018 scoped_ptr<ResourceProvider> resource_provider( |
1019 ResourceProvider::Create(outputSurface.get())); | 1019 ResourceProvider::Create(output_surface.get())); |
1020 | 1020 |
1021 // Lazy allocation. Don't allocate when creating the resource. | 1021 // Lazy allocation. Don't allocate when creating the resource. |
1022 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1022 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
1023 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1023 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
1024 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); | 1024 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(1); |
1025 EXPECT_CALL(*context, texImage2D(_, _, _, _, _, _, _, _, _)).Times(0); | 1025 EXPECT_CALL(*context, texImage2D(_, _, _, _, _, _, _, _, _)).Times(0); |
1026 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, _, _, _, _, _, _)) | 1026 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, _, _, _, _, _, _)) |
1027 .Times(0); | 1027 .Times(0); |
1028 id = resource_provider->CreateResource( | 1028 id = resource_provider->CreateResource( |
1029 size, format, ResourceProvider::TextureUsageAny); | 1029 size, format, ResourceProvider::TextureUsageAny); |
1030 resource_provider->DeleteResource(id); | 1030 resource_provider->DeleteResource(id); |
1031 Mock::VerifyAndClearExpectations(context); | 1031 Mock::VerifyAndClearExpectations(context); |
1032 | 1032 |
1033 // Do allocate when we set the pixels. | 1033 // Do allocate when we set the pixels. |
1034 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1034 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
1035 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1035 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
1036 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 1036 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
1037 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); | 1037 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); |
1038 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); | 1038 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); |
1039 id = resource_provider->CreateResource( | 1039 id = resource_provider->CreateResource( |
1040 size, format, ResourceProvider::TextureUsageAny); | 1040 size, format, ResourceProvider::TextureUsageAny); |
1041 resource_provider->SetPixels(id, pixels, rect, rect, offset); | 1041 resource_provider->SetPixels(id, pixels, rect, rect, offset); |
1042 resource_provider->DeleteResource(id); | 1042 resource_provider->DeleteResource(id); |
1043 Mock::VerifyAndClearExpectations(context); | 1043 Mock::VerifyAndClearExpectations(context); |
1044 | 1044 |
1045 // Same for setPixelsFromBuffer | 1045 // Same for SetPixelsFromBuffer |
1046 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1046 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
1047 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); | 1047 EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1); |
1048 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 1048 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
1049 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); | 1049 EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); |
1050 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); | 1050 EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); |
1051 id = resource_provider->CreateResource( | 1051 id = resource_provider->CreateResource( |
1052 size, format, ResourceProvider::TextureUsageAny); | 1052 size, format, ResourceProvider::TextureUsageAny); |
1053 resource_provider->AcquirePixelBuffer(id); | 1053 resource_provider->AcquirePixelBuffer(id); |
1054 resource_provider->SetPixelsFromBuffer(id); | 1054 resource_provider->SetPixelsFromBuffer(id); |
1055 resource_provider->ReleasePixelBuffer(id); | 1055 resource_provider->ReleasePixelBuffer(id); |
(...skipping 15 matching lines...) Expand all Loading... |
1071 Mock::VerifyAndClearExpectations(context); | 1071 Mock::VerifyAndClearExpectations(context); |
1072 } | 1072 } |
1073 | 1073 |
1074 TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) { | 1074 TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete) { |
1075 // Only for GL textures. | 1075 // Only for GL textures. |
1076 if (GetParam() != ResourceProvider::GLTexture) | 1076 if (GetParam() != ResourceProvider::GLTexture) |
1077 return; | 1077 return; |
1078 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( | 1078 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( |
1079 static_cast<WebKit::WebGraphicsContext3D*>( | 1079 static_cast<WebKit::WebGraphicsContext3D*>( |
1080 new NiceMock<AllocationTrackingContext3D>)); | 1080 new NiceMock<AllocationTrackingContext3D>)); |
1081 scoped_ptr<OutputSurface> outputSurface( | 1081 scoped_ptr<OutputSurface> output_surface( |
1082 FakeOutputSurface::Create3d(mock_context.Pass())); | 1082 FakeOutputSurface::Create3d(mock_context.Pass())); |
1083 | 1083 |
1084 gfx::Size size(2, 2); | 1084 gfx::Size size(2, 2); |
1085 WGC3Denum format = GL_RGBA; | 1085 WGC3Denum format = GL_RGBA; |
1086 ResourceProvider::ResourceId id = 0; | 1086 ResourceProvider::ResourceId id = 0; |
1087 int texture_id = 123; | 1087 int texture_id = 123; |
1088 | 1088 |
1089 AllocationTrackingContext3D* context = | 1089 AllocationTrackingContext3D* context = |
1090 static_cast<AllocationTrackingContext3D*>(outputSurface->context3d()); | 1090 static_cast<AllocationTrackingContext3D*>(output_surface->context3d()); |
1091 scoped_ptr<ResourceProvider> resource_provider( | 1091 scoped_ptr<ResourceProvider> resource_provider( |
1092 ResourceProvider::Create(outputSurface.get())); | 1092 ResourceProvider::Create(output_surface.get())); |
1093 | 1093 |
1094 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); | 1094 EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id)); |
1095 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); | 1095 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); |
1096 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 1096 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
1097 .Times(1); | 1097 .Times(1); |
1098 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); | 1098 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); |
1099 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); | 1099 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); |
1100 id = resource_provider->CreateResource( | 1100 id = resource_provider->CreateResource( |
1101 size, format, ResourceProvider::TextureUsageAny); | 1101 size, format, ResourceProvider::TextureUsageAny); |
1102 resource_provider->AcquirePixelBuffer(id); | 1102 resource_provider->AcquirePixelBuffer(id); |
1103 resource_provider->BeginSetPixels(id); | 1103 resource_provider->BeginSetPixels(id); |
1104 resource_provider->ForceSetPixelsToComplete(id); | 1104 resource_provider->ForceSetPixelsToComplete(id); |
1105 resource_provider->ReleasePixelBuffer(id); | 1105 resource_provider->ReleasePixelBuffer(id); |
1106 Mock::VerifyAndClearExpectations(context); | 1106 Mock::VerifyAndClearExpectations(context); |
1107 } | 1107 } |
1108 | 1108 |
1109 TEST_P(ResourceProviderTest, AbortForcedAsyncUpload) { | 1109 TEST_P(ResourceProviderTest, AbortForcedAsyncUpload) { |
1110 // Only for GL textures. | 1110 // Only for GL textures. |
1111 if (GetParam() != ResourceProvider::GLTexture) | 1111 if (GetParam() != ResourceProvider::GLTexture) |
1112 return; | 1112 return; |
1113 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( | 1113 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( |
1114 static_cast<WebKit::WebGraphicsContext3D*>( | 1114 static_cast<WebKit::WebGraphicsContext3D*>( |
1115 new NiceMock<AllocationTrackingContext3D>)); | 1115 new NiceMock<AllocationTrackingContext3D>)); |
1116 scoped_ptr<OutputSurface> outputSurface( | 1116 scoped_ptr<OutputSurface> output_surface( |
1117 FakeOutputSurface::Create3d(mock_context.Pass())); | 1117 FakeOutputSurface::Create3d(mock_context.Pass())); |
1118 | 1118 |
1119 gfx::Size size(2, 2); | 1119 gfx::Size size(2, 2); |
1120 WGC3Denum format = GL_RGBA; | 1120 WGC3Denum format = GL_RGBA; |
1121 ResourceProvider::ResourceId id = 0; | 1121 ResourceProvider::ResourceId id = 0; |
1122 int texture_id = 123; | 1122 int texture_id = 123; |
1123 | 1123 |
1124 AllocationTrackingContext3D* context = | 1124 AllocationTrackingContext3D* context = |
1125 static_cast<AllocationTrackingContext3D*>(outputSurface->context3d()); | 1125 static_cast<AllocationTrackingContext3D*>(output_surface->context3d()); |
1126 scoped_ptr<ResourceProvider> resource_provider( | 1126 scoped_ptr<ResourceProvider> resource_provider( |
1127 ResourceProvider::Create(outputSurface.get())); | 1127 ResourceProvider::Create(output_surface.get())); |
1128 | 1128 |
1129 EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id)); | 1129 EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(texture_id)); |
1130 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(4); | 1130 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(4); |
1131 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) | 1131 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_, _, _, 2, 2, _, _, _, _)) |
1132 .Times(1); | 1132 .Times(1); |
1133 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); | 1133 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1); |
1134 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); | 1134 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1); |
1135 EXPECT_CALL(*context, deleteTexture(_)).Times(1); | 1135 EXPECT_CALL(*context, deleteTexture(_)).Times(1); |
1136 id = resource_provider->CreateResource( | 1136 id = resource_provider->CreateResource( |
1137 size, format, ResourceProvider::TextureUsageAny); | 1137 size, format, ResourceProvider::TextureUsageAny); |
1138 resource_provider->AcquirePixelBuffer(id); | 1138 resource_provider->AcquirePixelBuffer(id); |
1139 resource_provider->BeginSetPixels(id); | 1139 resource_provider->BeginSetPixels(id); |
1140 resource_provider->ForceSetPixelsToComplete(id); | 1140 resource_provider->ForceSetPixelsToComplete(id); |
1141 resource_provider->AbortSetPixels(id); | 1141 resource_provider->AbortSetPixels(id); |
1142 resource_provider->ReleasePixelBuffer(id); | 1142 resource_provider->ReleasePixelBuffer(id); |
1143 Mock::VerifyAndClearExpectations(context); | 1143 Mock::VerifyAndClearExpectations(context); |
1144 } | 1144 } |
1145 | 1145 |
1146 INSTANTIATE_TEST_CASE_P( | 1146 INSTANTIATE_TEST_CASE_P( |
1147 ResourceProviderTests, | 1147 ResourceProviderTests, |
1148 ResourceProviderTest, | 1148 ResourceProviderTest, |
1149 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); | 1149 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); |
1150 | 1150 |
1151 } // namespace | 1151 } // namespace |
1152 } // namespace cc | 1152 } // namespace cc |
OLD | NEW |