Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 class FramebufferManager; | 32 class FramebufferManager; |
| 33 class MailboxManager; | 33 class MailboxManager; |
| 34 class TextureManager; | 34 class TextureManager; |
| 35 class TextureRef; | 35 class TextureRef; |
| 36 | 36 |
| 37 // Info about Textures currently in the system. | 37 // Info about Textures currently in the system. |
| 38 // This class wraps a real GL texture, keeping track of its meta-data. It is | 38 // This class wraps a real GL texture, keeping track of its meta-data. It is |
| 39 // jointly owned by possibly multiple TextureRef. | 39 // jointly owned by possibly multiple TextureRef. |
| 40 class GPU_EXPORT Texture { | 40 class GPU_EXPORT Texture { |
| 41 public: | 41 public: |
| 42 enum ImageState { UNBOUND, BOUND, COPIED }; | |
| 43 | |
| 42 explicit Texture(GLuint service_id); | 44 explicit Texture(GLuint service_id); |
| 43 | 45 |
| 44 GLenum min_filter() const { | 46 GLenum min_filter() const { |
| 45 return min_filter_; | 47 return min_filter_; |
| 46 } | 48 } |
| 47 | 49 |
| 48 GLenum mag_filter() const { | 50 GLenum mag_filter() const { |
| 49 return mag_filter_; | 51 return mag_filter_; |
| 50 } | 52 } |
| 51 | 53 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 // does not exist. | 128 // does not exist. |
| 127 // |depth| is optional and can be nullptr. | 129 // |depth| is optional and can be nullptr. |
| 128 bool GetLevelSize( | 130 bool GetLevelSize( |
| 129 GLint target, GLint level, | 131 GLint target, GLint level, |
| 130 GLsizei* width, GLsizei* height, GLsizei* depth) const; | 132 GLsizei* width, GLsizei* height, GLsizei* depth) const; |
| 131 | 133 |
| 132 // Get the type of a level. Returns false if level does not exist. | 134 // Get the type of a level. Returns false if level does not exist. |
| 133 bool GetLevelType( | 135 bool GetLevelType( |
| 134 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; | 136 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; |
| 135 | 137 |
| 136 // Get the image bound to a particular level. Returns NULL if level | 138 // Set the image for a particular level. |
| 139 void SetLevelImage(GLenum target, | |
| 140 GLint level, | |
| 141 gfx::GLImage* image, | |
| 142 ImageState state); | |
| 143 | |
| 144 // Get the image associated with a particular level. Returns NULL if level | |
| 137 // does not exist. | 145 // does not exist. |
| 138 gfx::GLImage* GetLevelImage(GLint target, GLint level) const; | 146 gfx::GLImage* GetLevelImage(GLint target, |
|
Daniele Castagna
2015/10/14 18:40:36
nit: Maybe overload this without the state paramet
reveman
2015/10/14 19:28:01
Done.
| |
| 147 GLint level, | |
| 148 ImageState* state) const; | |
| 139 | 149 |
| 140 bool HasImages() const { | 150 bool HasImages() const { |
| 141 return has_images_; | 151 return has_images_; |
| 142 } | 152 } |
| 143 | 153 |
| 144 // Returns true of the given dimensions are inside the dimensions of the | 154 // Returns true of the given dimensions are inside the dimensions of the |
| 145 // level. | 155 // level. |
| 146 bool ValidForTexture( | 156 bool ValidForTexture( |
| 147 GLint target, | 157 GLint target, |
| 148 GLint level, | 158 GLint level, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 bool IsLevelCleared(GLenum target, GLint level) const; | 196 bool IsLevelCleared(GLenum target, GLint level) const; |
| 187 | 197 |
| 188 // Whether the texture has been defined | 198 // Whether the texture has been defined |
| 189 bool IsDefined() const { | 199 bool IsDefined() const { |
| 190 return estimated_size() > 0; | 200 return estimated_size() > 0; |
| 191 } | 201 } |
| 192 | 202 |
| 193 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet. | 203 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet. |
| 194 void InitTextureMaxAnisotropyIfNeeded(GLenum target); | 204 void InitTextureMaxAnisotropyIfNeeded(GLenum target); |
| 195 | 205 |
| 196 void OnWillModifyPixels(); | |
| 197 void OnDidModifyPixels(); | |
| 198 | |
| 199 void DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, | 206 void DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, |
| 200 uint64_t client_tracing_id, | 207 uint64_t client_tracing_id, |
| 201 const std::string& dump_name) const; | 208 const std::string& dump_name) const; |
| 202 | 209 |
| 203 private: | 210 private: |
| 204 friend class MailboxManagerImpl; | 211 friend class MailboxManagerImpl; |
| 205 friend class MailboxManagerSync; | 212 friend class MailboxManagerSync; |
| 206 friend class MailboxManagerTest; | 213 friend class MailboxManagerTest; |
| 207 friend class TextureDefinition; | 214 friend class TextureDefinition; |
| 208 friend class TextureManager; | 215 friend class TextureManager; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 235 GLenum target; | 242 GLenum target; |
| 236 GLint level; | 243 GLint level; |
| 237 GLenum internal_format; | 244 GLenum internal_format; |
| 238 GLsizei width; | 245 GLsizei width; |
| 239 GLsizei height; | 246 GLsizei height; |
| 240 GLsizei depth; | 247 GLsizei depth; |
| 241 GLint border; | 248 GLint border; |
| 242 GLenum format; | 249 GLenum format; |
| 243 GLenum type; | 250 GLenum type; |
| 244 scoped_refptr<gfx::GLImage> image; | 251 scoped_refptr<gfx::GLImage> image; |
| 252 ImageState image_state; | |
| 245 uint32 estimated_size; | 253 uint32 estimated_size; |
| 246 }; | 254 }; |
| 247 | 255 |
| 248 struct FaceInfo { | 256 struct FaceInfo { |
| 249 FaceInfo(); | 257 FaceInfo(); |
| 250 ~FaceInfo(); | 258 ~FaceInfo(); |
| 251 | 259 |
| 252 GLsizei num_mip_levels; | 260 GLsizei num_mip_levels; |
| 253 std::vector<LevelInfo> level_infos; | 261 std::vector<LevelInfo> level_infos; |
| 254 }; | 262 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 363 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
| 356 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB | 364 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
| 357 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) | 365 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) |
| 358 // max_levels: The maximum levels this type of target can have. | 366 // max_levels: The maximum levels this type of target can have. |
| 359 void SetTarget( | 367 void SetTarget( |
| 360 const FeatureInfo* feature_info, GLenum target, GLint max_levels); | 368 const FeatureInfo* feature_info, GLenum target, GLint max_levels); |
| 361 | 369 |
| 362 // Update info about this texture. | 370 // Update info about this texture. |
| 363 void Update(const FeatureInfo* feature_info); | 371 void Update(const FeatureInfo* feature_info); |
| 364 | 372 |
| 365 // Set the image for a particular level. | |
| 366 void SetLevelImage( | |
| 367 const FeatureInfo* feature_info, | |
| 368 GLenum target, | |
| 369 GLint level, | |
| 370 gfx::GLImage* image); | |
| 371 | |
| 372 // Appends a signature for the given level. | 373 // Appends a signature for the given level. |
| 373 void AddToSignature( | 374 void AddToSignature( |
| 374 const FeatureInfo* feature_info, | 375 const FeatureInfo* feature_info, |
| 375 GLenum target, GLint level, std::string* signature) const; | 376 GLenum target, GLint level, std::string* signature) const; |
| 376 | 377 |
| 377 void SetMailboxManager(MailboxManager* mailbox_manager); | 378 void SetMailboxManager(MailboxManager* mailbox_manager); |
| 378 | 379 |
| 379 // Updates the unsafe textures count in all the managers referencing this | 380 // Updates the unsafe textures count in all the managers referencing this |
| 380 // texture. | 381 // texture. |
| 381 void UpdateSafeToRenderFrom(bool cleared); | 382 void UpdateSafeToRenderFrom(bool cleared); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 default: | 784 default: |
| 784 NOTREACHED(); | 785 NOTREACHED(); |
| 785 return 0; | 786 return 0; |
| 786 } | 787 } |
| 787 } | 788 } |
| 788 | 789 |
| 789 size_t mem_represented() const { | 790 size_t mem_represented() const { |
| 790 return memory_type_tracker_->GetMemRepresented(); | 791 return memory_type_tracker_->GetMemRepresented(); |
| 791 } | 792 } |
| 792 | 793 |
| 793 void SetLevelImage( | 794 void SetLevelImage(TextureRef* ref, |
| 794 TextureRef* ref, | 795 GLenum target, |
| 795 GLenum target, | 796 GLint level, |
| 796 GLint level, | 797 gfx::GLImage* image, |
| 797 gfx::GLImage* image); | 798 Texture::ImageState state); |
| 798 | 799 |
| 799 size_t GetSignatureSize() const; | 800 size_t GetSignatureSize() const; |
| 800 | 801 |
| 801 void AddToSignature( | 802 void AddToSignature( |
| 802 TextureRef* ref, | 803 TextureRef* ref, |
| 803 GLenum target, | 804 GLenum target, |
| 804 GLint level, | 805 GLint level, |
| 805 std::string* signature) const; | 806 std::string* signature) const; |
| 806 | 807 |
| 807 void AddObserver(DestructionObserver* observer) { | 808 void AddObserver(DestructionObserver* observer) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 private: | 959 private: |
| 959 DecoderTextureState* texture_state_; | 960 DecoderTextureState* texture_state_; |
| 960 base::TimeTicks begin_time_; | 961 base::TimeTicks begin_time_; |
| 961 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 962 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 962 }; | 963 }; |
| 963 | 964 |
| 964 } // namespace gles2 | 965 } // namespace gles2 |
| 965 } // namespace gpu | 966 } // namespace gpu |
| 966 | 967 |
| 967 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 968 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |