OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 // Whether or not this texture is a non-power-of-two texture. | 73 // Whether or not this texture is a non-power-of-two texture. |
74 bool npot() const { | 74 bool npot() const { |
75 return npot_; | 75 return npot_; |
76 } | 76 } |
77 | 77 |
78 // Returns true if mipmaps can be generated by GL. | 78 // Returns true if mipmaps can be generated by GL. |
79 bool CanGenerateMipmaps() const; | 79 bool CanGenerateMipmaps() const; |
80 | 80 |
81 // Makes each of the mip levels as though they were generated. | |
82 bool MarkMipmapsGenerated(); | |
83 | |
84 // Set the info for a particular level. | |
85 void SetLevelInfo( | |
86 GLenum target, | |
87 GLint level, | |
88 GLint internal_format, | |
89 GLsizei width, | |
90 GLsizei height, | |
91 GLsizei depth, | |
92 GLint border, | |
93 GLenum format, | |
94 GLenum type); | |
95 | |
96 // Get the width and height for a particular level. Returns false if level | 81 // Get the width and height for a particular level. Returns false if level |
97 // does not exist. | 82 // does not exist. |
98 bool GetLevelSize( | 83 bool GetLevelSize( |
99 GLint face, GLint level, GLsizei* width, GLsizei* height) const; | 84 GLint face, GLint level, GLsizei* width, GLsizei* height) const; |
100 | 85 |
101 // Sets a texture parameter. | |
102 // TODO(gman): Expand to SetParameteri,f,iv,fv | |
103 void SetParameter(GLenum pname, GLint param); | |
104 | |
105 bool IsDeleted() const { | 86 bool IsDeleted() const { |
106 return deleted_; | 87 return deleted_; |
107 } | 88 } |
108 | 89 |
109 private: | 90 private: |
110 friend class TextureManager; | 91 friend class TextureManager; |
111 friend class base::RefCounted<TextureInfo>; | 92 friend class base::RefCounted<TextureInfo>; |
112 | 93 |
113 ~TextureInfo() { } | 94 ~TextureInfo() { } |
114 | 95 |
(...skipping 12 matching lines...) Expand all Loading... |
127 bool valid; | 108 bool valid; |
128 GLint internal_format; | 109 GLint internal_format; |
129 GLsizei width; | 110 GLsizei width; |
130 GLsizei height; | 111 GLsizei height; |
131 GLsizei depth; | 112 GLsizei depth; |
132 GLint border; | 113 GLint border; |
133 GLenum format; | 114 GLenum format; |
134 GLenum type; | 115 GLenum type; |
135 }; | 116 }; |
136 | 117 |
| 118 // Set the info for a particular level. |
| 119 void SetLevelInfo( |
| 120 GLenum target, |
| 121 GLint level, |
| 122 GLint internal_format, |
| 123 GLsizei width, |
| 124 GLsizei height, |
| 125 GLsizei depth, |
| 126 GLint border, |
| 127 GLenum format, |
| 128 GLenum type); |
| 129 |
| 130 // Sets a texture parameter. |
| 131 // TODO(gman): Expand to SetParameteri,f,iv,fv |
| 132 void SetParameter(GLenum pname, GLint param); |
| 133 |
| 134 // Makes each of the mip levels as though they were generated. |
| 135 bool MarkMipmapsGenerated(); |
| 136 |
137 void MarkAsDeleted() { | 137 void MarkAsDeleted() { |
138 service_id_ = 0; | 138 service_id_ = 0; |
139 deleted_ = true; | 139 deleted_ = true; |
140 } | 140 } |
141 | 141 |
142 bool NeedsMips() const { | 142 bool NeedsMips() const { |
143 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; | 143 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; |
144 } | 144 } |
145 | 145 |
146 // Sets the TextureInfo's target | 146 // Sets the TextureInfo's target |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 // Sets the TextureInfo's target | 215 // Sets the TextureInfo's target |
216 // Parameters: | 216 // Parameters: |
217 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP | 217 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP |
218 // max_levels: The maximum levels this type of target can have. | 218 // max_levels: The maximum levels this type of target can have. |
219 void SetInfoTarget(TextureInfo* info, GLenum target) { | 219 void SetInfoTarget(TextureInfo* info, GLenum target) { |
220 DCHECK(info); | 220 DCHECK(info); |
221 info->SetTarget(target, MaxLevelsForTarget(target)); | 221 info->SetTarget(target, MaxLevelsForTarget(target)); |
222 } | 222 } |
223 | 223 |
| 224 // Set the info for a particular level in a TexureInfo. |
| 225 void SetLevelInfo( |
| 226 TextureInfo* info, |
| 227 GLenum target, |
| 228 GLint level, |
| 229 GLint internal_format, |
| 230 GLsizei width, |
| 231 GLsizei height, |
| 232 GLsizei depth, |
| 233 GLint border, |
| 234 GLenum format, |
| 235 GLenum type); |
| 236 |
| 237 // Sets a texture parameter of a TextureInfo |
| 238 // TODO(gman): Expand to SetParameteri,f,iv,fv |
| 239 void SetParameter(TextureInfo* info, GLenum pname, GLint param); |
| 240 |
| 241 // Makes each of the mip levels as though they were generated. |
| 242 bool MarkMipmapsGenerated(TextureInfo* info); |
| 243 |
224 // Creates a new texture info. | 244 // Creates a new texture info. |
225 TextureInfo* CreateTextureInfo(GLuint client_id, GLuint service_id); | 245 TextureInfo* CreateTextureInfo(GLuint client_id, GLuint service_id); |
226 | 246 |
227 // Gets the texture info for the given texture. | 247 // Gets the texture info for the given texture. |
228 TextureInfo* GetTextureInfo(GLuint client_id); | 248 TextureInfo* GetTextureInfo(GLuint client_id); |
229 | 249 |
230 // Removes a texture info. | 250 // Removes a texture info. |
231 void RemoveTextureInfo(GLuint client_id); | 251 void RemoveTextureInfo(GLuint client_id); |
232 | 252 |
233 // Gets a client id for a given service id. | 253 // Gets a client id for a given service id. |
234 bool GetClientId(GLuint service_id, GLuint* client_id) const; | 254 bool GetClientId(GLuint service_id, GLuint* client_id) const; |
235 | 255 |
236 TextureInfo* GetDefaultTextureInfo(GLenum target) { | 256 TextureInfo* GetDefaultTextureInfo(GLenum target) { |
237 return target == GL_TEXTURE_2D ? default_texture_2d_ : | 257 return target == GL_TEXTURE_2D ? default_texture_2d_ : |
238 default_texture_cube_map_; | 258 default_texture_cube_map_; |
239 } | 259 } |
240 | 260 |
| 261 bool HaveUnrenderableTextures() const { |
| 262 return num_unrenderable_textures_ > 0; |
| 263 } |
| 264 |
241 private: | 265 private: |
242 // Info for each texture in the system. | 266 // Info for each texture in the system. |
243 // TODO(gman): Choose a faster container. | 267 // TODO(gman): Choose a faster container. |
244 typedef std::map<GLuint, TextureInfo::Ref> TextureInfoMap; | 268 typedef std::map<GLuint, TextureInfo::Ref> TextureInfoMap; |
245 TextureInfoMap texture_infos_; | 269 TextureInfoMap texture_infos_; |
246 | 270 |
247 GLsizei max_texture_size_; | 271 GLsizei max_texture_size_; |
248 GLsizei max_cube_map_texture_size_; | 272 GLsizei max_cube_map_texture_size_; |
249 GLint max_levels_; | 273 GLint max_levels_; |
250 GLint max_cube_map_levels_; | 274 GLint max_cube_map_levels_; |
251 | 275 |
| 276 int num_unrenderable_textures_; |
| 277 |
252 // The default textures for each target (texture name = 0) | 278 // The default textures for each target (texture name = 0) |
253 TextureInfo::Ref default_texture_2d_; | 279 TextureInfo::Ref default_texture_2d_; |
254 TextureInfo::Ref default_texture_cube_map_; | 280 TextureInfo::Ref default_texture_cube_map_; |
255 | 281 |
256 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 282 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
257 }; | 283 }; |
258 | 284 |
259 } // namespace gles2 | 285 } // namespace gles2 |
260 } // namespace gpu | 286 } // namespace gpu |
261 | 287 |
262 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 288 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
263 | 289 |
OLD | NEW |