142 return JNI_FALSE; 143 } 144 145 NSAutoreleasePool *pool = [NSAutoreleasePool new]; 146 __block float screenScaleFactor = 1; 147 148 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ 149 // initialize NSApplication and AWT stuff 150 [NSApplicationAWT sharedApplication]; 151 screenScaleFactor = [SplashNSScreen() backingScaleFactor]; 152 }]; 153 154 if (screenScaleFactor > 1) { 155 NSString *fileName = [NSString stringWithUTF8String: file]; 156 NSUInteger length = [fileName length]; 157 NSRange range = [fileName rangeOfString: @"." 158 options:NSBackwardsSearch]; 159 NSUInteger dotIndex = range.location; 160 NSString *fileName2x = nil; 161 162 if (dotIndex == NSNotFound) { 163 fileName2x = [fileName stringByAppendingString: @"@2x"]; 164 } else { 165 fileName2x = [fileName substringToIndex: dotIndex]; 166 fileName2x = [fileName2x stringByAppendingString: @"@2x"]; 167 fileName2x = [fileName2x stringByAppendingString: 168 [fileName substringFromIndex: dotIndex]]; 169 } 170 171 if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager] 172 fileExistsAtPath: fileName2x])){ 173 if (strlen([fileName2x UTF8String]) > scaledImageLength) { 174 [pool drain]; 175 return JNI_FALSE; 176 } 177 *scaleFactor = 2; 178 strcpy(scaledFile, [fileName2x UTF8String]); 179 [pool drain]; 180 return JNI_TRUE; 181 } 182 } 183 [pool drain]; 184 return JNI_FALSE; 185 } 186 187 void 188 SplashInitPlatform(Splash * splash) { 189 pthread_mutex_init(&splash->lock, NULL); 190 191 splash->maskRequired = 0; 192 439 void 440 sendctl(Splash * splash, char code) { 441 if (splash && splash->controlpipe[1]) { 442 write(splash->controlpipe[1], &code, 1); 443 } 444 } 445 446 void 447 SplashClosePlatform(Splash * splash) { 448 sendctl(splash, SPLASHCTL_QUIT); 449 } 450 451 void 452 SplashUpdate(Splash * splash) { 453 sendctl(splash, SPLASHCTL_UPDATE); 454 } 455 456 void 457 SplashReconfigure(Splash * splash) { 458 sendctl(splash, SPLASHCTL_RECONFIGURE); 459 } 460 | 142 return JNI_FALSE; 143 } 144 145 NSAutoreleasePool *pool = [NSAutoreleasePool new]; 146 __block float screenScaleFactor = 1; 147 148 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ 149 // initialize NSApplication and AWT stuff 150 [NSApplicationAWT sharedApplication]; 151 screenScaleFactor = [SplashNSScreen() backingScaleFactor]; 152 }]; 153 154 if (screenScaleFactor > 1) { 155 NSString *fileName = [NSString stringWithUTF8String: file]; 156 NSUInteger length = [fileName length]; 157 NSRange range = [fileName rangeOfString: @"." 158 options:NSBackwardsSearch]; 159 NSUInteger dotIndex = range.location; 160 NSString *fileName2x = nil; 161 162 fileName2x = findScaledImageName(fileName, dotIndex, @"@2x"); 163 if(![[NSFileManager defaultManager] 164 fileExistsAtPath: fileName2x]) { 165 fileName2x = findScaledImageName(fileName, dotIndex, @"@200pct"); 166 } 167 if (jar || [[NSFileManager defaultManager] 168 fileExistsAtPath: fileName2x]){ 169 if (strlen([fileName2x UTF8String]) > scaledImageLength) { 170 [pool drain]; 171 return JNI_FALSE; 172 } 173 *scaleFactor = 2; 174 strcpy(scaledFile, [fileName2x UTF8String]); 175 [pool drain]; 176 return JNI_TRUE; 177 } 178 } 179 [pool drain]; 180 return JNI_FALSE; 181 } 182 183 void 184 SplashInitPlatform(Splash * splash) { 185 pthread_mutex_init(&splash->lock, NULL); 186 187 splash->maskRequired = 0; 188 435 void 436 sendctl(Splash * splash, char code) { 437 if (splash && splash->controlpipe[1]) { 438 write(splash->controlpipe[1], &code, 1); 439 } 440 } 441 442 void 443 SplashClosePlatform(Splash * splash) { 444 sendctl(splash, SPLASHCTL_QUIT); 445 } 446 447 void 448 SplashUpdate(Splash * splash) { 449 sendctl(splash, SPLASHCTL_UPDATE); 450 } 451 452 void 453 SplashReconfigure(Splash * splash) { 454 sendctl(splash, SPLASHCTL_RECONFIGURE); 455 } 456 457 NSString* findScaledImageName(NSString *fileName, NSUInteger dotIndex, NSString *strToAppend) { 458 NSString *fileName2x = nil; 459 if (dotIndex == NSNotFound) { 460 fileName2x = [fileName stringByAppendingString: strToAppend]; 461 } else { 462 fileName2x = [fileName substringToIndex: dotIndex]; 463 fileName2x = [fileName2x stringByAppendingString: strToAppend]; 464 fileName2x = [fileName2x stringByAppendingString: 465 [fileName substringFromIndex: dotIndex]]; 466 } 467 return fileName2x; 468 } 469 |