gdi32: Use NtGdiStretchDIBitsInternal for StretchDIBits.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-08-13 12:09:16 +02:00 committed by Alexandre Julliard
parent aa230489d2
commit 225004e1eb
8 changed files with 87 additions and 47 deletions

View File

@ -604,12 +604,12 @@ done:
} }
/*********************************************************************** /***********************************************************************
* StretchDIBits (GDI32.@) * NtGdiStretchDIBitsInternal (win32u.@)
*/ */
INT WINAPI DECLSPEC_HOTPATCH StretchDIBits( HDC hdc, INT xDst, INT yDst, INT widthDst, INT heightDst, INT WINAPI NtGdiStretchDIBitsInternal( HDC hdc, INT xDst, INT yDst, INT widthDst, INT heightDst,
INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc,
const void *bits, const BITMAPINFO *bmi, UINT coloruse, const void *bits, const BITMAPINFO *bmi, UINT coloruse,
DWORD rop ) DWORD rop, UINT max_info, UINT max_bits, HANDLE xform )
{ {
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *info = (BITMAPINFO *)buffer; BITMAPINFO *info = (BITMAPINFO *)buffer;

View File

@ -243,13 +243,21 @@ BOOL EMFDC_StretchBlt( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst, IN
INT CDECL EMFDRV_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT heightDst, INT CDECL EMFDRV_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT heightDst,
INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, const void *bits, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, const void *bits,
BITMAPINFO *info, UINT wUsage, DWORD dwRop ) BITMAPINFO *info, UINT wUsage, DWORD dwRop )
{
/* FIXME: Update bound rect */
return heightSrc;
}
BOOL EMFDC_StretchDIBits( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
INT x_src, INT y_src, INT width_src, INT height_src, const void *bits,
const BITMAPINFO *info, UINT usage, DWORD rop )
{ {
EMRSTRETCHDIBITS *emr; EMRSTRETCHDIBITS *emr;
BOOL ret; BOOL ret;
UINT bmi_size, emr_size; UINT bmi_size, emr_size;
/* calculate the size of the colour table */ /* calculate the size of the colour table */
bmi_size = get_dib_info_size(info, wUsage); bmi_size = get_dib_info_size( info, usage );
emr_size = sizeof (EMRSTRETCHDIBITS) + bmi_size + info->bmiHeader.biSizeImage; emr_size = sizeof (EMRSTRETCHDIBITS) + bmi_size + info->bmiHeader.biSizeImage;
emr = HeapAlloc(GetProcessHeap(), 0, emr_size ); emr = HeapAlloc(GetProcessHeap(), 0, emr_size );
@ -265,36 +273,36 @@ INT CDECL EMFDRV_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, I
emr->emr.iType = EMR_STRETCHDIBITS; emr->emr.iType = EMR_STRETCHDIBITS;
emr->emr.nSize = emr_size; emr->emr.nSize = emr_size;
emr->xDest = xDst; emr->xDest = x_dst;
emr->yDest = yDst; emr->yDest = y_dst;
emr->cxDest = widthDst; emr->cxDest = width_dst;
emr->cyDest = heightDst; emr->cyDest = height_dst;
emr->dwRop = dwRop; emr->dwRop = rop;
emr->xSrc = xSrc; /* FIXME: only save the piece of the bitmap needed */ emr->xSrc = x_src; /* FIXME: only save the piece of the bitmap needed */
emr->ySrc = ySrc; emr->ySrc = y_src;
emr->iUsageSrc = wUsage; emr->iUsageSrc = usage;
emr->offBmiSrc = sizeof (EMRSTRETCHDIBITS); emr->offBmiSrc = sizeof (EMRSTRETCHDIBITS);
emr->cbBmiSrc = bmi_size; emr->cbBmiSrc = bmi_size;
emr->offBitsSrc = emr->offBmiSrc + bmi_size; emr->offBitsSrc = emr->offBmiSrc + bmi_size;
emr->cbBitsSrc = info->bmiHeader.biSizeImage; emr->cbBitsSrc = info->bmiHeader.biSizeImage;
emr->cxSrc = widthSrc; emr->cxSrc = width_src;
emr->cySrc = heightSrc; emr->cySrc = height_src;
emr->rclBounds.left = xDst; emr->rclBounds.left = x_dst;
emr->rclBounds.top = yDst; emr->rclBounds.top = y_dst;
emr->rclBounds.right = xDst + widthDst; emr->rclBounds.right = x_dst + width_dst;
emr->rclBounds.bottom = yDst + heightDst; emr->rclBounds.bottom = y_dst + height_dst;
/* save the record we just created */ /* save the record we just created */
ret = EMFDRV_WriteRecord( dev, &emr->emr ); ret = EMFDRV_WriteRecord( dc_attr->emf, &emr->emr );
if(ret) if(ret)
EMFDRV_UpdateBBox( dev, &emr->rclBounds ); EMFDRV_UpdateBBox( dc_attr->emf, &emr->rclBounds );
HeapFree(GetProcessHeap(), 0, emr); HeapFree(GetProcessHeap(), 0, emr);
return ret ? heightSrc : GDI_ERROR; return ret;
} }
INT CDECL EMFDRV_SetDIBitsToDevice( PHYSDEV dev, INT xDst, INT yDst, DWORD width, DWORD height, INT CDECL EMFDRV_SetDIBitsToDevice( PHYSDEV dev, INT xDst, INT yDst, DWORD width, DWORD height,

View File

@ -113,7 +113,10 @@ extern BOOL METADC_SetWindowOrgEx( HDC, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL METADC_StretchBlt( HDC hdc_dst, INT x_dst, INT y_dst, INT width_dst, INT height_dst, extern BOOL METADC_StretchBlt( HDC hdc_dst, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src, HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src,
DWORD rop ); DWORD rop );
extern INT METADC_StretchDIBits( HDC hdc, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
INT x_src, INT y_src, INT width_src, INT height_src,
const void *bits, const BITMAPINFO *info, UINT coloruse,
DWORD rop ) DECLSPEC_HIDDEN;
/* enhanced metafiles */ /* enhanced metafiles */
extern BOOL EMFDC_AbortPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN; extern BOOL EMFDC_AbortPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_AlphaBlend( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst, extern BOOL EMFDC_AlphaBlend( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
@ -198,5 +201,9 @@ extern BOOL EMFDC_SetWorldTransform( DC_ATTR *dc_attr, const XFORM *xform ) DECL
extern BOOL EMFDC_StretchBlt( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst, extern BOOL EMFDC_StretchBlt( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src, HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src,
DWORD rop ); DWORD rop );
extern BOOL EMFDC_StretchDIBits( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst,
INT height_dst, INT x_src, INT y_src, INT width_src,
INT height_src, const void *bits, const BITMAPINFO *info,
UINT coloruse, DWORD rop ) DECLSPEC_HIDDEN;
#endif /* __WINE_GDI_PRIVATE_H */ #endif /* __WINE_GDI_PRIVATE_H */

View File

@ -1300,6 +1300,29 @@ INT WINAPI SetDIBitsToDevice( HDC hdc, INT x_dst, INT y_dst, DWORD cx,
0, 0, FALSE, NULL ); 0, 0, FALSE, NULL );
} }
/***********************************************************************
* StretchDIBits (GDI32.@)
*/
INT WINAPI DECLSPEC_HOTPATCH StretchDIBits( HDC hdc, INT x_dst, INT y_dst, INT width_dst,
INT height_dst, INT x_src, INT y_src, INT width_src,
INT height_src, const void *bits, const BITMAPINFO *bmi,
UINT coloruse, DWORD rop )
{
DC_ATTR *dc_attr;
if (is_meta_dc( hdc ))
return METADC_StretchDIBits( hdc, x_dst, y_dst, width_dst, height_dst, x_src, y_src,
width_src, height_src, bits, bmi, coloruse, rop );
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE;
if (dc_attr->emf && !EMFDC_StretchDIBits( dc_attr, x_dst, y_dst, width_dst, height_dst,
x_src, y_src, width_src, height_src, bits,
bmi, coloruse, rop ))
return FALSE;
return NtGdiStretchDIBitsInternal( hdc, x_dst, y_dst, width_dst, height_dst, x_src, y_src,
width_src, height_src, bits, bmi, coloruse, rop,
0, 0, NULL );
}
/*********************************************************************** /***********************************************************************
* BeginPath (GDI32.@) * BeginPath (GDI32.@)
*/ */

View File

@ -112,36 +112,36 @@ BOOL METADC_StretchBlt( HDC hdc_dst, INT x_dst, INT y_dst, INT width_dst, INT he
} }
/*********************************************************************** /***********************************************************************
* MFDRV_StretchDIBits * METADC_StretchDIBits
*/ */
INT CDECL MFDRV_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT METADC_StretchDIBits( HDC hdc, INT x_dst, INT y_dst, INT width_dst,
INT heightDst, INT xSrc, INT ySrc, INT widthSrc, INT height_dst, INT x_src, INT y_src, INT width_src,
INT heightSrc, const void *bits, INT height_src, const void *bits,
BITMAPINFO *info, UINT wUsage, DWORD dwRop ) const BITMAPINFO *info, UINT usage, DWORD rop )
{ {
DWORD infosize = get_dib_info_size(info, wUsage); DWORD infosize = get_dib_info_size( info, usage );
DWORD len = sizeof(METARECORD) + 10 * sizeof(WORD) + infosize + info->bmiHeader.biSizeImage; DWORD len = sizeof(METARECORD) + 10 * sizeof(WORD) + infosize + info->bmiHeader.biSizeImage;
METARECORD *mr = HeapAlloc( GetProcessHeap(), 0, len ); METARECORD *mr = HeapAlloc( GetProcessHeap(), 0, len );
if(!mr) return 0; if(!mr) return 0;
mr->rdSize = len / 2; mr->rdSize = len / 2;
mr->rdFunction = META_STRETCHDIB; mr->rdFunction = META_STRETCHDIB;
mr->rdParm[0] = LOWORD(dwRop); mr->rdParm[0] = LOWORD(rop);
mr->rdParm[1] = HIWORD(dwRop); mr->rdParm[1] = HIWORD(rop);
mr->rdParm[2] = wUsage; mr->rdParm[2] = usage;
mr->rdParm[3] = (INT16)heightSrc; mr->rdParm[3] = height_src;
mr->rdParm[4] = (INT16)widthSrc; mr->rdParm[4] = width_src;
mr->rdParm[5] = (INT16)ySrc; mr->rdParm[5] = y_src;
mr->rdParm[6] = (INT16)xSrc; mr->rdParm[6] = x_src;
mr->rdParm[7] = (INT16)heightDst; mr->rdParm[7] = height_dst;
mr->rdParm[8] = (INT16)widthDst; mr->rdParm[8] = width_dst;
mr->rdParm[9] = (INT16)yDst; mr->rdParm[9] = y_dst;
mr->rdParm[10] = (INT16)xDst; mr->rdParm[10] = x_dst;
memcpy(mr->rdParm + 11, info, infosize); memcpy(mr->rdParm + 11, info, infosize);
memcpy(mr->rdParm + 11 + infosize / 2, bits, info->bmiHeader.biSizeImage); memcpy(mr->rdParm + 11 + infosize / 2, bits, info->bmiHeader.biSizeImage);
MFDRV_WriteRecord( dev, mr, mr->rdSize * 2 ); metadc_record( hdc, mr, mr->rdSize * 2 );
HeapFree( GetProcessHeap(), 0, mr ); HeapFree( GetProcessHeap(), 0, mr );
return heightSrc; return height_src;
} }

View File

@ -193,7 +193,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
NULL, /* pStartDoc */ NULL, /* pStartDoc */
NULL, /* pStartPage */ NULL, /* pStartPage */
NULL, /* pStretchBlt */ NULL, /* pStretchBlt */
MFDRV_StretchDIBits, /* pStretchDIBits */ NULL, /* pStretchDIBits */
MFDRV_StrokeAndFillPath, /* pStrokeAndFillPath */ MFDRV_StrokeAndFillPath, /* pStrokeAndFillPath */
MFDRV_StrokePath, /* pStrokePath */ MFDRV_StrokePath, /* pStrokePath */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */

View File

@ -97,9 +97,6 @@ extern COLORREF CDECL MFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_H
extern COLORREF CDECL MFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF CDECL MFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL MFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF CDECL MFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL MFDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF CDECL MFDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst,
INT heightDst, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc,
const void *bits, BITMAPINFO *info, UINT wUsage, DWORD dwRop ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN; extern BOOL CDECL MFDRV_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;

View File

@ -283,6 +283,11 @@ INT WINAPI NtGdiStartPage( HDC hdc );
BOOL WINAPI NtGdiStretchBlt( HDC hdc, INT x_dst, INT y_dst, INT width_dst, INT height_dst, BOOL WINAPI NtGdiStretchBlt( HDC hdc, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src, HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src,
DWORD rop, COLORREF bk_color ); DWORD rop, COLORREF bk_color );
INT WINAPI NtGdiStretchDIBitsInternal( HDC hdc, INT x_dst, INT y_dst, INT width_dst,
INT height_dst, INT x_src, INT y_src, INT width_src,
INT height_src, const void *bits, const BITMAPINFO *bmi,
UINT coloruse, DWORD rop, UINT max_info, UINT max_bits,
HANDLE xform );
BOOL WINAPI NtGdiStrokePath( HDC hdc ); BOOL WINAPI NtGdiStrokePath( HDC hdc );
BOOL WINAPI NtGdiStrokeAndFillPath( HDC hdc ); BOOL WINAPI NtGdiStrokeAndFillPath( HDC hdc );
BOOL WINAPI NtGdiTransformPoints( HDC hdc, const POINT *points_in, POINT *points_out, BOOL WINAPI NtGdiTransformPoints( HDC hdc, const POINT *points_in, POINT *points_out,