518 {
519 MSG msg;
520
521 while (GetMessage(&msg, NULL, 0, 0)) {
522 TranslateMessage(&msg);
523 DispatchMessage(&msg);
524 }
525 }
526
527 DWORD WINAPI
528 SplashScreenThread(LPVOID param)
529 {
530 Splash *splash = (Splash *) param;
531
532 splash->currentFrame = 0;
533 SplashLock(splash);
534 splash->time = SplashTime();
535 splash->hWnd = SplashCreateWindow(splash);
536 if (splash->hWnd) {
537 SplashRedrawWindow(splash);
538 SplashUnlock(splash);
539 SplashMessagePump();
540 SplashLock(splash);
541 }
542 SplashDone(splash);
543 splash->isVisible = -1;
544 SplashUnlock(splash);
545 return 0;
546 }
547
548 void
549 SplashCreateThread(Splash * splash)
550 {
551 DWORD threadId;
552
553 CreateThread(NULL, 0, SplashScreenThread, (LPVOID) splash, 0, &threadId);
554 }
555
556 void
557 SplashClosePlatform(Splash * splash)
565 PostMessage(splash->hWnd, WM_SPLASHUPDATE, 0, 0);
566 }
567
568 void
569 SplashReconfigure(Splash * splash)
570 {
571 PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0);
572 }
573
574 jboolean
575 SplashGetScaledImageName(const char* jarName, const char* fileName,
576 float *scaleFactor, char *scaleImageName,
577 const size_t scaledImageLength)
578 {
579 float dpiScaleX = -1.0f;
580 float dpiScaleY = -1.0f;
581 FILE *fp = NULL;
582 *scaleFactor = 1.0;
583 GetScreenDpi(getPrimaryMonitor(), &dpiScaleX, &dpiScaleY);
584 *scaleFactor = dpiScaleX > 0 ? dpiScaleX / 96 : *scaleFactor;
585 if (*scaleFactor > 1.0) {
586 char strDpi[BUFF_SIZE];
587 char *dupFileName = strdup(fileName);
588 char *fileExtension = strrchr(dupFileName, '.');
589 char *nameToAppend = ".scale-";
590 size_t length = 0;
591 int retVal = 0;
592 _snprintf(strDpi, BUFF_SIZE, "%d", (int)dpiScaleX);
593 /*File is missing extension */
594 if (fileExtension == NULL) {
595 length = strlen(dupFileName) + strlen(nameToAppend) +
596 strlen(strDpi) + 1;
597 if (length > scaledImageLength) {
598 *scaleFactor = 1;
599 free(dupFileName);
600 return JNI_FALSE;
601 }
602 retVal = _snprintf(scaleImageName, length, "%s%s%s", dupFileName,
603 nameToAppend, strDpi);
604 if (retVal < 0 || (retVal != length - 1)) {
605 *scaleFactor = 1;
606 free(dupFileName);
607 return JNI_FALSE;
608 }
609 }
610 else {
611 size_t length_Without_Ext = fileExtension - dupFileName;
612 length = length_Without_Ext + strlen(nameToAppend) + strlen(strDpi) +
613 strlen(fileExtension) + 1;
614 if (length > scaledImageLength) {
615 *scaleFactor = 1;
616 free(dupFileName);
617 return JNI_FALSE;
618 }
619 retVal = _snprintf(scaleImageName, length, "%.*s%s%s%s",
620 length_Without_Ext, dupFileName, nameToAppend, strDpi, fileExtension);
621 if (retVal < 0 || (retVal != length - 1)) {
622 *scaleFactor = 1;
623 free(dupFileName);
624 return JNI_FALSE;
625 }
626 }
627 free(dupFileName);
628 if (!(fp = fopen(scaleImageName, "r"))) {
629 *scaleFactor = 1;
630 return JNI_FALSE;
631 }
632 fclose(fp);
633 return JNI_TRUE;
634 }
635 return JNI_FALSE;
636 }
|
518 {
519 MSG msg;
520
521 while (GetMessage(&msg, NULL, 0, 0)) {
522 TranslateMessage(&msg);
523 DispatchMessage(&msg);
524 }
525 }
526
527 DWORD WINAPI
528 SplashScreenThread(LPVOID param)
529 {
530 Splash *splash = (Splash *) param;
531
532 splash->currentFrame = 0;
533 SplashLock(splash);
534 splash->time = SplashTime();
535 splash->hWnd = SplashCreateWindow(splash);
536 if (splash->hWnd) {
537 SplashRedrawWindow(splash);
538 //map the splash co-ordinates as per system scale
539 splash->x /= splash->scaleFactor;
540 splash->y /= splash->scaleFactor;
541 SplashUnlock(splash);
542 SplashMessagePump();
543 SplashLock(splash);
544 }
545 SplashDone(splash);
546 splash->isVisible = -1;
547 SplashUnlock(splash);
548 return 0;
549 }
550
551 void
552 SplashCreateThread(Splash * splash)
553 {
554 DWORD threadId;
555
556 CreateThread(NULL, 0, SplashScreenThread, (LPVOID) splash, 0, &threadId);
557 }
558
559 void
560 SplashClosePlatform(Splash * splash)
568 PostMessage(splash->hWnd, WM_SPLASHUPDATE, 0, 0);
569 }
570
571 void
572 SplashReconfigure(Splash * splash)
573 {
574 PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0);
575 }
576
577 jboolean
578 SplashGetScaledImageName(const char* jarName, const char* fileName,
579 float *scaleFactor, char *scaleImageName,
580 const size_t scaledImageLength)
581 {
582 float dpiScaleX = -1.0f;
583 float dpiScaleY = -1.0f;
584 FILE *fp = NULL;
585 *scaleFactor = 1.0;
586 GetScreenDpi(getPrimaryMonitor(), &dpiScaleX, &dpiScaleY);
587 *scaleFactor = dpiScaleX > 0 ? dpiScaleX / 96 : *scaleFactor;
588 return GetScaledImageName(fileName, scaleImageName,
589 scaleFactor, scaledImageLength);
590
591 }
592
|