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

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

Issue 2014313002: StreamTextureImages can now override a Texture's service id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Partially implemented tying unowned id to StreamTextureImage Created 4 years, 6 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(), |service_id_| will be
180 // reset to |owned_service_id_|.
185 void SetLevelImage(GLenum target, 181 void SetLevelImage(GLenum target,
186 GLint level, 182 GLint level,
187 gl::GLImage* image, 183 gl::GLImage* image,
188 ImageState state); 184 ImageState state);
189 185
190 // Set the GLStreamTextureImage for a particular level. This is identical 186 // Set the GLStreamTextureImage for a particular level. This is like
191 // to SetLevelImage, but it also permits GetLevelStreamTextureImage to return 187 // SetLevelImage, but it also makes it optional to override |service_id_| with
192 // the image. 188 // a texture bound to the stream texture, and permits
189 // GetLevelStreamTextureImage to return the image. If |service_id| is zero,
190 // |service_id_| will be unchanged.
193 void SetLevelStreamTextureImage(GLenum target, 191 void SetLevelStreamTextureImage(GLenum target,
194 GLint level, 192 GLint level,
195 GLStreamTextureImage* image, 193 GLStreamTextureImage* image,
196 ImageState state); 194 ImageState state,
195 GLuint service_id);
197 196
198 // Get the image associated with a particular level. Returns NULL if level 197 // Get the image associated with a particular level. Returns NULL if level
199 // does not exist. 198 // does not exist.
200 gl::GLImage* GetLevelImage(GLint target, 199 gl::GLImage* GetLevelImage(GLint target,
201 GLint level, 200 GLint level,
202 ImageState* state) const; 201 ImageState* state) const;
203 gl::GLImage* GetLevelImage(GLint target, GLint level) const; 202 gl::GLImage* GetLevelImage(GLint target, GLint level) const;
204 203
205 // Like GetLevelImage, but will return NULL if the image wasn't set via 204 // Like GetLevelImage, but will return NULL if the image wasn't set via
206 // a call to SetLevelStreamTextureImage. 205 // a call to SetLevelStreamTextureImage.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 GLint level, 350 GLint level,
352 GLenum internal_format, 351 GLenum internal_format,
353 GLsizei width, 352 GLsizei width,
354 GLsizei height, 353 GLsizei height,
355 GLsizei depth, 354 GLsizei depth,
356 GLint border, 355 GLint border,
357 GLenum format, 356 GLenum format,
358 GLenum type, 357 GLenum type,
359 const gfx::Rect& cleared_rect); 358 const gfx::Rect& cleared_rect);
360 359
360 // Causes us to report |service_id| as our service id, but does not delete
361 // it when we are destroyed. Will rebind any OES_EXTERNAL texture units to
362 // our new service id in all contexts. If |service_id| is zero, then we
363 // revert to |owned_service_id_|.
364 void SetStreamTextureServiceId(GLuint service_id);
365
361 void MarkLevelAsInternalWorkaround(GLenum target, GLint level); 366 void MarkLevelAsInternalWorkaround(GLenum target, GLint level);
362 367
363 // In GLES2 "texture complete" means it has all required mips for filtering 368 // 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 369 // down to a 1x1 pixel texture, they are in the correct order, they are all
365 // the same format. 370 // the same format.
366 bool texture_complete() const { 371 bool texture_complete() const {
367 return texture_complete_; 372 return texture_complete_;
368 } 373 }
369 374
370 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the 375 // In GLES2 "cube complete" means all 6 faces level 0 are defined, all the
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 void UpdateBaseLevel(GLint base_level); 511 void UpdateBaseLevel(GLint base_level);
507 void UpdateMaxLevel(GLint max_level); 512 void UpdateMaxLevel(GLint max_level);
508 void UpdateNumMipLevels(); 513 void UpdateNumMipLevels();
509 514
510 // Increment the generation counter for all managers that have a reference to 515 // Increment the generation counter for all managers that have a reference to
511 // this texture. 516 // this texture.
512 void IncrementManagerServiceIdGeneration(); 517 void IncrementManagerServiceIdGeneration();
513 518
514 // Return the service id of the texture that we will delete when we are 519 // 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 520 // destroyed. Normally, this is the same as service_id(), unless it is
516 // overridden by SetUnownedServiceId. 521 // overridden by SetStreamTextureServiceId().
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 id is stored in
541 // in |service_id_|) for all purposes except deleting the texture name. 546 // |service_id_| and overrides the owned service id for all purposes except
542 // Whoever calls SetUnownedServiceId is assumed to handle deleting that id, 547 // 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
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698