summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-11-06 09:25:13 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-06 16:35:11 +0100
commit92cd94ed1d468554da9e3378a6ce5920b2cfc3c7 (patch)
tree1f4de01735f4f012dee03d0ad5069057ab3dd2a3 /src
parent15fc255c7c0a6a693c754734c39c37bd50b0634b (diff)
Dynamically resolve functions of dwmapi.dll.
The library is not present on Windows XP, for which /DELAYLOAD is used in ANGLE. However, as this causes problems with MinGW, use dynamic resolution. Task-number: QTBUG-27741 Change-Id: Ie4a2706d57b751fbb6fc6f3e76ef2e8ddac3b892 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/angle/src/libEGL/Surface.cpp39
-rw-r--r--src/angle/patches/0001-Dynamically-resolve-functions-of-dwmapi.dll.patch75
-rw-r--r--src/angle/src/libEGL/libEGL.pro5
3 files changed, 107 insertions, 12 deletions
diff --git a/src/3rdparty/angle/src/libEGL/Surface.cpp b/src/3rdparty/angle/src/libEGL/Surface.cpp
index 732c404b10..34df14cbb2 100644
--- a/src/3rdparty/angle/src/libEGL/Surface.cpp
+++ b/src/3rdparty/angle/src/libEGL/Surface.cpp
@@ -73,6 +73,9 @@ Surface::~Surface()
bool Surface::initialize()
{
+ typedef HRESULT (STDAPICALLTYPE *PtrDwmIsCompositionEnabled)(BOOL*);
+ typedef HRESULT (STDAPICALLTYPE *PtrDwmSetPresentParameters)(HWND, DWM_PRESENT_PARAMETERS *);
+
ASSERT(!mSwapChain && !mOffscreenTexture && !mDepthStencil);
if (!resetSwapChain())
@@ -82,17 +85,31 @@ bool Surface::initialize()
// to minimize the amount of queuing done by DWM between our calls to
// present and the actual screen.
if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) {
- BOOL isComposited;
- HRESULT result = DwmIsCompositionEnabled(&isComposited);
- if (SUCCEEDED(result) && isComposited) {
- DWM_PRESENT_PARAMETERS presentParams;
- memset(&presentParams, 0, sizeof(presentParams));
- presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
- presentParams.cBuffer = 2;
-
- result = DwmSetPresentParameters(mWindow, &presentParams);
- if (FAILED(result))
- ERR("Unable to set present parameters: 0x%08X", result);
+ // Resolve dwmapi.dll functions dynamically as the Library is
+ // not present on Windows XP. Alternatively, /DELAYLOAD could be used.
+ static PtrDwmIsCompositionEnabled dwmIsCompositionEnabled = 0;
+ static PtrDwmSetPresentParameters dwmSetPresentParameters = 0;
+ if (!dwmIsCompositionEnabled) {
+ if (const HMODULE dwmLibrary = LoadLibraryW(L"dwmapi.dll")) {
+ dwmIsCompositionEnabled =
+ (PtrDwmIsCompositionEnabled)GetProcAddress(dwmLibrary, "DwmIsCompositionEnabled");
+ dwmSetPresentParameters =
+ (PtrDwmSetPresentParameters)GetProcAddress(dwmLibrary, "DwmSetPresentParameters");
+ }
+ }
+ if (dwmIsCompositionEnabled && dwmSetPresentParameters) {
+ BOOL isComposited;
+ HRESULT result = dwmIsCompositionEnabled(&isComposited);
+ if (SUCCEEDED(result) && isComposited) {
+ DWM_PRESENT_PARAMETERS presentParams;
+ memset(&presentParams, 0, sizeof(presentParams));
+ presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
+ presentParams.cBuffer = 2;
+
+ result = dwmSetPresentParameters(mWindow, &presentParams);
+ if (FAILED(result))
+ ERR("Unable to set present parameters: 0x%08X", result);
+ }
}
}
diff --git a/src/angle/patches/0001-Dynamically-resolve-functions-of-dwmapi.dll.patch b/src/angle/patches/0001-Dynamically-resolve-functions-of-dwmapi.dll.patch
new file mode 100644
index 0000000000..f58cfe2d03
--- /dev/null
+++ b/src/angle/patches/0001-Dynamically-resolve-functions-of-dwmapi.dll.patch
@@ -0,0 +1,75 @@
+From a5ed22f7c9aa51eebbd3ec48904a4c0999dcced6 Mon Sep 17 00:00:00 2001
+From: Friedemann Kleint <Friedemann.Kleint@digia.com>
+Date: Tue, 6 Nov 2012 09:22:18 +0100
+Subject: [PATCH] Dynamically resolve functions of dwmapi.dll.
+
+The library is not present on Windows XP, for which /DELAYLOAD
+is used in ANGLE. However, as this causes problems with MinGW,
+use dynamic resolution.
+
+Task-number: QTBUG-27741
+Change-Id: I16214d6f98a184d89858c50ee5306371ea25469e
+---
+ src/3rdparty/angle/src/libEGL/Surface.cpp | 39 +++++++++++++++++++++--------
+ 1 file changed, 28 insertions(+), 11 deletions(-)
+
+diff --git a/src/3rdparty/angle/src/libEGL/Surface.cpp b/src/3rdparty/angle/src/libEGL/Surface.cpp
+index 732c404..34df14c 100644
+--- a/src/3rdparty/angle/src/libEGL/Surface.cpp
++++ b/src/3rdparty/angle/src/libEGL/Surface.cpp
+@@ -73,6 +73,9 @@ Surface::~Surface()
+
+ bool Surface::initialize()
+ {
++ typedef HRESULT (STDAPICALLTYPE *PtrDwmIsCompositionEnabled)(BOOL*);
++ typedef HRESULT (STDAPICALLTYPE *PtrDwmSetPresentParameters)(HWND, DWM_PRESENT_PARAMETERS *);
++
+ ASSERT(!mSwapChain && !mOffscreenTexture && !mDepthStencil);
+
+ if (!resetSwapChain())
+@@ -82,17 +85,31 @@ bool Surface::initialize()
+ // to minimize the amount of queuing done by DWM between our calls to
+ // present and the actual screen.
+ if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) {
+- BOOL isComposited;
+- HRESULT result = DwmIsCompositionEnabled(&isComposited);
+- if (SUCCEEDED(result) && isComposited) {
+- DWM_PRESENT_PARAMETERS presentParams;
+- memset(&presentParams, 0, sizeof(presentParams));
+- presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
+- presentParams.cBuffer = 2;
+-
+- result = DwmSetPresentParameters(mWindow, &presentParams);
+- if (FAILED(result))
+- ERR("Unable to set present parameters: 0x%08X", result);
++ // Resolve dwmapi.dll functions dynamically as the Library is
++ // not present on Windows XP. Alternatively, /DELAYLOAD could be used.
++ static PtrDwmIsCompositionEnabled dwmIsCompositionEnabled = 0;
++ static PtrDwmSetPresentParameters dwmSetPresentParameters = 0;
++ if (!dwmIsCompositionEnabled) {
++ if (const HMODULE dwmLibrary = LoadLibraryW(L"dwmapi.dll")) {
++ dwmIsCompositionEnabled =
++ (PtrDwmIsCompositionEnabled)GetProcAddress(dwmLibrary, "DwmIsCompositionEnabled");
++ dwmSetPresentParameters =
++ (PtrDwmSetPresentParameters)GetProcAddress(dwmLibrary, "DwmSetPresentParameters");
++ }
++ }
++ if (dwmIsCompositionEnabled && dwmSetPresentParameters) {
++ BOOL isComposited;
++ HRESULT result = dwmIsCompositionEnabled(&isComposited);
++ if (SUCCEEDED(result) && isComposited) {
++ DWM_PRESENT_PARAMETERS presentParams;
++ memset(&presentParams, 0, sizeof(presentParams));
++ presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
++ presentParams.cBuffer = 2;
++
++ result = dwmSetPresentParameters(mWindow, &presentParams);
++ if (FAILED(result))
++ ERR("Unable to set present parameters: 0x%08X", result);
++ }
+ }
+ }
+
+--
+1.7.10.msysgit.1
+
diff --git a/src/angle/src/libEGL/libEGL.pro b/src/angle/src/libEGL/libEGL.pro
index 845b1af0e9..82ca914f7e 100644
--- a/src/angle/src/libEGL/libEGL.pro
+++ b/src/angle/src/libEGL/libEGL.pro
@@ -3,7 +3,10 @@ TARGET = libEGL
include(../common/common.pri)
-LIBS += -ld3d9 -ldxguid -ldwmapi \
+# Note: ANGLE is patched to dynamically resolve DwmIsCompositionEnabled DwmSetPresentParameters
+# in Surface.cpp, which would otherwise require -ldwmapi, which does not exist on Windows XP
+# (QTBUG-27741).
+LIBS += -ld3d9 -ldxguid \
-L$$QT_BUILD_TREE/lib -llibGLESv2
HEADERS += \