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

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

Issue 7458008: Support GL_OES_EGL_image_external (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 8 #include <vector>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 service_id_ = 0; 199 service_id_ = 0;
200 deleted_ = true; 200 deleted_ = true;
201 } 201 }
202 202
203 bool NeedsMips() const { 203 bool NeedsMips() const {
204 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR; 204 return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR;
205 } 205 }
206 206
207 // Sets the TextureInfo's target 207 // Sets the TextureInfo's target
208 // Parameters: 208 // Parameters:
209 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP 209 // target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP or
210 // GL_TEXTURE_EXTERNAL_OES
210 // max_levels: The maximum levels this type of target can have. 211 // max_levels: The maximum levels this type of target can have.
211 void SetTarget(GLenum target, GLint max_levels) { 212 void SetTarget(GLenum target, GLint max_levels) {
212 DCHECK_EQ(0u, target_); // you can only set this once. 213 DCHECK_EQ(0u, target_); // you can only set this once.
213 target_ = target; 214 target_ = target;
214 size_t num_faces = (target == GL_TEXTURE_2D) ? 1 : 6; 215 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
215 level_infos_.resize(num_faces); 216 level_infos_.resize(num_faces);
216 for (size_t ii = 0; ii < num_faces; ++ii) { 217 for (size_t ii = 0; ii < num_faces; ++ii) {
217 level_infos_[ii].resize(max_levels); 218 level_infos_[ii].resize(max_levels);
218 } 219 }
219 } 220 }
220 221
221 // Update info about this texture. 222 // Update info about this texture.
222 void Update(const FeatureInfo* feature_info); 223 void Update(const FeatureInfo* feature_info);
223 224
224 // Info about each face and level of texture. 225 // Info about each face and level of texture.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 bool owned_; 263 bool owned_;
263 264
264 DISALLOW_COPY_AND_ASSIGN(TextureInfo); 265 DISALLOW_COPY_AND_ASSIGN(TextureInfo);
265 }; 266 };
266 267
267 TextureManager(GLsizei max_texture_size, 268 TextureManager(GLsizei max_texture_size,
268 GLsizei max_cube_map_texture_size); 269 GLsizei max_cube_map_texture_size);
269 ~TextureManager(); 270 ~TextureManager();
270 271
271 // Init the texture manager. 272 // Init the texture manager.
272 bool Initialize(); 273 bool Initialize(const FeatureInfo* feature_info);
273 274
274 // Must call before destruction. 275 // Must call before destruction.
275 void Destroy(bool have_context); 276 void Destroy(bool have_context);
276 277
277 // Returns the maximum number of levels. 278 // Returns the maximum number of levels.
278 GLint MaxLevelsForTarget(GLenum target) const { 279 GLint MaxLevelsForTarget(GLenum target) const {
279 return (target == GL_TEXTURE_2D) ? max_levels_ : max_cube_map_levels_; 280 switch (target) {
281 case GL_TEXTURE_2D:
greggman 2011/07/20 01:41:18 What about if this and the next function had all 3
no sievers 2011/07/20 23:00:37 I originally had it that way but it broke stuff, b
282 return max_levels_;
283 case GL_TEXTURE_EXTERNAL_OES:
284 return 1;
285 default:
286 return max_cube_map_levels_;
287 }
280 } 288 }
281 289
282 // Returns the maximum size. 290 // Returns the maximum size.
283 GLsizei MaxSizeForTarget(GLenum target) const { 291 GLsizei MaxSizeForTarget(GLenum target) const {
284 return (target == GL_TEXTURE_2D) ? max_texture_size_ : 292 switch (target) {
285 max_cube_map_texture_size_; 293 case GL_TEXTURE_2D:
294 case GL_TEXTURE_EXTERNAL_OES:
295 return max_texture_size_;
296 default:
297 return max_cube_map_texture_size_;
298 }
286 } 299 }
287 300
288 // Checks if a dimensions are valid for a given target. 301 // Checks if a dimensions are valid for a given target.
289 bool ValidForTarget( 302 bool ValidForTarget(
290 const FeatureInfo* feature_info, 303 const FeatureInfo* feature_info,
291 GLenum target, GLint level, 304 GLenum target, GLint level,
292 GLsizei width, GLsizei height, GLsizei depth); 305 GLsizei width, GLsizei height, GLsizei depth);
293 306
294 // Sets the TextureInfo's target 307 // Sets the TextureInfo's target
295 // Parameters: 308 // Parameters:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Gets the texture info for the given texture. 346 // Gets the texture info for the given texture.
334 TextureInfo* GetTextureInfo(GLuint client_id); 347 TextureInfo* GetTextureInfo(GLuint client_id);
335 348
336 // Removes a texture info. 349 // Removes a texture info.
337 void RemoveTextureInfo(const FeatureInfo* feature_info, GLuint client_id); 350 void RemoveTextureInfo(const FeatureInfo* feature_info, GLuint client_id);
338 351
339 // Gets a client id for a given service id. 352 // Gets a client id for a given service id.
340 bool GetClientId(GLuint service_id, GLuint* client_id) const; 353 bool GetClientId(GLuint service_id, GLuint* client_id) const;
341 354
342 TextureInfo* GetDefaultTextureInfo(GLenum target) { 355 TextureInfo* GetDefaultTextureInfo(GLenum target) {
343 return target == GL_TEXTURE_2D ? default_texture_2d_ : 356 switch (target) {
344 default_texture_cube_map_; 357 case GL_TEXTURE_2D:
358 return default_texture_2d_;
359 case GL_TEXTURE_CUBE_MAP:
360 return default_texture_cube_map_;
361 case GL_TEXTURE_EXTERNAL_OES:
362 return default_texture_external_oes_;
363 default:
364 NOTREACHED();
365 return NULL;
366 }
345 } 367 }
346 368
347 bool HaveUnrenderableTextures() const { 369 bool HaveUnrenderableTextures() const {
348 return num_unrenderable_textures_ > 0; 370 return num_unrenderable_textures_ > 0;
349 } 371 }
350 372
351 GLuint black_texture_id(GLenum target) const { 373 GLuint black_texture_id(GLenum target) const {
352 return target == GL_SAMPLER_2D ? black_2d_texture_id_ : 374 switch (target) {
353 black_cube_texture_id_; 375 case GL_SAMPLER_2D:
376 return black_2d_texture_id_;
377 case GL_SAMPLER_CUBE:
378 return black_cube_texture_id_;
379 case GL_SAMPLER_EXTERNAL_OES:
380 return black_oes_external_texture_id_;
381 default:
382 NOTREACHED();
383 return 0;
384 }
354 } 385 }
355 386
356 private: 387 private:
357 // Info for each texture in the system. 388 // Info for each texture in the system.
358 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap; 389 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap;
359 TextureInfoMap texture_infos_; 390 TextureInfoMap texture_infos_;
360 391
361 GLsizei max_texture_size_; 392 GLsizei max_texture_size_;
362 GLsizei max_cube_map_texture_size_; 393 GLsizei max_cube_map_texture_size_;
363 GLint max_levels_; 394 GLint max_levels_;
364 GLint max_cube_map_levels_; 395 GLint max_cube_map_levels_;
365 396
366 int num_unrenderable_textures_; 397 int num_unrenderable_textures_;
367 398
368 // Black (0,0,0,1) textures for when non-renderable textures are used. 399 // Black (0,0,0,1) textures for when non-renderable textures are used.
369 // NOTE: There is no corresponding TextureInfo for these textures. 400 // NOTE: There is no corresponding TextureInfo for these textures.
370 // TextureInfos are only for textures the client side can access. 401 // TextureInfos are only for textures the client side can access.
371 GLuint black_2d_texture_id_; 402 GLuint black_2d_texture_id_;
372 GLuint black_cube_texture_id_; 403 GLuint black_cube_texture_id_;
404 GLuint black_oes_external_texture_id_;
373 405
374 // The default textures for each target (texture name = 0) 406 // The default textures for each target (texture name = 0)
375 TextureInfo::Ref default_texture_2d_; 407 TextureInfo::Ref default_texture_2d_;
376 TextureInfo::Ref default_texture_cube_map_; 408 TextureInfo::Ref default_texture_cube_map_;
409 TextureInfo::Ref default_texture_external_oes_;
377 410
378 DISALLOW_COPY_AND_ASSIGN(TextureManager); 411 DISALLOW_COPY_AND_ASSIGN(TextureManager);
379 }; 412 };
380 413
381 } // namespace gles2 414 } // namespace gles2
382 } // namespace gpu 415 } // namespace gpu
383 416
384 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 417 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698