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" |
| 11 #include "base/logging.h" |
11 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
12 #include "gpu/command_buffer/service/gl_utils.h" | 13 #include "gpu/command_buffer/service/gl_utils.h" |
13 | 14 |
14 namespace gpu { | 15 namespace gpu { |
15 namespace gles2 { | 16 namespace gles2 { |
16 | 17 |
17 class FeatureInfo; | 18 class FeatureInfo; |
18 | 19 |
19 // This class keeps track of the textures and their sizes so we can do NPOT and | 20 // This class keeps track of the textures and their sizes so we can do NPOT and |
20 // texture complete checking. | 21 // texture complete checking. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 160 } |
160 | 161 |
161 bool NeedsMips() const { | 162 bool NeedsMips() const { |
162 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; | 163 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; |
163 } | 164 } |
164 | 165 |
165 // Sets the TextureInfo's target | 166 // Sets the TextureInfo's target |
166 // Parameters: | 167 // Parameters: |
167 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP | 168 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP |
168 // max_levels: The maximum levels this type of target can have. | 169 // max_levels: The maximum levels this type of target can have. |
169 void SetTarget(GLenum target, GLint max_levels); | 170 void SetTarget(GLenum target, GLint max_levels) { |
| 171 DCHECK_EQ(0u, target_); // you can only set this once. |
| 172 target_ = target; |
| 173 size_t num_faces = (target == GL_TEXTURE_2D) ? 1 : 6; |
| 174 level_infos_.resize(num_faces); |
| 175 for (size_t ii = 0; ii < num_faces; ++ii) { |
| 176 level_infos_[ii].resize(max_levels); |
| 177 } |
| 178 } |
170 | 179 |
171 // Update info about this texture. | 180 // Update info about this texture. |
172 void Update(const FeatureInfo* feature_info); | 181 void Update(const FeatureInfo* feature_info); |
173 | 182 |
174 // Info about each face and level of texture. | 183 // Info about each face and level of texture. |
175 std::vector<std::vector<LevelInfo> > level_infos_; | 184 std::vector<std::vector<LevelInfo> > level_infos_; |
176 | 185 |
177 // The id of the texure | 186 // The id of the texure |
178 GLuint service_id_; | 187 GLuint service_id_; |
179 | 188 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // Checks if a dimensions are valid for a given target. | 237 // Checks if a dimensions are valid for a given target. |
229 bool ValidForTarget( | 238 bool ValidForTarget( |
230 const FeatureInfo* feature_info, | 239 const FeatureInfo* feature_info, |
231 GLenum target, GLint level, | 240 GLenum target, GLint level, |
232 GLsizei width, GLsizei height, GLsizei depth); | 241 GLsizei width, GLsizei height, GLsizei depth); |
233 | 242 |
234 // Sets the TextureInfo's target | 243 // Sets the TextureInfo's target |
235 // Parameters: | 244 // Parameters: |
236 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP | 245 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP |
237 // max_levels: The maximum levels this type of target can have. | 246 // max_levels: The maximum levels this type of target can have. |
238 void SetInfoTarget(TextureInfo* info, GLenum target); | 247 void SetInfoTarget(TextureInfo* info, GLenum target) { |
| 248 DCHECK(info); |
| 249 info->SetTarget(target, MaxLevelsForTarget(target)); |
| 250 } |
239 | 251 |
240 // Set the info for a particular level in a TexureInfo. | 252 // Set the info for a particular level in a TexureInfo. |
241 void SetLevelInfo( | 253 void SetLevelInfo( |
242 const FeatureInfo* feature_info, | 254 const FeatureInfo* feature_info, |
243 TextureInfo* info, | 255 TextureInfo* info, |
244 GLenum target, | 256 GLenum target, |
245 GLint level, | 257 GLint level, |
246 GLenum internal_format, | 258 GLenum internal_format, |
247 GLsizei width, | 259 GLsizei width, |
248 GLsizei height, | 260 GLsizei height, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 TextureInfo::Ref default_texture_2d_; | 325 TextureInfo::Ref default_texture_2d_; |
314 TextureInfo::Ref default_texture_cube_map_; | 326 TextureInfo::Ref default_texture_cube_map_; |
315 | 327 |
316 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 328 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
317 }; | 329 }; |
318 | 330 |
319 } // namespace gles2 | 331 } // namespace gles2 |
320 } // namespace gpu | 332 } // namespace gpu |
321 | 333 |
322 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 334 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
| 335 |
OLD | NEW |