gdi32: Store a pointer instead of a global handle for DIB pattern brushes.
This commit is contained in:
parent
8afcff3c79
commit
6bf6575c5c
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue