From 81e9b43fb246a07793d62563a826c9c3bbfa767f Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 5 Mar 2008 15:57:21 +0100 Subject: [PATCH] gdi32: Move GetICMProfile to the driver. --- dlls/gdi32/driver.c | 1 + dlls/gdi32/enhmfdrv/init.c | 1 + dlls/gdi32/gdi_private.h | 1 + dlls/gdi32/icm.c | 49 +++++--------------------- dlls/gdi32/mfdrv/init.c | 1 + dlls/winex11.drv/graphics.c | 57 +++++++++++++++++++++++++++++++ dlls/winex11.drv/winex11.drv.spec | 1 + 7 files changed, 71 insertions(+), 40 deletions(-) diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index 31810b0f792..8d758034d2f 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -116,6 +116,7 @@ static struct graphics_driver *create_driver( HMODULE module ) GET_FUNC(GetDIBits); GET_FUNC(GetDeviceCaps); GET_FUNC(GetDeviceGammaRamp); + GET_FUNC(GetICMProfile); GET_FUNC(GetNearestColor); GET_FUNC(GetPixel); GET_FUNC(GetPixelFormat); diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index 0db9ff6db5f..2203ced50be 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -75,6 +75,7 @@ static const DC_FUNCTIONS EMFDRV_Funcs = NULL, /* pGetDIBits */ EMFDRV_GetDeviceCaps, /* pGetDeviceCaps */ NULL, /* pGetDeviceGammaRamp */ + NULL, /* pGetICMProfile */ NULL, /* pGetNearestColor */ NULL, /* pGetPixel */ NULL, /* pGetPixelFormat */ diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index dc66a0c4f6e..e3a320ace29 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -140,6 +140,7 @@ typedef struct tagDC_FUNCS INT (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT); INT (*pGetDeviceCaps)(PHYSDEV,INT); BOOL (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID); + BOOL (*pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR); COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF); COLORREF (*pGetPixel)(PHYSDEV,INT,INT); INT (*pGetPixelFormat)(PHYSDEV); diff --git a/dlls/gdi32/icm.c b/dlls/gdi32/icm.c index 12d1f3b1f22..0e346ee52cd 100644 --- a/dlls/gdi32/icm.c +++ b/dlls/gdi32/icm.c @@ -30,6 +30,8 @@ #include "winnls.h" #include "winreg.h" +#include "gdi_private.h" + #include "wine/debug.h" #include "wine/unicode.h" @@ -97,51 +99,18 @@ BOOL WINAPI GetICMProfileA(HDC hdc, LPDWORD size, LPSTR filename) */ BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename) { - HKEY hkey; - DWORD required; - WCHAR profile[MAX_PATH], fullname[MAX_PATH]; - static const WCHAR path[] = - {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s', - '\\','c','o','l','o','r','\\',0}; - static const WCHAR srgb[] = - {'s','R','G','B',' ','C','o','l','o','r',' ','S','p','a','c','e',' ', - 'P','r','o','f','i','l','e','.','i','c','m',0}; - static const WCHAR mntr[] = - {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t', - 'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r',0}; + BOOL ret = FALSE; + DC *dc = get_dc_ptr(hdc); TRACE("%p, %p, %p\n", hdc, size, filename); - if (!hdc || !size) return FALSE; - - strcpyW(profile, srgb); - if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, mntr, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL)) + if (dc) { - DWORD size = sizeof(profile) / sizeof(WCHAR); - /* FIXME handle multiple values */ - RegEnumValueW(hkey, 0, profile, &size, NULL, NULL, NULL, NULL); - RegCloseKey(hkey); + if (dc->funcs->pGetICMProfile) + ret = dc->funcs->pGetICMProfile(dc->physDev, size, filename); + release_dc_ptr(dc); } - GetSystemDirectoryW(fullname, MAX_PATH); - strcatW(fullname, path); - strcatW(fullname, profile); - - required = strlenW(fullname) + 1; - if (*size < required) - { - *size = required; - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return FALSE; - } - if (filename) - { - strcpyW(filename, fullname); - if (GetFileAttributesW(filename) == INVALID_FILE_ATTRIBUTES) - WARN("color profile not found\n"); - } - *size = required; - return TRUE; + return ret; } /********************************************************************** diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index c2cf404dace..69e5b55a237 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -75,6 +75,7 @@ static const DC_FUNCTIONS MFDRV_Funcs = NULL, /* pGetDIBits */ MFDRV_GetDeviceCaps, /* pGetDeviceCaps */ NULL, /* pGetDeviceGammaRamp */ + NULL, /* pGetICMProfile */ NULL, /* pGetNearestColor */ NULL, /* pGetPixel */ NULL, /* pGetPixelFormat */ diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c index e580fd6fa30..52726812376 100644 --- a/dlls/winex11.drv/graphics.c +++ b/dlls/winex11.drv/graphics.c @@ -25,6 +25,7 @@ #include "config.h" +#include #include #ifdef HAVE_FLOAT_H # include @@ -35,9 +36,14 @@ #endif #include +#include "windef.h" +#include "winbase.h" +#include "winreg.h" + #include "x11drv.h" #include "x11font.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(graphics); @@ -1374,3 +1380,54 @@ DWORD X11DRV_SetDCOrg( X11DRV_PDEVICE *physDev, INT x, INT y ) physDev->dc_rect.top = y - physDev->drawable_rect.top; return ret; } + +/*********************************************************************** + * GetICMProfile (X11DRV.@) + */ +BOOL X11DRV_GetICMProfile( X11DRV_PDEVICE *physDev, LPDWORD size, LPWSTR filename ) +{ + static const WCHAR path[] = + {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s', + '\\','c','o','l','o','r','\\',0}; + static const WCHAR srgb[] = + {'s','R','G','B',' ','C','o','l','o','r',' ','S','p','a','c','e',' ', + 'P','r','o','f','i','l','e','.','i','c','m',0}; + static const WCHAR mntr[] = + {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', + 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t', + 'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r',0}; + + HKEY hkey; + DWORD required; + WCHAR profile[MAX_PATH], fullname[MAX_PATH]; + + if (!size) return FALSE; + + strcpyW( profile, srgb ); + if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, mntr, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL )) + { + DWORD len = sizeof(profile)/sizeof(WCHAR); + /* FIXME handle multiple values */ + RegEnumValueW( hkey, 0, profile, &len, NULL, NULL, NULL, NULL ); + RegCloseKey( hkey ); + } + GetSystemDirectoryW( fullname, MAX_PATH ); + strcatW( fullname, path ); + strcatW( fullname, profile ); + + required = strlenW( fullname ) + 1; + if (*size < required) + { + *size = required; + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return FALSE; + } + if (filename) + { + strcpyW( filename, fullname ); + if (GetFileAttributesW( filename ) == INVALID_FILE_ATTRIBUTES) + WARN( "color profile not found\n" ); + } + *size = required; + return TRUE; +} diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec index 6c8fe6c08c5..751da527e6e 100644 --- a/dlls/winex11.drv/winex11.drv.spec +++ b/dlls/winex11.drv/winex11.drv.spec @@ -22,6 +22,7 @@ @ cdecl GetDIBits(ptr long long long ptr ptr long) X11DRV_GetDIBits @ cdecl GetDeviceCaps(ptr long) X11DRV_GetDeviceCaps @ cdecl GetDeviceGammaRamp(ptr ptr) X11DRV_GetDeviceGammaRamp +@ cdecl GetICMProfile(ptr ptr ptr) X11DRV_GetICMProfile @ cdecl GetNearestColor(ptr long) X11DRV_GetNearestColor @ cdecl GetPixel(ptr long long) X11DRV_GetPixel @ cdecl GetPixelFormat(ptr) X11DRV_GetPixelFormat