From 6bf6575c5c2f1b5181b6f33c299a77ac3de5fd90 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 2 Nov 2011 12:02:27 +0100 Subject: [PATCH] gdi32: Store a pointer instead of a global handle for DIB pattern brushes. --- dlls/gdi32/brush.c | 17 +++++------------ dlls/gdi32/dibdrv/objects.c | 4 +--- dlls/gdi32/enhmfdrv/objects.c | 3 +-- dlls/gdi32/mfdrv/objects.c | 4 +--- dlls/wineps.drv/brush.c | 3 +-- dlls/winex11.drv/brush.c | 6 ++---- 6 files changed, 11 insertions(+), 26 deletions(-) diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c index 0beda6468dc..222ba42a07b 100644 --- a/dlls/gdi32/brush.c +++ b/dlls/gdi32/brush.c @@ -53,10 +53,9 @@ static const struct gdi_obj_funcs brush_funcs = BRUSH_DeleteObject /* pDeleteObject */ }; -static HGLOBAL dib_copy(const BITMAPINFO *info, UINT coloruse) +static void *dib_copy(const BITMAPINFO *info, UINT coloruse) { BITMAPINFO *newInfo; - HGLOBAL hmem; INT size; if (info->bmiHeader.biCompression != BI_RGB && info->bmiHeader.biCompression != BI_BITFIELDS) @@ -65,14 +64,8 @@ static HGLOBAL dib_copy(const BITMAPINFO *info, UINT coloruse) size = get_dib_image_size(info); size += bitmap_info_size( info, coloruse ); - if (!(hmem = GlobalAlloc( GMEM_MOVEABLE, size ))) - { - return 0; - } - newInfo = GlobalLock( hmem ); - memcpy( newInfo, info, size ); - GlobalUnlock( hmem ); - return hmem; + if ((newInfo = HeapAlloc( GetProcessHeap(), 0, size ))) memcpy( newInfo, info, size ); + return newInfo; } @@ -162,7 +155,7 @@ HBRUSH WINAPI CreateBrushIndirect( const LOGBRUSH * brush ) if (ptr->logbrush.lbStyle == BS_PATTERN) DeleteObject( (HGDIOBJ)ptr->logbrush.lbHatch ); else if (ptr->logbrush.lbStyle == BS_DIBPATTERN) - GlobalFree( (HGLOBAL)ptr->logbrush.lbHatch ); + HeapFree( GetProcessHeap(), 0, (void *)ptr->logbrush.lbHatch ); } HeapFree( GetProcessHeap(), 0, ptr ); return 0; @@ -439,7 +432,7 @@ static BOOL BRUSH_DeleteObject( HGDIOBJ handle ) DeleteObject( (HGDIOBJ)brush->logbrush.lbHatch ); break; case BS_DIBPATTERN: - GlobalFree( (HGLOBAL)brush->logbrush.lbHatch ); + HeapFree( GetProcessHeap(), 0, (void *)brush->logbrush.lbHatch ); break; } return HeapFree( GetProcessHeap(), 0, brush ); diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c index 8d8428417bd..6c2469ab7dd 100644 --- a/dlls/gdi32/dibdrv/objects.c +++ b/dlls/gdi32/dibdrv/objects.c @@ -1372,13 +1372,12 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) case BS_DIBPATTERN: { - BITMAPINFOHEADER *bi = GlobalLock((HGLOBAL)logbrush.lbHatch); + BITMAPINFOHEADER *bi = (BITMAPINFOHEADER *)logbrush.lbHatch; dib_info orig_dib; WORD usage = LOWORD(logbrush.lbColor); HPALETTE pal = (usage == DIB_PAL_COLORS) ? GetCurrentObject(dev->hdc, OBJ_PAL) : NULL; RECT rect; - if(!bi) return NULL; if(init_dib_info_from_packed(&orig_dib, bi, usage, pal)) { copy_dib_color_info(&pdev->brush_dib, &pdev->dib); @@ -1402,7 +1401,6 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) pdev->defer &= ~DEFER_BRUSH; free_dib_info(&orig_dib); } - GlobalUnlock((HGLOBAL)logbrush.lbHatch); break; } diff --git a/dlls/gdi32/enhmfdrv/objects.c b/dlls/gdi32/enhmfdrv/objects.c index 4e1fa7e8ce3..0580700d4cb 100644 --- a/dlls/gdi32/enhmfdrv/objects.c +++ b/dlls/gdi32/enhmfdrv/objects.c @@ -136,7 +136,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) { EMRCREATEDIBPATTERNBRUSHPT *emr; DWORD bmSize, biSize, size; - BITMAPINFO *info = GlobalLock( (HGLOBAL)logbrush.lbHatch ); + BITMAPINFO *info = (BITMAPINFO *)logbrush.lbHatch; if (info->bmiHeader.biCompression) bmSize = info->bmiHeader.biSizeImage; @@ -160,7 +160,6 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) if(!EMFDRV_WriteRecord( dev, &emr->emr )) index = 0; HeapFree( GetProcessHeap(), 0, emr ); - GlobalUnlock( (HGLOBAL)logbrush.lbHatch ); } break; diff --git a/dlls/gdi32/mfdrv/objects.c b/dlls/gdi32/mfdrv/objects.c index 150fb22f383..ef0988b6c0d 100644 --- a/dlls/gdi32/mfdrv/objects.c +++ b/dlls/gdi32/mfdrv/objects.c @@ -232,10 +232,9 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush ) case BS_DIBPATTERN: { - BITMAPINFO *info; + BITMAPINFO *info = (BITMAPINFO *)logbrush.lbHatch; DWORD bmSize, biSize; - info = GlobalLock( (HGLOBAL)logbrush.lbHatch ); if (info->bmiHeader.biCompression) bmSize = info->bmiHeader.biSizeImage; else @@ -253,7 +252,6 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush ) *(mr->rdParm) = logbrush.lbStyle; *(mr->rdParm + 1) = LOWORD(logbrush.lbColor); memcpy(mr->rdParm + 2, info, biSize + bmSize); - GlobalUnlock( (HGLOBAL)logbrush.lbHatch ); break; } default: diff --git a/dlls/wineps.drv/brush.c b/dlls/wineps.drv/brush.c index 1e42c1f5626..94017468bc2 100644 --- a/dlls/wineps.drv/brush.c +++ b/dlls/wineps.drv/brush.c @@ -255,7 +255,7 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO) case BS_DIBPATTERN: { - BITMAPINFO *bmi = GlobalLock( (HGLOBAL)logbrush.lbHatch ); + BITMAPINFO *bmi = (BITMAPINFO *)logbrush.lbHatch; UINT usage = logbrush.lbColor; TRACE("size %dx%dx%d\n", bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount); @@ -268,7 +268,6 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO) FIXME("Trying to set a pattern brush on a level 1 printer\n"); ret = FALSE; } - GlobalUnlock( (HGLOBAL)logbrush.lbHatch ); } break; diff --git a/dlls/winex11.drv/brush.c b/dlls/winex11.drv/brush.c index d0fdb8d47c4..a3c7f28084b 100644 --- a/dlls/winex11.drv/brush.c +++ b/dlls/winex11.drv/brush.c @@ -254,11 +254,10 @@ static BOOL BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap ) /*********************************************************************** * BRUSH_SelectDIBPatternBrush */ -static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, HGLOBAL mem ) +static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, const BITMAPINFO *info ) { BOOL ret; HDC memdc; - BITMAPINFO *info = GlobalLock( mem ); HBITMAP bitmap = CreateDIBitmap( physDev->dev.hdc, &info->bmiHeader, CBM_INIT, (LPBYTE)info + bitmap_info_size( info, DIB_RGB_COLORS ), info, DIB_RGB_COLORS ); @@ -274,7 +273,6 @@ static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, HGLOBAL mem ) physBitmap->pixmap = 0; /* so it doesn't get freed */ } DeleteObject( bitmap ); - GlobalUnlock( mem ); return ret; } @@ -330,7 +328,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) case BS_DIBPATTERN: TRACE("BS_DIBPATTERN\n"); - if (!BRUSH_SelectDIBPatternBrush( physDev, (HGLOBAL)logbrush.lbHatch )) return 0; + if (!BRUSH_SelectDIBPatternBrush( physDev, (BITMAPINFO *)logbrush.lbHatch )) return 0; break; } return hbrush;