OpenJDK / amber / amber
changeset 59288:b7a958df3992
8234398: Replace ID2D1Factory::GetDesktopDpi with GetDeviceCaps
Reviewed-by: serb, prr
author | aivanov |
---|---|
date | Mon, 09 Dec 2019 19:43:44 +0000 |
parents | 434c10d551c7 |
children | aa0f481d0024 |
files | src/java.desktop/windows/native/common/awt/systemscale/systemScale.cpp |
diffstat | 1 files changed, 5 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.desktop/windows/native/common/awt/systemscale/systemScale.cpp Mon Dec 09 15:09:24 2019 +0530 +++ b/src/java.desktop/windows/native/common/awt/systemscale/systemScale.cpp Mon Dec 09 19:43:44 2019 +0000 @@ -23,7 +23,6 @@ * questions. */ #include "systemScale.h" -#include <d2d1.h> #include <jdk_util.h> #ifndef MDT_EFFECTIVE_DPI #define MDT_EFFECTIVE_DPI 0 @@ -52,9 +51,6 @@ return; } - typedef HRESULT(WINAPI D2D1CreateFactoryFunc) - (D2D1_FACTORY_TYPE, REFIID, - CONST D2D1_FACTORY_OPTIONS*, ID2D1Factory**); typedef HRESULT(WINAPI GetDpiForMonitorFunc)(HMONITOR, int, UINT*, UINT*); static HMODULE hLibSHCoreDll = NULL; static GetDpiForMonitorFunc *lpGetDpiForMonitor = NULL; @@ -75,30 +71,11 @@ *dpiY = static_cast<float>(y); } } else { - static HMODULE d2dDll = NULL; - static BOOL loadAttempted = FALSE; - static D2D1CreateFactoryFunc *lpD2D1CreateFactory = NULL; - if (!loadAttempted && d2dDll == NULL) { - loadAttempted = TRUE; - d2dDll = JDK_LoadSystemLibrary("d2d1.dll"); - } - if (d2dDll != NULL && lpD2D1CreateFactory == NULL) { - lpD2D1CreateFactory = (D2D1CreateFactoryFunc*)GetProcAddress( - d2dDll, "D2D1CreateFactory"); - } - if (lpD2D1CreateFactory != NULL) { - ID2D1Factory* m_pDirect2dFactory; - HRESULT res = lpD2D1CreateFactory - (D2D1_FACTORY_TYPE_SINGLE_THREADED, - __uuidof(ID2D1Factory), NULL, - &m_pDirect2dFactory); - if (res == S_OK) { -#pragma warning(push) -#pragma warning(disable : 4996) // GetDesktopDpi is deprecated. - m_pDirect2dFactory->GetDesktopDpi(dpiX, dpiY); -#pragma warning(pop) - m_pDirect2dFactory->Release(); - } + HDC hdc = GetDC(NULL); + if (hdc) { + *dpiX = static_cast<float>(GetDeviceCaps(hdc, LOGPIXELSX)); + *dpiY = static_cast<float>(GetDeviceCaps(hdc, LOGPIXELSY)); + ReleaseDC(NULL, hdc); } } return;