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:
parent
01c418f9df
commit
81746a1798
@ -36,13 +36,6 @@ struct w32_context {
|
|||||||
HGLRC context;
|
HGLRC context;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
int flags;
|
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);
|
static void w32_uninit(MPGLContext *ctx);
|
||||||
@ -228,17 +221,6 @@ static void create_ctx(void *ptr)
|
|||||||
if (!w32_ctx->context)
|
if (!w32_ctx->context)
|
||||||
create_context_w32_old(ctx);
|
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);
|
wglMakeCurrent(w32_ctx->hdc, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +245,7 @@ static int w32_init(struct MPGLContext *ctx, int flags)
|
|||||||
|
|
||||||
current_w32_context = w32_ctx;
|
current_w32_context = w32_ctx;
|
||||||
wglMakeCurrent(w32_ctx->hdc, w32_ctx->context);
|
wglMakeCurrent(w32_ctx->hdc, w32_ctx->context);
|
||||||
if (w32_ctx->pDwmEnableMMCSS)
|
DwmEnableMMCSS(TRUE);
|
||||||
w32_ctx->pDwmEnableMMCSS(TRUE);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
@ -298,32 +279,22 @@ static void w32_uninit(MPGLContext *ctx)
|
|||||||
wglMakeCurrent(w32_ctx->hdc, 0);
|
wglMakeCurrent(w32_ctx->hdc, 0);
|
||||||
vo_w32_run_on_thread(ctx->vo, destroy_gl, ctx);
|
vo_w32_run_on_thread(ctx->vo, destroy_gl, ctx);
|
||||||
|
|
||||||
if (w32_ctx->pDwmEnableMMCSS)
|
DwmEnableMMCSS(FALSE);
|
||||||
w32_ctx->pDwmEnableMMCSS(FALSE);
|
|
||||||
|
|
||||||
if (w32_ctx->dwmapi_dll)
|
|
||||||
FreeLibrary(w32_ctx->dwmapi_dll);
|
|
||||||
w32_ctx->dwmapi_dll = NULL;
|
|
||||||
vo_w32_uninit(ctx->vo);
|
vo_w32_uninit(ctx->vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compositor_active(MPGLContext *ctx)
|
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.
|
// For Windows 7.
|
||||||
BOOL enabled = 0;
|
BOOL enabled = 0;
|
||||||
if (FAILED(w32_ctx->pDwmIsCompositionEnabled(&enabled)) || !enabled)
|
if (FAILED(DwmIsCompositionEnabled(&enabled)) || !enabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// This works at least on Windows 8.1: it returns an error in fullscreen,
|
// 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
|
// which is also when we get consistent timings without DwmFlush. Might
|
||||||
// be cargo-cult.
|
// be cargo-cult.
|
||||||
DWM_TIMING_INFO info = { .cbSize = sizeof(DWM_TIMING_INFO) };
|
DWM_TIMING_INFO info = { .cbSize = sizeof(DWM_TIMING_INFO) };
|
||||||
if (FAILED(w32_ctx->pDwmGetCompositionTimingInfo(0, &info)))
|
if (FAILED(DwmGetCompositionTimingInfo(0, &info)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Test if a program is running in exclusive fullscreen mode. If so, it's
|
// 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 == 2) ||
|
||||||
(ctx->dwm_flush_opt == 0 && compositor_active(ctx)))
|
(ctx->dwm_flush_opt == 0 && compositor_active(ctx)))
|
||||||
{
|
{
|
||||||
if (w32_ctx->pDwmFlush && w32_ctx->pDwmFlush() == S_OK)
|
if (DwmFlush() == S_OK)
|
||||||
new_swapinterval = 0;
|
new_swapinterval = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
wscript
2
wscript
@ -135,7 +135,7 @@ main_dependencies = [
|
|||||||
'name': 'win32',
|
'name': 'win32',
|
||||||
'desc': 'win32',
|
'desc': 'win32',
|
||||||
'deps_any': [ 'os-win32', 'os-cygwin' ],
|
'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',
|
'name': '--win32-internal-pthreads',
|
||||||
'desc': 'internal pthread wrapper for win32 (Vista+)',
|
'desc': 'internal pthread wrapper for win32 (Vista+)',
|
||||||
|
Loading…
Reference in New Issue
Block a user