Commit a5cb435e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Use NtGdiGetAndSetDCDword for SetBkColor.

parent c230071d
......@@ -266,6 +266,13 @@ static BOOL DC_DeleteObject( HGDIOBJ handle )
}
static void set_bk_color( DC *dc, COLORREF color )
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
dc->attr->background_color = physdev->funcs->pSetBkColor( physdev, color );
}
/***********************************************************************
* DC_InitDC
*
......@@ -276,7 +283,7 @@ void DC_InitDC( DC* dc )
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette );
physdev->funcs->pRealizeDefaultPalette( physdev );
SetTextColor( dc->hSelf, dc->attr->text_color );
SetBkColor( dc->hSelf, dc->attr->background_color );
set_bk_color( dc, dc->attr->background_color );
NtGdiSelectPen( dc->hSelf, dc->hPen );
NtGdiSelectBrush( dc->hSelf, dc->hBrush );
NtGdiSelectFont( dc->hSelf, dc->hFont );
......@@ -458,7 +465,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
NtGdiSelectBrush( dev->hdc, dcs->hBrush );
NtGdiSelectFont( dev->hdc, dcs->hFont );
NtGdiSelectPen( dev->hdc, dcs->hPen );
SetBkColor( dev->hdc, dcs->attr->background_color);
set_bk_color( dc, dcs->attr->background_color);
SetTextColor( dev->hdc, dcs->attr->text_color);
GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
......@@ -488,7 +495,7 @@ static BOOL reset_dc_state( HDC hdc )
if (!(dc = get_dc_ptr( hdc ))) return FALSE;
set_initial_dc_state( dc );
SetBkColor( hdc, RGB( 255, 255, 255 ));
set_bk_color( dc, RGB( 255, 255, 255 ));
SetTextColor( hdc, RGB( 0, 0, 0 ));
NtGdiSelectBrush( hdc, GetStockObject( WHITE_BRUSH ));
NtGdiSelectFont( hdc, GetStockObject( SYSTEM_FONT ));
......@@ -809,27 +816,6 @@ INT WINAPI NtGdiGetDeviceCaps( HDC hdc, INT cap )
/***********************************************************************
* SetBkColor (GDI32.@)
*/
COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
{
COLORREF ret = CLR_INVALID;
DC * dc = get_dc_ptr( hdc );
TRACE("hdc=%p color=0x%08x\n", hdc, color);
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
ret = dc->attr->background_color;
dc->attr->background_color = physdev->funcs->pSetBkColor( physdev, color );
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* SetTextColor (GDI32.@)
*/
COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
......@@ -855,7 +841,7 @@ COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
*/
BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *prev_value )
{
BOOL ret;
BOOL ret = TRUE;
DC *dc;
if (!(dc = get_dc_ptr( hdc ))) return 0;
......@@ -867,6 +853,11 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
ret = set_map_mode( dc, value );
break;
case NtGdiSetBkColor:
*prev_value = dc->attr->background_color;
set_bk_color( dc, value );
break;
default:
WARN( "unknown method %u\n", method );
ret = FALSE;
......
......@@ -82,17 +82,14 @@ BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode )
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
COLORREF CDECL EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
BOOL EMFDC_SetBkColor( DC_ATTR *dc_attr, COLORREF color )
{
EMRSETBKCOLOR emr;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
if (physDev->restoring) return color; /* don't output records during RestoreDC */
emr.emr.iType = EMR_SETBKCOLOR;
emr.emr.nSize = sizeof(emr);
emr.crColor = color;
return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
......
......@@ -98,7 +98,6 @@ extern BOOL CDECL EMFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom
extern HBITMAP CDECL EMFDRV_SelectBitmap( PHYSDEV dev, HBITMAP handle ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) DECLSPEC_HIDDEN;
extern HFONT CDECL EMFDRV_SelectFont( PHYSDEV dev, HFONT handle, UINT *aa_flags ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) 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,
......
......@@ -116,7 +116,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
EMFDRV_SelectClipPath, /* pSelectClipPath */
EMFDRV_SelectFont, /* pSelectFont */
NULL, /* pSelectPen */
EMFDRV_SetBkColor, /* pSetBkColor */
NULL, /* pSetBkColor */
NULL, /* pSetBoundsRect */
EMFDRV_SetDCBrushColor, /* pSetDCBrushColor*/
EMFDRV_SetDCPenColor, /* pSetDCPenColor*/
......
......@@ -92,6 +92,7 @@ extern BOOL METADC_ScaleWindowExtEx( HDC hdc, INT x_num, INT x_denom, INT y_num,
INT y_denom ) DECLSPEC_HIDDEN;
extern HGDIOBJ METADC_SelectObject( HDC hdc, HGDIOBJ obj ) DECLSPEC_HIDDEN;
extern BOOL METADC_SelectPalette( HDC hdc, HPALETTE palette ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetBkColor( HDC hdc, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetBkMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN;
extern INT METADC_SetDIBitsToDevice( HDC hdc, INT x_dest, INT y_dest, DWORD width, DWORD height,
INT x_src, INT y_src, UINT startscan, UINT lines,
......@@ -181,6 +182,7 @@ extern BOOL EMFDC_ScaleWindowExtEx( DC_ATTR *dc_attr, INT x_num, INT x_denom, IN
extern BOOL EMFDC_SelectObject( DC_ATTR *dc_attr, HGDIOBJ obj ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SelectPalette( DC_ATTR *dc_attr, HPALETTE palette ) DECLSPEC_HIDDEN;
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 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,
......
......@@ -280,6 +280,20 @@ COLORREF WINAPI GetBkColor( HDC hdc )
}
/***********************************************************************
* SetBkColor (GDI32.@)
*/
COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
{
DC_ATTR *dc_attr;
COLORREF ret;
if (is_meta_dc( hdc )) return METADC_SetBkColor( hdc, color );
if (!(dc_attr = get_dc_attr( hdc ))) return CLR_INVALID;
if (dc_attr->emf && !EMFDC_SetBkColor( dc_attr, color )) return CLR_INVALID;
return NtGdiGetAndSetDCDword( hdc, NtGdiSetBkColor, color, &ret ) ? ret : CLR_INVALID;
}
/***********************************************************************
* GetDCBrushColor (GDI32.@)
*/
COLORREF WINAPI GetDCBrushColor( HDC hdc )
......
......@@ -40,9 +40,9 @@ BOOL METADC_SetBkMode( HDC hdc, INT mode )
return metadc_param1( hdc, META_SETBKMODE, (WORD)mode );
}
COLORREF CDECL MFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
BOOL METADC_SetBkColor( HDC hdc, COLORREF color )
{
return MFDRV_MetaParam2(dev, META_SETBKCOLOR, HIWORD(color), LOWORD(color)) ? color : CLR_INVALID;
return metadc_param2( hdc, META_SETBKCOLOR, HIWORD(color), LOWORD(color) );
}
COLORREF CDECL MFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
......
......@@ -181,7 +181,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_SelectClipPath, /* pSelectClipPath */
NULL, /* pSelectFont */
NULL, /* pSelectPen */
MFDRV_SetBkColor, /* pSetBkColor */
NULL, /* pSetBkColor */
MFDRV_SetBoundsRect, /* pSetBoundsRect */
MFDRV_SetDCBrushColor, /* pSetDCBrushColor*/
MFDRV_SetDCPenColor, /* pSetDCPenColor*/
......
......@@ -93,7 +93,6 @@ extern BOOL CDECL MFDRV_PolyBezierTo( PHYSDEV dev, const POINT* pt, DWORD count
extern BOOL CDECL MFDRV_RestoreDC( PHYSDEV dev, INT level ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) DECLSPEC_HIDDEN;
extern COLORREF CDECL MFDRV_SetBkColor( 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_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
......
......@@ -103,6 +103,8 @@ enum
enum
{
NtGdiSetMapMode = 8,
/* not compatible with Windows */
NtGdiSetBkColor = 100,
};
enum
......
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