d2d1: Introduce a registry key to limit the maximum supported factory version.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-01-22 15:40:46 +03:30 committed by Alexandre Julliard
parent 9d9fbc0e4a
commit 8247c13aae
3 changed files with 82 additions and 2 deletions

View file

@ -1,6 +1,6 @@
MODULE = d2d1.dll MODULE = d2d1.dll
IMPORTLIB = d2d1 IMPORTLIB = d2d1
IMPORTS = d3d10_1 dxguid uuid gdi32 user32 IMPORTS = d3d10_1 dxguid uuid gdi32 user32 advapi32
DELAYIMPORTS = dwrite DELAYIMPORTS = dwrite
C_SRCS = \ C_SRCS = \

View file

@ -52,6 +52,12 @@ enum d2d_shape_type
D2D_SHAPE_TYPE_COUNT, D2D_SHAPE_TYPE_COUNT,
}; };
struct d2d_settings
{
unsigned int max_version_factory;
};
extern struct d2d_settings d2d_settings DECLSPEC_HIDDEN;
struct d2d_clip_stack struct d2d_clip_stack
{ {
D2D1_RECT_F *stack; D2D1_RECT_F *stack;

View file

@ -22,8 +22,14 @@
#define D2D1_INIT_GUID #define D2D1_INIT_GUID
#include "d2d1_private.h" #include "d2d1_private.h"
WINE_DECLARE_DEBUG_CHANNEL(winediag);
WINE_DEFAULT_DEBUG_CHANNEL(d2d); WINE_DEFAULT_DEBUG_CHANNEL(d2d);
struct d2d_settings d2d_settings =
{
~0u, /* No ID2D1Factory version limit by default. */
};
struct d2d_factory struct d2d_factory
{ {
ID2D1Factory1 ID2D1Factory1_iface; 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); 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_ID2D1Factory)
|| IsEqualGUID(iid, &IID_IUnknown)) || 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->_31 = center.x - center.x * cos_theta + center.y * sin_theta;
matrix->_32 = center.y - center.x * sin_theta - center.y * cos_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;
}