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

Print this page




  28 #import <Cocoa/Cocoa.h>
  29 #import <objc/objc-auto.h>
  30 
  31 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  32 #import "NSApplicationAWT.h"
  33 
  34 #include <sys/time.h>
  35 #include <pthread.h>
  36 #include <iconv.h>
  37 #include <langinfo.h>
  38 #include <locale.h>
  39 #include <fcntl.h>
  40 #include <poll.h>
  41 #include <errno.h>
  42 #include <sys/types.h>
  43 #include <signal.h>
  44 #include <unistd.h>
  45 #include <dlfcn.h>
  46 
  47 #include <sizecalc.h>

  48 
  49 static NSScreen* SplashNSScreen()
  50 {
  51     return [[NSScreen screens] objectAtIndex: 0];
  52 }
  53 
  54 static void SplashCenter(Splash * splash)
  55 {
  56     NSRect screenFrame = [SplashNSScreen() frame];
  57 
  58     splash->x = (screenFrame.size.width - splash->width) / 2;
  59     splash->y = (screenFrame.size.height - splash->height) / 2 + screenFrame.origin.y;
  60 }
  61 
  62 unsigned
  63 SplashTime(void) {
  64     struct timeval tv;
  65     struct timezone tz;
  66     unsigned long long msec;
  67 


 113     iconv_close(cd);
 114 
 115     if (rc == (size_t)-1) {
 116         free(buf);
 117         buf = NULL;
 118     } else {
 119         if (size) {
 120             *size = (bufSize-outSize)/2; /* bytes to wchars */
 121         }
 122     }
 123 done:
 124     setlocale(LC_ALL, old_locale);
 125     return buf;
 126 }
 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])){




  28 #import <Cocoa/Cocoa.h>
  29 #import <objc/objc-auto.h>
  30 
  31 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  32 #import "NSApplicationAWT.h"
  33 
  34 #include <sys/time.h>
  35 #include <pthread.h>
  36 #include <iconv.h>
  37 #include <langinfo.h>
  38 #include <locale.h>
  39 #include <fcntl.h>
  40 #include <poll.h>
  41 #include <errno.h>
  42 #include <sys/types.h>
  43 #include <signal.h>
  44 #include <unistd.h>
  45 #include <dlfcn.h>
  46 
  47 #include <sizecalc.h>
  48 #import "ThreadUtilities.h"
  49 
  50 static NSScreen* SplashNSScreen()
  51 {
  52     return [[NSScreen screens] objectAtIndex: 0];
  53 }
  54 
  55 static void SplashCenter(Splash * splash)
  56 {
  57     NSRect screenFrame = [SplashNSScreen() frame];
  58 
  59     splash->x = (screenFrame.size.width - splash->width) / 2;
  60     splash->y = (screenFrame.size.height - splash->height) / 2 + screenFrame.origin.y;
  61 }
  62 
  63 unsigned
  64 SplashTime(void) {
  65     struct timeval tv;
  66     struct timezone tz;
  67     unsigned long long msec;
  68 


 114     iconv_close(cd);
 115 
 116     if (rc == (size_t)-1) {
 117         free(buf);
 118         buf = NULL;
 119     } else {
 120         if (size) {
 121             *size = (bufSize-outSize)/2; /* bytes to wchars */
 122         }
 123     }
 124 done:
 125     setlocale(LC_ALL, old_locale);
 126     return buf;
 127 }
 128 
 129 char* SplashGetScaledImageName(const char* jar, const char* file,
 130                                float *scaleFactor) {
 131     NSAutoreleasePool *pool = [NSAutoreleasePool new];
 132     *scaleFactor = 1;
 133     char* scaledFile = nil;
 134     __block float screenScaleFactor = 1;
 135 
 136     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 137         screenScaleFactor = [SplashNSScreen() backingScaleFactor];
 138     }];
 139 
 140     if (screenScaleFactor > 1) {
 141         NSString *fileName = [NSString stringWithUTF8String: file];
 142         NSUInteger length = [fileName length];
 143         NSRange range = [fileName rangeOfString: @"."
 144                                         options:NSBackwardsSearch];
 145         NSUInteger dotIndex = range.location;
 146         NSString *fileName2x = nil;
 147         
 148         if (dotIndex == NSNotFound) {
 149             fileName2x = [fileName stringByAppendingString: @"@2x"];
 150         } else {
 151             fileName2x = [fileName substringToIndex: dotIndex];
 152             fileName2x = [fileName2x stringByAppendingString: @"@2x"];
 153             fileName2x = [fileName2x stringByAppendingString:
 154                           [fileName substringFromIndex: dotIndex]];
 155         }
 156         
 157         if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager]
 158                     fileExistsAtPath: fileName2x])){