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 { |
| 43 // If an image is associated with the texture and image state is UNBOUND, |
| 44 // then sampling out of the texture or using it as a target for drawing |
| 45 // will not read/write from/to the image. |
| 46 UNBOUND, |
| 47 // If image state is BOUND, then sampling from the texture will return the |
| 48 // contents of the image and using it as a target will modify the image. |
| 49 BOUND, |
| 50 // Image state is set to COPIED if the contents of the image has been |
| 51 // copied to the texture. Sampling from the texture will be equivalent |
| 52 // to sampling out the image (assuming image has not been changed since |
| 53 // it was copied). Using the texture as a target for drawing will only |
| 54 // modify the texture and not the image. |
| 55 COPIED |
| 56 }; |
| 57 |
42 explicit Texture(GLuint service_id); | 58 explicit Texture(GLuint service_id); |
43 | 59 |
44 GLenum min_filter() const { | 60 GLenum min_filter() const { |
45 return min_filter_; | 61 return min_filter_; |
46 } | 62 } |
47 | 63 |
48 GLenum mag_filter() const { | 64 GLenum mag_filter() const { |
49 return mag_filter_; | 65 return mag_filter_; |
50 } | 66 } |
51 | 67 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // does not exist. | 142 // does not exist. |
127 // |depth| is optional and can be nullptr. | 143 // |depth| is optional and can be nullptr. |
128 bool GetLevelSize( | 144 bool GetLevelSize( |
129 GLint target, GLint level, | 145 GLint target, GLint level, |
130 GLsizei* width, GLsizei* height, GLsizei* depth) const; | 146 GLsizei* width, GLsizei* height, GLsizei* depth) const; |
131 | 147 |
132 // Get the type of a level. Returns false if level does not exist. | 148 // Get the type of a level. Returns false if level does not exist. |
133 bool GetLevelType( | 149 bool GetLevelType( |
134 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; | 150 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; |
135 | 151 |
136 // Get the image bound to a particular level. Returns NULL if level | 152 // Set the image for a particular level. |
| 153 void SetLevelImage(GLenum target, |
| 154 GLint level, |
| 155 gfx::GLImage* image, |
| 156 ImageState state); |
| 157 |
| 158 // Get the image associated with a particular level. Returns NULL if level |
137 // does not exist. | 159 // does not exist. |
| 160 gfx::GLImage* GetLevelImage(GLint target, |
| 161 GLint level, |
| 162 ImageState* state) const; |
138 gfx::GLImage* GetLevelImage(GLint target, GLint level) const; | 163 gfx::GLImage* GetLevelImage(GLint target, GLint level) const; |
139 | 164 |
140 bool HasImages() const { | 165 bool HasImages() const { |
141 return has_images_; | 166 return has_images_; |
142 } | 167 } |
143 | 168 |
144 // Returns true of the given dimensions are inside the dimensions of the | 169 // Returns true of the given dimensions are inside the dimensions of the |
145 // level. | 170 // level. |
146 bool ValidForTexture( | 171 bool ValidForTexture( |
147 GLint target, | 172 GLint target, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 bool IsLevelCleared(GLenum target, GLint level) const; | 211 bool IsLevelCleared(GLenum target, GLint level) const; |
187 | 212 |
188 // Whether the texture has been defined | 213 // Whether the texture has been defined |
189 bool IsDefined() const { | 214 bool IsDefined() const { |
190 return estimated_size() > 0; | 215 return estimated_size() > 0; |
191 } | 216 } |
192 | 217 |
193 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet. | 218 // Initialize TEXTURE_MAX_ANISOTROPY to 1 if we haven't done so yet. |
194 void InitTextureMaxAnisotropyIfNeeded(GLenum target); | 219 void InitTextureMaxAnisotropyIfNeeded(GLenum target); |
195 | 220 |
196 void OnWillModifyPixels(); | |
197 void OnDidModifyPixels(); | |
198 | |
199 void DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, | 221 void DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, |
200 uint64_t client_tracing_id, | 222 uint64_t client_tracing_id, |
201 const std::string& dump_name) const; | 223 const std::string& dump_name) const; |
202 | 224 |
203 private: | 225 private: |
204 friend class MailboxManagerImpl; | 226 friend class MailboxManagerImpl; |
205 friend class MailboxManagerSync; | 227 friend class MailboxManagerSync; |
206 friend class MailboxManagerTest; | 228 friend class MailboxManagerTest; |
207 friend class TextureDefinition; | 229 friend class TextureDefinition; |
208 friend class TextureManager; | 230 friend class TextureManager; |
(...skipping 26 matching lines...) Expand all Loading... |
235 GLenum target; | 257 GLenum target; |
236 GLint level; | 258 GLint level; |
237 GLenum internal_format; | 259 GLenum internal_format; |
238 GLsizei width; | 260 GLsizei width; |
239 GLsizei height; | 261 GLsizei height; |
240 GLsizei depth; | 262 GLsizei depth; |
241 GLint border; | 263 GLint border; |
242 GLenum format; | 264 GLenum format; |
243 GLenum type; | 265 GLenum type; |
244 scoped_refptr<gfx::GLImage> image; | 266 scoped_refptr<gfx::GLImage> image; |
| 267 ImageState image_state; |
245 uint32 estimated_size; | 268 uint32 estimated_size; |
246 }; | 269 }; |
247 | 270 |
248 struct FaceInfo { | 271 struct FaceInfo { |
249 FaceInfo(); | 272 FaceInfo(); |
250 ~FaceInfo(); | 273 ~FaceInfo(); |
251 | 274 |
252 GLsizei num_mip_levels; | 275 GLsizei num_mip_levels; |
253 std::vector<LevelInfo> level_infos; | 276 std::vector<LevelInfo> level_infos; |
254 }; | 277 }; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 378 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
356 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB | 379 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
357 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) | 380 // GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3) |
358 // max_levels: The maximum levels this type of target can have. | 381 // max_levels: The maximum levels this type of target can have. |
359 void SetTarget( | 382 void SetTarget( |
360 const FeatureInfo* feature_info, GLenum target, GLint max_levels); | 383 const FeatureInfo* feature_info, GLenum target, GLint max_levels); |
361 | 384 |
362 // Update info about this texture. | 385 // Update info about this texture. |
363 void Update(const FeatureInfo* feature_info); | 386 void Update(const FeatureInfo* feature_info); |
364 | 387 |
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. | 388 // Appends a signature for the given level. |
373 void AddToSignature( | 389 void AddToSignature( |
374 const FeatureInfo* feature_info, | 390 const FeatureInfo* feature_info, |
375 GLenum target, GLint level, std::string* signature) const; | 391 GLenum target, GLint level, std::string* signature) const; |
376 | 392 |
377 void SetMailboxManager(MailboxManager* mailbox_manager); | 393 void SetMailboxManager(MailboxManager* mailbox_manager); |
378 | 394 |
379 // Updates the unsafe textures count in all the managers referencing this | 395 // Updates the unsafe textures count in all the managers referencing this |
380 // texture. | 396 // texture. |
381 void UpdateSafeToRenderFrom(bool cleared); | 397 void UpdateSafeToRenderFrom(bool cleared); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 default: | 799 default: |
784 NOTREACHED(); | 800 NOTREACHED(); |
785 return 0; | 801 return 0; |
786 } | 802 } |
787 } | 803 } |
788 | 804 |
789 size_t mem_represented() const { | 805 size_t mem_represented() const { |
790 return memory_type_tracker_->GetMemRepresented(); | 806 return memory_type_tracker_->GetMemRepresented(); |
791 } | 807 } |
792 | 808 |
793 void SetLevelImage( | 809 void SetLevelImage(TextureRef* ref, |
794 TextureRef* ref, | 810 GLenum target, |
795 GLenum target, | 811 GLint level, |
796 GLint level, | 812 gfx::GLImage* image, |
797 gfx::GLImage* image); | 813 Texture::ImageState state); |
798 | 814 |
799 size_t GetSignatureSize() const; | 815 size_t GetSignatureSize() const; |
800 | 816 |
801 void AddToSignature( | 817 void AddToSignature( |
802 TextureRef* ref, | 818 TextureRef* ref, |
803 GLenum target, | 819 GLenum target, |
804 GLint level, | 820 GLint level, |
805 std::string* signature) const; | 821 std::string* signature) const; |
806 | 822 |
807 void AddObserver(DestructionObserver* observer) { | 823 void AddObserver(DestructionObserver* observer) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 private: | 974 private: |
959 DecoderTextureState* texture_state_; | 975 DecoderTextureState* texture_state_; |
960 base::TimeTicks begin_time_; | 976 base::TimeTicks begin_time_; |
961 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 977 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
962 }; | 978 }; |
963 | 979 |
964 } // namespace gles2 | 980 } // namespace gles2 |
965 } // namespace gpu | 981 } // namespace gpu |
966 | 982 |
967 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 983 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |