Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 class GLES2Decoder; | 32 class GLES2Decoder; |
| 33 class GLStreamTextureImage; | 33 class GLStreamTextureImage; |
| 34 struct ContextState; | 34 struct ContextState; |
| 35 struct DecoderFramebufferState; | 35 struct DecoderFramebufferState; |
| 36 class Display; | 36 class Display; |
| 37 class ErrorState; | 37 class ErrorState; |
| 38 class FeatureInfo; | 38 class FeatureInfo; |
| 39 class FramebufferManager; | 39 class FramebufferManager; |
| 40 class MailboxManager; | 40 class MailboxManager; |
| 41 class Texture; | |
| 41 class TextureManager; | 42 class TextureManager; |
| 42 class TextureRef; | 43 class TextureRef; |
| 43 | 44 |
| 45 class GPU_EXPORT TextureBase { | |
| 46 public: | |
| 47 explicit TextureBase(GLuint service_id); | |
| 48 virtual ~TextureBase(); | |
| 49 | |
| 50 // The service side OpenGL id of the texture. | |
| 51 GLuint service_id() const { return service_id_; } | |
| 52 | |
| 53 // Down-cast to other texture classes | |
| 54 virtual Texture* AsTexture(); | |
|
piman
2016/09/07 17:38:31
Will we ever use more than one derived type in a g
Geoff Lang
2016/09/07 18:14:49
No, each mailbox manager will only ever use one ki
| |
| 55 | |
| 56 protected: | |
| 57 // The id of the texture. | |
| 58 GLuint service_id_; | |
| 59 | |
| 60 void DeleteFromMailboxManager(); | |
| 61 | |
| 62 private: | |
| 63 friend class MailboxManagerSync; | |
| 64 friend class MailboxManagerImpl; | |
| 65 | |
| 66 void SetMailboxManager(MailboxManager* mailbox_manager); | |
| 67 | |
| 68 MailboxManager* mailbox_manager_; | |
| 69 }; | |
| 70 | |
| 44 // Info about Textures currently in the system. | 71 // Info about Textures currently in the system. |
| 45 // This class wraps a real GL texture, keeping track of its meta-data. It is | 72 // This class wraps a real GL texture, keeping track of its meta-data. It is |
| 46 // jointly owned by possibly multiple TextureRef. | 73 // jointly owned by possibly multiple TextureRef. |
| 47 class GPU_EXPORT Texture { | 74 class GPU_EXPORT Texture final : public TextureBase { |
| 48 public: | 75 public: |
| 49 enum ImageState { | 76 enum ImageState { |
| 50 // If an image is associated with the texture and image state is UNBOUND, | 77 // If an image is associated with the texture and image state is UNBOUND, |
| 51 // then sampling out of the texture or using it as a target for drawing | 78 // then sampling out of the texture or using it as a target for drawing |
| 52 // will not read/write from/to the image. | 79 // will not read/write from/to the image. |
| 53 UNBOUND, | 80 UNBOUND, |
| 54 // If image state is BOUND, then sampling from the texture will return the | 81 // If image state is BOUND, then sampling from the texture will return the |
| 55 // contents of the image and using it as a target will modify the image. | 82 // contents of the image and using it as a target will modify the image. |
| 56 BOUND, | 83 BOUND, |
| 57 // Image state is set to COPIED if the contents of the image has been | 84 // Image state is set to COPIED if the contents of the image has been |
| 58 // copied to the texture. Sampling from the texture will be equivalent | 85 // copied to the texture. Sampling from the texture will be equivalent |
| 59 // to sampling out the image (assuming image has not been changed since | 86 // to sampling out the image (assuming image has not been changed since |
| 60 // it was copied). Using the texture as a target for drawing will only | 87 // it was copied). Using the texture as a target for drawing will only |
| 61 // modify the texture and not the image. | 88 // modify the texture and not the image. |
| 62 COPIED | 89 COPIED |
| 63 }; | 90 }; |
| 64 | 91 |
| 65 struct CompatibilitySwizzle { | 92 struct CompatibilitySwizzle { |
| 66 GLenum format; | 93 GLenum format; |
| 67 GLenum dest_format; | 94 GLenum dest_format; |
| 68 GLenum red; | 95 GLenum red; |
| 69 GLenum green; | 96 GLenum green; |
| 70 GLenum blue; | 97 GLenum blue; |
| 71 GLenum alpha; | 98 GLenum alpha; |
| 72 }; | 99 }; |
| 73 | 100 |
| 74 explicit Texture(GLuint service_id); | 101 explicit Texture(GLuint service_id); |
| 75 | 102 |
| 103 Texture* AsTexture() final; | |
| 104 | |
| 76 const SamplerState& sampler_state() const { | 105 const SamplerState& sampler_state() const { |
| 77 return sampler_state_; | 106 return sampler_state_; |
| 78 } | 107 } |
| 79 | 108 |
| 80 GLenum min_filter() const { | 109 GLenum min_filter() const { |
| 81 return sampler_state_.min_filter; | 110 return sampler_state_.min_filter; |
| 82 } | 111 } |
| 83 | 112 |
| 84 GLenum mag_filter() const { | 113 GLenum mag_filter() const { |
| 85 return sampler_state_.mag_filter; | 114 return sampler_state_.mag_filter; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 GLenum swizzle_a() const { return swizzle_a_; } | 163 GLenum swizzle_a() const { return swizzle_a_; } |
| 135 | 164 |
| 136 int num_uncleared_mips() const { | 165 int num_uncleared_mips() const { |
| 137 return num_uncleared_mips_; | 166 return num_uncleared_mips_; |
| 138 } | 167 } |
| 139 | 168 |
| 140 uint32_t estimated_size() const { return estimated_size_; } | 169 uint32_t estimated_size() const { return estimated_size_; } |
| 141 | 170 |
| 142 bool CanRenderTo(const FeatureInfo* feature_info, GLint level) const; | 171 bool CanRenderTo(const FeatureInfo* feature_info, GLint level) const; |
| 143 | 172 |
| 144 // The service side OpenGL id of the texture. | |
| 145 GLuint service_id() const { | |
| 146 return service_id_; | |
| 147 } | |
| 148 | |
| 149 void SetServiceId(GLuint service_id) { | 173 void SetServiceId(GLuint service_id) { |
| 150 DCHECK(service_id); | 174 DCHECK(service_id); |
| 151 DCHECK_EQ(owned_service_id_, service_id_); | 175 DCHECK_EQ(owned_service_id_, service_id_); |
| 152 service_id_ = service_id; | 176 service_id_ = service_id; |
| 153 owned_service_id_ = service_id; | 177 owned_service_id_ = service_id; |
| 154 } | 178 } |
| 155 | 179 |
| 156 // Returns the target this texure was first bound to or 0 if it has not | 180 // Returns the target this texure was first bound to or 0 if it has not |
| 157 // been bound. Once a texture is bound to a specific target it can never be | 181 // been bound. Once a texture is bound to a specific target it can never be |
| 158 // bound to a different target. | 182 // bound to a different target. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 | 306 |
| 283 private: | 307 private: |
| 284 friend class MailboxManagerImpl; | 308 friend class MailboxManagerImpl; |
| 285 friend class MailboxManagerSync; | 309 friend class MailboxManagerSync; |
| 286 friend class MailboxManagerTest; | 310 friend class MailboxManagerTest; |
| 287 friend class TextureDefinition; | 311 friend class TextureDefinition; |
| 288 friend class TextureManager; | 312 friend class TextureManager; |
| 289 friend class TextureRef; | 313 friend class TextureRef; |
| 290 friend class TextureTestHelper; | 314 friend class TextureTestHelper; |
| 291 | 315 |
| 292 ~Texture(); | 316 ~Texture() override; |
| 293 void AddTextureRef(TextureRef* ref); | 317 void AddTextureRef(TextureRef* ref); |
| 294 void RemoveTextureRef(TextureRef* ref, bool have_context); | 318 void RemoveTextureRef(TextureRef* ref, bool have_context); |
| 295 MemoryTypeTracker* GetMemTracker(); | 319 MemoryTypeTracker* GetMemTracker(); |
| 296 | 320 |
| 297 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it | 321 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it |
| 298 // depends on context support for non-power-of-two textures (i.e. will be | 322 // depends on context support for non-power-of-two textures (i.e. will be |
| 299 // renderable if NPOT support is in the context, otherwise not, e.g. texture | 323 // renderable if NPOT support is in the context, otherwise not, e.g. texture |
| 300 // with a NPOT level). ALWAYS means it doesn't depend on context features | 324 // with a NPOT level). ALWAYS means it doesn't depend on context features |
| 301 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g. | 325 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g. |
| 302 // incomplete). | 326 // incomplete). |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 void SetTarget(GLenum target, GLint max_levels); | 497 void SetTarget(GLenum target, GLint max_levels); |
| 474 | 498 |
| 475 // Update info about this texture. | 499 // Update info about this texture. |
| 476 void Update(); | 500 void Update(); |
| 477 | 501 |
| 478 // Appends a signature for the given level. | 502 // Appends a signature for the given level. |
| 479 void AddToSignature( | 503 void AddToSignature( |
| 480 const FeatureInfo* feature_info, | 504 const FeatureInfo* feature_info, |
| 481 GLenum target, GLint level, std::string* signature) const; | 505 GLenum target, GLint level, std::string* signature) const; |
| 482 | 506 |
| 483 void SetMailboxManager(MailboxManager* mailbox_manager); | |
| 484 | |
| 485 // Updates the unsafe textures count in all the managers referencing this | 507 // Updates the unsafe textures count in all the managers referencing this |
| 486 // texture. | 508 // texture. |
| 487 void UpdateSafeToRenderFrom(bool cleared); | 509 void UpdateSafeToRenderFrom(bool cleared); |
| 488 | 510 |
| 489 // Updates the uncleared mip count in all the managers referencing this | 511 // Updates the uncleared mip count in all the managers referencing this |
| 490 // texture. | 512 // texture. |
| 491 void UpdateMipCleared(LevelInfo* info, | 513 void UpdateMipCleared(LevelInfo* info, |
| 492 GLsizei width, | 514 GLsizei width, |
| 493 GLsizei height, | 515 GLsizei height, |
| 494 const gfx::Rect& cleared_rect); | 516 const gfx::Rect& cleared_rect); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 520 // this texture. | 542 // this texture. |
| 521 void IncrementManagerServiceIdGeneration(); | 543 void IncrementManagerServiceIdGeneration(); |
| 522 | 544 |
| 523 // Return the service id of the texture that we will delete when we are | 545 // Return the service id of the texture that we will delete when we are |
| 524 // destroyed. | 546 // destroyed. |
| 525 GLuint owned_service_id() const { return owned_service_id_; } | 547 GLuint owned_service_id() const { return owned_service_id_; } |
| 526 | 548 |
| 527 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); | 549 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); |
| 528 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); | 550 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); |
| 529 | 551 |
| 530 MailboxManager* mailbox_manager_; | |
| 531 | |
| 532 // Info about each face and level of texture. | 552 // Info about each face and level of texture. |
| 533 std::vector<FaceInfo> face_infos_; | 553 std::vector<FaceInfo> face_infos_; |
| 534 | 554 |
| 535 // The texture refs that point to this Texture. | 555 // The texture refs that point to this Texture. |
| 536 typedef std::set<TextureRef*> RefSet; | 556 typedef std::set<TextureRef*> RefSet; |
| 537 RefSet refs_; | 557 RefSet refs_; |
| 538 | 558 |
| 539 // The single TextureRef that accounts for memory for this texture. Must be | 559 // The single TextureRef that accounts for memory for this texture. Must be |
| 540 // one of refs_. | 560 // one of refs_. |
| 541 TextureRef* memory_tracking_ref_; | 561 TextureRef* memory_tracking_ref_; |
| 542 | 562 |
| 543 // The id of the texture. | |
| 544 GLuint service_id_; | |
| 545 | |
| 546 // The id of the texture that we are responsible for deleting. Normally, this | 563 // The id of the texture that we are responsible for deleting. Normally, this |
| 547 // is the same as |service_id_|, unless a GLStreamTextureImage with its own | 564 // is the same as |service_id_|, unless a GLStreamTextureImage with its own |
| 548 // service id is bound. In that case the GLStreamTextureImage service id is | 565 // service id is bound. In that case the GLStreamTextureImage service id is |
| 549 // stored in |service_id_| and overrides the owned service id for all purposes | 566 // stored in |service_id_| and overrides the owned service id for all purposes |
| 550 // except deleting the texture name. | 567 // except deleting the texture name. |
| 551 GLuint owned_service_id_; | 568 GLuint owned_service_id_; |
| 552 | 569 |
| 553 // Whether all renderable mips of this texture have been cleared. | 570 // Whether all renderable mips of this texture have been cleared. |
| 554 bool cleared_; | 571 bool cleared_; |
| 555 | 572 |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 private: | 1211 private: |
| 1195 DecoderTextureState* texture_state_; | 1212 DecoderTextureState* texture_state_; |
| 1196 base::TimeTicks begin_time_; | 1213 base::TimeTicks begin_time_; |
| 1197 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 1214 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
| 1198 }; | 1215 }; |
| 1199 | 1216 |
| 1200 } // namespace gles2 | 1217 } // namespace gles2 |
| 1201 } // namespace gpu | 1218 } // namespace gpu |
| 1202 | 1219 |
| 1203 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 1220 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| OLD | NEW |