src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
Print this page
@@ -123,10 +123,43 @@
done:
setlocale(LC_ALL, old_locale);
return buf;
}
+char* SplashGetScaledImageName(const char* jar, const char* file,
+ float *scaleFactor) {
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ *scaleFactor = 1;
+ char* scaledFile = nil;
+ float screenScaleFactor = [SplashNSScreen() backingScaleFactor];
+
+ if (screenScaleFactor > 1) {
+ NSString *fileName = [NSString stringWithUTF8String: file];
+ NSUInteger length = [fileName length];
+ NSRange range = [fileName rangeOfString: @"."
+ options:NSBackwardsSearch];
+ NSUInteger dotIndex = range.location;
+ NSString *fileName2x = nil;
+
+ if (dotIndex == NSNotFound) {
+ fileName2x = [fileName stringByAppendingString: @"@2x"];
+ } else {
+ fileName2x = [fileName substringToIndex: dotIndex];
+ fileName2x = [fileName2x stringByAppendingString: @"@2x"];
+ fileName2x = [fileName2x stringByAppendingString:
+ [fileName substringFromIndex: dotIndex]];
+ }
+
+ if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager]
+ fileExistsAtPath: fileName2x])){
+ *scaleFactor = 2;
+ scaledFile = strdup([fileName2x UTF8String]);
+ }
+ }
+ [pool drain];
+ return scaledFile;
+}
void
SplashInitPlatform(Splash * splash) {
pthread_mutex_init(&splash->lock, NULL);
@@ -223,10 +256,18 @@
NSImage * image = [[NSImage alloc]
initWithSize: NSMakeSize(splash->width, splash->height)];
[image setBackgroundColor: [NSColor clearColor]];
[image addRepresentation: rep];
+ float scaleFactor = splash->scaleFactor;
+ if (0 < scaleFactor && scaleFactor != 1) {
+ [image setScalesWhenResized:YES];
+ NSSize size = [image size];
+ size.width /= scaleFactor;
+ size.height /= scaleFactor;
+ [image setSize: size];
+ }
NSImageView * view = [[NSImageView alloc] init];
[view setImage: image];
[view setEditable: NO];