8158411: Regression on Swingmark on 8u102 b03 comparing 8u102 b02 on several configs on win32

Reviewed-by: prr, ssadetsky
This commit is contained in:
Alexander Scherbatiy 2016-09-01 12:02:22 +03:00
parent 252779d212
commit 6d5b6597cd
2 changed files with 19 additions and 10 deletions

View File

@ -753,10 +753,15 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPosition
}
void rescale(SIZE *size) {
HWND hWnd = ::GetDesktopWindow();
HDC hDC = ::GetDC(hWnd);
int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
static int dpiX = -1;
static int dpiY = -1;
if (dpiX == -1 || dpiY == -1) {
HWND hWnd = ::GetDesktopWindow();
HDC hDC = ::GetDC(hWnd);
dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hWnd, hDC);
}
if (dpiX !=0 && dpiX != 96) {
float invScaleX = 96.0f / dpiX;
@ -766,7 +771,6 @@ void rescale(SIZE *size) {
float invScaleY = 96.0f / dpiY;
size->cy = ROUND_TO_INT(size->cy * invScaleY);
}
::ReleaseDC(hWnd, hDC);
}
/*

View File

@ -88,11 +88,16 @@ void AwtDesktopProperties::GetWindowsParameters() {
}
void getInvScale(float &invScaleX, float &invScaleY) {
HWND hWnd = ::GetDesktopWindow();
HDC hDC = ::GetDC(hWnd);
int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hWnd, hDC);
static int dpiX = -1;
static int dpiY = -1;
if (dpiX == -1 || dpiY == -1) {
HWND hWnd = ::GetDesktopWindow();
HDC hDC = ::GetDC(hWnd);
dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hWnd, hDC);
}
invScaleX = (dpiX == 0.0f) ? 1.0f : 96.0f / dpiX;
invScaleY = (dpiY == 0.0f) ? 1.0f : 96.0f / dpiY;
}