Commit 6bf6575c authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Store a pointer instead of a global handle for DIB pattern brushes.

parent 8afcff3c
...@@ -53,10 +53,9 @@ static const struct gdi_obj_funcs brush_funcs = ...@@ -53,10 +53,9 @@ static const struct gdi_obj_funcs brush_funcs =
BRUSH_DeleteObject /* pDeleteObject */ BRUSH_DeleteObject /* pDeleteObject */
}; };
static HGLOBAL dib_copy(const BITMAPINFO *info, UINT coloruse) static void *dib_copy(const BITMAPINFO *info, UINT coloruse)
{ {
BITMAPINFO *newInfo; BITMAPINFO *newInfo;
HGLOBAL hmem;
INT size; INT size;
if (info->bmiHeader.biCompression != BI_RGB && info->bmiHeader.biCompression != BI_BITFIELDS) if (info->bmiHeader.biCompression != BI_RGB && info->bmiHeader.biCompression != BI_BITFIELDS)
...@@ -65,14 +64,8 @@ static HGLOBAL dib_copy(const BITMAPINFO *info, UINT coloruse) ...@@ -65,14 +64,8 @@ static HGLOBAL dib_copy(const BITMAPINFO *info, UINT coloruse)
size = get_dib_image_size(info); size = get_dib_image_size(info);
size += bitmap_info_size( info, coloruse ); size += bitmap_info_size( info, coloruse );
if (!(hmem = GlobalAlloc( GMEM_MOVEABLE, size ))) if ((newInfo = HeapAlloc( GetProcessHeap(), 0, size ))) memcpy( newInfo, info, size );
{ return newInfo;
return 0;
}
newInfo = GlobalLock( hmem );
memcpy( newInfo, info, size );
GlobalUnlock( hmem );
return hmem;
} }
...@@ -162,7 +155,7 @@ HBRUSH WINAPI CreateBrushIndirect( const LOGBRUSH * brush ) ...@@ -162,7 +155,7 @@ HBRUSH WINAPI CreateBrushIndirect( const LOGBRUSH * brush )
if (ptr->logbrush.lbStyle == BS_PATTERN) if (ptr->logbrush.lbStyle == BS_PATTERN)
DeleteObject( (HGDIOBJ)ptr->logbrush.lbHatch ); DeleteObject( (HGDIOBJ)ptr->logbrush.lbHatch );
else if (ptr->logbrush.lbStyle == BS_DIBPATTERN) else if (ptr->logbrush.lbStyle == BS_DIBPATTERN)
GlobalFree( (HGLOBAL)ptr->logbrush.lbHatch ); HeapFree( GetProcessHeap(), 0, (void *)ptr->logbrush.lbHatch );
} }
HeapFree( GetProcessHeap(), 0, ptr ); HeapFree( GetProcessHeap(), 0, ptr );
return 0; return 0;
...@@ -439,7 +432,7 @@ static BOOL BRUSH_DeleteObject( HGDIOBJ handle ) ...@@ -439,7 +432,7 @@ static BOOL BRUSH_DeleteObject( HGDIOBJ handle )
DeleteObject( (HGDIOBJ)brush->logbrush.lbHatch ); DeleteObject( (HGDIOBJ)brush->logbrush.lbHatch );
break; break;
case BS_DIBPATTERN: case BS_DIBPATTERN:
GlobalFree( (HGLOBAL)brush->logbrush.lbHatch ); HeapFree( GetProcessHeap(), 0, (void *)brush->logbrush.lbHatch );
break; break;
} }
return HeapFree( GetProcessHeap(), 0, brush ); return HeapFree( GetProcessHeap(), 0, brush );
......
...@@ -1372,13 +1372,12 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) ...@@ -1372,13 +1372,12 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
case BS_DIBPATTERN: case BS_DIBPATTERN:
{ {
BITMAPINFOHEADER *bi = GlobalLock((HGLOBAL)logbrush.lbHatch); BITMAPINFOHEADER *bi = (BITMAPINFOHEADER *)logbrush.lbHatch;
dib_info orig_dib; dib_info orig_dib;
WORD usage = LOWORD(logbrush.lbColor); WORD usage = LOWORD(logbrush.lbColor);
HPALETTE pal = (usage == DIB_PAL_COLORS) ? GetCurrentObject(dev->hdc, OBJ_PAL) : NULL; HPALETTE pal = (usage == DIB_PAL_COLORS) ? GetCurrentObject(dev->hdc, OBJ_PAL) : NULL;
RECT rect; RECT rect;
if(!bi) return NULL;
if(init_dib_info_from_packed(&orig_dib, bi, usage, pal)) if(init_dib_info_from_packed(&orig_dib, bi, usage, pal))
{ {
copy_dib_color_info(&pdev->brush_dib, &pdev->dib); copy_dib_color_info(&pdev->brush_dib, &pdev->dib);
...@@ -1402,7 +1401,6 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) ...@@ -1402,7 +1401,6 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
pdev->defer &= ~DEFER_BRUSH; pdev->defer &= ~DEFER_BRUSH;
free_dib_info(&orig_dib); free_dib_info(&orig_dib);
} }
GlobalUnlock((HGLOBAL)logbrush.lbHatch);
break; break;
} }
......
...@@ -136,7 +136,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) ...@@ -136,7 +136,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
{ {
EMRCREATEDIBPATTERNBRUSHPT *emr; EMRCREATEDIBPATTERNBRUSHPT *emr;
DWORD bmSize, biSize, size; DWORD bmSize, biSize, size;
BITMAPINFO *info = GlobalLock( (HGLOBAL)logbrush.lbHatch ); BITMAPINFO *info = (BITMAPINFO *)logbrush.lbHatch;
if (info->bmiHeader.biCompression) if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage; bmSize = info->bmiHeader.biSizeImage;
...@@ -160,7 +160,6 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) ...@@ -160,7 +160,6 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
if(!EMFDRV_WriteRecord( dev, &emr->emr )) if(!EMFDRV_WriteRecord( dev, &emr->emr ))
index = 0; index = 0;
HeapFree( GetProcessHeap(), 0, emr ); HeapFree( GetProcessHeap(), 0, emr );
GlobalUnlock( (HGLOBAL)logbrush.lbHatch );
} }
break; break;
......
...@@ -232,10 +232,9 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush ) ...@@ -232,10 +232,9 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush )
case BS_DIBPATTERN: case BS_DIBPATTERN:
{ {
BITMAPINFO *info; BITMAPINFO *info = (BITMAPINFO *)logbrush.lbHatch;
DWORD bmSize, biSize; DWORD bmSize, biSize;
info = GlobalLock( (HGLOBAL)logbrush.lbHatch );
if (info->bmiHeader.biCompression) if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage; bmSize = info->bmiHeader.biSizeImage;
else else
...@@ -253,7 +252,6 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush ) ...@@ -253,7 +252,6 @@ INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush )
*(mr->rdParm) = logbrush.lbStyle; *(mr->rdParm) = logbrush.lbStyle;
*(mr->rdParm + 1) = LOWORD(logbrush.lbColor); *(mr->rdParm + 1) = LOWORD(logbrush.lbColor);
memcpy(mr->rdParm + 2, info, biSize + bmSize); memcpy(mr->rdParm + 2, info, biSize + bmSize);
GlobalUnlock( (HGLOBAL)logbrush.lbHatch );
break; break;
} }
default: default:
......
...@@ -255,7 +255,7 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO) ...@@ -255,7 +255,7 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
case BS_DIBPATTERN: case BS_DIBPATTERN:
{ {
BITMAPINFO *bmi = GlobalLock( (HGLOBAL)logbrush.lbHatch ); BITMAPINFO *bmi = (BITMAPINFO *)logbrush.lbHatch;
UINT usage = logbrush.lbColor; UINT usage = logbrush.lbColor;
TRACE("size %dx%dx%d\n", bmi->bmiHeader.biWidth, TRACE("size %dx%dx%d\n", bmi->bmiHeader.biWidth,
bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount); bmi->bmiHeader.biHeight, bmi->bmiHeader.biBitCount);
...@@ -268,7 +268,6 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO) ...@@ -268,7 +268,6 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
FIXME("Trying to set a pattern brush on a level 1 printer\n"); FIXME("Trying to set a pattern brush on a level 1 printer\n");
ret = FALSE; ret = FALSE;
} }
GlobalUnlock( (HGLOBAL)logbrush.lbHatch );
} }
break; break;
......
...@@ -254,11 +254,10 @@ static BOOL BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap ) ...@@ -254,11 +254,10 @@ static BOOL BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap )
/*********************************************************************** /***********************************************************************
* BRUSH_SelectDIBPatternBrush * BRUSH_SelectDIBPatternBrush
*/ */
static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, HGLOBAL mem ) static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, const BITMAPINFO *info )
{ {
BOOL ret; BOOL ret;
HDC memdc; HDC memdc;
BITMAPINFO *info = GlobalLock( mem );
HBITMAP bitmap = CreateDIBitmap( physDev->dev.hdc, &info->bmiHeader, CBM_INIT, HBITMAP bitmap = CreateDIBitmap( physDev->dev.hdc, &info->bmiHeader, CBM_INIT,
(LPBYTE)info + bitmap_info_size( info, DIB_RGB_COLORS ), (LPBYTE)info + bitmap_info_size( info, DIB_RGB_COLORS ),
info, DIB_RGB_COLORS ); info, DIB_RGB_COLORS );
...@@ -274,7 +273,6 @@ static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, HGLOBAL mem ) ...@@ -274,7 +273,6 @@ static BOOL BRUSH_SelectDIBPatternBrush( X11DRV_PDEVICE *physDev, HGLOBAL mem )
physBitmap->pixmap = 0; /* so it doesn't get freed */ physBitmap->pixmap = 0; /* so it doesn't get freed */
} }
DeleteObject( bitmap ); DeleteObject( bitmap );
GlobalUnlock( mem );
return ret; return ret;
} }
...@@ -330,7 +328,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) ...@@ -330,7 +328,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
case BS_DIBPATTERN: case BS_DIBPATTERN:
TRACE("BS_DIBPATTERN\n"); TRACE("BS_DIBPATTERN\n");
if (!BRUSH_SelectDIBPatternBrush( physDev, (HGLOBAL)logbrush.lbHatch )) return 0; if (!BRUSH_SelectDIBPatternBrush( physDev, (BITMAPINFO *)logbrush.lbHatch )) return 0;
break; break;
} }
return hbrush; return hbrush;
......
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