| 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 <algorithm> | 8 #include <algorithm> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 base::TimeDelta total_texture_upload_time; | 548 base::TimeDelta total_texture_upload_time; |
| 549 | 549 |
| 550 bool texsubimage_faster_than_teximage; | 550 bool texsubimage_faster_than_teximage; |
| 551 }; | 551 }; |
| 552 | 552 |
| 553 // This class keeps track of the textures and their sizes so we can do NPOT and | 553 // This class keeps track of the textures and their sizes so we can do NPOT and |
| 554 // texture complete checking. | 554 // texture complete checking. |
| 555 // | 555 // |
| 556 // NOTE: To support shared resources an instance of this class will need to be | 556 // NOTE: To support shared resources an instance of this class will need to be |
| 557 // shared by multiple GLES2Decoders. | 557 // shared by multiple GLES2Decoders. |
| 558 class GPU_EXPORT TextureManager { | 558 class GPU_EXPORT TextureManager : public base::trace_event::MemoryDumpProvider { |
| 559 public: | 559 public: |
| 560 class GPU_EXPORT DestructionObserver { | 560 class GPU_EXPORT DestructionObserver { |
| 561 public: | 561 public: |
| 562 DestructionObserver(); | 562 DestructionObserver(); |
| 563 virtual ~DestructionObserver(); | 563 virtual ~DestructionObserver(); |
| 564 | 564 |
| 565 // Called in ~TextureManager. | 565 // Called in ~TextureManager. |
| 566 virtual void OnTextureManagerDestroying(TextureManager* manager) = 0; | 566 virtual void OnTextureManagerDestroying(TextureManager* manager) = 0; |
| 567 | 567 |
| 568 // Called via ~TextureRef. | 568 // Called via ~TextureRef. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 580 kNumDefaultTextures | 580 kNumDefaultTextures |
| 581 }; | 581 }; |
| 582 | 582 |
| 583 TextureManager(MemoryTracker* memory_tracker, | 583 TextureManager(MemoryTracker* memory_tracker, |
| 584 FeatureInfo* feature_info, | 584 FeatureInfo* feature_info, |
| 585 GLsizei max_texture_size, | 585 GLsizei max_texture_size, |
| 586 GLsizei max_cube_map_texture_size, | 586 GLsizei max_cube_map_texture_size, |
| 587 GLsizei max_rectangle_texture_size, | 587 GLsizei max_rectangle_texture_size, |
| 588 GLsizei max_3d_texture_size, | 588 GLsizei max_3d_texture_size, |
| 589 bool use_default_textures); | 589 bool use_default_textures); |
| 590 ~TextureManager(); | 590 ~TextureManager() override; |
| 591 | 591 |
| 592 void set_framebuffer_manager(FramebufferManager* manager) { | 592 void set_framebuffer_manager(FramebufferManager* manager) { |
| 593 framebuffer_manager_ = manager; | 593 framebuffer_manager_ = manager; |
| 594 } | 594 } |
| 595 | 595 |
| 596 // Init the texture manager. | 596 // Init the texture manager. |
| 597 bool Initialize(); | 597 bool Initialize(); |
| 598 | 598 |
| 599 // Must call before destruction. | 599 // Must call before destruction. |
| 600 void Destroy(bool have_context); | 600 void Destroy(bool have_context); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 bool ValidateFormatAndTypeCombination( | 860 bool ValidateFormatAndTypeCombination( |
| 861 ErrorState* error_state, const char* function_name, | 861 ErrorState* error_state, const char* function_name, |
| 862 GLenum format, GLenum type); | 862 GLenum format, GLenum type); |
| 863 | 863 |
| 864 // Note that internal_format is only checked in relation to the format | 864 // Note that internal_format is only checked in relation to the format |
| 865 // parameter, so that this function may be used to validate texSubImage2D. | 865 // parameter, so that this function may be used to validate texSubImage2D. |
| 866 bool ValidateTextureParameters( | 866 bool ValidateTextureParameters( |
| 867 ErrorState* error_state, const char* function_name, | 867 ErrorState* error_state, const char* function_name, |
| 868 GLenum format, GLenum type, GLenum internal_format, GLint level); | 868 GLenum format, GLenum type, GLenum internal_format, GLint level); |
| 869 | 869 |
| 870 // base::trace_event::MemoryDumpProvider implementation. |
| 871 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; |
| 872 |
| 870 private: | 873 private: |
| 871 friend class Texture; | 874 friend class Texture; |
| 872 friend class TextureRef; | 875 friend class TextureRef; |
| 873 | 876 |
| 874 // Helper for Initialize(). | 877 // Helper for Initialize(). |
| 875 scoped_refptr<TextureRef> CreateDefaultAndBlackTextures( | 878 scoped_refptr<TextureRef> CreateDefaultAndBlackTextures( |
| 876 GLenum target, | 879 GLenum target, |
| 877 GLuint* black_texture); | 880 GLuint* black_texture); |
| 878 | 881 |
| 879 void DoTexImage( | 882 void DoTexImage( |
| 880 DecoderTextureState* texture_state, | 883 DecoderTextureState* texture_state, |
| 881 ErrorState* error_state, | 884 ErrorState* error_state, |
| 882 DecoderFramebufferState* framebuffer_state, | 885 DecoderFramebufferState* framebuffer_state, |
| 883 const char* function_name, | 886 const char* function_name, |
| 884 TextureRef* texture_ref, | 887 TextureRef* texture_ref, |
| 885 const DoTexImageArguments& args); | 888 const DoTexImageArguments& args); |
| 886 | 889 |
| 887 void StartTracking(TextureRef* texture); | 890 void StartTracking(TextureRef* texture); |
| 888 void StopTracking(TextureRef* texture); | 891 void StopTracking(TextureRef* texture); |
| 889 | 892 |
| 890 void UpdateSafeToRenderFrom(int delta); | 893 void UpdateSafeToRenderFrom(int delta); |
| 891 void UpdateUnclearedMips(int delta); | 894 void UpdateUnclearedMips(int delta); |
| 892 void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition, | 895 void UpdateCanRenderCondition(Texture::CanRenderCondition old_condition, |
| 893 Texture::CanRenderCondition new_condition); | 896 Texture::CanRenderCondition new_condition); |
| 894 void UpdateNumImages(int delta); | 897 void UpdateNumImages(int delta); |
| 895 void IncFramebufferStateChangeCount(); | 898 void IncFramebufferStateChangeCount(); |
| 896 | 899 |
| 897 GLenum AdjustTexFormat(GLenum format) const; | 900 GLenum AdjustTexFormat(GLenum format) const; |
| 898 | 901 |
| 902 // Helper function called by OnMemoryDump. |
| 903 void DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
| 904 TextureRef* ref); |
| 905 |
| 899 MemoryTypeTracker* GetMemTracker(GLenum texture_pool); | 906 MemoryTypeTracker* GetMemTracker(GLenum texture_pool); |
| 900 scoped_ptr<MemoryTypeTracker> memory_tracker_managed_; | 907 scoped_ptr<MemoryTypeTracker> memory_tracker_managed_; |
| 901 scoped_ptr<MemoryTypeTracker> memory_tracker_unmanaged_; | 908 scoped_ptr<MemoryTypeTracker> memory_tracker_unmanaged_; |
| 909 MemoryTracker* memory_tracker_; |
| 902 | 910 |
| 903 scoped_refptr<FeatureInfo> feature_info_; | 911 scoped_refptr<FeatureInfo> feature_info_; |
| 904 | 912 |
| 905 FramebufferManager* framebuffer_manager_; | 913 FramebufferManager* framebuffer_manager_; |
| 906 | 914 |
| 907 // Info for each texture in the system. | 915 // Info for each texture in the system. |
| 908 typedef base::hash_map<GLuint, scoped_refptr<TextureRef> > TextureMap; | 916 typedef base::hash_map<GLuint, scoped_refptr<TextureRef> > TextureMap; |
| 909 TextureMap textures_; | 917 TextureMap textures_; |
| 910 | 918 |
| 911 GLsizei max_texture_size_; | 919 GLsizei max_texture_size_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 private: | 959 private: |
| 952 DecoderTextureState* texture_state_; | 960 DecoderTextureState* texture_state_; |
| 953 base::TimeTicks begin_time_; | 961 base::TimeTicks begin_time_; |
| 954 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 962 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 955 }; | 963 }; |
| 956 | 964 |
| 957 } // namespace gles2 | 965 } // namespace gles2 |
| 958 } // namespace gpu | 966 } // namespace gpu |
| 959 | 967 |
| 960 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 968 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |