Oolite
Loading...
Searching...
No Matches
OOTextureVerifierStage Class Reference

#include <OOTextureVerifierStage.h>

Inheritance diagram for OOTextureVerifierStage:
Collaboration diagram for OOTextureVerifierStage:

Instance Methods

(void) - textureNamed:usedInContext:
(id) - init [implementation]
(void) - dealloc [implementation]
(NSString *) - name [implementation]
(BOOL) - shouldRun [implementation]
(void) - run [implementation]
(void) - checkTextureNamed:inFolder: [implementation]
Instance Methods inherited from OOFileHandlingVerifierStage
(NSSet *) - dependencies [implementation]
(NSSet *) - dependents [implementation]
Instance Methods inherited from OOOXPVerifierStage
(OOOXPVerifier *) - verifier
(BOOL) - completed
(id) - description [implementation]
(void) - setVerifier: [implementation]
(BOOL) - isDependentOf: [implementation]
(void) - registerDependency: [implementation]
(void) - dependencyRegistrationComplete [implementation]
(BOOL) - canRun [implementation]
(void) - performRun [implementation]
(void) - noteSkipped [implementation]
(NSSet *) - resolvedDependencies [implementation]
(NSSet *) - resolvedDependents [implementation]
(void) - registerDepedent: [implementation]
(void) - dependencyCompleted: [implementation]

Class Methods

(NSString *) + nameForReverseDependencyForVerifier:

Private Attributes

NSMutableSet * _usedTextures

Detailed Description

Definition at line 33 of file OOTextureVerifierStage.h.

Method Documentation

◆ checkTextureNamed:inFolder:

- (void) checkTextureNamed: (NSString*) name
inFolder: (NSString*) folder 
implementation

Provided by category OOTextureVerifierStage(OOPrivate).

Definition at line 119 of file OOTextureVerifierStage.m.

119 :(NSString*)name inFolder:(NSString*)folder
120{
121 OOTextureLoader* loader = nil;
122 NSString* path = nil;
123 OOFileScannerVerifierStage* fileScanner = nil;
124 NSString* displayName = nil;
125 OOPixMapDimension rWidth, rHeight;
126 BOOL success;
127 OOPixMap pixmap;
128 OOTextureDataFormat format;
129
130 fileScanner = [[self verifier] fileScannerStage];
131 path = [fileScanner pathForFile:name
132 inFolder:folder
134 checkBuiltIn:NO];
135
136 if (path == nil)
137 return;
138
139 loader = [OOTextureLoader loaderWithPath:path
140 options:kOOTextureMinFilterNearest | kOOTextureMinFilterNearest | kOOTextureNoShrink | kOOTextureNoFNFMessage |
141 kOOTextureNeverScale];
142
143 displayName = [fileScanner displayNameForFile:name andFolder:folder];
144 if (loader == nil) {
145 OOLog(@"verifyOXP.texture.failed", @"***** ERROR: image %@ could not be read.", displayName);
146 } else {
147 success = [loader getResult:&pixmap format:&format originalWidth:NULL originalHeight:NULL];
148
149 if (success) {
150 rWidth = OORoundUpToPowerOf2_PixMap((2 * pixmap.width) / 3);
151 rHeight = OORoundUpToPowerOf2_PixMap((2 * pixmap.height) / 3);
152 if (pixmap.width != rWidth || pixmap.height != rHeight) {
153 OOLog(@"verifyOXP.texture.notPOT", @"----- WARNING: image %@ has non-power-of-two dimensions; it will have to be rescaled (from %ux%u pixels to %ux%u pixels) at runtime.", displayName, pixmap.width, pixmap.height, rWidth, rHeight);
154 } else {
155 OOLog(@"verifyOXP.verbose.texture.OK", @"- %@ (%ux%u px) OK.", displayName, pixmap.width, pixmap.height);
156 }
157
158 OOFreePixMap(&pixmap);
159 } else {
160 OOLog(@"verifyOXP.texture.failed", @"***** ERROR: texture loader failed to load %@.", displayName);
161 }
162 }
163}
#define OOLog(class, format,...)
Definition OOLogging.h:84
void OOFreePixMap(OOPixMap *ioPixMap)
Definition OOPixMap.m:80
uint32_t OOPixMapDimension
Definition OOPixMap.h:32
#define OORoundUpToPowerOf2_PixMap
Definition OOPixMap.h:34
struct OOPixMap OOPixMap
return nil
OOPixMapFormat OOTextureDataFormat
Definition OOTexture.h:107
id displayNameForFile:andFolder:(NSString *file,[andFolder] NSString *folder)
NSString * pathForFile:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)
id loaderWithPath:options:(NSString *path,[options] uint32_t options)
BOOL getResult:format:originalWidth:originalHeight:(OOPixMap *result,[format] OOTextureDataFormat *outFormat,[originalWidth] uint32_t *outWidth,[originalHeight] uint32_t *outHeight)
OOPixMapDimension height
Definition OOPixMap.h:45
OOPixMapDimension width
Definition OOPixMap.h:45

Referenced by run.

Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 53 of file OOTextureVerifierStage.m.

54{
55 [_usedTextures release];
56
57 [super dealloc];
58}

References OOOXPVerifierStage::dealloc, and dealloc.

Referenced by dealloc.

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

◆ init

- (id) init
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 44 of file OOTextureVerifierStage.m.

45{
46 self = [super init];
47 if (self != nil) {
48 _usedTextures = [[NSMutableSet alloc] init];
49 }
50 return self;
51}

References _usedTextures, OOOXPVerifierStage::init, init, and nil.

Referenced by init.

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

◆ name

- (NSString *) name
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 65 of file OOTextureVerifierStage.m.

66{
67 return kStageName;
68}
static NSString *const kStageName

References kStageName, and name.

Referenced by name, run, and textureNamed:usedInContext:.

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

◆ nameForReverseDependencyForVerifier:

+ (NSString *) nameForReverseDependencyForVerifier: (OOOXPVerifier*) verifier

Definition at line 60 of file OOTextureVerifierStage.m.

60 :(OOOXPVerifier*)verifier
61{
62 return kStageName;
63}
OOOXPVerifier * verifier()

References kStageName.

Referenced by OOTextureHandlingStage::dependents.

Here is the caller graph for this function:

◆ run

- (void) run
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 75 of file OOTextureVerifierStage.m.

76{
77 NSArray* nameEnum = nil;
78 NSString* name = nil;
79 NSAutoreleasePool* pool = nil;
80
81 foreach (name, _usedTextures) {
82 pool = [[NSAutoreleasePool alloc] init];
83 [self checkTextureNamed:name inFolder:@"Textures"];
84 [pool release];
85 }
86 [_usedTextures release];
88
89 // All "images" are considered used, since we don't have a reasonable way to look for images referenced in JavaScript scripts.
90 nameEnum = [[[self verifier] fileScannerStage] filesInFolder:@"Images"];
91 foreach (name, nameEnum) {
92 [self checkTextureNamed:name inFolder:@"Images"];
93 }
94}

References _usedTextures, checkTextureNamed:inFolder:, OOOXPVerifier::fileScannerStage, OOFileScannerVerifierStage::filesInFolder:, name, nil, run, and OOOXPVerifierStage::verifier.

Referenced by run.

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

◆ shouldRun

- (BOOL) shouldRun
implementation

Reimplemented from OOOXPVerifierStage.

Definition at line 70 of file OOTextureVerifierStage.m.

71{
72 return [_usedTextures count] != 0 || [[[self verifier] fileScannerStage] filesInFolder:@"Images"] != nil;
73}

References OOOXPVerifier::fileScannerStage, OOFileScannerVerifierStage::filesInFolder:, nil, shouldRun, and OOOXPVerifierStage::verifier.

Referenced by shouldRun.

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

◆ textureNamed:usedInContext:

- (void) textureNamed: (NSString*) name
usedInContext: (NSString*) context 

Definition at line 96 of file OOTextureVerifierStage.m.

96 :(NSString*)name usedInContext:(NSString*)context
97{
98 OOFileScannerVerifierStage* fileScanner = nil;
99
100 if (name == nil)
101 return;
102 if ([_usedTextures containsObject:name])
103 return;
104 [_usedTextures addObject:name];
105
106 fileScanner = [[self verifier] fileScannerStage];
107 if (![fileScanner fileExists:name
108 inFolder:@"Textures"
109 referencedFrom:context
110 checkBuiltIn:YES]) {
111 OOLog(@"verifyOXP.texture.notFound", @"----- WARNING: texture \"%@\" referenced in %@ could not be found in %@ or in Oolite.", name, context, [[self verifier] oxpDisplayName]);
112 }
113}

References _usedTextures, OOOXPVerifier::fileScannerStage, name, nil, OOLog, and OOOXPVerifierStage::verifier.

Here is the call graph for this function:

Member Data Documentation

◆ _usedTextures

- (NSMutableSet*) _usedTextures
private

Definition at line 35 of file OOTextureVerifierStage.h.

Referenced by init, run, and textureNamed:usedInContext:.


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