gdi32: Use NtGdiGetAndSetDCDword for SetDCPenColor.

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-19 10:24:55 +02:00 committed by Alexandre Julliard
parent 02ee9bf246
commit b223f82603
7 changed files with 32 additions and 38 deletions

View File

@ -851,6 +851,13 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
if (value != CLR_INVALID) dc->attr->brush_color = value;
break;
case NtGdiSetDCPenColor:
physdev = GET_DC_PHYSDEV( dc, pSetDCPenColor );
*prev_value = dc->attr->pen_color;
value = physdev->funcs->pSetDCPenColor( physdev, value );
if (value != CLR_INVALID) dc->attr->pen_color = value;
break;
default:
WARN( "unknown method %u\n", method );
ret = FALSE;
@ -1294,29 +1301,3 @@ DWORD WINAPI NtGdiSetLayout( HDC hdc, LONG wox, DWORD layout )
return old_layout;
}
/***********************************************************************
* SetDCPenColor (GDI32.@)
*/
COLORREF WINAPI SetDCPenColor(HDC hdc, COLORREF crColor)
{
DC *dc;
COLORREF oldClr = CLR_INVALID;
TRACE("hdc(%p) crColor(%08x)\n", hdc, crColor);
dc = get_dc_ptr( hdc );
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetDCPenColor );
crColor = physdev->funcs->pSetDCPenColor( physdev, crColor );
if (crColor != CLR_INVALID)
{
oldClr = dc->attr->pen_color;
dc->attr->pen_color = crColor;
}
release_dc_ptr( dc );
}
return oldClr;
}

View File

@ -93,7 +93,6 @@ extern BOOL CDECL EMFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom
INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
extern HBITMAP CDECL EMFDRV_SelectBitmap( PHYSDEV dev, HBITMAP handle ) DECLSPEC_HIDDEN;
extern HFONT CDECL EMFDRV_SelectFont( PHYSDEV dev, HFONT handle, UINT *aa_flags ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_SetDIBitsToDevice( PHYSDEV dev, INT xDest, INT yDest, DWORD cx, DWORD cy, INT xSrc,
INT ySrc, UINT startscan, UINT lines, LPCVOID bits,
BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;

View File

@ -115,7 +115,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
NULL, /* pSetBkColor */
NULL, /* pSetBoundsRect */
NULL, /* pSetDCBrushColor*/
EMFDRV_SetDCPenColor, /* pSetDCPenColor*/
NULL, /* pSetDCPenColor*/
EMFDRV_SetDIBitsToDevice, /* pSetDIBitsToDevice */
NULL, /* pSetDeviceClipping */
NULL, /* pSetDeviceGammaRamp */

View File

@ -487,26 +487,25 @@ BOOL EMFDC_SetDCBrushColor( DC_ATTR *dc_attr, COLORREF color )
}
/******************************************************************
* EMFDRV_SetDCPenColor
* EMFDC_SetDCPenColor
*/
COLORREF CDECL EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color )
BOOL EMFDC_SetDCPenColor( DC_ATTR *dc_attr, COLORREF color )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMFDRV_PDEVICE *emf = dc_attr->emf;
EMRSELECTOBJECT emr;
DWORD index;
LOGPEN logpen = { PS_SOLID, { 0, 0 }, color };
if (dc->hPen != GetStockObject( DC_PEN )) return color;
if (GetCurrentObject( dc_attr->hdc, OBJ_PEN ) != GetStockObject( DC_PEN )) return TRUE;
if (physDev->dc_pen) DeleteObject( physDev->dc_pen );
if (!(physDev->dc_pen = CreatePenIndirect( &logpen ))) return CLR_INVALID;
if (!(index = EMFDRV_CreatePenIndirect(dev, physDev->dc_pen))) return CLR_INVALID;
GDI_hdc_using_object( physDev->dc_pen, dev->hdc, EMFDC_DeleteObject );
if (emf->dc_pen) DeleteObject( emf->dc_pen );
if (!(emf->dc_pen = CreatePenIndirect( &logpen ))) return FALSE;
if (!(index = EMFDRV_CreatePenIndirect( &emf->dev, emf->dc_pen ))) return FALSE;
GDI_hdc_using_object( emf->dc_pen, dc_attr->hdc, EMFDC_DeleteObject );
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
}
/*******************************************************************

View File

@ -192,6 +192,7 @@ extern BOOL EMFDC_SetArcDirection( DC_ATTR *dc_attr, INT dir ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetBkColor( DC_ATTR *dc_attr, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetDCBrushColor( DC_ATTR *dc_attr, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetDCPenColor( DC_ATTR *dc_attr, COLORREF color ) DECLSPEC_HIDDEN;
extern INT EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dest, INT y_dest, DWORD width,
DWORD height, INT x_src, INT y_src, UINT startscan,
UINT lines, const void *bits, const BITMAPINFO *info,

View File

@ -337,6 +337,19 @@ COLORREF WINAPI GetDCPenColor(HDC hdc)
return dc_attr ? dc_attr->pen_color : CLR_INVALID;
}
/***********************************************************************
* SetDCPenColor (GDI32.@)
*/
COLORREF WINAPI SetDCPenColor( HDC hdc, COLORREF color )
{
DC_ATTR *dc_attr;
COLORREF ret;
if (!(dc_attr = get_dc_attr( hdc ))) return CLR_INVALID;
if (dc_attr->emf && !EMFDC_SetDCPenColor( dc_attr, color )) return CLR_INVALID;
return NtGdiGetAndSetDCDword( hdc, NtGdiSetDCPenColor, color, &ret ) ? ret : CLR_INVALID;
}
/***********************************************************************
* GetTextColor (GDI32.@)
*/

View File

@ -107,6 +107,7 @@ enum
NtGdiSetBkColor = 100,
NtGdiSetTextColor,
NtGdiSetDCBrushColor,
NtGdiSetDCPenColor,
};
enum