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 }; | |
|
no sievers
2015/10/15 21:52:44
nit: mind putting some comments with each enum abo
no sievers
2015/10/15 21:52:44
is the COPIED state actually used for anything?
reveman
2015/10/15 22:56:16
Done. COPIED is used. See the comment in latest pa
| |
| 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. |
| 146 gfx::GLImage* GetLevelImage(GLint target, | |
| 147 GLint level, | |
| 148 ImageState* state) const; | |
| 138 gfx::GLImage* GetLevelImage(GLint target, GLint level) const; | 149 gfx::GLImage* GetLevelImage(GLint target, GLint level) const; |
| 139 | 150 |
| 140 bool HasImages() const { | 151 bool HasImages() const { |
| 141 return has_images_; | 152 return has_images_; |
| 142 } | 153 } |
| 143 | 154 |
| 144 // Returns true of the given dimensions are inside the dimensions of the | 155 // Returns true of the given dimensions are inside the dimensions of the |
| 145 // level. | 156 // level. |
| 146 bool ValidForTexture( | 157 bool ValidForTexture( |
| 147 GLint target, | 158 GLint target, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 bool IsLevelCleared(GLenum target, GLint level) const; | 197 bool IsLevelCleared(GLenum target, GLint level) const; |
| 187 | 198 |
| 188 // Whether the texture has been defined | 199 // Whether the texture has been defined |
| 189 bool IsDefined() const { | 200 bool IsDefined() const { |
| 190 return estimated_size() > 0; | 201 return estimated_size() > 0; |
| 191 } | 202 } |
| 192 | 203 |
| 193 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet. | 204 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet. |
| 194 void InitTextureMaxAnisotropyIfNeeded(GLenum target); | 205 void InitTextureMaxAnisotropyIfNeeded(GLenum target); |
| 195 | 206 |
| 196 void OnWillModifyPixels(); | |
| 197 void OnDidModifyPixels(); | |
| 198 | |
| 199 void DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, | 207 void DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, |
| 200 uint64_t client_tracing_id, | 208 uint64_t client_tracing_id, |
| 201 const std::string& dump_name) const; | 209 const std::string& dump_name) const; |
| 202 | 210 |
| 203 private: | 211 private: |
| 204 friend class MailboxManagerImpl; | 212 friend class MailboxManagerImpl; |
| 205 friend class MailboxManagerSync; | 213 friend class MailboxManagerSync; |
| 206 friend class MailboxManagerTest; | 214 friend class MailboxManagerTest; |
| 207 friend class TextureDefinition; | 215 friend class TextureDefinition; |
| 208 friend class TextureManager; | 216 friend class TextureManager; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 235 GLenum target; | 243 GLenum target; |
| 236 GLint level; | 244 GLint level; |
| 237 GLenum internal_format; | 245 GLenum internal_format; |
| 238 GLsizei width; | 246 GLsizei width; |
| 239 GLsizei height; | 247 GLsizei height; |
| 240 GLsizei depth; | 248 GLsizei depth; |
| 241 GLint border; | 249 GLint border; |
| 242 GLenum format; | 250 GLenum format; |
| 243 GLenum type; | 251 GLenum type; |
| 244 scoped_refptr<gfx::GLImage> image; | 252 scoped_refptr<gfx::GLImage> image; |
| 253 ImageState image_state; | |
| 245 uint32 estimated_size; | 254 uint32 estimated_size; |
| 246 }; | 255 }; |
| 247 | 256 |
| 248 struct FaceInfo { | 257 struct FaceInfo { |
| 249 FaceInfo(); | 258 FaceInfo(); |
| 250 ~FaceInfo(); | 259 ~FaceInfo(); |
| 251 | 260 |
| 252 GLsizei num_mip_levels; | 261 GLsizei num_mip_levels; |
| 253 std::vector<LevelInfo> level_infos; | 262 std::vector<LevelInfo> level_infos; |
| 254 }; | 263 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 364 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
| 356 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB | 365 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
| 357 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) | 366 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) |
| 358 // max_levels: The maximum levels this type of target can have. | 367 // max_levels: The maximum levels this type of target can have. |
| 359 void SetTarget( | 368 void SetTarget( |
| 360 const FeatureInfo* feature_info, GLenum target, GLint max_levels); | 369 const FeatureInfo* feature_info, GLenum target, GLint max_levels); |
| 361 | 370 |
| 362 // Update info about this texture. | 371 // Update info about this texture. |
| 363 void Update(const FeatureInfo* feature_info); | 372 void Update(const FeatureInfo* feature_info); |
| 364 | 373 |
| 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. | 374 // Appends a signature for the given level. |
| 373 void AddToSignature( | 375 void AddToSignature( |
| 374 const FeatureInfo* feature_info, | 376 const FeatureInfo* feature_info, |
| 375 GLenum target, GLint level, std::string* signature) const; | 377 GLenum target, GLint level, std::string* signature) const; |
| 376 | 378 |
| 377 void SetMailboxManager(MailboxManager* mailbox_manager); | 379 void SetMailboxManager(MailboxManager* mailbox_manager); |
| 378 | 380 |
| 379 // Updates the unsafe textures count in all the managers referencing this | 381 // Updates the unsafe textures count in all the managers referencing this |
| 380 // texture. | 382 // texture. |
| 381 void UpdateSafeToRenderFrom(bool cleared); | 383 void UpdateSafeToRenderFrom(bool cleared); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 default: | 785 default: |
| 784 NOTREACHED(); | 786 NOTREACHED(); |
| 785 return 0; | 787 return 0; |
| 786 } | 788 } |
| 787 } | 789 } |
| 788 | 790 |
| 789 size_t mem_represented() const { | 791 size_t mem_represented() const { |
| 790 return memory_type_tracker_->GetMemRepresented(); | 792 return memory_type_tracker_->GetMemRepresented(); |
| 791 } | 793 } |
| 792 | 794 |
| 793 void SetLevelImage( | 795 void SetLevelImage(TextureRef* ref, |
| 794 TextureRef* ref, | 796 GLenum target, |
| 795 GLenum target, | 797 GLint level, |
| 796 GLint level, | 798 gfx::GLImage* image, |
| 797 gfx::GLImage* image); | 799 Texture::ImageState state); |
| 798 | 800 |
| 799 size_t GetSignatureSize() const; | 801 size_t GetSignatureSize() const; |
| 800 | 802 |
| 801 void AddToSignature( | 803 void AddToSignature( |
| 802 TextureRef* ref, | 804 TextureRef* ref, |
| 803 GLenum target, | 805 GLenum target, |
| 804 GLint level, | 806 GLint level, |
| 805 std::string* signature) const; | 807 std::string* signature) const; |
| 806 | 808 |
| 807 void AddObserver(DestructionObserver* observer) { | 809 void AddObserver(DestructionObserver* observer) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 private: | 960 private: |
| 959 DecoderTextureState* texture_state_; | 961 DecoderTextureState* texture_state_; |
| 960 base::TimeTicks begin_time_; | 962 base::TimeTicks begin_time_; |
| 961 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 963 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 962 }; | 964 }; |
| 963 | 965 |
| 964 } // namespace gles2 | 966 } // namespace gles2 |
| 965 } // namespace gpu | 967 } // namespace gpu |
| 966 | 968 |
| 967 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 969 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |