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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 EXPECT_CALL(*context, | 1190 EXPECT_CALL(*context, |
1191 texParameteri(GL_TEXTURE_2D, | 1191 texParameteri(GL_TEXTURE_2D, |
1192 GL_TEXTURE_POOL_CHROMIUM, | 1192 GL_TEXTURE_POOL_CHROMIUM, |
1193 GL_TEXTURE_POOL_MANAGED_CHROMIUM)); | 1193 GL_TEXTURE_POOL_MANAGED_CHROMIUM)); |
1194 resource_provider->CreateForTesting(id); | 1194 resource_provider->CreateForTesting(id); |
1195 EXPECT_NE(0u, id); | 1195 EXPECT_NE(0u, id); |
1196 | 1196 |
1197 Mock::VerifyAndClearExpectations(context); | 1197 Mock::VerifyAndClearExpectations(context); |
1198 } | 1198 } |
1199 | 1199 |
| 1200 TEST_P(ResourceProviderTest, TextureWrapMode) { |
| 1201 // Sampling is only supported for GL textures. |
| 1202 if (GetParam() != ResourceProvider::GLTexture) |
| 1203 return; |
| 1204 |
| 1205 scoped_ptr<TextureStateTrackingContext> context_owned( |
| 1206 new TextureStateTrackingContext); |
| 1207 TextureStateTrackingContext* context = context_owned.get(); |
| 1208 |
| 1209 FakeOutputSurfaceClient output_surface_client; |
| 1210 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 1211 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 1212 CHECK(output_surface->BindToClient(&output_surface_client)); |
| 1213 |
| 1214 scoped_ptr<ResourceProvider> resource_provider( |
| 1215 ResourceProvider::Create(output_surface.get(), 0)); |
| 1216 |
| 1217 gfx::Size size(1, 1); |
| 1218 WGC3Denum format = GL_RGBA; |
| 1219 int texture_id = 1; |
| 1220 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; |
| 1221 |
| 1222 for (int i = 0; i < 2; ++i) { |
| 1223 GLint wrap_mode = i ? GL_CLAMP_TO_EDGE : GL_REPEAT; |
| 1224 // Check that the texture gets created with the right sampler settings. |
| 1225 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( |
| 1226 size, format, texture_pool, wrap_mode, |
| 1227 ResourceProvider::TextureUsageAny); |
| 1228 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1229 EXPECT_CALL(*context, |
| 1230 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 1231 EXPECT_CALL(*context, |
| 1232 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 1233 EXPECT_CALL( |
| 1234 *context, |
| 1235 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode)); |
| 1236 EXPECT_CALL( |
| 1237 *context, |
| 1238 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode)); |
| 1239 EXPECT_CALL(*context, |
| 1240 texParameteri(GL_TEXTURE_2D, |
| 1241 GL_TEXTURE_POOL_CHROMIUM, |
| 1242 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); |
| 1243 resource_provider->CreateForTesting(id); |
| 1244 EXPECT_NE(0u, id); |
| 1245 |
| 1246 Mock::VerifyAndClearExpectations(context); |
| 1247 } |
| 1248 } |
| 1249 |
1200 static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} | 1250 static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} |
1201 | 1251 |
1202 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { | 1252 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { |
1203 if (GetParam() != ResourceProvider::Bitmap) | 1253 if (GetParam() != ResourceProvider::Bitmap) |
1204 return; | 1254 return; |
1205 | 1255 |
1206 gfx::Size size(64, 64); | 1256 gfx::Size size(64, 64); |
1207 const uint32_t kBadBeef = 0xbadbeef; | 1257 const uint32_t kBadBeef = 0xbadbeef; |
1208 scoped_ptr<base::SharedMemory> shared_memory( | 1258 scoped_ptr<base::SharedMemory> shared_memory( |
1209 CreateAndFillSharedMemory(size, kBadBeef)); | 1259 CreateAndFillSharedMemory(size, kBadBeef)); |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 output_surface.get()); | 1860 output_surface.get()); |
1811 } | 1861 } |
1812 | 1862 |
1813 INSTANTIATE_TEST_CASE_P( | 1863 INSTANTIATE_TEST_CASE_P( |
1814 ResourceProviderTests, | 1864 ResourceProviderTests, |
1815 ResourceProviderTest, | 1865 ResourceProviderTest, |
1816 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); | 1866 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); |
1817 | 1867 |
1818 } // namespace | 1868 } // namespace |
1819 } // namespace cc | 1869 } // namespace cc |
OLD | NEW |