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