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 ) ...@@ -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 * DC_InitDC
* *
...@@ -276,7 +283,7 @@ void DC_InitDC( DC* dc ) ...@@ -276,7 +283,7 @@ void DC_InitDC( DC* dc )
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette ); PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette );
physdev->funcs->pRealizeDefaultPalette( physdev ); physdev->funcs->pRealizeDefaultPalette( physdev );
SetTextColor( dc->hSelf, dc->attr->text_color ); 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 ); NtGdiSelectPen( dc->hSelf, dc->hPen );
NtGdiSelectBrush( dc->hSelf, dc->hBrush ); NtGdiSelectBrush( dc->hSelf, dc->hBrush );
NtGdiSelectFont( dc->hSelf, dc->hFont ); NtGdiSelectFont( dc->hSelf, dc->hFont );
...@@ -458,7 +465,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) ...@@ -458,7 +465,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
NtGdiSelectBrush( dev->hdc, dcs->hBrush ); NtGdiSelectBrush( dev->hdc, dcs->hBrush );
NtGdiSelectFont( dev->hdc, dcs->hFont ); NtGdiSelectFont( dev->hdc, dcs->hFont );
NtGdiSelectPen( dev->hdc, dcs->hPen ); 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); SetTextColor( dev->hdc, dcs->attr->text_color);
GDISelectPalette( dev->hdc, dcs->hPalette, FALSE ); GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
...@@ -488,7 +495,7 @@ static BOOL reset_dc_state( HDC hdc ) ...@@ -488,7 +495,7 @@ static BOOL reset_dc_state( HDC hdc )
if (!(dc = get_dc_ptr( hdc ))) return FALSE; if (!(dc = get_dc_ptr( hdc ))) return FALSE;
set_initial_dc_state( dc ); 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 )); SetTextColor( hdc, RGB( 0, 0, 0 ));
NtGdiSelectBrush( hdc, GetStockObject( WHITE_BRUSH )); NtGdiSelectBrush( hdc, GetStockObject( WHITE_BRUSH ));
NtGdiSelectFont( hdc, GetStockObject( SYSTEM_FONT )); NtGdiSelectFont( hdc, GetStockObject( SYSTEM_FONT ));
...@@ -809,27 +816,6 @@ INT WINAPI NtGdiGetDeviceCaps( HDC hdc, INT cap ) ...@@ -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.@) * SetTextColor (GDI32.@)
*/ */
COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color ) COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
...@@ -855,7 +841,7 @@ 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 WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *prev_value )
{ {
BOOL ret; BOOL ret = TRUE;
DC *dc; DC *dc;
if (!(dc = get_dc_ptr( hdc ))) return 0; if (!(dc = get_dc_ptr( hdc ))) return 0;
...@@ -867,6 +853,11 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre ...@@ -867,6 +853,11 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
ret = set_map_mode( dc, value ); ret = set_map_mode( dc, value );
break; break;
case NtGdiSetBkColor:
*prev_value = dc->attr->background_color;
set_bk_color( dc, value );
break;
default: default:
WARN( "unknown method %u\n", method ); WARN( "unknown method %u\n", method );
ret = FALSE; ret = FALSE;
......
...@@ -82,17 +82,14 @@ BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode ) ...@@ -82,17 +82,14 @@ BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode )
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr ); 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; 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.iType = EMR_SETBKCOLOR;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
emr.crColor = color; 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 ...@@ -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 HBITMAP CDECL EMFDRV_SelectBitmap( PHYSDEV dev, HBITMAP handle ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) 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 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_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetDCPenColor( 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, 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 = ...@@ -116,7 +116,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
EMFDRV_SelectClipPath, /* pSelectClipPath */ EMFDRV_SelectClipPath, /* pSelectClipPath */
EMFDRV_SelectFont, /* pSelectFont */ EMFDRV_SelectFont, /* pSelectFont */
NULL, /* pSelectPen */ NULL, /* pSelectPen */
EMFDRV_SetBkColor, /* pSetBkColor */ NULL, /* pSetBkColor */
NULL, /* pSetBoundsRect */ NULL, /* pSetBoundsRect */
EMFDRV_SetDCBrushColor, /* pSetDCBrushColor*/ EMFDRV_SetDCBrushColor, /* pSetDCBrushColor*/
EMFDRV_SetDCPenColor, /* pSetDCPenColor*/ EMFDRV_SetDCPenColor, /* pSetDCPenColor*/
......
...@@ -92,6 +92,7 @@ extern BOOL METADC_ScaleWindowExtEx( HDC hdc, INT x_num, INT x_denom, INT y_num, ...@@ -92,6 +92,7 @@ extern BOOL METADC_ScaleWindowExtEx( HDC hdc, INT x_num, INT x_denom, INT y_num,
INT y_denom ) DECLSPEC_HIDDEN; INT y_denom ) DECLSPEC_HIDDEN;
extern HGDIOBJ METADC_SelectObject( HDC hdc, HGDIOBJ obj ) 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_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 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, 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, 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 ...@@ -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_SelectObject( DC_ATTR *dc_attr, HGDIOBJ obj ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SelectPalette( DC_ATTR *dc_attr, HPALETTE palette ) 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_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_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, 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, DWORD height, INT x_src, INT y_src, UINT startscan,
......
...@@ -280,6 +280,20 @@ COLORREF WINAPI GetBkColor( HDC hdc ) ...@@ -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.@) * GetDCBrushColor (GDI32.@)
*/ */
COLORREF WINAPI GetDCBrushColor( HDC hdc ) COLORREF WINAPI GetDCBrushColor( HDC hdc )
......
...@@ -40,9 +40,9 @@ BOOL METADC_SetBkMode( HDC hdc, INT mode ) ...@@ -40,9 +40,9 @@ BOOL METADC_SetBkMode( HDC hdc, INT mode )
return metadc_param1( hdc, META_SETBKMODE, (WORD)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 ) COLORREF CDECL MFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
......
...@@ -181,7 +181,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs = ...@@ -181,7 +181,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_SelectClipPath, /* pSelectClipPath */ MFDRV_SelectClipPath, /* pSelectClipPath */
NULL, /* pSelectFont */ NULL, /* pSelectFont */
NULL, /* pSelectPen */ NULL, /* pSelectPen */
MFDRV_SetBkColor, /* pSetBkColor */ NULL, /* pSetBkColor */
MFDRV_SetBoundsRect, /* pSetBoundsRect */ MFDRV_SetBoundsRect, /* pSetBoundsRect */
MFDRV_SetDCBrushColor, /* pSetDCBrushColor*/ MFDRV_SetDCBrushColor, /* pSetDCBrushColor*/
MFDRV_SetDCPenColor, /* pSetDCPenColor*/ MFDRV_SetDCPenColor, /* pSetDCPenColor*/
......
...@@ -93,7 +93,6 @@ extern BOOL CDECL MFDRV_PolyBezierTo( PHYSDEV dev, const POINT* pt, DWORD count ...@@ -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_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_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 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_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;
......
...@@ -103,6 +103,8 @@ enum ...@@ -103,6 +103,8 @@ enum
enum enum
{ {
NtGdiSetMapMode = 8, NtGdiSetMapMode = 8,
/* not compatible with Windows */
NtGdiSetBkColor = 100,
}; };
enum 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