123 done: |
123 done: |
124 setlocale(LC_ALL, old_locale); |
124 setlocale(LC_ALL, old_locale); |
125 return buf; |
125 return buf; |
126 } |
126 } |
127 |
127 |
|
128 char* SplashGetScaledImageName(const char* jar, const char* file, |
|
129 float *scaleFactor) { |
|
130 NSAutoreleasePool *pool = [NSAutoreleasePool new]; |
|
131 *scaleFactor = 1; |
|
132 char* scaledFile = nil; |
|
133 float screenScaleFactor = [SplashNSScreen() backingScaleFactor]; |
|
134 |
|
135 if (screenScaleFactor > 1) { |
|
136 NSString *fileName = [NSString stringWithUTF8String: file]; |
|
137 NSUInteger length = [fileName length]; |
|
138 NSRange range = [fileName rangeOfString: @"." |
|
139 options:NSBackwardsSearch]; |
|
140 NSUInteger dotIndex = range.location; |
|
141 NSString *fileName2x = nil; |
|
142 |
|
143 if (dotIndex == NSNotFound) { |
|
144 fileName2x = [fileName stringByAppendingString: @"@2x"]; |
|
145 } else { |
|
146 fileName2x = [fileName substringToIndex: dotIndex]; |
|
147 fileName2x = [fileName2x stringByAppendingString: @"@2x"]; |
|
148 fileName2x = [fileName2x stringByAppendingString: |
|
149 [fileName substringFromIndex: dotIndex]]; |
|
150 } |
|
151 |
|
152 if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager] |
|
153 fileExistsAtPath: fileName2x])){ |
|
154 *scaleFactor = 2; |
|
155 scaledFile = strdup([fileName2x UTF8String]); |
|
156 } |
|
157 } |
|
158 [pool drain]; |
|
159 return scaledFile; |
|
160 } |
128 |
161 |
129 void |
162 void |
130 SplashInitPlatform(Splash * splash) { |
163 SplashInitPlatform(Splash * splash) { |
131 pthread_mutex_init(&splash->lock, NULL); |
164 pthread_mutex_init(&splash->lock, NULL); |
132 |
165 |
133 splash->maskRequired = 0; |
166 splash->maskRequired = 0; |
134 |
167 |
135 |
168 |
136 //TODO: the following is too much of a hack but should work in 90% cases. |
169 //TODO: the following is too much of a hack but should work in 90% cases. |
137 // besides we don't use device-dependant drawing, so probably |
170 // besides we don't use device-dependant drawing, so probably |
138 // that's very fine indeed |
171 // that's very fine indeed |
139 splash->byteAlignment = 1; |
172 splash->byteAlignment = 1; |
140 initFormat(&splash->screenFormat, 0xff << 8, |
173 initFormat(&splash->screenFormat, 0xff << 8, |
223 NSImage * image = [[NSImage alloc] |
256 NSImage * image = [[NSImage alloc] |
224 initWithSize: NSMakeSize(splash->width, splash->height)]; |
257 initWithSize: NSMakeSize(splash->width, splash->height)]; |
225 [image setBackgroundColor: [NSColor clearColor]]; |
258 [image setBackgroundColor: [NSColor clearColor]]; |
226 |
259 |
227 [image addRepresentation: rep]; |
260 [image addRepresentation: rep]; |
228 |
261 float scaleFactor = splash->scaleFactor; |
|
262 if (scaleFactor > 0 && scaleFactor != 1) { |
|
263 [image setScalesWhenResized:YES]; |
|
264 NSSize size = [image size]; |
|
265 size.width /= scaleFactor; |
|
266 size.height /= scaleFactor; |
|
267 [image setSize: size]; |
|
268 } |
|
269 |
229 NSImageView * view = [[NSImageView alloc] init]; |
270 NSImageView * view = [[NSImageView alloc] init]; |
230 |
271 |
231 [view setImage: image]; |
272 [view setImage: image]; |
232 [view setEditable: NO]; |
273 [view setEditable: NO]; |
233 //NOTE: we don't set a 'wait cursor' for the view because: |
274 //NOTE: we don't set a 'wait cursor' for the view because: |