gdi32: Share font_gamma_ramp structure between all DCs.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-09-23 17:44:57 +02:00 committed by Alexandre Julliard
parent 94db5c8719
commit 2370e7b9a1
4 changed files with 14 additions and 9 deletions

View File

@ -168,7 +168,6 @@ static void free_dc_state( DC *dc )
if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
if (dc->region) DeleteObject( dc->region );
if (dc->path) free_gdi_path( dc->path );
HeapFree( GetProcessHeap(), 0, dc->font_gamma_ramp );
HeapFree( GetProcessHeap(), 0, dc );
}

View File

@ -88,7 +88,7 @@ struct intensity_range
struct font_intensities
{
struct intensity_range ranges[17];
struct font_gamma_ramp *gamma_ramp;
const struct font_gamma_ramp *gamma_ramp;
};
typedef struct dibdrv_physdev

View File

@ -730,20 +730,17 @@ static void update_font_code_page( DC *dc, HANDLE font )
TRACE("charset %d => cp %d\n", charset, dc->font_code_page);
}
static struct font_gamma_ramp *get_font_gamma_ramp( void )
static BOOL WINAPI fill_font_gamma_ramp( INIT_ONCE *once, void *param, void **context )
{
static const WCHAR desktopW[] = { 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
'D','e','s','k','t','o','p',0 };
static const WCHAR smoothing_gamma[] = { 'F','o','n','t','S','m','o','o','t','h','i','n','g',
'G','a','m','m','a',0 };
struct font_gamma_ramp *ramp = param;
const DWORD gamma_default = 1400;
struct font_gamma_ramp *ramp;
DWORD i, gamma;
HKEY key;
ramp = HeapAlloc( GetProcessHeap(), 0, sizeof(*ramp) );
if ( ramp == NULL) return NULL;
gamma = gamma_default;
if (RegOpenKeyW( HKEY_CURRENT_USER, desktopW, &key ) == ERROR_SUCCESS)
{
@ -768,7 +765,16 @@ static struct font_gamma_ramp *get_font_gamma_ramp( void )
ramp->gamma = gamma;
TRACE("gamma %d\n", ramp->gamma);
return ramp;
return TRUE;
}
static struct font_gamma_ramp *get_font_gamma_ramp( void )
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
static struct font_gamma_ramp ramp;
InitOnceExecuteOnce( &init_once, fill_font_gamma_ramp, &ramp, NULL );
return &ramp;
}
/***********************************************************************

View File

@ -99,7 +99,7 @@ typedef struct tagDC
struct gdi_path *path;
struct font_gamma_ramp *font_gamma_ramp;
const struct font_gamma_ramp *font_gamma_ramp;
UINT font_code_page;
WORD ROPmode;