0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

win32: remove dwmapi.dll dynamic loading

All Windows versions we support have this API.
This commit is contained in:
wm4 2015-12-04 16:26:00 +01:00
parent 01c418f9df
commit 81746a1798
2 changed files with 6 additions and 35 deletions

View File

@ -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;
}
}

View File

@ -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+)',