diff options
author | wm4 <wm4@nowhere> | 2015-12-04 16:26:00 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-12-04 16:30:53 +0100 |
commit | 81746a1798e8194c74dfa49fb53a328ec89a1153 (patch) | |
tree | 27a461ada2edc4d01078d6e262ad8dc116ffc5b0 /video | |
parent | 01c418f9df79306fe24bedb5fda74f8186a7d832 (diff) | |
download | mpv-81746a1798e8194c74dfa49fb53a328ec89a1153.tar.bz2 mpv-81746a1798e8194c74dfa49fb53a328ec89a1153.tar.xz |
win32: remove dwmapi.dll dynamic loading
All Windows versions we support have this API.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/opengl/w32.c | 39 |
1 files changed, 5 insertions, 34 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; } } |