| 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 <vector> | 8 #include <vector> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "gpu/command_buffer/service/feature_info.h" | 13 #include "gpu/command_buffer/service/feature_info.h" |
| 14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
| 15 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
| 16 #include "ui/gl/gl_image.h" |
| 16 | 17 |
| 17 namespace gpu { | 18 namespace gpu { |
| 18 namespace gles2 { | 19 namespace gles2 { |
| 19 | 20 |
| 20 class GLES2Decoder; | 21 class GLES2Decoder; |
| 21 class Display; | 22 class Display; |
| 22 class TextureDefinition; | 23 class TextureDefinition; |
| 23 | 24 |
| 24 // This class keeps track of the textures and their sizes so we can do NPOT and | 25 // This class keeps track of the textures and their sizes so we can do NPOT and |
| 25 // texture complete checking. | 26 // texture complete checking. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 116 |
| 116 // Get the width and height for a particular level. Returns false if level | 117 // Get the width and height for a particular level. Returns false if level |
| 117 // does not exist. | 118 // does not exist. |
| 118 bool GetLevelSize( | 119 bool GetLevelSize( |
| 119 GLint face, GLint level, GLsizei* width, GLsizei* height) const; | 120 GLint face, GLint level, GLsizei* width, GLsizei* height) const; |
| 120 | 121 |
| 121 // Get the type of a level. Returns false if level does not exist. | 122 // Get the type of a level. Returns false if level does not exist. |
| 122 bool GetLevelType( | 123 bool GetLevelType( |
| 123 GLint face, GLint level, GLenum* type, GLenum* internal_format) const; | 124 GLint face, GLint level, GLenum* type, GLenum* internal_format) const; |
| 124 | 125 |
| 126 // Get the image bound to a particular level. Returns NULL if level |
| 127 // does not exist. |
| 128 scoped_refptr<gfx::GLImage> GetLevelImage(GLint face, GLint level) const; |
| 129 |
| 125 bool IsDeleted() const { | 130 bool IsDeleted() const { |
| 126 return deleted_; | 131 return deleted_; |
| 127 } | 132 } |
| 128 | 133 |
| 129 // Returns true of the given dimensions are inside the dimensions of the | 134 // Returns true of the given dimensions are inside the dimensions of the |
| 130 // level and if the format and type match the level. | 135 // level and if the format and type match the level. |
| 131 bool ValidForTexture( | 136 bool ValidForTexture( |
| 132 GLint face, | 137 GLint face, |
| 133 GLint level, | 138 GLint level, |
| 134 GLint xoffset, | 139 GLint xoffset, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 : cleared(rhs.cleared), | 209 : cleared(rhs.cleared), |
| 205 target(rhs.target), | 210 target(rhs.target), |
| 206 level(rhs.level), | 211 level(rhs.level), |
| 207 internal_format(rhs.internal_format), | 212 internal_format(rhs.internal_format), |
| 208 width(rhs.width), | 213 width(rhs.width), |
| 209 height(rhs.height), | 214 height(rhs.height), |
| 210 depth(rhs.depth), | 215 depth(rhs.depth), |
| 211 border(rhs.border), | 216 border(rhs.border), |
| 212 format(rhs.format), | 217 format(rhs.format), |
| 213 type(rhs.type), | 218 type(rhs.type), |
| 219 image(rhs.image), |
| 214 estimated_size(rhs.estimated_size) { | 220 estimated_size(rhs.estimated_size) { |
| 215 } | 221 } |
| 216 | 222 |
| 223 ~LevelInfo() {} |
| 224 |
| 217 bool cleared; | 225 bool cleared; |
| 218 GLenum target; | 226 GLenum target; |
| 219 GLint level; | 227 GLint level; |
| 220 GLenum internal_format; | 228 GLenum internal_format; |
| 221 GLsizei width; | 229 GLsizei width; |
| 222 GLsizei height; | 230 GLsizei height; |
| 223 GLsizei depth; | 231 GLsizei depth; |
| 224 GLint border; | 232 GLint border; |
| 225 GLenum format; | 233 GLenum format; |
| 226 GLenum type; | 234 GLenum type; |
| 235 scoped_refptr<gfx::GLImage> image; |
| 227 uint32 estimated_size; | 236 uint32 estimated_size; |
| 228 }; | 237 }; |
| 229 | 238 |
| 230 // Set the info for a particular level. | 239 // Set the info for a particular level. |
| 231 void SetLevelInfo( | 240 void SetLevelInfo( |
| 232 const FeatureInfo* feature_info, | 241 const FeatureInfo* feature_info, |
| 233 GLenum target, | 242 GLenum target, |
| 234 GLint level, | 243 GLint level, |
| 235 GLenum internal_format, | 244 GLenum internal_format, |
| 236 GLsizei width, | 245 GLsizei width, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // Sets the TextureInfo's target | 291 // Sets the TextureInfo's target |
| 283 // Parameters: | 292 // Parameters: |
| 284 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or | 293 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or |
| 285 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB | 294 // GL_TEXTURE_EXTERNAL_OES or GL_TEXTURE_RECTANGLE_ARB |
| 286 // max_levels: The maximum levels this type of target can have. | 295 // max_levels: The maximum levels this type of target can have. |
| 287 void SetTarget(GLenum target, GLint max_levels); | 296 void SetTarget(GLenum target, GLint max_levels); |
| 288 | 297 |
| 289 // Update info about this texture. | 298 // Update info about this texture. |
| 290 void Update(const FeatureInfo* feature_info); | 299 void Update(const FeatureInfo* feature_info); |
| 291 | 300 |
| 301 // Set the image for a particular level. |
| 302 void SetLevelImage( |
| 303 const FeatureInfo* feature_info, |
| 304 GLenum target, |
| 305 GLint level, |
| 306 scoped_refptr<gfx::GLImage> image); |
| 307 |
| 292 // Info about each face and level of texture. | 308 // Info about each face and level of texture. |
| 293 std::vector<std::vector<LevelInfo> > level_infos_; | 309 std::vector<std::vector<LevelInfo> > level_infos_; |
| 294 | 310 |
| 295 // The texture manager that manages this TextureInfo. | 311 // The texture manager that manages this TextureInfo. |
| 296 TextureManager* manager_; | 312 TextureManager* manager_; |
| 297 | 313 |
| 298 // The id of the texure | 314 // The id of the texure |
| 299 GLuint service_id_; | 315 GLuint service_id_; |
| 300 | 316 |
| 301 // Whether this texture has been deleted. | 317 // Whether this texture has been deleted. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 default: | 522 default: |
| 507 NOTREACHED(); | 523 NOTREACHED(); |
| 508 return 0; | 524 return 0; |
| 509 } | 525 } |
| 510 } | 526 } |
| 511 | 527 |
| 512 uint32 mem_represented() const { | 528 uint32 mem_represented() const { |
| 513 return mem_represented_; | 529 return mem_represented_; |
| 514 } | 530 } |
| 515 | 531 |
| 532 void SetLevelImage( |
| 533 TextureInfo* info, |
| 534 GLenum target, |
| 535 GLint level, |
| 536 scoped_refptr<gfx::GLImage> image); |
| 537 |
| 516 private: | 538 private: |
| 517 // Helper for Initialize(). | 539 // Helper for Initialize(). |
| 518 TextureInfo::Ref CreateDefaultAndBlackTextures( | 540 TextureInfo::Ref CreateDefaultAndBlackTextures( |
| 519 GLenum target, | 541 GLenum target, |
| 520 GLuint* black_texture); | 542 GLuint* black_texture); |
| 521 | 543 |
| 522 void UpdateMemRepresented(); | 544 void UpdateMemRepresented(); |
| 523 | 545 |
| 524 void StartTracking(TextureInfo* info); | 546 void StartTracking(TextureInfo* info); |
| 525 void StopTracking(TextureInfo* info); | 547 void StopTracking(TextureInfo* info); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 556 // The default textures for each target (texture name = 0) | 578 // The default textures for each target (texture name = 0) |
| 557 TextureInfo::Ref default_textures_[kNumDefaultTextures]; | 579 TextureInfo::Ref default_textures_[kNumDefaultTextures]; |
| 558 | 580 |
| 559 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 581 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
| 560 }; | 582 }; |
| 561 | 583 |
| 562 } // namespace gles2 | 584 } // namespace gles2 |
| 563 } // namespace gpu | 585 } // namespace gpu |
| 564 | 586 |
| 565 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 587 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |