Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: gpu/command_buffer/service/texture_manager.h

Issue 2315313003: Add a base class of Texture for interfacing with the mailbox manager. (Closed)
Patch Set: Address piman's comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 protected:
54 // The id of the texture.
55 GLuint service_id_;
56
57 void DeleteFromMailboxManager();
58
59 private:
60 friend class MailboxManagerSync;
61 friend class MailboxManagerImpl;
62
63 void SetMailboxManager(MailboxManager* mailbox_manager);
64
65 MailboxManager* mailbox_manager_;
66 };
67
44 // Info about Textures currently in the system. 68 // Info about Textures currently in the system.
45 // This class wraps a real GL texture, keeping track of its meta-data. It is 69 // This class wraps a real GL texture, keeping track of its meta-data. It is
46 // jointly owned by possibly multiple TextureRef. 70 // jointly owned by possibly multiple TextureRef.
47 class GPU_EXPORT Texture { 71 class GPU_EXPORT Texture final : public TextureBase {
48 public: 72 public:
49 enum ImageState { 73 enum ImageState {
50 // If an image is associated with the texture and image state is UNBOUND, 74 // 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 75 // then sampling out of the texture or using it as a target for drawing
52 // will not read/write from/to the image. 76 // will not read/write from/to the image.
53 UNBOUND, 77 UNBOUND,
54 // If image state is BOUND, then sampling from the texture will return the 78 // 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. 79 // contents of the image and using it as a target will modify the image.
56 BOUND, 80 BOUND,
57 // Image state is set to COPIED if the contents of the image has been 81 // Image state is set to COPIED if the contents of the image has been
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 GLenum swizzle_a() const { return swizzle_a_; } 158 GLenum swizzle_a() const { return swizzle_a_; }
135 159
136 int num_uncleared_mips() const { 160 int num_uncleared_mips() const {
137 return num_uncleared_mips_; 161 return num_uncleared_mips_;
138 } 162 }
139 163
140 uint32_t estimated_size() const { return estimated_size_; } 164 uint32_t estimated_size() const { return estimated_size_; }
141 165
142 bool CanRenderTo(const FeatureInfo* feature_info, GLint level) const; 166 bool CanRenderTo(const FeatureInfo* feature_info, GLint level) const;
143 167
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) { 168 void SetServiceId(GLuint service_id) {
150 DCHECK(service_id); 169 DCHECK(service_id);
151 DCHECK_EQ(owned_service_id_, service_id_); 170 DCHECK_EQ(owned_service_id_, service_id_);
152 service_id_ = service_id; 171 service_id_ = service_id;
153 owned_service_id_ = service_id; 172 owned_service_id_ = service_id;
154 } 173 }
155 174
156 // Returns the target this texure was first bound to or 0 if it has not 175 // 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 176 // been bound. Once a texture is bound to a specific target it can never be
158 // bound to a different target. 177 // bound to a different target.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 301
283 private: 302 private:
284 friend class MailboxManagerImpl; 303 friend class MailboxManagerImpl;
285 friend class MailboxManagerSync; 304 friend class MailboxManagerSync;
286 friend class MailboxManagerTest; 305 friend class MailboxManagerTest;
287 friend class TextureDefinition; 306 friend class TextureDefinition;
288 friend class TextureManager; 307 friend class TextureManager;
289 friend class TextureRef; 308 friend class TextureRef;
290 friend class TextureTestHelper; 309 friend class TextureTestHelper;
291 310
292 ~Texture(); 311 ~Texture() override;
293 void AddTextureRef(TextureRef* ref); 312 void AddTextureRef(TextureRef* ref);
294 void RemoveTextureRef(TextureRef* ref, bool have_context); 313 void RemoveTextureRef(TextureRef* ref, bool have_context);
295 MemoryTypeTracker* GetMemTracker(); 314 MemoryTypeTracker* GetMemTracker();
296 315
297 // Condition on which this texture is renderable. Can be ONLY_IF_NPOT if it 316 // 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 317 // 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 318 // 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 319 // 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. 320 // (e.g. complete POT), NEVER means it's not renderable regardless (e.g.
302 // incomplete). 321 // incomplete).
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 void SetTarget(GLenum target, GLint max_levels); 492 void SetTarget(GLenum target, GLint max_levels);
474 493
475 // Update info about this texture. 494 // Update info about this texture.
476 void Update(); 495 void Update();
477 496
478 // Appends a signature for the given level. 497 // Appends a signature for the given level.
479 void AddToSignature( 498 void AddToSignature(
480 const FeatureInfo* feature_info, 499 const FeatureInfo* feature_info,
481 GLenum target, GLint level, std::string* signature) const; 500 GLenum target, GLint level, std::string* signature) const;
482 501
483 void SetMailboxManager(MailboxManager* mailbox_manager);
484
485 // Updates the unsafe textures count in all the managers referencing this 502 // Updates the unsafe textures count in all the managers referencing this
486 // texture. 503 // texture.
487 void UpdateSafeToRenderFrom(bool cleared); 504 void UpdateSafeToRenderFrom(bool cleared);
488 505
489 // Updates the uncleared mip count in all the managers referencing this 506 // Updates the uncleared mip count in all the managers referencing this
490 // texture. 507 // texture.
491 void UpdateMipCleared(LevelInfo* info, 508 void UpdateMipCleared(LevelInfo* info,
492 GLsizei width, 509 GLsizei width,
493 GLsizei height, 510 GLsizei height,
494 const gfx::Rect& cleared_rect); 511 const gfx::Rect& cleared_rect);
(...skipping 25 matching lines...) Expand all
520 // this texture. 537 // this texture.
521 void IncrementManagerServiceIdGeneration(); 538 void IncrementManagerServiceIdGeneration();
522 539
523 // Return the service id of the texture that we will delete when we are 540 // Return the service id of the texture that we will delete when we are
524 // destroyed. 541 // destroyed.
525 GLuint owned_service_id() const { return owned_service_id_; } 542 GLuint owned_service_id() const { return owned_service_id_; }
526 543
527 GLenum GetCompatibilitySwizzleForChannel(GLenum channel); 544 GLenum GetCompatibilitySwizzleForChannel(GLenum channel);
528 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle); 545 void SetCompatibilitySwizzle(const CompatibilitySwizzle* swizzle);
529 546
530 MailboxManager* mailbox_manager_;
531
532 // Info about each face and level of texture. 547 // Info about each face and level of texture.
533 std::vector<FaceInfo> face_infos_; 548 std::vector<FaceInfo> face_infos_;
534 549
535 // The texture refs that point to this Texture. 550 // The texture refs that point to this Texture.
536 typedef std::set<TextureRef*> RefSet; 551 typedef std::set<TextureRef*> RefSet;
537 RefSet refs_; 552 RefSet refs_;
538 553
539 // The single TextureRef that accounts for memory for this texture. Must be 554 // The single TextureRef that accounts for memory for this texture. Must be
540 // one of refs_. 555 // one of refs_.
541 TextureRef* memory_tracking_ref_; 556 TextureRef* memory_tracking_ref_;
542 557
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 558 // 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 559 // 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 560 // 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 561 // stored in |service_id_| and overrides the owned service id for all purposes
550 // except deleting the texture name. 562 // except deleting the texture name.
551 GLuint owned_service_id_; 563 GLuint owned_service_id_;
552 564
553 // Whether all renderable mips of this texture have been cleared. 565 // Whether all renderable mips of this texture have been cleared.
554 bool cleared_; 566 bool cleared_;
555 567
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 private: 1206 private:
1195 DecoderTextureState* texture_state_; 1207 DecoderTextureState* texture_state_;
1196 base::TimeTicks begin_time_; 1208 base::TimeTicks begin_time_;
1197 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); 1209 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer);
1198 }; 1210 };
1199 1211
1200 } // namespace gles2 1212 } // namespace gles2
1201 } // namespace gpu 1213 } // namespace gpu
1202 1214
1203 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 1215 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_unittest.cc ('k') | gpu/command_buffer/service/texture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698