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, |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 GLenum target; | 245 GLenum target; |
236 GLint level; | 246 GLint level; |
237 GLenum internal_format; | 247 GLenum internal_format; |
238 GLsizei width; | 248 GLsizei width; |
239 GLsizei height; | 249 GLsizei height; |
240 GLsizei depth; | 250 GLsizei depth; |
241 GLint border; | 251 GLint border; |
242 GLenum format; | 252 GLenum format; |
243 GLenum type; | 253 GLenum type; |
244 scoped_refptr<gfx::GLImage> image; | 254 scoped_refptr<gfx::GLImage> image; |
| 255 ImageState image_state; |
245 uint32 estimated_size; | 256 uint32 estimated_size; |
246 }; | 257 }; |
247 | 258 |
248 struct FaceInfo { | 259 struct FaceInfo { |
249 FaceInfo(); | 260 FaceInfo(); |
250 ~FaceInfo(); | 261 ~FaceInfo(); |
251 | 262 |
252 GLsizei num_mip_levels; | 263 GLsizei num_mip_levels; |
253 std::vector<LevelInfo> level_infos; | 264 std::vector<LevelInfo> level_infos; |
254 }; | 265 }; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 366 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
356 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB | 367 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
357 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) | 368 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) |
358 // max_levels: The maximum levels this type of target can have. | 369 // max_levels: The maximum levels this type of target can have. |
359 void SetTarget( | 370 void SetTarget( |
360 const FeatureInfo* feature_info, GLenum target, GLint max_levels); | 371 const FeatureInfo* feature_info, GLenum target, GLint max_levels); |
361 | 372 |
362 // Update info about this texture. | 373 // Update info about this texture. |
363 void Update(const FeatureInfo* feature_info); | 374 void Update(const FeatureInfo* feature_info); |
364 | 375 |
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. | 376 // Appends a signature for the given level. |
373 void AddToSignature( | 377 void AddToSignature( |
374 const FeatureInfo* feature_info, | 378 const FeatureInfo* feature_info, |
375 GLenum target, GLint level, std::string* signature) const; | 379 GLenum target, GLint level, std::string* signature) const; |
376 | 380 |
377 void SetMailboxManager(MailboxManager* mailbox_manager); | 381 void SetMailboxManager(MailboxManager* mailbox_manager); |
378 | 382 |
379 // Updates the unsafe textures count in all the managers referencing this | 383 // Updates the unsafe textures count in all the managers referencing this |
380 // texture. | 384 // texture. |
381 void UpdateSafeToRenderFrom(bool cleared); | 385 void UpdateSafeToRenderFrom(bool cleared); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 default: | 787 default: |
784 NOTREACHED(); | 788 NOTREACHED(); |
785 return 0; | 789 return 0; |
786 } | 790 } |
787 } | 791 } |
788 | 792 |
789 size_t mem_represented() const { | 793 size_t mem_represented() const { |
790 return memory_type_tracker_->GetMemRepresented(); | 794 return memory_type_tracker_->GetMemRepresented(); |
791 } | 795 } |
792 | 796 |
793 void SetLevelImage( | 797 void SetLevelImage(TextureRef* ref, |
794 TextureRef* ref, | 798 GLenum target, |
795 GLenum target, | 799 GLint level, |
796 GLint level, | 800 gfx::GLImage* image, |
797 gfx::GLImage* image); | 801 Texture::ImageState state); |
798 | 802 |
799 size_t GetSignatureSize() const; | 803 size_t GetSignatureSize() const; |
800 | 804 |
801 void AddToSignature( | 805 void AddToSignature( |
802 TextureRef* ref, | 806 TextureRef* ref, |
803 GLenum target, | 807 GLenum target, |
804 GLint level, | 808 GLint level, |
805 std::string* signature) const; | 809 std::string* signature) const; |
806 | 810 |
807 void AddObserver(DestructionObserver* observer) { | 811 void AddObserver(DestructionObserver* observer) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 private: | 962 private: |
959 DecoderTextureState* texture_state_; | 963 DecoderTextureState* texture_state_; |
960 base::TimeTicks begin_time_; | 964 base::TimeTicks begin_time_; |
961 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 965 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
962 }; | 966 }; |
963 | 967 |
964 } // namespace gles2 | 968 } // namespace gles2 |
965 } // namespace gpu | 969 } // namespace gpu |
966 | 970 |
967 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 971 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |