OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 deleted_ = true; | 246 deleted_ = true; |
247 } | 247 } |
248 | 248 |
249 bool NeedsMips() const { | 249 bool NeedsMips() const { |
250 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; | 250 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; |
251 } | 251 } |
252 | 252 |
253 // Sets the TextureInfo's target | 253 // Sets the TextureInfo's target |
254 // Parameters: | 254 // Parameters: |
255 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 255 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
256 // GL_TEXTURE_EXTERNAL_OES | 256 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
257 // max_levels: The maximum levels this type of target can have. | 257 // max_levels: The maximum levels this type of target can have. |
258 void SetTarget(GLenum target, GLint max_levels); | 258 void SetTarget(GLenum target, GLint max_levels); |
259 | 259 |
260 // Update info about this texture. | 260 // Update info about this texture. |
261 void Update(const FeatureInfo* feature_info); | 261 void Update(const FeatureInfo* feature_info); |
262 | 262 |
263 // Info about each face and level of texture. | 263 // Info about each face and level of texture. |
264 std::vector<std::vector<LevelInfo> > level_infos_; | 264 std::vector<std::vector<LevelInfo> > level_infos_; |
265 | 265 |
266 // The id of the texure | 266 // The id of the texure |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 bool GetClientId(GLuint service_id, GLuint* client_id) const; | 408 bool GetClientId(GLuint service_id, GLuint* client_id) const; |
409 | 409 |
410 TextureInfo* GetDefaultTextureInfo(GLenum target) { | 410 TextureInfo* GetDefaultTextureInfo(GLenum target) { |
411 switch (target) { | 411 switch (target) { |
412 case GL_TEXTURE_2D: | 412 case GL_TEXTURE_2D: |
413 return default_texture_2d_; | 413 return default_texture_2d_; |
414 case GL_TEXTURE_CUBE_MAP: | 414 case GL_TEXTURE_CUBE_MAP: |
415 return default_texture_cube_map_; | 415 return default_texture_cube_map_; |
416 case GL_TEXTURE_EXTERNAL_OES: | 416 case GL_TEXTURE_EXTERNAL_OES: |
417 return default_texture_external_oes_; | 417 return default_texture_external_oes_; |
| 418 case GL_TEXTURE_RECTANGLE_ARB: |
| 419 return default_texture_rectangle_arb_; |
418 default: | 420 default: |
419 NOTREACHED(); | 421 NOTREACHED(); |
420 return NULL; | 422 return NULL; |
421 } | 423 } |
422 } | 424 } |
423 | 425 |
424 bool HaveUnrenderableTextures() const { | 426 bool HaveUnrenderableTextures() const { |
425 return num_unrenderable_textures_ > 0; | 427 return num_unrenderable_textures_ > 0; |
426 } | 428 } |
427 | 429 |
428 bool HaveUnsafeTextures() const { | 430 bool HaveUnsafeTextures() const { |
429 return num_unsafe_textures_ > 0; | 431 return num_unsafe_textures_ > 0; |
430 } | 432 } |
431 | 433 |
432 bool HaveUnclearedMips() const { | 434 bool HaveUnclearedMips() const { |
433 return num_uncleared_mips_ > 0; | 435 return num_uncleared_mips_ > 0; |
434 } | 436 } |
435 | 437 |
436 GLuint black_texture_id(GLenum target) const { | 438 GLuint black_texture_id(GLenum target) const { |
437 switch (target) { | 439 switch (target) { |
438 case GL_SAMPLER_2D: | 440 case GL_SAMPLER_2D: |
439 return black_2d_texture_id_; | 441 return black_2d_texture_id_; |
440 case GL_SAMPLER_CUBE: | 442 case GL_SAMPLER_CUBE: |
441 return black_cube_texture_id_; | 443 return black_cube_texture_id_; |
442 case GL_SAMPLER_EXTERNAL_OES: | 444 case GL_SAMPLER_EXTERNAL_OES: |
443 return black_oes_external_texture_id_; | 445 return black_oes_external_texture_id_; |
| 446 case GL_SAMPLER_2D_RECT_ARB: |
| 447 return black_arb_texture_rectangle_id_; |
444 default: | 448 default: |
445 NOTREACHED(); | 449 NOTREACHED(); |
446 return 0; | 450 return 0; |
447 } | 451 } |
448 } | 452 } |
449 | 453 |
450 private: | 454 private: |
| 455 // Helper for Initialize(). |
| 456 TextureInfo::Ref CreateDefaultAndBlackTextures( |
| 457 const FeatureInfo* feature_info, |
| 458 GLenum target, |
| 459 GLuint* black_texture); |
| 460 |
451 // Info for each texture in the system. | 461 // Info for each texture in the system. |
452 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap; | 462 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap; |
453 TextureInfoMap texture_infos_; | 463 TextureInfoMap texture_infos_; |
454 | 464 |
455 GLsizei max_texture_size_; | 465 GLsizei max_texture_size_; |
456 GLsizei max_cube_map_texture_size_; | 466 GLsizei max_cube_map_texture_size_; |
457 GLint max_levels_; | 467 GLint max_levels_; |
458 GLint max_cube_map_levels_; | 468 GLint max_cube_map_levels_; |
459 | 469 |
460 int num_unrenderable_textures_; | 470 int num_unrenderable_textures_; |
461 int num_unsafe_textures_; | 471 int num_unsafe_textures_; |
462 int num_uncleared_mips_; | 472 int num_uncleared_mips_; |
463 | 473 |
464 // Black (0,0,0,1) textures for when non-renderable textures are used. | 474 // Black (0,0,0,1) textures for when non-renderable textures are used. |
465 // NOTE: There is no corresponding TextureInfo for these textures. | 475 // NOTE: There is no corresponding TextureInfo for these textures. |
466 // TextureInfos are only for textures the client side can access. | 476 // TextureInfos are only for textures the client side can access. |
467 GLuint black_2d_texture_id_; | 477 GLuint black_2d_texture_id_; |
468 GLuint black_cube_texture_id_; | 478 GLuint black_cube_texture_id_; |
469 GLuint black_oes_external_texture_id_; | 479 GLuint black_oes_external_texture_id_; |
| 480 GLuint black_arb_texture_rectangle_id_; |
470 | 481 |
471 // The default textures for each target (texture name = 0) | 482 // The default textures for each target (texture name = 0) |
472 TextureInfo::Ref default_texture_2d_; | 483 TextureInfo::Ref default_texture_2d_; |
473 TextureInfo::Ref default_texture_cube_map_; | 484 TextureInfo::Ref default_texture_cube_map_; |
474 TextureInfo::Ref default_texture_external_oes_; | 485 TextureInfo::Ref default_texture_external_oes_; |
| 486 TextureInfo::Ref default_texture_rectangle_arb_; |
475 | 487 |
476 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 488 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
477 }; | 489 }; |
478 | 490 |
479 } // namespace gles2 | 491 } // namespace gles2 |
480 } // namespace gpu | 492 } // namespace gpu |
481 | 493 |
482 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 494 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |