< prev index next >

src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c

Print this page




 785 void
 786 SplashClosePlatform(Splash * splash) {
 787     sendctl(splash, SPLASHCTL_QUIT);
 788 }
 789 
 790 void
 791 SplashUpdate(Splash * splash) {
 792     sendctl(splash, SPLASHCTL_UPDATE);
 793 }
 794 
 795 void
 796 SplashReconfigure(Splash * splash) {
 797     sendctl(splash, SPLASHCTL_RECONFIGURE);
 798 }
 799 
 800 SPLASHEXPORT char*
 801 SplashGetScaledImageName(const char* jarName, const char* fileName,
 802                            float *scaleFactor)
 803 {
 804     *scaleFactor = 1;

 805     return NULL;



















































 806 }


 785 void
 786 SplashClosePlatform(Splash * splash) {
 787     sendctl(splash, SPLASHCTL_QUIT);
 788 }
 789 
 790 void
 791 SplashUpdate(Splash * splash) {
 792     sendctl(splash, SPLASHCTL_UPDATE);
 793 }
 794 
 795 void
 796 SplashReconfigure(Splash * splash) {
 797     sendctl(splash, SPLASHCTL_RECONFIGURE);
 798 }
 799 
 800 SPLASHEXPORT char*
 801 SplashGetScaledImageName(const char* jarName, const char* fileName,
 802                            float *scaleFactor)
 803 {
 804     *scaleFactor = 1;
 805 #ifndef __linux__
 806     return NULL;
 807 #endif
 808     *scaleFactor = getNativeScaleFactor();
 809     if (*scaleFactor == 2.0) {
 810         char *scaledImgName = NULL;
 811         size_t length = 0;
 812         char *stringToAppend = ".java-scale2x";
 813         char *dupFileName = strdup(fileName);
 814         char *fileExtension = strrchr(dupFileName, '.');
 815         
 816         if (fileExtension == NULL) {
 817             length = strlen(dupFileName) + strlen(stringToAppend) + 1;
 818             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
 819             snprintf(scaledImgName, length, "%s%s",
 820                     dupFileName, stringToAppend);
 821         } else {
 822             length = fileExtension - dupFileName + 1;
 823             char *fileNameWithoutExt = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
 824             memcpy(fileNameWithoutExt, dupFileName, length);
 825             fileNameWithoutExt[length - 1] = '\0';
 826             length = strlen(fileNameWithoutExt) + 
 827                     strlen(stringToAppend) + strlen(fileExtension) + 1;
 828             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
 829             snprintf(scaledImgName, length, "%s%s%s", 
 830                     fileNameWithoutExt, stringToAppend, fileExtension);
 831             free(fileNameWithoutExt);
 832         }
 833         free(dupFileName);
 834         FILE *fp;
 835         if (!(fp = fopen(scaledImgName, "r"))) {
 836             *scaleFactor = 1;
 837             free(scaledImgName);
 838             return NULL;
 839         }
 840         fclose(fp);
 841         SplashSetScaleFactor(*scaleFactor);
 842         return scaledImgName;
 843     }
 844     return NULL;
 845 }
 846 
 847 float getNativeScaleFactor()
 848 {
 849     float scaleFactor = 1.0f;
 850     char *scale = getenv("GDK_SCALE");
 851     if (scale != NULL) {
 852         scaleFactor = strtof(scale, NULL);
 853         if (scaleFactor == 0 || scaleFactor < 1) {
 854             scaleFactor = 1.0f;
 855         }
 856     }
 857     return scaleFactor;
 858 }
< prev index next >