| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 GLsizei width; | 201 GLsizei width; |
| 202 GLsizei height; | 202 GLsizei height; |
| 203 GLsizei depth; | 203 GLsizei depth; |
| 204 GLint border; | 204 GLint border; |
| 205 GLenum format; | 205 GLenum format; |
| 206 GLenum type; | 206 GLenum type; |
| 207 scoped_refptr<gfx::GLImage> image; | 207 scoped_refptr<gfx::GLImage> image; |
| 208 uint32 estimated_size; | 208 uint32 estimated_size; |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 struct FaceInfo { |
| 212 FaceInfo(); |
| 213 ~FaceInfo(); |
| 214 |
| 215 GLsizei num_mip_levels; |
| 216 std::vector<LevelInfo> level_infos; |
| 217 }; |
| 218 |
| 211 // Set the info for a particular level. | 219 // Set the info for a particular level. |
| 212 void SetLevelInfo( | 220 void SetLevelInfo( |
| 213 const FeatureInfo* feature_info, | 221 const FeatureInfo* feature_info, |
| 214 GLenum target, | 222 GLenum target, |
| 215 GLint level, | 223 GLint level, |
| 216 GLenum internal_format, | 224 GLenum internal_format, |
| 217 GLsizei width, | 225 GLsizei width, |
| 218 GLsizei height, | 226 GLsizei height, |
| 219 GLsizei depth, | 227 GLsizei depth, |
| 220 GLint border, | 228 GLint border, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; | 277 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; |
| 270 } | 278 } |
| 271 | 279 |
| 272 // True if this texture meets all the GLES2 criteria for rendering. | 280 // True if this texture meets all the GLES2 criteria for rendering. |
| 273 // See section 3.8.2 of the GLES2 spec. | 281 // See section 3.8.2 of the GLES2 spec. |
| 274 bool CanRender(const FeatureInfo* feature_info) const; | 282 bool CanRender(const FeatureInfo* feature_info) const; |
| 275 | 283 |
| 276 // Returns true if mipmaps can be generated by GL. | 284 // Returns true if mipmaps can be generated by GL. |
| 277 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const; | 285 bool CanGenerateMipmaps(const FeatureInfo* feature_info) const; |
| 278 | 286 |
| 287 // Returns true if any of the texture dimensions are not a power of two. |
| 288 static bool TextureIsNPOT(GLsizei width, GLsizei height, GLsizei depth); |
| 289 |
| 290 // Returns true if texture face is complete relative to the first face. |
| 291 static bool TextureFaceComplete(const Texture::LevelInfo& first_face, |
| 292 size_t face_index, |
| 293 GLenum target, |
| 294 GLenum internal_format, |
| 295 GLsizei width, |
| 296 GLsizei height, |
| 297 GLsizei depth, |
| 298 GLenum format, |
| 299 GLenum type); |
| 300 |
| 301 // Returns true if texture mip level is complete relative to first level. |
| 302 static bool TextureMipComplete(const Texture::LevelInfo& level0_face, |
| 303 GLenum target, |
| 304 GLint level, |
| 305 GLenum internal_format, |
| 306 GLsizei width, |
| 307 GLsizei height, |
| 308 GLsizei depth, |
| 309 GLenum format, |
| 310 GLenum type); |
| 311 |
| 279 // Sets the Texture's target | 312 // Sets the Texture's target |
| 280 // Parameters: | 313 // Parameters: |
| 281 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 314 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
| 282 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB | 315 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
| 283 // max_levels: The maximum levels this type of target can have. | 316 // max_levels: The maximum levels this type of target can have. |
| 284 void SetTarget( | 317 void SetTarget( |
| 285 const FeatureInfo* feature_info, GLenum target, GLint max_levels); | 318 const FeatureInfo* feature_info, GLenum target, GLint max_levels); |
| 286 | 319 |
| 287 // Update info about this texture. | 320 // Update info about this texture. |
| 288 void Update(const FeatureInfo* feature_info); | 321 void Update(const FeatureInfo* feature_info); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // texture. | 353 // texture. |
| 321 void UpdateHasImages(); | 354 void UpdateHasImages(); |
| 322 | 355 |
| 323 // Increment the framebuffer state change count in all the managers | 356 // Increment the framebuffer state change count in all the managers |
| 324 // referencing this texture. | 357 // referencing this texture. |
| 325 void IncAllFramebufferStateChangeCount(); | 358 void IncAllFramebufferStateChangeCount(); |
| 326 | 359 |
| 327 MailboxManager* mailbox_manager_; | 360 MailboxManager* mailbox_manager_; |
| 328 | 361 |
| 329 // Info about each face and level of texture. | 362 // Info about each face and level of texture. |
| 330 std::vector<std::vector<LevelInfo> > level_infos_; | 363 std::vector<FaceInfo> face_infos_; |
| 331 | 364 |
| 332 // The texture refs that point to this Texture. | 365 // The texture refs that point to this Texture. |
| 333 typedef std::set<TextureRef*> RefSet; | 366 typedef std::set<TextureRef*> RefSet; |
| 334 RefSet refs_; | 367 RefSet refs_; |
| 335 | 368 |
| 336 // The single TextureRef that accounts for memory for this texture. Must be | 369 // The single TextureRef that accounts for memory for this texture. Must be |
| 337 // one of refs_. | 370 // one of refs_. |
| 338 TextureRef* memory_tracking_ref_; | 371 TextureRef* memory_tracking_ref_; |
| 339 | 372 |
| 340 // The id of the texure | 373 // The id of the texure |
| 341 GLuint service_id_; | 374 GLuint service_id_; |
| 342 | 375 |
| 343 // Whether all renderable mips of this texture have been cleared. | 376 // Whether all renderable mips of this texture have been cleared. |
| 344 bool cleared_; | 377 bool cleared_; |
| 345 | 378 |
| 346 int num_uncleared_mips_; | 379 int num_uncleared_mips_; |
| 380 int num_npot_faces_; |
| 347 | 381 |
| 348 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. | 382 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. |
| 349 GLenum target_; | 383 GLenum target_; |
| 350 | 384 |
| 351 // Texture parameters. | 385 // Texture parameters. |
| 352 GLenum min_filter_; | 386 GLenum min_filter_; |
| 353 GLenum mag_filter_; | 387 GLenum mag_filter_; |
| 354 GLenum wrap_s_; | 388 GLenum wrap_s_; |
| 355 GLenum wrap_t_; | 389 GLenum wrap_t_; |
| 356 GLenum usage_; | 390 GLenum usage_; |
| 357 GLenum pool_; | 391 GLenum pool_; |
| 358 | 392 |
| 359 // The maximum level that has been set. | 393 // The maximum level that has been set. |
| 360 GLint max_level_set_; | 394 GLint max_level_set_; |
| 361 | 395 |
| 362 // Whether or not this texture is "texture complete" | 396 // Whether or not this texture is "texture complete" |
| 363 bool texture_complete_; | 397 bool texture_complete_; |
| 364 | 398 |
| 399 // Whether mip levels have changed and should be reverified. |
| 400 bool texture_mips_dirty_; |
| 401 |
| 365 // Whether or not this texture is "cube complete" | 402 // Whether or not this texture is "cube complete" |
| 366 bool cube_complete_; | 403 bool cube_complete_; |
| 367 | 404 |
| 405 // Whether any level 0 faces have changed and should be reverified. |
| 406 bool texture_level0_dirty_; |
| 407 |
| 368 // Whether or not this texture is non-power-of-two | 408 // Whether or not this texture is non-power-of-two |
| 369 bool npot_; | 409 bool npot_; |
| 370 | 410 |
| 371 // Whether this texture has ever been bound. | 411 // Whether this texture has ever been bound. |
| 372 bool has_been_bound_; | 412 bool has_been_bound_; |
| 373 | 413 |
| 374 // The number of framebuffers this texture is attached to. | 414 // The number of framebuffers this texture is attached to. |
| 375 int framebuffer_attachment_count_; | 415 int framebuffer_attachment_count_; |
| 376 | 416 |
| 377 // Whether the texture is immutable and no further changes to the format | 417 // Whether the texture is immutable and no further changes to the format |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 private: | 864 private: |
| 825 DecoderTextureState* texture_state_; | 865 DecoderTextureState* texture_state_; |
| 826 base::TimeTicks begin_time_; | 866 base::TimeTicks begin_time_; |
| 827 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 867 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 828 }; | 868 }; |
| 829 | 869 |
| 830 } // namespace gles2 | 870 } // namespace gles2 |
| 831 } // namespace gpu | 871 } // namespace gpu |
| 832 | 872 |
| 833 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 873 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |