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 |image| is not the same as the |
| 179 // currently bound image, and the currently bound image is a |
| 180 // GLStreamTextureImage, then |service_id_| will be reset back to |
| 181 // |owned_service_id_|. |
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 | 197 |
198 // Get the image associated with a particular level. Returns NULL if level | 198 // Get the image associated with a particular level. Returns NULL if level |
199 // does not exist. | 199 // does not exist. |
200 gl::GLImage* GetLevelImage(GLint target, | 200 gl::GLImage* GetLevelImage(GLint target, |
201 GLint level, | 201 GLint level, |
202 ImageState* state) const; | 202 ImageState* state) const; |
203 gl::GLImage* GetLevelImage(GLint target, GLint level) const; | 203 gl::GLImage* GetLevelImage(GLint target, GLint level) const; |
204 | 204 |
205 // Like GetLevelImage, but will return NULL if the image wasn't set via | 205 // Like GetLevelImage, but will return NULL if the image wasn't set via |
206 // a call to SetLevelStreamTextureImage. | 206 // a call to SetLevelStreamTextureImage. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 GLint level, | 351 GLint level, |
352 GLenum internal_format, | 352 GLenum internal_format, |
353 GLsizei width, | 353 GLsizei width, |
354 GLsizei height, | 354 GLsizei height, |
355 GLsizei depth, | 355 GLsizei depth, |
356 GLint border, | 356 GLint border, |
357 GLenum format, | 357 GLenum format, |
358 GLenum type, | 358 GLenum type, |
359 const gfx::Rect& cleared_rect); | 359 const gfx::Rect& cleared_rect); |
360 | 360 |
| 361 // Causes us to report |service_id| as our service id, but does not delete |
| 362 // it when we are destroyed. Will rebind any OES_EXTERNAL texture units to |
| 363 // our new service id in all contexts. If |service_id| is zero, then we |
| 364 // revert to |owned_service_id_|. |
| 365 void SetStreamTextureServiceId(GLuint service_id); |
| 366 |
361 void MarkLevelAsInternalWorkaround(GLenum target, GLint level); | 367 void MarkLevelAsInternalWorkaround(GLenum target, GLint level); |
362 | 368 |
363 // In GLES2 "texture complete" means it has all required mips for filtering | 369 // 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 | 370 // down to a 1x1 pixel texture, they are in the correct order, they are all |
365 // the same format. | 371 // the same format. |
366 bool texture_complete() const { | 372 bool texture_complete() const { |
367 return texture_complete_; | 373 return texture_complete_; |
368 } | 374 } |
369 | 375 |
370 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the | 376 // 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 | 511 |
506 void UpdateBaseLevel(GLint base_level); | 512 void UpdateBaseLevel(GLint base_level); |
507 void UpdateMaxLevel(GLint max_level); | 513 void UpdateMaxLevel(GLint max_level); |
508 void UpdateNumMipLevels(); | 514 void UpdateNumMipLevels(); |
509 | 515 |
510 // Increment the generation counter for all managers that have a reference to | 516 // Increment the generation counter for all managers that have a reference to |
511 // this texture. | 517 // this texture. |
512 void IncrementManagerServiceIdGeneration(); | 518 void IncrementManagerServiceIdGeneration(); |
513 | 519 |
514 // Return the service id of the texture that we will delete when we are | 520 // 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 | 521 // destroyed. |
516 // overridden by SetUnownedServiceId. | |
517 GLuint owned_service_id() const { return owned_service_id_; } | 522 GLuint owned_service_id() const { return owned_service_id_; } |
518 | 523 |
519 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); | 524 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); |
520 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); | 525 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); |
521 | 526 |
522 MailboxManager* mailbox_manager_; | 527 MailboxManager* mailbox_manager_; |
523 | 528 |
524 // Info about each face and level of texture. | 529 // Info about each face and level of texture. |
525 std::vector<FaceInfo> face_infos_; | 530 std::vector<FaceInfo> face_infos_; |
526 | 531 |
527 // The texture refs that point to this Texture. | 532 // The texture refs that point to this Texture. |
528 typedef std::set<TextureRef*> RefSet; | 533 typedef std::set<TextureRef*> RefSet; |
529 RefSet refs_; | 534 RefSet refs_; |
530 | 535 |
531 // The single TextureRef that accounts for memory for this texture. Must be | 536 // The single TextureRef that accounts for memory for this texture. Must be |
532 // one of refs_. | 537 // one of refs_. |
533 TextureRef* memory_tracking_ref_; | 538 TextureRef* memory_tracking_ref_; |
534 | 539 |
535 // The id of the texure | 540 // The id of the texture. |
536 GLuint service_id_; | 541 GLuint service_id_; |
537 | 542 |
538 // The id of the texture that we are responsible for deleting. Normally, | 543 // 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 | 544 // 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 | 545 // service id is bound. In that case the GLStreamTextureImage service id is |
541 // in |service_id_|) for all purposes except deleting the texture name. | 546 // stored in |service_id_| and overrides the owned service id for all purposes |
542 // Whoever calls SetUnownedServiceId is assumed to handle deleting that id, | 547 // 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_; | 548 GLuint owned_service_id_; |
546 | 549 |
547 // Whether all renderable mips of this texture have been cleared. | 550 // Whether all renderable mips of this texture have been cleared. |
548 bool cleared_; | 551 bool cleared_; |
549 | 552 |
550 int num_uncleared_mips_; | 553 int num_uncleared_mips_; |
551 int num_npot_faces_; | 554 int num_npot_faces_; |
552 | 555 |
553 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. | 556 // 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). | 557 // 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, | 932 void SetLevelImage(TextureRef* ref, |
930 GLenum target, | 933 GLenum target, |
931 GLint level, | 934 GLint level, |
932 gl::GLImage* image, | 935 gl::GLImage* image, |
933 Texture::ImageState state); | 936 Texture::ImageState state); |
934 | 937 |
935 void SetLevelStreamTextureImage(TextureRef* ref, | 938 void SetLevelStreamTextureImage(TextureRef* ref, |
936 GLenum target, | 939 GLenum target, |
937 GLint level, | 940 GLint level, |
938 GLStreamTextureImage* image, | 941 GLStreamTextureImage* image, |
939 Texture::ImageState state); | 942 Texture::ImageState state, |
| 943 GLuint service_id); |
940 | 944 |
941 size_t GetSignatureSize() const; | 945 size_t GetSignatureSize() const; |
942 | 946 |
943 void AddToSignature( | 947 void AddToSignature( |
944 TextureRef* ref, | 948 TextureRef* ref, |
945 GLenum target, | 949 GLenum target, |
946 GLint level, | 950 GLint level, |
947 std::string* signature) const; | 951 std::string* signature) const; |
948 | 952 |
949 void AddObserver(DestructionObserver* observer) { | 953 void AddObserver(DestructionObserver* observer) { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 private: | 1179 private: |
1176 DecoderTextureState* texture_state_; | 1180 DecoderTextureState* texture_state_; |
1177 base::TimeTicks begin_time_; | 1181 base::TimeTicks begin_time_; |
1178 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 1182 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
1179 }; | 1183 }; |
1180 | 1184 |
1181 } // namespace gles2 | 1185 } // namespace gles2 |
1182 } // namespace gpu | 1186 } // namespace gpu |
1183 | 1187 |
1184 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 1188 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |