OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 DISALLOW_COPY_AND_ASSIGN(TextureInfo); | 210 DISALLOW_COPY_AND_ASSIGN(TextureInfo); |
211 }; | 211 }; |
212 | 212 |
213 TextureManager(bool npot_ok, | 213 TextureManager(bool npot_ok, |
214 bool enable_float_linear, | 214 bool enable_float_linear, |
215 bool enable_half_float_linear, | 215 bool enable_half_float_linear, |
216 GLsizei max_texture_size, | 216 GLsizei max_texture_size, |
217 GLsizei max_cube_map_texture_size); | 217 GLsizei max_cube_map_texture_size); |
218 ~TextureManager(); | 218 ~TextureManager(); |
219 | 219 |
| 220 // Init the texture manager. |
| 221 bool Initialize(); |
| 222 |
220 // Must call before destruction. | 223 // Must call before destruction. |
221 void Destroy(bool have_context); | 224 void Destroy(bool have_context); |
222 | 225 |
223 // Whether or not npot textures can render. | 226 // Whether or not npot textures can render. |
224 bool npot_ok() const { | 227 bool npot_ok() const { |
225 return npot_ok_; | 228 return npot_ok_; |
226 } | 229 } |
227 | 230 |
228 // Whether float textures can have linear filtering. | 231 // Whether float textures can have linear filtering. |
229 bool enable_float_linear() const { | 232 bool enable_float_linear() const { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 298 |
296 TextureInfo* GetDefaultTextureInfo(GLenum target) { | 299 TextureInfo* GetDefaultTextureInfo(GLenum target) { |
297 return target == GL_TEXTURE_2D ? default_texture_2d_ : | 300 return target == GL_TEXTURE_2D ? default_texture_2d_ : |
298 default_texture_cube_map_; | 301 default_texture_cube_map_; |
299 } | 302 } |
300 | 303 |
301 bool HaveUnrenderableTextures() const { | 304 bool HaveUnrenderableTextures() const { |
302 return num_unrenderable_textures_ > 0; | 305 return num_unrenderable_textures_ > 0; |
303 } | 306 } |
304 | 307 |
| 308 GLuint black_texture_id(GLenum target) const { |
| 309 return target == GL_SAMPLER_2D ? black_2d_texture_id_ : |
| 310 black_cube_texture_id_; |
| 311 } |
| 312 |
305 private: | 313 private: |
306 // Info for each texture in the system. | 314 // Info for each texture in the system. |
307 // TODO(gman): Choose a faster container. | 315 // TODO(gman): Choose a faster container. |
308 typedef std::map<GLuint, TextureInfo::Ref> TextureInfoMap; | 316 typedef std::map<GLuint, TextureInfo::Ref> TextureInfoMap; |
309 TextureInfoMap texture_infos_; | 317 TextureInfoMap texture_infos_; |
310 | 318 |
311 bool npot_ok_; | 319 bool npot_ok_; |
312 bool enable_float_linear_; | 320 bool enable_float_linear_; |
313 bool enable_half_float_linear_; | 321 bool enable_half_float_linear_; |
314 GLsizei max_texture_size_; | 322 GLsizei max_texture_size_; |
315 GLsizei max_cube_map_texture_size_; | 323 GLsizei max_cube_map_texture_size_; |
316 GLint max_levels_; | 324 GLint max_levels_; |
317 GLint max_cube_map_levels_; | 325 GLint max_cube_map_levels_; |
318 | 326 |
319 int num_unrenderable_textures_; | 327 int num_unrenderable_textures_; |
320 | 328 |
| 329 // Black (0,0,0,1) textures for when non-renderable textures are used. |
| 330 // NOTE: There is no corresponding TextureInfo for these textures. |
| 331 // TextureInfos are only for textures the client side can access. |
| 332 GLuint black_2d_texture_id_; |
| 333 GLuint black_cube_texture_id_; |
| 334 |
321 // The default textures for each target (texture name = 0) | 335 // The default textures for each target (texture name = 0) |
322 TextureInfo::Ref default_texture_2d_; | 336 TextureInfo::Ref default_texture_2d_; |
323 TextureInfo::Ref default_texture_cube_map_; | 337 TextureInfo::Ref default_texture_cube_map_; |
324 | 338 |
325 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 339 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
326 }; | 340 }; |
327 | 341 |
328 } // namespace gles2 | 342 } // namespace gles2 |
329 } // namespace gpu | 343 } // namespace gpu |
330 | 344 |
331 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 345 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
332 | 346 |
OLD | NEW |