8158411: Regression on Swingmark on 8u102 b03 comparing 8u102 b02 on several configs on win32
Reviewed-by: prr, ssadetsky
--- a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Thu Sep 01 10:21:29 2016 +0530
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Thu Sep 01 12:02:22 2016 +0300
@@ -753,10 +753,15 @@
}
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 @@
float invScaleY = 96.0f / dpiY;
size->cy = ROUND_TO_INT(size->cy * invScaleY);
}
- ::ReleaseDC(hWnd, hDC);
}
/*
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp Thu Sep 01 10:21:29 2016 +0530
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp Thu Sep 01 12:02:22 2016 +0300
@@ -88,11 +88,16 @@
}
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;
}