diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 4fc1204d70c..f1648575ecb 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -821,6 +821,7 @@ INT WINAPI NtGdiGetDeviceCaps( HDC hdc, INT cap ) */ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *prev_value ) { + PHYSDEV physdev; BOOL ret = TRUE; DC *dc; @@ -843,6 +844,13 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre set_text_color( dc, value ); break; + case NtGdiSetDCBrushColor: + physdev = GET_DC_PHYSDEV( dc, pSetDCBrushColor ); + *prev_value = dc->attr->brush_color; + value = physdev->funcs->pSetDCBrushColor( physdev, value ); + if (value != CLR_INVALID) dc->attr->brush_color = value; + break; + default: WARN( "unknown method %u\n", method ); ret = FALSE; @@ -1287,32 +1295,6 @@ DWORD WINAPI NtGdiSetLayout( HDC hdc, LONG wox, DWORD layout ) return old_layout; } -/*********************************************************************** - * SetDCBrushColor (GDI32.@) - */ -COLORREF WINAPI SetDCBrushColor(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, pSetDCBrushColor ); - crColor = physdev->funcs->pSetDCBrushColor( physdev, crColor ); - if (crColor != CLR_INVALID) - { - oldClr = dc->attr->brush_color; - dc->attr->brush_color = crColor; - } - release_dc_ptr( dc ); - } - - return oldClr; -} - /*********************************************************************** * SetDCPenColor (GDI32.@) */ diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h index e96093b825b..82b450a3e03 100644 --- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h +++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h @@ -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_SetDCBrushColor( PHYSDEV dev, COLORREF color ) 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, diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index 0088ee29609..d1e19993e8e 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -114,7 +114,7 @@ static const struct gdi_dc_funcs emfdrv_driver = NULL, /* pSelectPen */ NULL, /* pSetBkColor */ NULL, /* pSetBoundsRect */ - EMFDRV_SetDCBrushColor, /* pSetDCBrushColor*/ + NULL, /* pSetDCBrushColor*/ EMFDRV_SetDCPenColor, /* pSetDCPenColor*/ EMFDRV_SetDIBitsToDevice, /* pSetDIBitsToDevice */ NULL, /* pSetDeviceClipping */ diff --git a/dlls/gdi32/enhmfdrv/objects.c b/dlls/gdi32/enhmfdrv/objects.c index 1e2cb52dc6a..76f67594770 100644 --- a/dlls/gdi32/enhmfdrv/objects.c +++ b/dlls/gdi32/enhmfdrv/objects.c @@ -466,25 +466,24 @@ BOOL EMFDC_SelectObject( DC_ATTR *dc_attr, HGDIOBJ obj ) } /****************************************************************** - * EMFDRV_SetDCBrushColor + * EMFDC_SetDCBrushColor */ -COLORREF CDECL EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) +BOOL EMFDC_SetDCBrushColor( 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; - if (dc->hBrush != GetStockObject( DC_BRUSH )) return color; + if (GetCurrentObject( dc_attr->hdc, OBJ_BRUSH ) != GetStockObject( DC_BRUSH )) return TRUE; - if (physDev->dc_brush) DeleteObject( physDev->dc_brush ); - if (!(physDev->dc_brush = CreateSolidBrush( color ))) return CLR_INVALID; - if (!(index = EMFDRV_CreateBrushIndirect(dev, physDev->dc_brush ))) return CLR_INVALID; - GDI_hdc_using_object( physDev->dc_brush, dev->hdc, EMFDC_DeleteObject ); + if (emf->dc_brush) DeleteObject( emf->dc_brush ); + if (!(emf->dc_brush = CreateSolidBrush( color ))) return FALSE; + if (!(index = EMFDRV_CreateBrushIndirect( &emf->dev, emf->dc_brush ))) return FALSE; + GDI_hdc_using_object( emf->dc_brush, 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 ); } /****************************************************************** diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 969cd324f98..3b2e787005d 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -191,6 +191,7 @@ extern BOOL EMFDC_SelectPalette( DC_ATTR *dc_attr, HPALETTE palette ) DECLSPEC_H 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 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, diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c index e5d0e711eab..98cb01476d2 100644 --- a/dlls/gdi32/gdidc.c +++ b/dlls/gdi32/gdidc.c @@ -315,6 +315,19 @@ COLORREF WINAPI GetDCBrushColor( HDC hdc ) return dc_attr ? dc_attr->brush_color : CLR_INVALID; } +/*********************************************************************** + * SetDCBrushColor (GDI32.@) + */ +COLORREF WINAPI SetDCBrushColor( 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_SetDCBrushColor( dc_attr, color )) return CLR_INVALID; + return NtGdiGetAndSetDCDword( hdc, NtGdiSetDCBrushColor, color, &ret ) ? ret : CLR_INVALID; +} + /*********************************************************************** * GetDCPenColor (GDI32.@) */ diff --git a/include/ntgdi.h b/include/ntgdi.h index 5fb3ac76c04..e6447dd836f 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -106,6 +106,7 @@ enum /* not compatible with Windows */ NtGdiSetBkColor = 100, NtGdiSetTextColor, + NtGdiSetDCBrushColor, }; enum