| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return service_id_; | 146 return service_id_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void SetServiceId(GLuint service_id) { | 149 void SetServiceId(GLuint service_id) { |
| 150 DCHECK(service_id); | 150 DCHECK(service_id); |
| 151 DCHECK_EQ(owned_service_id_, service_id_); | 151 DCHECK_EQ(owned_service_id_, service_id_); |
| 152 service_id_ = service_id; | 152 service_id_ = service_id; |
| 153 owned_service_id_ = service_id; | 153 owned_service_id_ = service_id; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Causes us to report |service_id| as our service id, but does not delete | |
| 157 // it when we are destroyed. Will rebind any OES_EXTERNAL texture units to | |
| 158 // our new service id in all contexts. If |service_id| is zero, then we | |
| 159 // revert to our original service id. | |
| 160 void SetUnownedServiceId(GLuint service_id); | |
| 161 | |
| 162 // Returns the target this texure was first bound to or 0 if it has not | 156 // Returns the target this texure was first bound to or 0 if it has not |
| 163 // been bound. Once a texture is bound to a specific target it can never be | 157 // been bound. Once a texture is bound to a specific target it can never be |
| 164 // bound to a different target. | 158 // bound to a different target. |
| 165 GLenum target() const { | 159 GLenum target() const { |
| 166 return target_; | 160 return target_; |
| 167 } | 161 } |
| 168 | 162 |
| 169 bool SafeToRenderFrom() const { | 163 bool SafeToRenderFrom() const { |
| 170 return cleared_; | 164 return cleared_; |
| 171 } | 165 } |
| 172 | 166 |
| 173 // Get the width/height/depth for a particular level. Returns false if level | 167 // Get the width/height/depth for a particular level. Returns false if level |
| 174 // does not exist. | 168 // does not exist. |
| 175 // |depth| is optional and can be nullptr. | 169 // |depth| is optional and can be nullptr. |
| 176 bool GetLevelSize( | 170 bool GetLevelSize( |
| 177 GLint target, GLint level, | 171 GLint target, GLint level, |
| 178 GLsizei* width, GLsizei* height, GLsizei* depth) const; | 172 GLsizei* width, GLsizei* height, GLsizei* depth) const; |
| 179 | 173 |
| 180 // Get the type of a level. Returns false if level does not exist. | 174 // Get the type of a level. Returns false if level does not exist. |
| 181 bool GetLevelType( | 175 bool GetLevelType( |
| 182 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; | 176 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; |
| 183 | 177 |
| 184 // Set the image for a particular level. | 178 // Set the image for a particular level. If a GLStreamTextureImage was |
| 179 // previously set with SetLevelStreamTextureImage(), this will reset |
| 180 // |service_id_| back to |owned_service_id_|, removing the service id override |
| 181 // set by the GLStreamTextureImage. |
| 185 void SetLevelImage(GLenum target, | 182 void SetLevelImage(GLenum target, |
| 186 GLint level, | 183 GLint level, |
| 187 gl::GLImage* image, | 184 gl::GLImage* image, |
| 188 ImageState state); | 185 ImageState state); |
| 189 | 186 |
| 190 // Set the GLStreamTextureImage for a particular level. This is identical | 187 // Set the GLStreamTextureImage for a particular level. This is like |
| 191 // to SetLevelImage, but it also permits GetLevelStreamTextureImage to return | 188 // SetLevelImage, but it also makes it optional to override |service_id_| with |
| 192 // the image. | 189 // a texture bound to the stream texture, and permits |
| 190 // GetLevelStreamTextureImage to return the image. See |
| 191 // SetStreamTextureServiceId() for the details of how |service_id| is used. |
| 193 void SetLevelStreamTextureImage(GLenum target, | 192 void SetLevelStreamTextureImage(GLenum target, |
| 194 GLint level, | 193 GLint level, |
| 195 GLStreamTextureImage* image, | 194 GLStreamTextureImage* image, |
| 196 ImageState state); | 195 ImageState state, |
| 196 GLuint service_id); |
| 197 |
| 198 // Set the ImageState for the image bound to the given level. |
| 199 void SetLevelImageState(GLenum target, GLint level, ImageState state); |
| 200 |
| 197 | 201 |
| 198 // Get the image associated with a particular level. Returns NULL if level | 202 // Get the image associated with a particular level. Returns NULL if level |
| 199 // does not exist. | 203 // does not exist. |
| 200 gl::GLImage* GetLevelImage(GLint target, | 204 gl::GLImage* GetLevelImage(GLint target, |
| 201 GLint level, | 205 GLint level, |
| 202 ImageState* state) const; | 206 ImageState* state) const; |
| 203 gl::GLImage* GetLevelImage(GLint target, GLint level) const; | 207 gl::GLImage* GetLevelImage(GLint target, GLint level) const; |
| 204 | 208 |
| 205 // Like GetLevelImage, but will return NULL if the image wasn't set via | 209 // Like GetLevelImage, but will return NULL if the image wasn't set via |
| 206 // a call to SetLevelStreamTextureImage. | 210 // a call to SetLevelStreamTextureImage. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 std::vector<LevelInfo> level_infos; | 339 std::vector<LevelInfo> level_infos; |
| 336 }; | 340 }; |
| 337 | 341 |
| 338 // Helper for SetLevel*Image. |stream_texture_image| may be null. | 342 // Helper for SetLevel*Image. |stream_texture_image| may be null. |
| 339 void SetLevelImageInternal(GLenum target, | 343 void SetLevelImageInternal(GLenum target, |
| 340 GLint level, | 344 GLint level, |
| 341 gl::GLImage* image, | 345 gl::GLImage* image, |
| 342 GLStreamTextureImage* stream_texture_image, | 346 GLStreamTextureImage* stream_texture_image, |
| 343 ImageState state); | 347 ImageState state); |
| 344 | 348 |
| 345 // Helper for GetLevel*Image. Returns the LevelInfo for |target| and |level| | 349 // Returns the LevelInfo for |target| and |level| if it's set, else NULL. |
| 346 // if it's set, else NULL. | |
| 347 const LevelInfo* GetLevelInfo(GLint target, GLint level) const; | 350 const LevelInfo* GetLevelInfo(GLint target, GLint level) const; |
| 348 | 351 |
| 349 // Set the info for a particular level. | 352 // Set the info for a particular level. |
| 350 void SetLevelInfo(GLenum target, | 353 void SetLevelInfo(GLenum target, |
| 351 GLint level, | 354 GLint level, |
| 352 GLenum internal_format, | 355 GLenum internal_format, |
| 353 GLsizei width, | 356 GLsizei width, |
| 354 GLsizei height, | 357 GLsizei height, |
| 355 GLsizei depth, | 358 GLsizei depth, |
| 356 GLint border, | 359 GLint border, |
| 357 GLenum format, | 360 GLenum format, |
| 358 GLenum type, | 361 GLenum type, |
| 359 const gfx::Rect& cleared_rect); | 362 const gfx::Rect& cleared_rect); |
| 360 | 363 |
| 364 // Causes us to report |service_id| as our service id, but does not delete |
| 365 // it when we are destroyed. Will rebind any OES_EXTERNAL texture units to |
| 366 // our new service id in all contexts. If |service_id| is zero, then we |
| 367 // revert to |owned_service_id_|. |
| 368 void SetStreamTextureServiceId(GLuint service_id); |
| 369 |
| 361 void MarkLevelAsInternalWorkaround(GLenum target, GLint level); | 370 void MarkLevelAsInternalWorkaround(GLenum target, GLint level); |
| 362 | 371 |
| 363 // In GLES2 "texture complete" means it has all required mips for filtering | 372 // In GLES2 "texture complete" means it has all required mips for filtering |
| 364 // down to a 1x1 pixel texture, they are in the correct order, they are all | 373 // down to a 1x1 pixel texture, they are in the correct order, they are all |
| 365 // the same format. | 374 // the same format. |
| 366 bool texture_complete() const { | 375 bool texture_complete() const { |
| 367 return texture_complete_; | 376 return texture_complete_; |
| 368 } | 377 } |
| 369 | 378 |
| 370 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the | 379 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 514 |
| 506 void UpdateBaseLevel(GLint base_level); | 515 void UpdateBaseLevel(GLint base_level); |
| 507 void UpdateMaxLevel(GLint max_level); | 516 void UpdateMaxLevel(GLint max_level); |
| 508 void UpdateNumMipLevels(); | 517 void UpdateNumMipLevels(); |
| 509 | 518 |
| 510 // Increment the generation counter for all managers that have a reference to | 519 // Increment the generation counter for all managers that have a reference to |
| 511 // this texture. | 520 // this texture. |
| 512 void IncrementManagerServiceIdGeneration(); | 521 void IncrementManagerServiceIdGeneration(); |
| 513 | 522 |
| 514 // Return the service id of the texture that we will delete when we are | 523 // Return the service id of the texture that we will delete when we are |
| 515 // destroyed. Normally, this is the same as service_id(), unless it is | 524 // destroyed. |
| 516 // overridden by SetUnownedServiceId. | |
| 517 GLuint owned_service_id() const { return owned_service_id_; } | 525 GLuint owned_service_id() const { return owned_service_id_; } |
| 518 | 526 |
| 519 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); | 527 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); |
| 520 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); | 528 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); |
| 521 | 529 |
| 522 MailboxManager* mailbox_manager_; | 530 MailboxManager* mailbox_manager_; |
| 523 | 531 |
| 524 // Info about each face and level of texture. | 532 // Info about each face and level of texture. |
| 525 std::vector<FaceInfo> face_infos_; | 533 std::vector<FaceInfo> face_infos_; |
| 526 | 534 |
| 527 // The texture refs that point to this Texture. | 535 // The texture refs that point to this Texture. |
| 528 typedef std::set<TextureRef*> RefSet; | 536 typedef std::set<TextureRef*> RefSet; |
| 529 RefSet refs_; | 537 RefSet refs_; |
| 530 | 538 |
| 531 // The single TextureRef that accounts for memory for this texture. Must be | 539 // The single TextureRef that accounts for memory for this texture. Must be |
| 532 // one of refs_. | 540 // one of refs_. |
| 533 TextureRef* memory_tracking_ref_; | 541 TextureRef* memory_tracking_ref_; |
| 534 | 542 |
| 535 // The id of the texure | 543 // The id of the texture. |
| 536 GLuint service_id_; | 544 GLuint service_id_; |
| 537 | 545 |
| 538 // The id of the texture that we are responsible for deleting. Normally, | 546 // The id of the texture that we are responsible for deleting. Normally, this |
| 539 // this is the same as service_id_, unless a call to SetUnownedServiceId | 547 // is the same as |service_id_|, unless a GLStreamTextureImage with its own |
| 540 // overrides it. In that case, we'll use the overridden service id (stored | 548 // service id is bound. In that case the GLStreamTextureImage service id is |
| 541 // in |service_id_|) for all purposes except deleting the texture name. | 549 // stored in |service_id_| and overrides the owned service id for all purposes |
| 542 // Whoever calls SetUnownedServiceId is assumed to handle deleting that id, | 550 // except deleting the texture name. |
| 543 // and only after we are either deleted or told to stop using it via | |
| 544 // another call to SetUnownedServiceId. | |
| 545 GLuint owned_service_id_; | 551 GLuint owned_service_id_; |
| 546 | 552 |
| 547 // Whether all renderable mips of this texture have been cleared. | 553 // Whether all renderable mips of this texture have been cleared. |
| 548 bool cleared_; | 554 bool cleared_; |
| 549 | 555 |
| 550 int num_uncleared_mips_; | 556 int num_uncleared_mips_; |
| 551 int num_npot_faces_; | 557 int num_npot_faces_; |
| 552 | 558 |
| 553 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. | 559 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. |
| 554 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3). | 560 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3). |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 void SetLevelImage(TextureRef* ref, | 935 void SetLevelImage(TextureRef* ref, |
| 930 GLenum target, | 936 GLenum target, |
| 931 GLint level, | 937 GLint level, |
| 932 gl::GLImage* image, | 938 gl::GLImage* image, |
| 933 Texture::ImageState state); | 939 Texture::ImageState state); |
| 934 | 940 |
| 935 void SetLevelStreamTextureImage(TextureRef* ref, | 941 void SetLevelStreamTextureImage(TextureRef* ref, |
| 936 GLenum target, | 942 GLenum target, |
| 937 GLint level, | 943 GLint level, |
| 938 GLStreamTextureImage* image, | 944 GLStreamTextureImage* image, |
| 939 Texture::ImageState state); | 945 Texture::ImageState state, |
| 946 GLuint service_id); |
| 947 |
| 948 void SetLevelImageState(TextureRef* ref, |
| 949 GLenum target, |
| 950 GLint level, |
| 951 Texture::ImageState state); |
| 940 | 952 |
| 941 size_t GetSignatureSize() const; | 953 size_t GetSignatureSize() const; |
| 942 | 954 |
| 943 void AddToSignature( | 955 void AddToSignature( |
| 944 TextureRef* ref, | 956 TextureRef* ref, |
| 945 GLenum target, | 957 GLenum target, |
| 946 GLint level, | 958 GLint level, |
| 947 std::string* signature) const; | 959 std::string* signature) const; |
| 948 | 960 |
| 949 void AddObserver(DestructionObserver* observer) { | 961 void AddObserver(DestructionObserver* observer) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 private: | 1187 private: |
| 1176 DecoderTextureState* texture_state_; | 1188 DecoderTextureState* texture_state_; |
| 1177 base::TimeTicks begin_time_; | 1189 base::TimeTicks begin_time_; |
| 1178 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 1190 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 1179 }; | 1191 }; |
| 1180 | 1192 |
| 1181 } // namespace gles2 | 1193 } // namespace gles2 |
| 1182 } // namespace gpu | 1194 } // namespace gpu |
| 1183 | 1195 |
| 1184 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 1196 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |