From 81746a1798e8194c74dfa49fb53a328ec89a1153 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 4 Dec 2015 16:26:00 +0100 Subject: win32: remove dwmapi.dll dynamic loading All Windows versions we support have this API. --- video/out/opengl/w32.c | 39 +++++---------------------------------- wscript | 2 +- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/video/out/opengl/w32.c b/video/out/opengl/w32.c index 2525ccfc1f..05e2f5c4a3 100644 --- a/video/out/opengl/w32.c +++ b/video/out/opengl/w32.c @@ -36,13 +36,6 @@ struct w32_context { HGLRC context; HDC hdc; int flags; - - HINSTANCE dwmapi_dll; - HRESULT (WINAPI *pDwmFlush)(void); - HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *pfEnabled); - HRESULT (WINAPI *pDwmEnableMMCSS)(BOOL fEnableMMCSS); - HRESULT (WINAPI *pDwmGetCompositionTimingInfo) - (HWND hwnd, DWM_TIMING_INFO *pTimingInfo); }; static void w32_uninit(MPGLContext *ctx); @@ -228,17 +221,6 @@ static void create_ctx(void *ptr) if (!w32_ctx->context) create_context_w32_old(ctx); - w32_ctx->dwmapi_dll = LoadLibrary(L"Dwmapi.dll"); - if (w32_ctx->dwmapi_dll) { - w32_ctx->pDwmFlush = (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmFlush"); - w32_ctx->pDwmIsCompositionEnabled = - (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmIsCompositionEnabled"); - w32_ctx->pDwmGetCompositionTimingInfo = - (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmGetCompositionTimingInfo"); - w32_ctx->pDwmEnableMMCSS = - (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmEnableMMCSS"); - } - wglMakeCurrent(w32_ctx->hdc, NULL); } @@ -263,8 +245,7 @@ static int w32_init(struct MPGLContext *ctx, int flags) current_w32_context = w32_ctx; wglMakeCurrent(w32_ctx->hdc, w32_ctx->context); - if (w32_ctx->pDwmEnableMMCSS) - w32_ctx->pDwmEnableMMCSS(TRUE); + DwmEnableMMCSS(TRUE); return 0; fail: @@ -298,32 +279,22 @@ static void w32_uninit(MPGLContext *ctx) wglMakeCurrent(w32_ctx->hdc, 0); vo_w32_run_on_thread(ctx->vo, destroy_gl, ctx); - if (w32_ctx->pDwmEnableMMCSS) - w32_ctx->pDwmEnableMMCSS(FALSE); - - if (w32_ctx->dwmapi_dll) - FreeLibrary(w32_ctx->dwmapi_dll); - w32_ctx->dwmapi_dll = NULL; + DwmEnableMMCSS(FALSE); vo_w32_uninit(ctx->vo); } static bool compositor_active(MPGLContext *ctx) { - struct w32_context *w32_ctx = ctx->priv; - - if (!w32_ctx->pDwmIsCompositionEnabled || !w32_ctx->pDwmGetCompositionTimingInfo) - return false; - // For Windows 7. BOOL enabled = 0; - if (FAILED(w32_ctx->pDwmIsCompositionEnabled(&enabled)) || !enabled) + if (FAILED(DwmIsCompositionEnabled(&enabled)) || !enabled) return false; // This works at least on Windows 8.1: it returns an error in fullscreen, // which is also when we get consistent timings without DwmFlush. Might // be cargo-cult. DWM_TIMING_INFO info = { .cbSize = sizeof(DWM_TIMING_INFO) }; - if (FAILED(w32_ctx->pDwmGetCompositionTimingInfo(0, &info))) + if (FAILED(DwmGetCompositionTimingInfo(0, &info))) return false; // Test if a program is running in exclusive fullscreen mode. If so, it's @@ -347,7 +318,7 @@ static void w32_swap_buffers(MPGLContext *ctx) (ctx->dwm_flush_opt == 2) || (ctx->dwm_flush_opt == 0 && compositor_active(ctx))) { - if (w32_ctx->pDwmFlush && w32_ctx->pDwmFlush() == S_OK) + if (DwmFlush() == S_OK) new_swapinterval = 0; } } diff --git a/wscript b/wscript index 1873881b1a..bd2e69345d 100644 --- a/wscript +++ b/wscript @@ -135,7 +135,7 @@ main_dependencies = [ 'name': 'win32', 'desc': 'win32', 'deps_any': [ 'os-win32', 'os-cygwin' ], - 'func': check_cc(lib=['winmm', 'gdi32', 'ole32', 'uuid', 'avrt']), + 'func': check_cc(lib=['winmm', 'gdi32', 'ole32', 'uuid', 'avrt', 'dwmapi']), }, { 'name': '--win32-internal-pthreads', 'desc': 'internal pthread wrapper for win32 (Vista+)', -- cgit v1.2.3