Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win32: remove not needed compatibility code #14320

Merged
merged 9 commits into from
Sep 23, 2024
9 changes: 3 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -497,17 +497,15 @@ endif

features += {'win32-desktop': win32 and not uwp.found()}
if features['win32-desktop']
pathcch = cc.find_library('pathcch', required: false)
features += {'pathcch': pathcch.found()}
if features['pathcch']
dependencies += pathcch
endif
win32_desktop_libs = [cc.find_library('avrt'),
cc.find_library('dwmapi'),
cc.find_library('gdi32'),
cc.find_library('imm32'),
cc.find_library('ntdll'),
cc.find_library('ole32'),
cc.find_library('pathcch'),
cc.find_library('shcore'),
cc.find_library('user32'),
cc.find_library('uuid'),
cc.find_library('uxtheme'),
cc.find_library('version')]
Expand Down Expand Up @@ -1009,7 +1007,6 @@ if features['d3d11']
sources += files('video/out/d3d11/context.c',
'video/out/d3d11/ra_d3d11.c')
features += {'dxgi-debug-d3d11': cc.has_header_symbol('d3d11sdklayers.h', 'DXGI_DEBUG_D3D11')}
features += {'dxgi-debug': cc.has_header_symbol('dxgidebug.h', 'IID_IDXGIInfoQueue')}
endif

wayland = {
Expand Down
6 changes: 2 additions & 4 deletions misc/path_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "misc/ctype.h"
#include "misc/path_utils.h"

#if defined(HAVE_PATHCCH) && HAVE_PATHCCH
#if HAVE_DOS_PATHS
#include <windows.h>
#include <pathcch.h>
#endif
Expand Down Expand Up @@ -171,7 +171,7 @@ char *mp_normalize_path(void *talloc_ctx, const char *path)
path = mp_path_join(talloc_ctx, cwd, path);
}

#if defined(HAVE_PATHCCH) && HAVE_PATHCCH
#if HAVE_DOS_PATHS
wchar_t *pathw = mp_from_utf8(NULL, path);
wchar_t *read = pathw, *write = pathw;
wchar_t prev = '\0';
Expand All @@ -198,8 +198,6 @@ char *mp_normalize_path(void *talloc_ctx, const char *path)
talloc_free(pathw);
talloc_free(pathc);
return ret;
#elif HAVE_DOS_PATHS
return talloc_strdup(talloc_ctx, path);
#else
char *result = talloc_strdup(talloc_ctx, "");
const char *next;
Expand Down
4 changes: 0 additions & 4 deletions osdep/main-fn-win.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include <windows.h>
#include <shellapi.h>

#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE (0x0001)
#endif

#include "common/common.h"
#include "osdep/io.h"
#include "osdep/terminal.h"
Expand Down
9 changes: 0 additions & 9 deletions osdep/terminal-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
#include "osdep/threads.h"
#include "osdep/w32_keyboard.h"

// https://docs.microsoft.com/en-us/windows/console/setconsolemode
// These values are effective on Windows 10 build 16257 (August 2017) or later
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#ifndef DISABLE_NEWLINE_AUTO_RETURN
#define DISABLE_NEWLINE_AUTO_RETURN 0x0008
#endif

kasper93 marked this conversation as resolved.
Show resolved Hide resolved
// Note: the DISABLE_NEWLINE_AUTO_RETURN docs say it enables delayed-wrap, but
// it's wrong. It does only what its names suggests - and we want it unset:
// https://github.com/microsoft/terminal/issues/4126#issuecomment-571418661
Expand Down
5 changes: 0 additions & 5 deletions osdep/timer-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ void mp_sleep_ns(int64_t ns)
return;

int64_t hrt = mp_start_hires_timers(ns);

#ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x2
#endif

HANDLE timer = CreateWaitableTimerEx(NULL, NULL,
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION,
TIMER_ALL_ACCESS);
Expand Down
8 changes: 3 additions & 5 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ if not features['win32-threads']
endif

if features['win32-desktop']
test_utils_deps += cc.find_library('imm32')
test_utils_deps += cc.find_library('ntdll')
if features['pathcch']
test_utils_deps += cc.find_library('pathcch')
endif
test_utils_deps += [cc.find_library('imm32'),
cc.find_library('ntdll'),
cc.find_library('pathcch')]
endif
test_utils_objects = libmpv.extract_objects(test_utils_files)
test_utils = static_library('test-utils', 'test_utils.c', include_directories: incdir,
Expand Down
4 changes: 0 additions & 4 deletions test/paths.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ int main(void)
TEST_NORMALIZE("/foo", "/foo");
#endif

#if defined(_WIN32) && (!defined(HAVE_PATHCCH) || !HAVE_PATHCCH)
return 0;
#endif

void *ctx = talloc_new(NULL);
bstr dst = bstr0(mp_getcwd(ctx));
bstr_xappend(ctx, &dst, bstr0("/foo"));
Expand Down
8 changes: 0 additions & 8 deletions video/filter/vf_d3d11vpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
#include "video/mp_image.h"
#include "video/mp_image_pool.h"

// missing in MinGW
#define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BLEND 0x1
#define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_BOB 0x2
#define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE 0x4
#define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION 0x8
#define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_INVERSE_TELECINE 0x10
#define D3D11_VIDEO_PROCESSOR_PROCESSOR_CAPS_FRAME_RATE_CONVERSION 0x20

// For video procesor extensions identifiers reference see:
// https://chromium.googlesource.com/chromium/src/+/5f354f38/ui/gl/swap_chain_presenter.cc

Expand Down
12 changes: 0 additions & 12 deletions video/out/d3d11/ra_d3d11.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ struct ra_d3d11 {

struct dll_version d3d_compiler_ver;

#if HAVE_DXGI_DEBUG
// Debug interfaces (--gpu-debug)
IDXGIDebug *debug;
IDXGIInfoQueue *iqueue;
#endif

// Device capabilities
D3D_FEATURE_LEVEL fl;
Expand Down Expand Up @@ -2097,7 +2095,6 @@ static uint64_t timer_stop(struct ra *ra, ra_timer *ratimer)
return timer->result;
}

#if HAVE_DXGI_DEBUG
static int map_msg_severity(DXGI_INFO_QUEUE_MESSAGE_SEVERITY sev)
{
switch (sev) {
Expand Down Expand Up @@ -2172,11 +2169,9 @@ static int map_msg_severity_by_id(D3D11_MESSAGE_ID id,
return map_msg_severity(sev);
}
}
#endif

static void debug_marker(struct ra *ra, const char *msg)
{
#if HAVE_DXGI_DEBUG
struct ra_d3d11 *p = ra->priv;
void *talloc_ctx = talloc_new(NULL);
HRESULT hr;
Expand Down Expand Up @@ -2217,7 +2212,6 @@ static void debug_marker(struct ra *ra, const char *msg)
IDXGIInfoQueue_ClearStoredMessages(p->iqueue, DXGI_DEBUG_ALL);
done:
talloc_free(talloc_ctx);
#endif
}

static void destroy(struct ra *ra)
Expand Down Expand Up @@ -2248,7 +2242,6 @@ static void destroy(struct ra *ra)
}
SAFE_RELEASE(p->ctx);

#if HAVE_DXGI_DEBUG
if (p->debug) {
// Report any leaked objects
debug_marker(ra, "after destroy");
Expand All @@ -2259,7 +2252,6 @@ static void destroy(struct ra *ra)
}
SAFE_RELEASE(p->debug);
SAFE_RELEASE(p->iqueue);
#endif

talloc_free(ra);
}
Expand Down Expand Up @@ -2451,10 +2443,8 @@ struct ra *ra_d3d11_create(ID3D11Device *dev, struct mp_log *log,
p->max_uavs = D3D11_PS_CS_UAV_REGISTER_COUNT;
}

#if HAVE_DXGI_DEBUG
if (ID3D11Device_GetCreationFlags(p->dev) & D3D11_CREATE_DEVICE_DEBUG)
mp_d3d11_get_debug_interfaces(ra->log, &p->debug, &p->iqueue);
#endif

// Some level 9_x devices don't have timestamp queries
hr = ID3D11Device_CreateQuery(p->dev,
Expand All @@ -2468,11 +2458,9 @@ struct ra *ra_d3d11_create(ID3D11Device *dev, struct mp_log *log,
// https://msdn.microsoft.com/en-us/library/windows/desktop/ff476874.aspx
find_max_texture_dimension(ra);

#if HAVE_DXGI_DEBUG
// Ignore any messages during find_max_texture_dimension
if (p->iqueue)
IDXGIInfoQueue_ClearStoredMessages(p->iqueue, DXGI_DEBUG_ALL);
#endif

MP_VERBOSE(ra, "Maximum Texture2D size: %dx%d\n", ra->max_texture_wh,
ra->max_texture_wh);
Expand Down
2 changes: 0 additions & 2 deletions video/out/gpu/d3d11_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,6 @@ bool mp_get_dxgi_output_desc(IDXGISwapChain *swapchain, DXGI_OUTPUT_DESC1 *desc)
return ret;
}

#if HAVE_DXGI_DEBUG
void mp_d3d11_get_debug_interfaces(struct mp_log *log, IDXGIDebug **debug,
IDXGIInfoQueue **iqueue)
{
Expand Down Expand Up @@ -1038,4 +1037,3 @@ void mp_d3d11_get_debug_interfaces(struct mp_log *log, IDXGIDebug **debug,
return;
}
}
#endif
14 changes: 0 additions & 14 deletions video/out/gpu/d3d11_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,10 @@
#include <d3d11.h>
#include <dxgi1_2.h>
#include <dxgi1_6.h>

#if HAVE_DXGI_DEBUG
#include <dxgidebug.h>
#endif

#include "video/mp_image.h"

#define D3D_FEATURE_LEVEL_12_0 (0xc000)
#define D3D_FEATURE_LEVEL_12_1 (0xc100)

#define DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P709 ((DXGI_COLOR_SPACE_TYPE)20)
#define DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P2020 ((DXGI_COLOR_SPACE_TYPE)21)
#define DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709 ((DXGI_COLOR_SPACE_TYPE)22)
#define DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020 ((DXGI_COLOR_SPACE_TYPE)23)
#define DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020 ((DXGI_COLOR_SPACE_TYPE)24)

#if !HAVE_DXGI_DEBUG_D3D11
DEFINE_GUID(DXGI_DEBUG_D3D11, 0x4b99317b, 0xac39, 0x4aa6, 0xbb, 0xb, 0xba, 0xa0, 0x47, 0x84, 0x79, 0x8f);
#endif
Expand Down Expand Up @@ -117,9 +105,7 @@ bool mp_d3d11_create_swapchain(ID3D11Device *dev, struct mp_log *log,
struct d3d11_swapchain_opts *opts,
IDXGISwapChain **swapchain_out);

#if HAVE_DXGI_DEBUG
void mp_d3d11_get_debug_interfaces(struct mp_log *log, IDXGIDebug **debug,
IDXGIInfoQueue **iqueue);
#endif

#endif
5 changes: 0 additions & 5 deletions video/out/opengl/context_dxinterop.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)

// mingw-w64 header typo?
#ifndef IDirect3DSwapChain9Ex_GetBackBuffer
#define IDirect3DSwapChain9Ex_GetBackBuffer IDirect3DSwapChain9EX_GetBackBuffer
#endif

struct priv {
GL gl;

Expand Down
45 changes: 5 additions & 40 deletions video/out/w32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <dwmapi.h>
#include <ole2.h>
#include <process.h>
#include <shellscalingapi.h>
#include <shobjidl.h>
#include <avrt.h>

Expand Down Expand Up @@ -55,10 +56,6 @@
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)

#ifndef WM_DPICHANGED
#define WM_DPICHANGED (0x02E0)
#endif

#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
#endif
Expand All @@ -75,24 +72,12 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define DWMWA_SYSTEMBACKDROP_TYPE 38
#endif

#ifndef DPI_ENUMS_DECLARED
typedef enum MONITOR_DPI_TYPE {
MDT_EFFECTIVE_DPI = 0,
MDT_ANGULAR_DPI = 1,
MDT_RAW_DPI = 2,
MDT_DEFAULT = MDT_EFFECTIVE_DPI
} MONITOR_DPI_TYPE;
#endif

#define rect_w(r) ((r).right - (r).left)
#define rect_h(r) ((r).bottom - (r).top)

#define WM_SHOWMENU (WM_USER + 1)

struct w32_api {
HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*);
BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi);
int (WINAPI *pGetSystemMetricsForDpi)(int nIndex, UINT dpi);
BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void);
DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode);
};
Expand Down Expand Up @@ -207,23 +192,16 @@ struct vo_w32_state {

static inline int get_system_metrics(struct vo_w32_state *w32, int metric)
{
return w32->api.pGetSystemMetricsForDpi
? w32->api.pGetSystemMetricsForDpi(metric, w32->dpi)
: GetSystemMetrics(metric);
return GetSystemMetricsForDpi(metric, w32->dpi);
}

static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc)
{
if (!w32->opts->border && !IsMaximized(w32->window))
return;

if (w32->api.pAdjustWindowRectExForDpi) {
w32->api.pAdjustWindowRectExForDpi(rc,
GetWindowLongPtrW(hwnd, GWL_STYLE), 0,
GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi);
} else {
AdjustWindowRect(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0);
}
AdjustWindowRectExForDpi(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0,
GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi);
}

static bool check_windows10_build(DWORD build)
Expand Down Expand Up @@ -689,8 +667,7 @@ static void update_dpi(struct vo_w32_state *w32)
HDC hdc = NULL;
int dpi = 0;

if (w32->api.pGetDpiForMonitor && w32->api.pGetDpiForMonitor(w32->monitor,
MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) {
if (GetDpiForMonitor(w32->monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) {
dpi = (int)dpiX;
MP_VERBOSE(w32, "DPI detected from the new API: %d\n", dpi);
} else if ((hdc = GetDC(NULL))) {
Expand Down Expand Up @@ -1998,18 +1975,6 @@ void vo_w32_config(struct vo *vo)

static void w32_api_load(struct vo_w32_state *w32)
{
HMODULE shcore_dll = LoadLibraryW(L"shcore.dll");
// Available since Win8.1
w32->api.pGetDpiForMonitor = !shcore_dll ? NULL :
(void *)GetProcAddress(shcore_dll, "GetDpiForMonitor");

HMODULE user32_dll = LoadLibraryW(L"user32.dll");
// Available since Win10
w32->api.pAdjustWindowRectExForDpi = !user32_dll ? NULL :
(void *)GetProcAddress(user32_dll, "AdjustWindowRectExForDpi");
w32->api.pGetSystemMetricsForDpi = !user32_dll ? NULL :
(void *)GetProcAddress(user32_dll, "GetSystemMetricsForDpi");

// Dark mode related functions, available since the 1809 Windows 10 update
// Check the Windows build version as on previous versions used ordinals
// may point to unexpected code/data. Alternatively could check uxtheme.dll
Expand Down
Loading