Chromium Code Reviews| 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 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 EXPECT_CALL(*context, | 1137 EXPECT_CALL(*context, |
| 1138 texParameteri(GL_TEXTURE_2D, | 1138 texParameteri(GL_TEXTURE_2D, |
| 1139 GL_TEXTURE_POOL_CHROMIUM, | 1139 GL_TEXTURE_POOL_CHROMIUM, |
| 1140 GL_TEXTURE_POOL_MANAGED_CHROMIUM)); | 1140 GL_TEXTURE_POOL_MANAGED_CHROMIUM)); |
| 1141 resource_provider->CreateForTesting(id); | 1141 resource_provider->CreateForTesting(id); |
| 1142 EXPECT_NE(0u, id); | 1142 EXPECT_NE(0u, id); |
| 1143 | 1143 |
| 1144 Mock::VerifyAndClearExpectations(context); | 1144 Mock::VerifyAndClearExpectations(context); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 TEST_P(ResourceProviderTest, TextureWrapMode) { | |
| 1148 // Sampling is only supported for GL textures. | |
| 1149 if (GetParam() != ResourceProvider::GLTexture) | |
| 1150 return; | |
| 1151 | |
| 1152 scoped_ptr<OutputSurface> output_surface( | |
| 1153 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | |
| 1154 new TextureStateTrackingContext))); | |
| 1155 TextureStateTrackingContext* context = | |
| 1156 static_cast<TextureStateTrackingContext*>(output_surface->context3d()); | |
| 1157 scoped_ptr<ResourceProvider> resource_provider( | |
| 1158 ResourceProvider::Create(output_surface.get(), 0)); | |
| 1159 | |
| 1160 gfx::Size size(1, 1); | |
| 1161 WGC3Denum format = GL_RGBA; | |
| 1162 int texture_id = 1; | |
| 1163 GLenum texture_pool = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; | |
| 1164 | |
| 1165 for (int i = 0; i < 2; ++i) { | |
| 1166 GLint wrap_mode = i ? GL_CLAMP_TO_EDGE : GL_REPEAT; | |
| 1167 // Check that the texture gets created with the right sampler settings. | |
| 1168 ResourceProvider::ResourceId id = resource_provider->CreateGLTexture( | |
| 1169 size, format, texture_pool, wrap_mode, | |
| 1170 ResourceProvider::TextureUsageAny); | |
| 1171 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)); | |
| 1172 EXPECT_CALL(*context, | |
| 1173 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
| 1174 EXPECT_CALL(*context, | |
| 1175 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
| 1176 EXPECT_CALL( | |
| 1177 *context, | |
| 1178 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode)); | |
| 1179 EXPECT_CALL( | |
| 1180 *context, | |
| 1181 texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode)); | |
| 1182 EXPECT_CALL(*context, | |
| 1183 texParameteri(GL_TEXTURE_2D, | |
| 1184 GL_TEXTURE_POOL_CHROMIUM, | |
| 1185 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); | |
| 1186 resource_provider->CreateForTesting(id); | |
| 1187 EXPECT_NE(0u, id); | |
| 1188 } | |
| 1189 | |
| 1190 Mock::VerifyAndClearExpectations(context); | |
|
enne (OOO)
2013/08/07 20:57:52
Can you put this inside the loop? I think these e
ccameron
2013/08/31 00:37:58
Done.
| |
| 1191 } | |
| 1192 | |
| 1147 static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} | 1193 static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} |
| 1148 | 1194 |
| 1149 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { | 1195 TEST_P(ResourceProviderTest, TextureMailbox_SharedMemory) { |
| 1150 if (GetParam() != ResourceProvider::Bitmap) | 1196 if (GetParam() != ResourceProvider::Bitmap) |
| 1151 return; | 1197 return; |
| 1152 | 1198 |
| 1153 gfx::Size size(64, 64); | 1199 gfx::Size size(64, 64); |
| 1154 const uint32_t kBadBeef = 0xbadbeef; | 1200 const uint32_t kBadBeef = 0xbadbeef; |
| 1155 scoped_ptr<base::SharedMemory> shared_memory( | 1201 scoped_ptr<base::SharedMemory> shared_memory( |
| 1156 CreateAndFillSharedMemory(size, kBadBeef)); | 1202 CreateAndFillSharedMemory(size, kBadBeef)); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1734 output_surface.get()); | 1780 output_surface.get()); |
| 1735 } | 1781 } |
| 1736 | 1782 |
| 1737 INSTANTIATE_TEST_CASE_P( | 1783 INSTANTIATE_TEST_CASE_P( |
| 1738 ResourceProviderTests, | 1784 ResourceProviderTests, |
| 1739 ResourceProviderTest, | 1785 ResourceProviderTest, |
| 1740 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); | 1786 ::testing::Values(ResourceProvider::GLTexture, ResourceProvider::Bitmap)); |
| 1741 | 1787 |
| 1742 } // namespace | 1788 } // namespace |
| 1743 } // namespace cc | 1789 } // namespace cc |
| OLD | NEW |