| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "gpu/command_buffer/service/feature_info.h" | 13 #include "gpu/command_buffer/service/feature_info.h" |
| 14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
| 15 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
| 16 | 16 |
| 17 namespace gpu { | 17 namespace gpu { |
| 18 namespace gles2 { | 18 namespace gles2 { |
| 19 | 19 |
| 20 class GLES2Decoder; | 20 class GLES2Decoder; |
| 21 class Display; | 21 class Display; |
| 22 class TextureDefinition; | 22 class TextureDefinition; |
| 23 class MemoryTracker; |
| 24 class MemoryTypeTracker; |
| 23 | 25 |
| 24 // This class keeps track of the textures and their sizes so we can do NPOT and | 26 // This class keeps track of the textures and their sizes so we can do NPOT and |
| 25 // texture complete checking. | 27 // texture complete checking. |
| 26 // | 28 // |
| 27 // NOTE: To support shared resources an instance of this class will need to be | 29 // NOTE: To support shared resources an instance of this class will need to be |
| 28 // shared by multiple GLES2Decoders. | 30 // shared by multiple GLES2Decoders. |
| 29 class GPU_EXPORT TextureManager { | 31 class GPU_EXPORT TextureManager { |
| 30 public: | 32 public: |
| 31 enum DefaultAndBlackTextures { | 33 enum DefaultAndBlackTextures { |
| 32 kTexture2D, | 34 kTexture2D, |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Whether the texture is immutable and no further changes to the format | 346 // Whether the texture is immutable and no further changes to the format |
| 345 // or dimensions of the texture object can be made. | 347 // or dimensions of the texture object can be made. |
| 346 bool immutable_; | 348 bool immutable_; |
| 347 | 349 |
| 348 // Size in bytes this texture is assumed to take in memory. | 350 // Size in bytes this texture is assumed to take in memory. |
| 349 uint32 estimated_size_; | 351 uint32 estimated_size_; |
| 350 | 352 |
| 351 DISALLOW_COPY_AND_ASSIGN(TextureInfo); | 353 DISALLOW_COPY_AND_ASSIGN(TextureInfo); |
| 352 }; | 354 }; |
| 353 | 355 |
| 354 TextureManager(FeatureInfo* feature_info, | 356 TextureManager(MemoryTracker* memory_tracker, |
| 357 FeatureInfo* feature_info, |
| 355 GLsizei max_texture_size, | 358 GLsizei max_texture_size, |
| 356 GLsizei max_cube_map_texture_size); | 359 GLsizei max_cube_map_texture_size); |
| 357 ~TextureManager(); | 360 ~TextureManager(); |
| 358 | 361 |
| 359 // Init the texture manager. | 362 // Init the texture manager. |
| 360 bool Initialize(); | 363 bool Initialize(); |
| 361 | 364 |
| 362 // Must call before destruction. | 365 // Must call before destruction. |
| 363 void Destroy(bool have_context); | 366 void Destroy(bool have_context); |
| 364 | 367 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 // Helper for Initialize(). | 520 // Helper for Initialize(). |
| 518 TextureInfo::Ref CreateDefaultAndBlackTextures( | 521 TextureInfo::Ref CreateDefaultAndBlackTextures( |
| 519 GLenum target, | 522 GLenum target, |
| 520 GLuint* black_texture); | 523 GLuint* black_texture); |
| 521 | 524 |
| 522 void UpdateMemRepresented(); | 525 void UpdateMemRepresented(); |
| 523 | 526 |
| 524 void StartTracking(TextureInfo* info); | 527 void StartTracking(TextureInfo* info); |
| 525 void StopTracking(TextureInfo* info); | 528 void StopTracking(TextureInfo* info); |
| 526 | 529 |
| 530 scoped_ptr<MemoryTypeTracker> texture_memory_tracker_; |
| 531 |
| 527 FeatureInfo::Ref feature_info_; | 532 FeatureInfo::Ref feature_info_; |
| 528 | 533 |
| 529 // Info for each texture in the system. | 534 // Info for each texture in the system. |
| 530 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap; | 535 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap; |
| 531 TextureInfoMap texture_infos_; | 536 TextureInfoMap texture_infos_; |
| 532 | 537 |
| 533 GLsizei max_texture_size_; | 538 GLsizei max_texture_size_; |
| 534 GLsizei max_cube_map_texture_size_; | 539 GLsizei max_cube_map_texture_size_; |
| 535 GLint max_levels_; | 540 GLint max_levels_; |
| 536 GLint max_cube_map_levels_; | 541 GLint max_cube_map_levels_; |
| 537 | 542 |
| 538 int num_unrenderable_textures_; | 543 int num_unrenderable_textures_; |
| 539 int num_unsafe_textures_; | 544 int num_unsafe_textures_; |
| 540 int num_uncleared_mips_; | 545 int num_uncleared_mips_; |
| 541 | 546 |
| 542 // Counts the number of TextureInfo allocated with 'this' as its manager. | 547 // Counts the number of TextureInfo allocated with 'this' as its manager. |
| 543 // Allows to check no TextureInfo will outlive this. | 548 // Allows to check no TextureInfo will outlive this. |
| 544 unsigned int texture_info_count_; | 549 unsigned int texture_info_count_; |
| 545 | 550 |
| 546 uint32 mem_represented_; | 551 uint32 mem_represented_; |
| 547 uint32 last_reported_mem_represented_; | |
| 548 | 552 |
| 549 bool have_context_; | 553 bool have_context_; |
| 550 | 554 |
| 551 // Black (0,0,0,1) textures for when non-renderable textures are used. | 555 // Black (0,0,0,1) textures for when non-renderable textures are used. |
| 552 // NOTE: There is no corresponding TextureInfo for these textures. | 556 // NOTE: There is no corresponding TextureInfo for these textures. |
| 553 // TextureInfos are only for textures the client side can access. | 557 // TextureInfos are only for textures the client side can access. |
| 554 GLuint black_texture_ids_[kNumDefaultTextures]; | 558 GLuint black_texture_ids_[kNumDefaultTextures]; |
| 555 | 559 |
| 556 // The default textures for each target (texture name = 0) | 560 // The default textures for each target (texture name = 0) |
| 557 TextureInfo::Ref default_textures_[kNumDefaultTextures]; | 561 TextureInfo::Ref default_textures_[kNumDefaultTextures]; |
| 558 | 562 |
| 559 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 563 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
| 560 }; | 564 }; |
| 561 | 565 |
| 562 } // namespace gles2 | 566 } // namespace gles2 |
| 563 } // namespace gpu | 567 } // namespace gpu |
| 564 | 568 |
| 565 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 569 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |