< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp

Print this page




 615  * Links this native object with its java Win32GraphicsDevice.
 616  * Need this link because the colorModel of the java device
 617  * may be updated from native code.
 618  */
 619 void AwtWin32GraphicsDevice::SetJavaDevice(JNIEnv *env, jobject objPtr)
 620 {
 621     javaDevice = env->NewWeakGlobalRef(objPtr);
 622 }
 623 
 624 /**
 625  * Sets horizontal and vertical scale factors
 626  */
 627 void AwtWin32GraphicsDevice::SetScale(float sx, float sy)
 628 {
 629     scaleX = sx;
 630     scaleY = sy;
 631 }
 632 
 633 int AwtWin32GraphicsDevice::ScaleUpX(int x)
 634 {
 635     return (int)ceil(x * scaleX);
 636 }
 637 
 638 int AwtWin32GraphicsDevice::ScaleUpY(int y)
 639 {
 640     return (int)ceil(y * scaleY);
 641 }
 642 
 643 int AwtWin32GraphicsDevice::ScaleDownX(int x)
 644 {
 645     return (int)ceil(x / scaleX);
 646 }
 647 
 648 int AwtWin32GraphicsDevice::ScaleDownY(int y)
 649 {
 650     return (int)ceil(y / scaleY);















 651 }
 652 
 653 void AwtWin32GraphicsDevice::InitDesktopScales()
 654 {
 655     float dpiX = -1.0f;
 656     float dpiY = -1.0f;
 657     GetScreenDpi(GetMonitor(), &dpiX, &dpiY);
 658     if (dpiX > 0 && dpiY > 0) {
 659         SetScale(dpiX / 96, dpiY / 96);
 660     }
 661 }
 662 
 663 float AwtWin32GraphicsDevice::GetScaleX()
 664 {
 665     return scaleX;
 666 }
 667 
 668 float AwtWin32GraphicsDevice::GetScaleY()
 669 {
 670     return scaleY;




 615  * Links this native object with its java Win32GraphicsDevice.
 616  * Need this link because the colorModel of the java device
 617  * may be updated from native code.
 618  */
 619 void AwtWin32GraphicsDevice::SetJavaDevice(JNIEnv *env, jobject objPtr)
 620 {
 621     javaDevice = env->NewWeakGlobalRef(objPtr);
 622 }
 623 
 624 /**
 625  * Sets horizontal and vertical scale factors
 626  */
 627 void AwtWin32GraphicsDevice::SetScale(float sx, float sy)
 628 {
 629     scaleX = sx;
 630     scaleY = sy;
 631 }
 632 
 633 int AwtWin32GraphicsDevice::ScaleUpX(int x)
 634 {
 635     return CheckIntLimits(x * scaleX);
 636 }
 637 
 638 int AwtWin32GraphicsDevice::ScaleUpY(int y)
 639 {
 640     return CheckIntLimits(y * scaleY);
 641 }
 642 
 643 int AwtWin32GraphicsDevice::ScaleDownX(int x)
 644 {
 645     return CheckIntLimits(x / scaleX);
 646 }
 647 
 648 int AwtWin32GraphicsDevice::ScaleDownY(int y)
 649 {
 650     return CheckIntLimits(y / scaleY);
 651 }
 652 
 653 int AwtWin32GraphicsDevice::CheckIntLimits(double value)
 654 {
 655     if (value < INT_MIN)
 656     {
 657         return INT_MIN;
 658     }
 659 
 660     if (value > INT_MAX)
 661     {
 662         return INT_MAX;
 663     }
 664 
 665     return (int)ceil(value);
 666 }
 667 
 668 void AwtWin32GraphicsDevice::InitDesktopScales()
 669 {
 670     float dpiX = -1.0f;
 671     float dpiY = -1.0f;
 672     GetScreenDpi(GetMonitor(), &dpiX, &dpiY);
 673     if (dpiX > 0 && dpiY > 0) {
 674         SetScale(dpiX / 96, dpiY / 96);
 675     }
 676 }
 677 
 678 float AwtWin32GraphicsDevice::GetScaleX()
 679 {
 680     return scaleX;
 681 }
 682 
 683 float AwtWin32GraphicsDevice::GetScaleY()
 684 {
 685     return scaleY;


< prev index next >