diff --git a/dlls/d2d1/Makefile.in b/dlls/d2d1/Makefile.in index 51b96270478..20d3f26f6fa 100644 --- a/dlls/d2d1/Makefile.in +++ b/dlls/d2d1/Makefile.in @@ -1,6 +1,6 @@ MODULE = d2d1.dll IMPORTLIB = d2d1 -IMPORTS = d3d10_1 dxguid uuid gdi32 user32 +IMPORTS = d3d10_1 dxguid uuid gdi32 user32 advapi32 DELAYIMPORTS = dwrite C_SRCS = \ diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 3b21bc1fb67..f876cbf40d6 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -52,6 +52,12 @@ enum d2d_shape_type D2D_SHAPE_TYPE_COUNT, }; +struct d2d_settings +{ + unsigned int max_version_factory; +}; +extern struct d2d_settings d2d_settings DECLSPEC_HIDDEN; + struct d2d_clip_stack { D2D1_RECT_F *stack; diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index da2b892654d..f202332f973 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -22,8 +22,14 @@ #define D2D1_INIT_GUID #include "d2d1_private.h" +WINE_DECLARE_DEBUG_CHANNEL(winediag); WINE_DEFAULT_DEBUG_CHANNEL(d2d); +struct d2d_settings d2d_settings = +{ + ~0u, /* No ID2D1Factory version limit by default. */ +}; + struct d2d_factory { ID2D1Factory1 ID2D1Factory1_iface; @@ -62,7 +68,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_QueryInterface(ID2D1Factory1 *iface { TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); - if (IsEqualGUID(iid, &IID_ID2D1Factory1) + if ((IsEqualGUID(iid, &IID_ID2D1Factory1) && d2d_settings.max_version_factory >= 1) || IsEqualGUID(iid, &IID_ID2D1Factory) || IsEqualGUID(iid, &IID_IUnknown)) { @@ -537,3 +543,71 @@ void WINAPI D2D1MakeRotateMatrix(float angle, D2D1_POINT_2F center, D2D1_MATRIX_ matrix->_31 = center.x - center.x * cos_theta + center.y * sin_theta; matrix->_32 = center.y - center.x * sin_theta - center.y * cos_theta; } + +static BOOL get_config_key_dword(HKEY default_key, HKEY application_key, const char *name, DWORD *value) +{ + DWORD type, data, size; + + size = sizeof(data); + if (application_key && !RegQueryValueExA(application_key, + name, 0, &type, (BYTE *)&data, &size) && type == REG_DWORD) + goto success; + + size = sizeof(data); + if (default_key && !RegQueryValueExA(default_key, + name, 0, &type, (BYTE *)&data, &size) && type == REG_DWORD) + goto success; + + return FALSE; + +success: + *value = data; + return TRUE; +} + +static void d2d_settings_init(void) +{ + HKEY default_key, tmp_key, application_key = NULL; + char buffer[MAX_PATH + 10]; + DWORD len; + + if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Direct2D", &default_key)) + default_key = NULL; + + len = GetModuleFileNameA(0, buffer, MAX_PATH); + if (len && len < MAX_PATH) + { + char *p, *appname = buffer; + + if ((p = strrchr(appname, '/'))) + appname = p + 1; + if ((p = strrchr(appname, '\\'))) + appname = p + 1; + strcat(appname, "\\Direct2D"); + + if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmp_key)) + { + if (RegOpenKeyA(tmp_key, appname, &application_key)) + application_key = NULL; + RegCloseKey(tmp_key); + } + } + + if (!default_key && !application_key) + return; + + if (get_config_key_dword(default_key, application_key, "max_version_factory", &d2d_settings.max_version_factory)) + ERR_(winediag)("Limiting maximum Direct2D factory version to %#x.\n", d2d_settings.max_version_factory); + + if (application_key) + RegCloseKey(application_key); + if (default_key) + RegCloseKey(default_key); +} + +BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) +{ + if (reason == DLL_PROCESS_ATTACH) + d2d_settings_init(); + return TRUE; +}