From e8d1d9ac858317040235e57b87b435b6fdb93b91 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sun, 5 Sep 2010 17:26:39 -0500 Subject: [PATCH] gdiplus: Add a registry setting to control use of software bitmaps. --- dlls/gdiplus/Makefile.in | 2 +- dlls/gdiplus/gdiplus.c | 60 ++++++++++++++++++++++++++++++++++++++++ dlls/gdiplus/gdiplus_private.h | 2 + dlls/gdiplus/image.c | 3 +- 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in index 2c10047..3dbf8a5 100644 --- a/dlls/gdiplus/Makefile.in +++ b/dlls/gdiplus/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = gdiplus.dll IMPORTLIB = gdiplus -IMPORTS = uuid shlwapi oleaut32 ole32 user32 gdi32 +IMPORTS = uuid shlwapi oleaut32 ole32 user32 gdi32 advapi32 DELAYIMPORTS = windowscodecs C_SRCS = \ diff --git a/dlls/gdiplus/gdiplus.c b/dlls/gdiplus/gdiplus.c index 9bb9fab..ca3793d 100644 --- a/dlls/gdiplus/gdiplus.c +++ b/dlls/gdiplus/gdiplus.c @@ -49,6 +49,65 @@ static void WINAPI NotificationUnhook(ULONG_PTR token) TRACE("%ld\n", token); } +int use_software_bitmaps; + +/*********************************************************************** + * get_config_key + * + * Get a config key from either the app-specific or the default config + */ +static inline DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name, + char *buffer, DWORD size ) +{ + if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE)buffer, &size )) return 0; + if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE)buffer, &size )) return 0; + return ERROR_FILE_NOT_FOUND; +} + +/*********************************************************************** + * setup_options + * + * Setup the x11drv options. + */ +static void setup_options(void) +{ + char buffer[MAX_PATH+16]; + HKEY hkey, appkey = 0; + DWORD len; + + /* @@ Wine registry key: HKCU\Software\Wine\GdiPlus */ + if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\GdiPlus", &hkey )) hkey = 0; + + /* open the app-specific key */ + + len = (GetModuleFileNameA( 0, buffer, MAX_PATH )); + if (len && len < MAX_PATH) + { + HKEY tmpkey; + char *p, *appname = buffer; + if ((p = strrchr( appname, '/' ))) appname = p + 1; + if ((p = strrchr( appname, '\\' ))) appname = p + 1; + strcat( appname, "\\GdiPlus" ); + /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\GdiPlus */ + if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) + { + if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0; + RegCloseKey( tmpkey ); + } + } + + use_software_bitmaps = 0; + if (!get_config_key( hkey, appkey, "SoftwareBitmaps", buffer, sizeof(buffer) )) + { + if (strcmp(buffer, "always") == 0) use_software_bitmaps = 2; + else if (strcmp(buffer, "asneeded") == 0) use_software_bitmaps = 1; + else if (strcmp(buffer, "never") == 0) use_software_bitmaps = 0; + } + + if (appkey) RegCloseKey( appkey ); + if (hkey) RegCloseKey( hkey ); +} + /***************************************************** * DllMain */ @@ -60,6 +119,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls( hinst ); + setup_options(); break; case DLL_PROCESS_DETACH: diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index b78e459..1a5737a 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -41,6 +41,8 @@ #define VERSION_MAGIC 0xdbc01001 #define TENSION_CONST (0.3) +extern int use_software_bitmaps; + COLORREF ARGB2COLORREF(ARGB color); HBITMAP ARGB2BMP(ARGB color); extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2, diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 4ed226d..02d663e 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1655,7 +1655,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, if(stride == 0) stride = dib_stride; - if (format & PixelFormatGDI) + if ((use_software_bitmaps == 0 && (format & PixelFormatGDI)) || + (use_software_bitmaps == 1 && (format & PixelFormatGDI) && !scan0 && !(format & (PixelFormatAlpha|PixelFormatIndexed)))) { pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); if (!pbmi) -- 1.6.3.3