Oolite 1.91.0.7665-250419-c535bfe
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
OOTexture Class Reference

#include <OOTexture.h>

+ Inheritance diagram for OOTexture:
+ Collaboration diagram for OOTexture:

Instance Methods

(void) - apply
 
(void) - ensureFinishedLoading
 
(BOOL) - isFinishedLoading
 
(NSString *) - cacheKey
 
(NSSize) - dimensions
 
(NSSize) - originalDimensions
 
(BOOL) - isMipMapped
 
(OOPixMap- copyPixMapRepresentation
 
(BOOL) - isRectangleTexture
 
(BOOL) - isCubeMap
 
(NSSize) - texCoordsScale
 
(GLint) - glTextureName
 
(void) - setTrace:
 
(size_t) - dataSize
 
(NSString *) - name
 
(id) - init [implementation]
 
(void) - dealloc [implementation]
 
(void) - forceRebind [implementation]
 
(void) - addToCaches [implementation]
 
(void) - removeFromCaches [implementation]
 
(id) - retainInContext: [implementation]
 
(void) - releaseInContext: [implementation]
 
(id) - autoreleaseInContext: [implementation]
 
(id) - retain [implementation]
 
(oneway void) - release [implementation]
 
(id) - autorelease [implementation]
 
- Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
 
(id) - weakRetain [implementation]
 
(void) - weakRefDied: [implementation]
 
- Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED
 

Class Methods

(id) + textureWithName:inFolder:options:anisotropy:lodBias:
 
(id) + textureWithName:inFolder:
 
(id) + textureWithConfiguration:
 
(id) + textureWithConfiguration:extraOptions:
 
(id) + nullTexture
 
(id) + textureWithGenerator:
 
(id) + textureWithGenerator:enqueue:
 
(void) + applyNone
 
(void) + clearCache
 
(void) + rebindAllTextures
 
(NSArray *) + cachedTexturesByAge
 
(NSSet *) + allTextures
 
(OOTexture *) + existingTextureForKey: [implementation]
 
(void) + checkExtensions [implementation]
 

Protected Attributes

BOOL _trace
 
- Protected Attributes inherited from OOWeakRefObject
OOWeakReferenceweakSelf
 

Detailed Description

Definition at line 116 of file OOTexture.h.

Method Documentation

◆ addToCaches

- (void) addToCaches
implementation

Provided by category OOTexture(SubclassInterface).

Definition at line 444 of file OOTexture.m.

445{
446#ifndef OOTEXTURE_NO_CACHE
447 NSString *cacheKey = [self cacheKey];
448 if (cacheKey == nil) return;
449
450 // Add self to in-use textures cache, wrapped in an NSValue so the texture isn't retained by the cache.
451 if (EXPECT_NOT(sLiveTextureCache == nil)) sLiveTextureCache = [[NSMutableDictionary alloc] init];
452
453 SET_TRACE_CONTEXT(@"in-use textures cache - SHOULD NOT RETAIN");
454 [sLiveTextureCache setObject:[NSValue valueWithPointer:self] forKey:cacheKey];
456
457 // Add self to recent textures cache.
459 {
460 sRecentTextures = [[OOCache alloc] init];
461 [sRecentTextures setName:@"recent textures"];
463 [sRecentTextures setPruneThreshold:kRecentTexturesCount];
464 }
465
466 SET_TRACE_CONTEXT(@"adding to recent textures cache");
467 [sRecentTextures setObject:self forKey:cacheKey];
469#endif
470}
#define EXPECT_NOT(x)
return nil
#define CLEAR_TRACE_CONTEXT()
Definition OOTexture.m:129
#define SET_TRACE_CONTEXT(str)
Definition OOTexture.m:125
static OOCache * sRecentTextures
Definition OOTexture.m:97
static NSMutableDictionary * sLiveTextureCache
Definition OOTexture.m:95
void setPruneThreshold:(unsigned threshold)
Definition OOCache.m:272
void setName:(NSString *name)
Definition OOCache.m:348
void setAutoPrune:(BOOL flag)
Definition OOCache.m:289
void setObject:forKey:(id value,[forKey] id key)
Definition OOCache.m:248
NSString * cacheKey()
Definition OOTexture.m:300

References OOTexture(OOPrivate)::addToCaches, cacheKey, CLEAR_TRACE_CONTEXT, EXPECT_NOT, nil, SET_TRACE_CONTEXT, OOCache::setAutoPrune:, OOCache::setName:, OOCache::setObject:forKey:, OOCache::setPruneThreshold:, sLiveTextureCache, and sRecentTextures.

Referenced by OOTexture(OOPrivate)::addToCaches, and OOConcreteTexture::initWithLoader:key:options:anisotropy:lodBias:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ allTextures

+ (NSSet *) allTextures

Definition at line 405 of file OOTexture.m.

406{
407 NSMutableSet *result = [NSMutableSet setWithCapacity:[sAllLiveTextures count]];
408 NSValue *box = nil;
409 NSEnumerator *texEnum = nil;
410 for (texEnum = [sAllLiveTextures objectEnumerator]; (box = [texEnum nextObject]); )
411 {
412 [result addObject:[box pointerValue]];
413 }
414
415 return result;
416}
static NSMutableSet * sAllLiveTextures
Definition OOTexture.m:96

References allTextures, nil, and sAllLiveTextures.

Referenced by allTextures, and OODebugMonitor::dumpMemoryStatistics.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ apply

- (void) apply

Reimplemented in OOConcreteTexture, and OONullTexture.

Provided by category OOTexture(SubclassResponsibilities).

Definition at line 269 of file OOTexture.m.

270{
272}
#define OOLogGenericSubclassResponsibility()
Definition OOLogging.h:129

References apply, OOLogGenericSubclassResponsibility, and textureWithName:inFolder:options:anisotropy:lodBias:.

Referenced by apply, OOTextureSprite::blitToX:Y:Z:alpha:, OOSingleTextureMaterial::doApply, DustEntity::drawImmediate:translucent:, OOLaserShotEntity::drawImmediate:translucent:, OOLightParticleEntity::drawImmediate:translucent:, OOParticleSystem::drawImmediate:translucent:, HeadUpDisplay(Private)::drawScannerZoomIndicator:, OOExhaustPlumeEntity::drawSubEntityImmediate:translucent:, OOTrumble::drawTrumble:, PlanetEntity::drawUnconditionally, HeadUpDisplay::OODrawPlanetInfo, HeadUpDisplay::OOStartDrawingStrings, and OOSkyQuadSet::render.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyNone

+ (void) applyNone

Definition at line 275 of file OOTexture.m.

276{
278 OOGL(glBindTexture(GL_TEXTURE_2D, 0));
279#if OO_TEXTURE_CUBE_MAP
280 if (OOCubeMapsAvailable()) OOGL(glBindTexture(GL_TEXTURE_CUBE_MAP, 0));
281#endif
282
283#if GL_EXT_texture_lod_bias
284 if (gOOTextureInfo.textureLODBiasAvailable) OOGL(glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0));
285#endif
286}
#define OO_ENTER_OPENGL()
#define OOGL(statement)
Definition OOOpenGL.h:251
BOOL OOCubeMapsAvailable(void)
Definition OOTexture.m:688
OOTextureInfo gOOTextureInfo
Definition OOTexture.m:101
unsigned textureLODBiasAvailable

References applyNone, gOOTextureInfo, OO_ENTER_OPENGL, OOCubeMapsAvailable(), and OOGL.

Referenced by OONullTexture::apply, applyNone, OOBasicMaterial::doApply, GuiDisplayGen(Internal)::drawGLDisplay:x:y:z:, HeadUpDisplay(Private)::drawScannerZoomIndicator:, PlanetEntity::drawUnconditionally, HeadUpDisplay::OODrawPlanetInfo, HeadUpDisplay::OOStopDrawingStrings, and OOSingleTextureMaterial::unapplyWithNext:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ autorelease

- (id) autorelease
implementation

Reimplemented in OONullTexture.

Definition at line 620 of file OOTexture.m.

621{
622 return [self autoreleaseInContext:sGlobalTraceContext];
623}

References autorelease, and autoreleaseInContext:.

Referenced by autorelease.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ autoreleaseInContext:

- (id) autoreleaseInContext: (NSString *) context
implementation

Provided by category OOTexture(OOPrivate).

Definition at line 596 of file OOTexture.m.

596 :(NSString *)context
597{
598 if (_trace)
599 {
600 if (context) OOLog(@"texture.allocTrace.autoreleased", @"Texture %p autoreleased - %@.", self, context);
601 else OOLog(@"texture.allocTrace.autoreleased", @"Texture %p autoreleased.", self);
602 }
603
604 return [super autorelease];
605}
#define OOLog(class, format,...)
Definition OOLogging.h:88
BOOL _trace
Definition OOTexture.h:120

References OOLog.

Referenced by autorelease.

+ Here is the caller graph for this function:

◆ cachedTexturesByAge

+ (NSArray *) cachedTexturesByAge

Definition at line 399 of file OOTexture.m.

400{
402}
NSArray * objectsByAge()
Definition OOCache.m:354

References cachedTexturesByAge, and OOCache::objectsByAge.

Referenced by cachedTexturesByAge, and OODebugMonitor::dumpMemoryStatistics.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cacheKey

- (NSString *) cacheKey

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 300 of file OOTexture.m.

301{
302 return nil;
303}

References cacheKey, and nil.

Referenced by OOTexture(OOPrivate)::addToCaches, cacheKey, and OOTexture(SubclassInterface)::removeFromCaches.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExtensions

+ (void) checkExtensions
implementation

Provided by category OOTexture(OOPrivate).

Definition at line 516 of file OOTexture.m.

517{
519
520 sCheckedExtensions = YES;
521
522 OOOpenGLExtensionManager *extMgr = [OOOpenGLExtensionManager sharedManager];
523 BOOL ver120 = [extMgr versionIsAtLeastMajor:1 minor:2];
524 BOOL ver130 = [extMgr versionIsAtLeastMajor:1 minor:3];
525
526#if GL_EXT_texture_filter_anisotropic
527 gOOTextureInfo.anisotropyAvailable = [extMgr haveExtension:@"GL_EXT_texture_filter_anisotropic"];
528 OOGL(glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gOOTextureInfo.anisotropyScale));
529 gOOTextureInfo.anisotropyScale *= OOClamp_0_1_f([[NSUserDefaults standardUserDefaults] oo_floatForKey:@"texture-anisotropy-scale" defaultValue:0.5]);
530#endif
531
532#ifdef GL_CLAMP_TO_EDGE
533 gOOTextureInfo.clampToEdgeAvailable = ver120 || [extMgr haveExtension:@"GL_SGIS_texture_edge_clamp"];
534#endif
535
536#if OO_GL_CLIENT_STORAGE
537 gOOTextureInfo.clientStorageAvailable = [extMgr haveExtension:@"GL_APPLE_client_storage"];
538#endif
539
540 gOOTextureInfo.textureMaxLevelAvailable = ver120 || [extMgr haveExtension:@"GL_SGIS_texture_lod"];
541
542#if GL_EXT_texture_lod_bias
543 if ([[NSUserDefaults standardUserDefaults] oo_boolForKey:@"use-texture-lod-bias" defaultValue:YES])
544 {
545 gOOTextureInfo.textureLODBiasAvailable = [extMgr haveExtension:@"GL_EXT_texture_lod_bias"];
546 }
547 else
548 {
550 }
551#endif
552
553#if GL_EXT_texture_rectangle
554 gOOTextureInfo.rectangleTextureAvailable = [extMgr haveExtension:@"GL_EXT_texture_rectangle"];
555#endif
556
557#if OO_TEXTURE_CUBE_MAP
558 if (![[NSUserDefaults standardUserDefaults] boolForKey:@"disable-cube-maps"])
559 {
560 gOOTextureInfo.cubeMapAvailable = ver130 || [extMgr haveExtension:@"GL_ARB_texture_cube_map"];
561 }
562 else
563 {
565 }
566
567#endif
568}
static BOOL sCheckedExtensions
Definition OOTexture.m:100
BOOL versionIsAtLeastMajor:minor:(unsigned maj,[minor] unsigned min)
OOOpenGLExtensionManager * sharedManager()
BOOL haveExtension:(NSString *extension)
unsigned clientStorageAvailable
unsigned textureMaxLevelAvailable
unsigned anisotropyAvailable
unsigned clampToEdgeAvailable
unsigned cubeMapAvailable
unsigned rectangleTextureAvailable

References checkExtensions, gOOTextureInfo, OOOpenGLExtensionManager::haveExtension:, OO_ENTER_OPENGL, OOGL, sCheckedExtensions, OOOpenGLExtensionManager::sharedManager, and OOOpenGLExtensionManager::versionIsAtLeastMajor:minor:.

Referenced by checkExtensions, and textureWithName:inFolder:options:anisotropy:lodBias:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearCache

+ (void) clearCache

Definition at line 357 of file OOTexture.m.

358{
359 /* Does not clear sAllLiveTextures - that really must refer to all
360 live texture objects.
361 */
362 SET_TRACE_CONTEXT(@"clearing sLiveTextureCache");
363 [sLiveTextureCache autorelease];
365
366 SET_TRACE_CONTEXT(@"clearing sRecentTextures");
367 [sRecentTextures autorelease];
370}

References CLEAR_TRACE_CONTEXT, clearCache, nil, SET_TRACE_CONTEXT, sLiveTextureCache, and sRecentTextures.

Referenced by clearCache, OODebugController::clearTextureCacheAction:, Universe::reinitAndShowDemo:, and OODebugController::resetAndClearAction:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyPixMapRepresentation

- (struct OOPixMap) copyPixMapRepresentation

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 326 of file OOTexture.m.

327{
328 return kOONullPixMap;
329}
const OOPixMap kOONullPixMap
Definition OOPixMap.m:31

References copyPixMapRepresentation, and kOONullPixMap.

Referenced by copyPixMapRepresentation, and OOCombinedEmissionMapGenerator(Private)::initWithEmissionMapSpec:emissionColor:diffuseMap:diffuseColor:illuminationMapSpec:illuminationColor:isCombinedMap:optionsSpecifier:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dataSize

- (size_t) dataSize

Definition at line 419 of file OOTexture.m.

420{
421 NSSize dimensions = [self dimensions];
422 size_t size = dimensions.width * dimensions.height;
423 if ([self isCubeMap]) size *= 6;
424 if ([self isMipMapped]) size = size * 4 / 3;
425
426 return size;
427}
NSSize dimensions()
Definition OOTexture.m:306
BOOL isCubeMap()
Definition OOTexture.m:338
BOOL isMipMapped()
Definition OOTexture.m:319
voidpf void uLong size
Definition ioapi.h:134

References dataSize, dimensions, isCubeMap, and isMipMapped.

Referenced by dataSize, and OODebugMonitor::dumpMemoryStatistics.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOWeakRefObject.

Reimplemented in OOConcreteTexture.

Definition at line 261 of file OOTexture.m.

262{
263 [sAllLiveTextures removeObject:[NSValue valueWithPointer:self]];
264
265 [super dealloc];
266}

References dealloc, and OOWeakRefObject::dealloc.

Referenced by OOConcreteTexture::dealloc, and dealloc.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dimensions

- (NSSize) dimensions

Reimplemented in OOConcreteTexture, and OONullTexture.

Provided by category OOTexture(SubclassResponsibilities).

Definition at line 306 of file OOTexture.m.

307{
309 return NSZeroSize;
310}

References dimensions, nil, OOLogGenericSubclassResponsibility, and textureWithName:inFolder:options:anisotropy:lodBias:.

Referenced by HeadUpDisplay::addLegend:, dataSize, dimensions, HeadUpDisplay(Private)::drawCustomImage:, and originalDimensions.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureFinishedLoading

- (void) ensureFinishedLoading

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 289 of file OOTexture.m.

290{
291}

References ensureFinishedLoading, and textureWithName:inFolder:options:anisotropy:lodBias:.

Referenced by PlanetEntity::drawUnconditionally, OOSingleTextureMaterial::ensureFinishedLoading, ensureFinishedLoading, and OOProbabilisticTextureManager::ensureTexturesLoaded.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ existingTextureForKey:

+ (OOTexture *) existingTextureForKey: (NSString *) key
implementation

Provided by category OOTexture(SubclassInterface).

Definition at line 502 of file OOTexture.m.

502 :(NSString *)key
503{
504#ifndef OOTEXTURE_NO_CACHE
505 if (key != nil)
506 {
507 return (OOTexture *)[[sLiveTextureCache objectForKey:key] pointerValue];
508 }
509 return nil;
510#else
511 return nil;
512#endif
513}

References nil.

Referenced by textureWithGenerator:enqueue:, and textureWithName:inFolder:options:anisotropy:lodBias:.

+ Here is the caller graph for this function:

◆ forceRebind

- (void) forceRebind
implementation

Reimplemented in OOConcreteTexture, and OONullTexture.

Provided by category OOTexture(SubclassResponsibilities).

Definition at line 438 of file OOTexture.m.

References OOTexture(OOPrivate)::forceRebind, and OOLogGenericSubclassResponsibility.

Referenced by OOTexture(OOPrivate)::existingTextureForKey:, and OOTexture(OOPrivate)::forceRebind.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ glTextureName

- (GLint) glTextureName

Reimplemented in OOConcreteTexture.

Definition at line 350 of file OOTexture.m.

351{
353 return 0;
354}

References glTextureName, and OOLogGenericSubclassResponsibility.

Referenced by glTextureName.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init

- (id) init
implementation

Definition at line 249 of file OOTexture.m.

250{
251 if ((self = [super init]))
252 {
253 if (EXPECT_NOT(sAllLiveTextures == nil)) sAllLiveTextures = [[NSMutableSet alloc] init];
254 [sAllLiveTextures addObject:[NSValue valueWithPointer:self]];
255 }
256
257 return self;
258}

References EXPECT_NOT, init, nil, and sAllLiveTextures.

Referenced by init, and OOConcreteTexture::initWithLoader:key:options:anisotropy:lodBias:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCubeMap

- (BOOL) isCubeMap

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 338 of file OOTexture.m.

339{
340 return NO;
341}

References isCubeMap.

Referenced by dataSize, isCubeMap, and OOSingleTextureMaterial::wantsNormalsAsTextureCoordinates.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFinishedLoading

- (BOOL) isFinishedLoading

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 294 of file OOTexture.m.

295{
296 return YES;
297}

References isFinishedLoading, and textureWithConfiguration:extraOptions:.

Referenced by OOSingleTextureMaterial::isFinishedLoading, and isFinishedLoading.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isMipMapped

- (BOOL) isMipMapped

Reimplemented in OOConcreteTexture, and OONullTexture.

Definition at line 319 of file OOTexture.m.

320{
322 return NO;
323}

References isMipMapped, and OOLogGenericSubclassResponsibility.

Referenced by dataSize, and isMipMapped.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRectangleTexture

- (BOOL) isRectangleTexture

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 332 of file OOTexture.m.

333{
334 return NO;
335}

References isRectangleTexture.

Referenced by isRectangleTexture.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ name

- (NSString *) name

Reimplemented in OOConcreteTexture, and OONullTexture.

Definition at line 430 of file OOTexture.m.

431{
433 return nil;
434}

References name, nil, and OOLogGenericSubclassResponsibility.

Referenced by name, textureWithConfiguration:extraOptions:, and textureWithName:inFolder:options:anisotropy:lodBias:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nullTexture

+ (id) nullTexture

Definition at line 211 of file OOTexture.m.

212{
214}
OONullTexture * sharedNullTexture()

References nullTexture, and OONullTexture::sharedNullTexture.

Referenced by nullTexture.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ originalDimensions

- (NSSize) originalDimensions

Reimplemented in OOConcreteTexture.

Definition at line 313 of file OOTexture.m.

314{
315 return [self dimensions];
316}

References dimensions, and originalDimensions.

Referenced by OOTextureSprite::initWithTexture:, GuiDisplayGen::NewTextureSpriteWithDescriptor, and originalDimensions.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rebindAllTextures

+ (void) rebindAllTextures

Definition at line 373 of file OOTexture.m.

374{
375 NSEnumerator *textureEnum = nil;
376 id texture = nil;
377
378 // Keeping around unused, cached textures is unhelpful at this point.
380
381 for (textureEnum = [sAllLiveTextures objectEnumerator]; (texture = [[textureEnum nextObject] pointerValue]); )
382 {
383 [texture forceRebind];
384 }
385}
#define DESTROY(x)
Definition OOCocoa.h:77

References DESTROY, nil, rebindAllTextures, sAllLiveTextures, and sRecentTextures.

Referenced by rebindAllTextures, and OOGraphicsResetManager::resetGraphicsState.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ release

- (oneway void) release
implementation

Reimplemented in OONullTexture.

Definition at line 614 of file OOTexture.m.

615{
616 [self releaseInContext:sGlobalTraceContext];
617}

References release, and releaseInContext:.

Referenced by OOProbabilisticTextureManager::dealloc, OOSingleTextureMaterial::dealloc, OOSkyQuadSet::dealloc, OOTextureSprite::dealloc, OOTrumble::dealloc, OOConcreteTexture::initWithLoader:key:options:anisotropy:lodBias:, OOConcreteTexture::initWithPath:key:options:anisotropy:lodBias:, release, OOExhaustPlumeEntity::resetGraphicsState, OOFlashEffectEntity::resetGraphicsState, OOLaserShotEntity::resetGraphicsState, and OOLightParticleEntity::resetGraphicsState.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ releaseInContext:

- (void) releaseInContext: (NSString *) context
implementation

Provided by category OOTexture(OOPrivate).

Definition at line 584 of file OOTexture.m.

584 :(NSString *)context
585{
586 if (_trace)
587 {
588 if (context) OOLog(@"texture.allocTrace.release", @"Texture %p released (retain count -> %lu) - %@.", self, [self retainCount] - 1, context);
589 else OOLog(@"texture.allocTrace.release", @"Texture %p released (retain count -> %lu).", self, [self retainCount] - 1);
590 }
591
592 [super release];
593}

References OOLog.

Referenced by release.

+ Here is the caller graph for this function:

◆ removeFromCaches

- (void) removeFromCaches
implementation

Provided by category OOTexture(SubclassInterface).

Definition at line 473 of file OOTexture.m.

474{
475#ifndef OOTEXTURE_NO_CACHE
476 NSString *cacheKey = [self cacheKey];
477 if (cacheKey == nil) return;
478
479 [sLiveTextureCache removeObjectForKey:cacheKey];
480 if (EXPECT_NOT([sRecentTextures objectForKey:cacheKey] == self))
481 {
482 /* Experimental for now: I think the recent crash problems may
483 * be because if the last reference to a texture is in
484 * sRecentTextures, and the texture is regenerated, it
485 * replaces the texture, causing a release. Therefore, if this
486 * texture *isn't* overretained in the texture cache, the 2009
487 * crash avoider will delete its replacement from the cache
488 * ... possibly before that texture has been fully added to
489 * the cache itself. So, the texture is only removed from the
490 * cache by key if it was in it with that key. The extra time
491 * needed to generate a planet texture compared with loading a
492 * standard one may be why this problem shows up. - CIM 20140122
493 */
494 NSAssert2(0, @"Texture retain count error for %@; cacheKey is %@.", self, cacheKey); //miscount in autorelease
495 // The following line is needed in order to avoid crashes when there's a 'texture retain count error'. Please do not delete. -- Kaks 20091221
496 [sRecentTextures removeObjectForKey:cacheKey]; // make sure there's no reference left inside sRecentTexture ( was a show stopper for 1.73)
497 }
498#endif
499}
void removeObjectForKey:(id key)
Definition OOCache.m:262

References cacheKey, EXPECT_NOT, nil, OOTexture(SubclassInterface)::removeFromCaches, OOCache::removeObjectForKey:, and sRecentTextures.

Referenced by OOConcreteTexture::dealloc, and OOTexture(SubclassInterface)::removeFromCaches.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retain

- (id) retain
implementation

Reimplemented in OONullTexture.

Definition at line 608 of file OOTexture.m.

609{
610 return [self retainInContext:sGlobalTraceContext];
611}

References retain, and retainInContext:.

Referenced by PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, HeadUpDisplay::InitTextEngine(void), OOCombinedEmissionMapGenerator(Private)::initWithEmissionMapSpec:emissionColor:diffuseMap:diffuseColor:illuminationMapSpec:illuminationColor:isCombinedMap:optionsSpecifier:, OOSingleTextureMaterial::initWithName:texture:configuration:, OOProbabilisticTextureManager::initWithPListName:options:anisotropy:lodBias:seed:, OOSkyQuadSet::initWithQuadsWithTexture:inArray:count:, OOTextureSprite::initWithTexture:size:, retain, OOTrumble::setupForPlayer:digram:, and textureWithGenerator:enqueue:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retainInContext:

- (id) retainInContext: (NSString *) context
implementation

Provided by category OOTexture(OOPrivate).

Definition at line 572 of file OOTexture.m.

572 :(NSString *)context
573{
574 if (_trace)
575 {
576 if (context) OOLog(@"texture.allocTrace.retain", @"Texture %p retained (retain count -> %lu) - %@.", self, [self retainCount] + 1, context);
577 else OOLog(@"texture.allocTrace.retain", @"Texture %p retained (retain count -> %lu).", self, [self retainCount] + 1);
578 }
579
580 return [super retain];
581}

References OOLog.

Referenced by retain.

+ Here is the caller graph for this function:

◆ setTrace:

- (void) setTrace: (BOOL) trace

Definition at line 389 of file OOTexture.m.

389 :(BOOL)trace
390{
391 if (trace && !_trace)
392 {
393 OOLog(@"texture.allocTrace.begin", @"Started tracing texture %p with retain count %lu.", self, [self retainCount]);
394 }
395 _trace = trace;
396}

References _trace, and OOLog.

◆ texCoordsScale

- (NSSize) texCoordsScale

Reimplemented in OOConcreteTexture.

Provided by category OOTexture(SubclassOptional).

Definition at line 344 of file OOTexture.m.

345{
346 return NSMakeSize(1.0, 1.0);
347}

References texCoordsScale.

Referenced by texCoordsScale.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ textureWithConfiguration:

+ (id) textureWithConfiguration: (id) configuration

Definition at line 192 of file OOTexture.m.

192 :(id)configuration
193{
194 return [self textureWithConfiguration:configuration extraOptions:0];
195}

Referenced by OOSingleTextureMaterial::initWithName:configuration:.

+ Here is the caller graph for this function:

◆ textureWithConfiguration:extraOptions:

+ (id) textureWithConfiguration: (id) configuration
extraOptions: (OOTextureFlags) extraOptions 

Definition at line 198 of file OOTexture.m.

198 :(id)configuration extraOptions:(OOTextureFlags)extraOptions
199{
200 NSString *name = nil;
201 OOTextureFlags options = 0;
202 GLfloat anisotropy = 0.0f;
203 GLfloat lodBias = 0.0f;
204
205 if (!OOInterpretTextureSpecifier(configuration, &name, &options, &anisotropy, &lodBias, NO)) return nil;
206
207 return [self textureWithName:name inFolder:@"Textures" options:options | extraOptions anisotropy:anisotropy lodBias:lodBias];
208}
uint32_t OOTextureFlags
Definition OOTexture.h:98
BOOL OOInterpretTextureSpecifier(id specifier, NSString **outName, OOTextureFlags *outOptions, float *outAnisotropy, float *outLODBias, BOOL ignoreExtract)
Definition OOTexture.m:694
NSString * name()
Definition OOTexture.m:430

References name, and nil.

Referenced by OOTexture(SubclassOptional)::isFinishedLoading, and PlanetEntity(OOPrivate)::loadTexture:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ textureWithGenerator:

+ (id) textureWithGenerator: (OOTextureGenerator *) generator

Definition at line 217 of file OOTexture.m.

217 :(OOTextureGenerator *)generator
218{
219 return [self textureWithGenerator:generator enqueue: NO];
220}

References textureWithGenerator:enqueue:.

Referenced by PlanetEntity(OOPrivate)::cloudTextureWithCloudColor:cloudImpress:cloudBias:, and PlanetEntity(OOPrivate)::planetTextureWithInfo:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ textureWithGenerator:enqueue:

+ (id) textureWithGenerator: (OOTextureGenerator *) generator
enqueue: (BOOL) enqueue 

Definition at line 223 of file OOTexture.m.

223 :(OOTextureGenerator *)generator enqueue:(BOOL) enqueue
224{
225 if (generator == nil) return nil;
226
227#ifndef OOTEXTURE_NO_CACHE
228 OOTexture *existing = [OOTexture existingTextureForKey:[generator cacheKey]];
229 if (existing != nil && !enqueue) return [[existing retain] autorelease];
230#endif
231
232 if (![generator enqueue])
233 {
234 OOLogERR(@"texture.generator.queue.failed", @"Failed to queue generator %@", generator);
235 return nil;
236 }
237 OOLog(@"texture.generator.queue", @"Queued texture generator %@", generator);
238
239 OOTexture *result = [[[OOConcreteTexture alloc] initWithLoader:generator
240 key:[generator cacheKey]
241 options:OOApplyTextureOptionDefaults([generator textureOptions])
242 anisotropy:[generator anisotropy]
243 lodBias:[generator lodBias]] autorelease];
244
245 return result;
246}
#define OOLogERR(class, format,...)
Definition OOLogging.h:112
OOTexture * existingTextureForKey:(NSString *key)
Definition OOTexture.m:502
id autorelease()
Definition OOTexture.m:620

References OOTextureGenerator::anisotropy, OOTextureGenerator::cacheKey, existingTextureForKey:, OOTextureGenerator::lodBias, nil, OOLog, OOLogERR, retain, and OOTextureGenerator::textureOptions.

Referenced by textureWithGenerator:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ textureWithName:inFolder:

+ (id) textureWithName: (NSString *) name
inFolder: (NSString*) directory 

Definition at line 181 of file OOTexture.m.

181 :(NSString *)name
182 inFolder:(NSString*)directory
183{
184 return [self textureWithName:name
185 inFolder:directory
186 options:kOOTextureDefaultOptions
187 anisotropy:kOOTextureDefaultAnisotropy
188 lodBias:kOOTextureDefaultLODBias];
189}

Referenced by OOMaterial(OOConvenienceCreators)::materialWithName:cacheKey:materialDictionary:shadersDictionary:macros:bindingTarget:forSmoothedMesh:.

+ Here is the caller graph for this function:

◆ textureWithName:inFolder:options:anisotropy:lodBias:

+ (id) textureWithName: (NSString *) name
inFolder: (NSString *) directory
options: (OOTextureFlags) options
anisotropy: (GLfloat) anisotropy
lodBias: (GLfloat) lodBias 

Definition at line 134 of file OOTexture.m.

134 :(NSString *)name
135 inFolder:(NSString*)directory
136 options:(OOTextureFlags)options
137 anisotropy:(GLfloat)anisotropy
138 lodBias:(GLfloat)lodBias
139{
140 NSString *key = nil;
141 OOTexture *result = nil;
142 NSString *path = nil;
143 BOOL noFNF;
144
145 if (EXPECT_NOT(name == nil)) return nil;
147
149 {
150 anisotropy = 0.0f;
151 }
153 {
154 lodBias = 0.0f;
155 }
156
157 noFNF = (options & kOOTextureNoFNFMessage) != 0;
159
160 // Look for existing texture
161 key = OOGenerateTextureCacheKey(directory, name, options, anisotropy, lodBias);
162 result = [OOTexture existingTextureForKey:key];
163 if (result == nil)
164 {
165 path = [ResourceManager pathForFileNamed:name inFolder:directory];
166 if (path == nil)
167 {
168 if (!noFNF) OOLogWARN(kOOLogFileNotFound, @"Could not find texture file \"%@\".", name);
169 return nil;
170 }
171
172 // No existing texture, load texture.
173 result = [[[OOConcreteTexture alloc] initWithPath:path key:key options:options anisotropy:anisotropy lodBias:lodBias] autorelease];
174 }
175
176
177 return result;
178}
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
NSString *const kOOLogFileNotFound
Definition OOLogging.m:652
OOTextureFlags OOApplyTextureOptionDefaults(OOTextureFlags options)
Definition OOTexture.m:855
@ kOOTextureNoFNFMessage
Definition OOTexture.h:58
@ kOOTextureMinFilterMask
Definition OOTexture.h:72
@ kOOTextureMinFilterMipMap
Definition OOTexture.h:48
NSString * OOGenerateTextureCacheKey(NSString *directory, NSString *name, OOTextureFlags options, float anisotropy, float lodBias)
Definition OOTexture.m:908
void checkExtensions()
Definition OOTexture.m:516
NSString * pathForFileNamed:inFolder:(NSString *fileName,[inFolder] NSString *folderName)

References checkExtensions, existingTextureForKey:, EXPECT_NOT, gOOTextureInfo, kOOLogFileNotFound, kOOTextureMinFilterMask, kOOTextureMinFilterMipMap, kOOTextureNoFNFMessage, name, nil, OOApplyTextureOptionDefaults(), OOGenerateTextureCacheKey(), OOLogWARN, ResourceManager::pathForFileNamed:inFolder:, and sCheckedExtensions.

Referenced by HeadUpDisplay::addLegend:, OOTexture(SubclassResponsibilities)::apply, OOTexture(SubclassResponsibilities)::dimensions, HeadUpDisplay(Private)::drawCustomImage:, OOTexture(SubclassOptional)::ensureFinishedLoading, DustEntity::init, OOExplosionCloudEntity(OOPrivate)::initExplosionCloudWithEntity:size:andSettings:, HeadUpDisplay::InitTextEngine(void), OOProbabilisticTextureManager::initWithPListName:options:anisotropy:lodBias:seed:, OOTrumble::setupForPlayer:digram:, OOExhaustPlumeEntity::setUpTexture, OOFlashEffectEntity::setUpTexture, OOLaserShotEntity::setUpTexture, OOLightParticleEntity::setUpTexture, and GuiDisplayGen::TextureForGUITexture.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _trace

- (BOOL) _trace
protected

Definition at line 120 of file OOTexture.h.

Referenced by OOConcreteTexture::dealloc, and setTrace:.


The documentation for this class was generated from the following files: