Commit ff8647ea authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Avoid opening the desktop registry key multiple times.

parent 7fdba1f3
...@@ -260,32 +260,28 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC ...@@ -260,32 +260,28 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC
memcpy(&ptmA->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE)); memcpy(&ptmA->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
} }
static DWORD get_desktop_value( const WCHAR *name, DWORD *value ) static DWORD get_key_value( HKEY key, const WCHAR *name, DWORD *value )
{ {
static const WCHAR desktop[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
HKEY key;
WCHAR buf[12]; WCHAR buf[12];
DWORD count = sizeof(buf), type, err; DWORD count = sizeof(buf), type, err;
err = RegOpenKeyW( HKEY_CURRENT_USER, desktop, &key ); err = RegQueryValueExW( key, name, NULL, &type, (BYTE *)buf, &count );
if (!err) if (!err)
{ {
err = RegQueryValueExW( key, name, NULL, &type, (BYTE*)buf, &count ); if (type == REG_DWORD) memcpy( value, buf, sizeof(*value) );
if (!err) *value = atoiW( buf ); else *value = atoiW( buf );
RegCloseKey( key );
} }
return err; return err;
} }
static UINT get_subpixel_orientation( void ) static UINT get_subpixel_orientation( HKEY key )
{ {
static const WCHAR smoothing_orientation[] = {'F','o','n','t','S','m','o','o','t','h','i','n','g', static const WCHAR smoothing_orientation[] = {'F','o','n','t','S','m','o','o','t','h','i','n','g',
'O','r','i','e','n','t','a','t','i','o','n',0}; 'O','r','i','e','n','t','a','t','i','o','n',0};
DWORD orient, err; DWORD orient;
/* FIXME: handle vertical orientations even though Windows doesn't */ /* FIXME: handle vertical orientations even though Windows doesn't */
err = get_desktop_value( smoothing_orientation, &orient ); if (get_key_value( key, smoothing_orientation, &orient )) return GGO_GRAY4_BITMAP;
if (err) return GGO_GRAY4_BITMAP;
switch (orient) switch (orient)
{ {
...@@ -297,23 +293,22 @@ static UINT get_subpixel_orientation( void ) ...@@ -297,23 +293,22 @@ static UINT get_subpixel_orientation( void )
return GGO_GRAY4_BITMAP; return GGO_GRAY4_BITMAP;
} }
static UINT get_default_smoothing( void ) static UINT get_default_smoothing( HKEY key )
{ {
static const WCHAR smoothing_type[] = {'F','o','n','t','S','m','o','o','t','h','i','n','g','T','y','p','e',0}; static const WCHAR smoothing_type[] = {'F','o','n','t','S','m','o','o','t','h','i','n','g','T','y','p','e',0};
DWORD type, err; DWORD type;
/* FIXME: Ignoring FontSmoothing for now since this is /* FIXME: Ignoring FontSmoothing for now since this is
set to off by default in wine.inf */ set to off by default in wine.inf */
err = get_desktop_value( smoothing_type, &type ); if (get_key_value( key, smoothing_type, &type )) return 0;
if (err) return 0;
switch (type) switch (type)
{ {
case 1: /* FE_FONTSMOOTHINGSTANDARD */ case 1: /* FE_FONTSMOOTHINGSTANDARD */
return GGO_GRAY4_BITMAP; return GGO_GRAY4_BITMAP;
case 2: /* FE_FONTSMOOTHINGCLEARTYPE */ case 2: /* FE_FONTSMOOTHINGCLEARTYPE */
return get_subpixel_orientation(); return get_subpixel_orientation( key );
} }
return 0; return 0;
} }
...@@ -666,7 +661,10 @@ static BOOL FONT_DeleteObject( HGDIOBJ handle ) ...@@ -666,7 +661,10 @@ static BOOL FONT_DeleteObject( HGDIOBJ handle )
*/ */
HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font, UINT *aa_flags ) HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font, UINT *aa_flags )
{ {
static const WCHAR desktopW[] = { 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
'D','e','s','k','t','o','p',0 };
LOGFONTW lf; LOGFONTW lf;
HKEY key;
if (*aa_flags) return 0; if (*aa_flags) return 0;
...@@ -681,10 +679,14 @@ HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font, UINT *aa_flags ) ...@@ -681,10 +679,14 @@ HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font, UINT *aa_flags )
break; break;
case CLEARTYPE_QUALITY: case CLEARTYPE_QUALITY:
case CLEARTYPE_NATURAL_QUALITY: case CLEARTYPE_NATURAL_QUALITY:
*aa_flags = get_subpixel_orientation(); if (RegOpenKeyW( HKEY_CURRENT_USER, desktopW, &key )) break;
*aa_flags = get_subpixel_orientation( key );
RegCloseKey( key );
break; break;
default: default:
*aa_flags = get_default_smoothing(); if (RegOpenKeyW( HKEY_CURRENT_USER, desktopW, &key )) break;
*aa_flags = get_default_smoothing( key );
RegCloseKey( key );
break; break;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment