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

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

Issue 2518413002: Add validation to the mailbox functions in the passthrough cmd decoder. (Closed)
Patch Set: Fix explicit. Created 4 years 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class TextureRef; 44 class TextureRef;
45 45
46 class GPU_EXPORT TextureBase { 46 class GPU_EXPORT TextureBase {
47 public: 47 public:
48 explicit TextureBase(GLuint service_id); 48 explicit TextureBase(GLuint service_id);
49 virtual ~TextureBase(); 49 virtual ~TextureBase();
50 50
51 // The service side OpenGL id of the texture. 51 // The service side OpenGL id of the texture.
52 GLuint service_id() const { return service_id_; } 52 GLuint service_id() const { return service_id_; }
53 53
54 // Returns the target this texure was first bound to or 0 if it has not
55 // been bound. Once a texture is bound to a specific target it can never be
56 // bound to a different target.
57 GLenum target() const { return target_; }
58
54 protected: 59 protected:
55 // The id of the texture. 60 // The id of the texture.
56 GLuint service_id_; 61 GLuint service_id_;
57 62
63 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
64 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3).
65 GLenum target_;
66
67 void SetTarget(GLenum target);
68
58 void DeleteFromMailboxManager(); 69 void DeleteFromMailboxManager();
59 70
60 private: 71 private:
61 friend class MailboxManagerSync; 72 friend class MailboxManagerSync;
62 friend class MailboxManagerImpl; 73 friend class MailboxManagerImpl;
63 74
64 void SetMailboxManager(MailboxManager* mailbox_manager); 75 void SetMailboxManager(MailboxManager* mailbox_manager);
65 76
66 MailboxManager* mailbox_manager_; 77 MailboxManager* mailbox_manager_;
67 }; 78 };
68 79
69 // A ref-counted version of the TextureBase class that deletes the texture after 80 // A ref-counted version of the TextureBase class that deletes the texture after
70 // all references have been released. 81 // all references have been released.
71 class TexturePassthrough final : public TextureBase, 82 class TexturePassthrough final : public TextureBase,
72 public base::RefCounted<TexturePassthrough> { 83 public base::RefCounted<TexturePassthrough> {
73 public: 84 public:
74 explicit TexturePassthrough(GLuint service_id); 85 TexturePassthrough(GLuint service_id, GLenum target);
75 86
76 // Notify the texture that the context is lost and it shouldn't delete the 87 // Notify the texture that the context is lost and it shouldn't delete the
77 // native GL texture in the destructor 88 // native GL texture in the destructor
78 void MarkContextLost(); 89 void MarkContextLost();
79 90
80 protected: 91 protected:
81 ~TexturePassthrough() override; 92 ~TexturePassthrough() override;
82 93
83 private: 94 private:
84 friend class base::RefCounted<TexturePassthrough>; 95 friend class base::RefCounted<TexturePassthrough>;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 199
189 bool CanRenderTo(const FeatureInfo* feature_info, GLint level) const; 200 bool CanRenderTo(const FeatureInfo* feature_info, GLint level) const;
190 201
191 void SetServiceId(GLuint service_id) { 202 void SetServiceId(GLuint service_id) {
192 DCHECK(service_id); 203 DCHECK(service_id);
193 DCHECK_EQ(owned_service_id_, service_id_); 204 DCHECK_EQ(owned_service_id_, service_id_);
194 service_id_ = service_id; 205 service_id_ = service_id;
195 owned_service_id_ = service_id; 206 owned_service_id_ = service_id;
196 } 207 }
197 208
198 // Returns the target this texure was first bound to or 0 if it has not
199 // been bound. Once a texture is bound to a specific target it can never be
200 // bound to a different target.
201 GLenum target() const {
202 return target_;
203 }
204
205 bool SafeToRenderFrom() const { 209 bool SafeToRenderFrom() const {
206 return cleared_; 210 return cleared_;
207 } 211 }
208 212
209 // Get the width/height/depth for a particular level. Returns false if level 213 // Get the width/height/depth for a particular level. Returns false if level
210 // does not exist. 214 // does not exist.
211 // |depth| is optional and can be nullptr. 215 // |depth| is optional and can be nullptr.
212 bool GetLevelSize( 216 bool GetLevelSize(
213 GLint target, GLint level, 217 GLint target, GLint level,
214 GLsizei* width, GLsizei* height, GLsizei* depth) const; 218 GLsizei* width, GLsizei* height, GLsizei* depth) const;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // stored in |service_id_| and overrides the owned service id for all purposes 590 // stored in |service_id_| and overrides the owned service id for all purposes
587 // except deleting the texture name. 591 // except deleting the texture name.
588 GLuint owned_service_id_; 592 GLuint owned_service_id_;
589 593
590 // Whether all renderable mips of this texture have been cleared. 594 // Whether all renderable mips of this texture have been cleared.
591 bool cleared_; 595 bool cleared_;
592 596
593 int num_uncleared_mips_; 597 int num_uncleared_mips_;
594 int num_npot_faces_; 598 int num_npot_faces_;
595 599
596 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
597 // Or GL_TEXTURE_2D_ARRAY or GL_TEXTURE_3D (for GLES3).
598 GLenum target_;
599
600 // Texture parameters. 600 // Texture parameters.
601 SamplerState sampler_state_; 601 SamplerState sampler_state_;
602 GLenum usage_; 602 GLenum usage_;
603 GLint base_level_; 603 GLint base_level_;
604 GLint max_level_; 604 GLint max_level_;
605 GLenum swizzle_r_; 605 GLenum swizzle_r_;
606 GLenum swizzle_g_; 606 GLenum swizzle_g_;
607 GLenum swizzle_b_; 607 GLenum swizzle_b_;
608 GLenum swizzle_a_; 608 GLenum swizzle_a_;
609 609
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 private: 1265 private:
1266 DecoderTextureState* texture_state_; 1266 DecoderTextureState* texture_state_;
1267 base::TimeTicks begin_time_; 1267 base::TimeTicks begin_time_;
1268 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); 1268 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer);
1269 }; 1269 };
1270 1270
1271 } // namespace gles2 1271 } // namespace gles2
1272 } // namespace gpu 1272 } // namespace gpu
1273 1273
1274 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 1274 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc ('k') | gpu/command_buffer/service/texture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698