diff options
author | Moonchild <moonchild@palemoon.org> | 2020-09-17 15:28:59 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-09-21 11:05:03 +0000 |
commit | e2e483ac47ae12c9d4151d7936d2f793fbc60620 (patch) | |
tree | afd9024a78030eb8e4680ad453b7d7ced0c5cdd2 | |
parent | 892a2d9655650616c361750a4d1a49f7d7914ad2 (diff) | |
download | UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar.gz UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar.lz UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.tar.xz UXP-e2e483ac47ae12c9d4151d7936d2f793fbc60620.zip |
Issue #1653 - Part 2: Stop indirectly loading DWM functions through WinUtils.
-rwxr-xr-x | gfx/thebes/gfxWindowsPlatform.cpp | 18 | ||||
-rw-r--r-- | toolkit/library/moz.build | 1 | ||||
-rw-r--r-- | widget/windows/TaskbarPreview.cpp | 14 | ||||
-rw-r--r-- | widget/windows/WinUtils.cpp | 31 | ||||
-rw-r--r-- | widget/windows/WinUtils.h | 25 | ||||
-rw-r--r-- | widget/windows/nsUXThemeData.cpp | 12 | ||||
-rw-r--r-- | widget/windows/nsWindow.cpp | 10 |
7 files changed, 25 insertions, 86 deletions
diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 82e36efe2..4a94a751b 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -39,8 +39,6 @@ #include "DeviceManagerD3D9.h" #include "mozilla/layers/ReadbackManagerD3D11.h" -#include "WinUtils.h" - #include "gfxDWriteFontList.h" #include "gfxDWriteFonts.h" #include "gfxDWriteCommon.h" @@ -59,6 +57,7 @@ #include "nsMemory.h" +#include <dwmapi.h> #include <d3d11.h> #include "nsIMemoryReporter.h" @@ -1633,10 +1632,9 @@ gfxWindowsPlatform::InitGPUProcessSupport() bool gfxWindowsPlatform::DwmCompositionEnabled() { - MOZ_ASSERT(WinUtils::dwmIsCompositionEnabledPtr); BOOL dwmEnabled = false; - if (FAILED(WinUtils::dwmIsCompositionEnabledPtr(&dwmEnabled))) { + if (FAILED(DwmIsCompositionEnabled(&dwmEnabled))) { return false; } @@ -1671,7 +1669,7 @@ public: DWM_TIMING_INFO vblankTime; // Make sure to init the cbSize, otherwise GetCompositionTiming will fail vblankTime.cbSize = sizeof(DWM_TIMING_INFO); - HRESULT hr = WinUtils::dwmGetCompositionTimingInfoPtr(0, &vblankTime); + HRESULT hr = DwmGetCompositionTimingInfo(0, &vblankTime); if (SUCCEEDED(hr)) { UNSIGNED_RATIO refreshRate = vblankTime.rateRefresh; // We get the rate in hertz / time, but we want the rate in ms. @@ -1756,7 +1754,7 @@ public: // Make sure to init the cbSize, otherwise // GetCompositionTiming will fail vblankTime.cbSize = sizeof(DWM_TIMING_INFO); - HRESULT hr = WinUtils::dwmGetCompositionTimingInfoPtr(0, &vblankTime); + HRESULT hr = DwmGetCompositionTimingInfo(0, &vblankTime); if (!SUCCEEDED(hr)) { return vsync; } @@ -1838,7 +1836,7 @@ public: // Using WaitForVBlank, the whole system dies because WaitForVBlank // only works if it's run on the same thread as the Present(); - HRESULT hr = WinUtils::dwmFlushProcPtr(); + HRESULT hr = DwmFlush(); if (!SUCCEEDED(hr)) { // DWMFlush isn't working, fallback to software vsync. ScheduleSoftwareVsync(TimeStamp::Now()); @@ -1918,13 +1916,9 @@ already_AddRefed<mozilla::gfx::VsyncSource> gfxWindowsPlatform::CreateHardwareVsyncSource() { MOZ_RELEASE_ASSERT(NS_IsMainThread(), "GFX: Not in main thread."); - if (!WinUtils::dwmIsCompositionEnabledPtr) { - NS_WARNING("Dwm composition not available, falling back to software vsync"); - return gfxPlatform::CreateHardwareVsyncSource(); - } BOOL dwmEnabled = false; - WinUtils::dwmIsCompositionEnabledPtr(&dwmEnabled); + DwmIsCompositionEnabled(&dwmEnabled); if (!dwmEnabled) { NS_WARNING("DWM not enabled, falling back to software vsync"); return gfxPlatform::CreateHardwareVsyncSource(); diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index d9b167547..9daef44a4 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -277,6 +277,7 @@ if CONFIG['OS_ARCH'] == 'WINNT': 'psapi', 'ws2_32', 'dbghelp', + 'dwmapi', 'rasapi32', 'rasdlg', 'iphlpapi', diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp index 6c15df2e0..b07b8039f 100644 --- a/widget/windows/TaskbarPreview.cpp +++ b/widget/windows/TaskbarPreview.cpp @@ -139,7 +139,7 @@ TaskbarPreview::Invalidate() { return NS_OK; HWND previewWindow = PreviewWindow(); - return FAILED(WinUtils::dwmInvalidateIconicBitmapsPtr(previewWindow)) + return FAILED(DwmInvalidateIconicBitmaps(previewWindow)) ? NS_ERROR_FAILURE : NS_OK; } @@ -284,13 +284,13 @@ TaskbarPreview::GetWindowHook() { void TaskbarPreview::EnableCustomDrawing(HWND aHWND, bool aEnable) { BOOL enabled = aEnable; - WinUtils::dwmSetWindowAttributePtr( + DwmSetWindowAttribute( aHWND, DWMWA_FORCE_ICONIC_REPRESENTATION, &enabled, sizeof(enabled)); - WinUtils::dwmSetWindowAttributePtr( + DwmSetWindowAttribute( aHWND, DWMWA_HAS_ICONIC_BITMAP, &enabled, @@ -385,11 +385,11 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) { POINT pptClient = { 0, 0 }; HRESULT hr; if (!mIsThumbnail) { - hr = WinUtils::dwmSetIconicLivePreviewBitmapPtr(mPreview->PreviewWindow(), - hBitmap, &pptClient, flags); + hr = DwmSetIconicLivePreviewBitmap(mPreview->PreviewWindow(), + hBitmap, &pptClient, flags); } else { - hr = WinUtils::dwmSetIconicThumbnailPtr(mPreview->PreviewWindow(), - hBitmap, flags); + hr = DwmSetIconicThumbnail(mPreview->PreviewWindow(), + hBitmap, flags); } MOZ_ASSERT(SUCCEEDED(hr)); return NS_OK; diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 6d9aab50d..28033193f 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -423,20 +423,6 @@ WinUtils::SHCreateItemFromParsingNamePtr WinUtils::sCreateItemFromParsingName = // on them during shutdown anyway. static const wchar_t kShellLibraryName[] = L"shell32.dll"; static HMODULE sShellDll = nullptr; -static const wchar_t kDwmLibraryName[] = L"dwmapi.dll"; -static HMODULE sDwmDll = nullptr; - -WinUtils::DwmExtendFrameIntoClientAreaProc WinUtils::dwmExtendFrameIntoClientAreaPtr = nullptr; -WinUtils::DwmIsCompositionEnabledProc WinUtils::dwmIsCompositionEnabledPtr = nullptr; -WinUtils::DwmSetIconicThumbnailProc WinUtils::dwmSetIconicThumbnailPtr = nullptr; -WinUtils::DwmSetIconicLivePreviewBitmapProc WinUtils::dwmSetIconicLivePreviewBitmapPtr = nullptr; -WinUtils::DwmGetWindowAttributeProc WinUtils::dwmGetWindowAttributePtr = nullptr; -WinUtils::DwmSetWindowAttributeProc WinUtils::dwmSetWindowAttributePtr = nullptr; -WinUtils::DwmInvalidateIconicBitmapsProc WinUtils::dwmInvalidateIconicBitmapsPtr = nullptr; -WinUtils::DwmDefWindowProcProc WinUtils::dwmDwmDefWindowProcPtr = nullptr; -WinUtils::DwmGetCompositionTimingInfoProc WinUtils::dwmGetCompositionTimingInfoPtr = nullptr; -WinUtils::DwmFlushProc WinUtils::dwmFlushProcPtr = nullptr; - // Prefix for path used by NT calls. const wchar_t kNTPrefix[] = L"\\??\\"; const size_t kNTPrefixLen = ArrayLength(kNTPrefix) - 1; @@ -460,23 +446,6 @@ static NtTestAlertPtr sNtTestAlert = nullptr; void WinUtils::Initialize() { - if (!sDwmDll) { - sDwmDll = ::LoadLibraryW(kDwmLibraryName); - - if (sDwmDll) { - dwmExtendFrameIntoClientAreaPtr = (DwmExtendFrameIntoClientAreaProc)::GetProcAddress(sDwmDll, "DwmExtendFrameIntoClientArea"); - dwmIsCompositionEnabledPtr = (DwmIsCompositionEnabledProc)::GetProcAddress(sDwmDll, "DwmIsCompositionEnabled"); - dwmSetIconicThumbnailPtr = (DwmSetIconicThumbnailProc)::GetProcAddress(sDwmDll, "DwmSetIconicThumbnail"); - dwmSetIconicLivePreviewBitmapPtr = (DwmSetIconicLivePreviewBitmapProc)::GetProcAddress(sDwmDll, "DwmSetIconicLivePreviewBitmap"); - dwmGetWindowAttributePtr = (DwmGetWindowAttributeProc)::GetProcAddress(sDwmDll, "DwmGetWindowAttribute"); - dwmSetWindowAttributePtr = (DwmSetWindowAttributeProc)::GetProcAddress(sDwmDll, "DwmSetWindowAttribute"); - dwmInvalidateIconicBitmapsPtr = (DwmInvalidateIconicBitmapsProc)::GetProcAddress(sDwmDll, "DwmInvalidateIconicBitmaps"); - dwmDwmDefWindowProcPtr = (DwmDefWindowProcProc)::GetProcAddress(sDwmDll, "DwmDefWindowProc"); - dwmGetCompositionTimingInfoPtr = (DwmGetCompositionTimingInfoProc)::GetProcAddress(sDwmDll, "DwmGetCompositionTimingInfo"); - dwmFlushProcPtr = (DwmFlushProc)::GetProcAddress(sDwmDll, "DwmFlush"); - } - } - if (IsWin10OrLater()) { HMODULE user32Dll = ::GetModuleHandleW(L"user32"); if (user32Dll) { diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 9aa2c1c8a..1281171be 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -470,31 +470,6 @@ public: */ static bool ResolveJunctionPointsAndSymLinks(std::wstring& aPath); - /** - * dwmapi.dll function typedefs and declarations - */ - typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset); - typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled); - typedef HRESULT (WINAPI*DwmSetIconicThumbnailProc)(HWND hWnd, HBITMAP hBitmap, DWORD dwSITFlags); - typedef HRESULT (WINAPI*DwmSetIconicLivePreviewBitmapProc)(HWND hWnd, HBITMAP hBitmap, POINT *pptClient, DWORD dwSITFlags); - typedef HRESULT (WINAPI*DwmGetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute); - typedef HRESULT (WINAPI*DwmSetWindowAttributeProc)(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute); - typedef HRESULT (WINAPI*DwmInvalidateIconicBitmapsProc)(HWND hWnd); - typedef HRESULT (WINAPI*DwmDefWindowProcProc)(HWND hWnd, UINT msg, LPARAM lParam, WPARAM wParam, LRESULT *aRetValue); - typedef HRESULT (WINAPI*DwmGetCompositionTimingInfoProc)(HWND hWnd, DWM_TIMING_INFO *info); - typedef HRESULT (WINAPI*DwmFlushProc)(void); - - static DwmExtendFrameIntoClientAreaProc dwmExtendFrameIntoClientAreaPtr; - static DwmIsCompositionEnabledProc dwmIsCompositionEnabledPtr; - static DwmSetIconicThumbnailProc dwmSetIconicThumbnailPtr; - static DwmSetIconicLivePreviewBitmapProc dwmSetIconicLivePreviewBitmapPtr; - static DwmGetWindowAttributeProc dwmGetWindowAttributePtr; - static DwmSetWindowAttributeProc dwmSetWindowAttributePtr; - static DwmInvalidateIconicBitmapsProc dwmInvalidateIconicBitmapsPtr; - static DwmDefWindowProcProc dwmDwmDefWindowProcPtr; - static DwmGetCompositionTimingInfoProc dwmGetCompositionTimingInfoPtr; - static DwmFlushProc dwmFlushProcPtr; - static void Initialize(); static bool ShouldHideScrollbars(); diff --git a/widget/windows/nsUXThemeData.cpp b/widget/windows/nsUXThemeData.cpp index 4d9ac9570..ce2777585 100644 --- a/widget/windows/nsUXThemeData.cpp +++ b/widget/windows/nsUXThemeData.cpp @@ -156,10 +156,10 @@ nsUXThemeData::UpdateTitlebarInfo(HWND aWnd) if (!sTitlebarInfoPopulatedAero && nsUXThemeData::CheckForCompositor()) { RECT captionButtons; - if (SUCCEEDED(WinUtils::dwmGetWindowAttributePtr(aWnd, - DWMWA_CAPTION_BUTTON_BOUNDS, - &captionButtons, - sizeof(captionButtons)))) { + if (SUCCEEDED(DwmGetWindowAttribute(aWnd, + DWMWA_CAPTION_BUTTON_BOUNDS, + &captionButtons, + sizeof(captionButtons)))) { sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx = captionButtons.right - captionButtons.left - 3; sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy = (captionButtons.bottom - captionButtons.top) - 1; sTitlebarInfoPopulatedAero = true; @@ -293,8 +293,8 @@ bool nsUXThemeData::IsHighContrastOn() bool nsUXThemeData::CheckForCompositor(bool aUpdateCache) { static BOOL sCachedValue = FALSE; - if (aUpdateCache && WinUtils::dwmIsCompositionEnabledPtr) { - WinUtils::dwmIsCompositionEnabledPtr(&sCachedValue); + if (aUpdateCache) { + DwmIsCompositionEnabled(&sCachedValue); } return sCachedValue; } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 122d18686..907d8b9a5 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -846,9 +846,9 @@ nsWindow::Create(nsIWidget* aParent, return NS_ERROR_FAILURE; } - if (mIsRTL && WinUtils::dwmSetWindowAttributePtr) { + if (mIsRTL) { DWORD dwAttribute = TRUE; - WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, sizeof dwAttribute); + DwmSetWindowAttribute(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, sizeof dwAttribute); } if (!IsPlugin() && @@ -3113,8 +3113,8 @@ void nsWindow::UpdateGlass() // Extends the window frame behind the client area if (nsUXThemeData::CheckForCompositor()) { - WinUtils::dwmExtendFrameIntoClientAreaPtr(mWnd, &margins); - WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NCRENDERING_POLICY, &policy, sizeof policy); + DwmExtendFrameIntoClientArea(mWnd, &margins); + DwmSetWindowAttribute(mWnd, DWMWA_NCRENDERING_POLICY, &policy, sizeof policy); } } #endif @@ -4961,7 +4961,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, /* We don't do this for win10 glass with a custom titlebar, * in order to avoid the caption buttons breaking. */ !(IsWin10OrLater() && HasGlass()) && - WinUtils::dwmDwmDefWindowProcPtr(mWnd, msg, wParam, lParam, &dwmHitResult)) { + DwmDefWindowProc(mWnd, msg, wParam, lParam, &dwmHitResult)) { *aRetValue = dwmHitResult; return true; } |