src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m

Print this page

        

*** 123,132 **** --- 123,162 ---- done: setlocale(LC_ALL, old_locale); return buf; } + char* SplashGetScaledImageName(const char* jar, const char* file, + float *scaleFactor) { + NSString *fileName = [[[NSString alloc] initWithUTF8String: file] + autorelease]; + NSUInteger length = [fileName length]; + *scaleFactor = 1; + float screenScaleFactor = [[NSScreen mainScreen] backingScaleFactor]; + + if (1 < screenScaleFactor) { + NSRange range = [fileName rangeOfString: @"." + options:NSBackwardsSearch]; + int index = range.location; + + if (index != NSNotFound && index != 0 && index != length-1) { + NSString *fileName2x = [fileName substringToIndex: index]; + fileName2x = [fileName2x stringByAppendingString: @"@2x"]; + fileName2x = [fileName2x stringByAppendingString: + [fileName substringFromIndex: index]]; + + if (!jar && ![[NSFileManager defaultManager] + fileExistsAtPath: fileName2x]){ + return nil; + } + + *scaleFactor = 2; + return strdup([fileName2x UTF8String]); + } + } + return nil; + } void SplashInitPlatform(Splash * splash) { pthread_mutex_init(&splash->lock, NULL);
*** 223,232 **** --- 253,270 ---- NSImage * image = [[NSImage alloc] initWithSize: NSMakeSize(splash->width, splash->height)]; [image setBackgroundColor: [NSColor clearColor]]; [image addRepresentation: rep]; + float scaleFactor = splash->scaleFactor; + if (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];