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

gdi32: Use NtGdiGetAndSetDCDword for SetTextColor.

parent a5cb435e
......@@ -273,6 +273,13 @@ static void set_bk_color( DC *dc, COLORREF color )
}
static void set_text_color( DC *dc, COLORREF color )
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor );
dc->attr->text_color = physdev->funcs->pSetTextColor( physdev, color );
}
/***********************************************************************
* DC_InitDC
*
......@@ -282,7 +289,7 @@ void DC_InitDC( DC* dc )
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette );
physdev->funcs->pRealizeDefaultPalette( physdev );
SetTextColor( dc->hSelf, dc->attr->text_color );
set_text_color( dc, dc->attr->text_color );
set_bk_color( dc, dc->attr->background_color );
NtGdiSelectPen( dc->hSelf, dc->hPen );
NtGdiSelectBrush( dc->hSelf, dc->hBrush );
......@@ -466,7 +473,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
NtGdiSelectFont( dev->hdc, dcs->hFont );
NtGdiSelectPen( dev->hdc, dcs->hPen );
set_bk_color( dc, dcs->attr->background_color);
SetTextColor( dev->hdc, dcs->attr->text_color);
set_text_color( dc, dcs->attr->text_color);
GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
dc->saved_dc = dcs->saved_dc;
......@@ -496,7 +503,7 @@ static BOOL reset_dc_state( HDC hdc )
set_initial_dc_state( dc );
set_bk_color( dc, RGB( 255, 255, 255 ));
SetTextColor( hdc, RGB( 0, 0, 0 ));
set_text_color( dc, RGB( 0, 0, 0 ));
NtGdiSelectBrush( hdc, GetStockObject( WHITE_BRUSH ));
NtGdiSelectFont( hdc, GetStockObject( SYSTEM_FONT ));
NtGdiSelectPen( hdc, GetStockObject( BLACK_PEN ));
......@@ -816,27 +823,6 @@ INT WINAPI NtGdiGetDeviceCaps( HDC hdc, INT cap )
/***********************************************************************
* SetTextColor (GDI32.@)
*/
COLORREF WINAPI SetTextColor( 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, pSetTextColor );
ret = dc->attr->text_color;
dc->attr->text_color = physdev->funcs->pSetTextColor( physdev, color );
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* NtGdiGetAndSetDCDword (win32u.@)
*/
BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *prev_value )
......@@ -858,6 +844,11 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
set_bk_color( dc, value );
break;
case NtGdiSetTextColor:
*prev_value = dc->attr->text_color;
set_text_color( dc, value );
break;
default:
WARN( "unknown method %u\n", method );
ret = FALSE;
......
......@@ -93,17 +93,14 @@ BOOL EMFDC_SetBkColor( DC_ATTR *dc_attr, COLORREF color )
}
COLORREF CDECL EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
BOOL EMFDC_SetTextColor( DC_ATTR *dc_attr, COLORREF color )
{
EMRSETTEXTCOLOR emr;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
if (physDev->restoring) return color; /* don't output records during RestoreDC */
emr.emr.iType = EMR_SETTEXTCOLOR;
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 );
}
BOOL EMFDC_SetROP2( DC_ATTR *dc_attr, INT rop )
......
......@@ -104,7 +104,6 @@ extern INT CDECL EMFDRV_SetDIBitsToDevice( PHYSDEV dev, INT xDest, INT yDes
INT ySrc, UINT startscan, UINT lines, LPCVOID bits,
BITMAPINFO *info, UINT coloruse ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern 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, BITMAPINFO *info, UINT wUsage, DWORD dwRop ) DECLSPEC_HIDDEN;
......
......@@ -124,7 +124,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
NULL, /* pSetDeviceClipping */
NULL, /* pSetDeviceGammaRamp */
EMFDRV_SetPixel, /* pSetPixel */
EMFDRV_SetTextColor, /* pSetTextColor */
NULL, /* pSetTextColor */
NULL, /* pStartDoc */
NULL, /* pStartPage */
NULL, /* pStretchBlt */
......
......@@ -108,6 +108,7 @@ extern BOOL METADC_SetRelAbs( HDC hdc, INT mode ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetROP2( HDC hdc, INT rop ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetStretchBltMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetTextAlign( HDC hdc, UINT align ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetTextColor( HDC hdc, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetTextJustification( HDC hdc, INT extra, INT breaks ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetViewportExtEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetViewportOrgEx( HDC hdc, INT x, INT y ) DECLSPEC_HIDDEN;
......@@ -196,6 +197,7 @@ extern BOOL EMFDC_SetPolyFillMode( DC_ATTR *dc_attr, INT mode ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetROP2( DC_ATTR *dc_attr, INT rop ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetStretchBltMode( DC_ATTR *dc_attr, INT mode ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetTextColor( DC_ATTR *dc_attr, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetTextJustification( DC_ATTR *dc_attr, INT extra, INT breaks ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetViewportExtEx( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetViewportOrgEx( DC_ATTR *dc_attr, INT x, INT y ) DECLSPEC_HIDDEN;
......
......@@ -321,6 +321,20 @@ COLORREF WINAPI GetTextColor( HDC hdc )
}
/***********************************************************************
* SetTextColor (GDI32.@)
*/
COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
{
DC_ATTR *dc_attr;
COLORREF ret;
if (is_meta_dc( hdc )) return METADC_SetTextColor( hdc, color );
if (!(dc_attr = get_dc_attr( hdc ))) return CLR_INVALID;
if (dc_attr->emf && !EMFDC_SetTextColor( dc_attr, color )) return CLR_INVALID;
return NtGdiGetAndSetDCDword( hdc, NtGdiSetTextColor, color, &ret ) ? ret : CLR_INVALID;
}
/***********************************************************************
* GetBkMode (GDI32.@)
*/
INT WINAPI GetBkMode( HDC hdc )
......
......@@ -45,9 +45,9 @@ BOOL METADC_SetBkColor( HDC hdc, COLORREF color )
return metadc_param2( hdc, META_SETBKCOLOR, HIWORD(color), LOWORD(color) );
}
COLORREF CDECL MFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
BOOL METADC_SetTextColor( HDC hdc, COLORREF color )
{
return MFDRV_MetaParam2(dev, META_SETTEXTCOLOR, HIWORD(color), LOWORD(color)) ? color : CLR_INVALID;
return metadc_param2( hdc, META_SETTEXTCOLOR, HIWORD(color), LOWORD(color) );
}
BOOL METADC_SetROP2( HDC hdc, INT rop )
......
......@@ -189,7 +189,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
NULL, /* pSetDeviceClipping */
NULL, /* pSetDeviceGammaRamp */
NULL, /* pSetPixel */
MFDRV_SetTextColor, /* pSetTextColor */
NULL, /* pSetTextColor */
NULL, /* pStartDoc */
NULL, /* pStartPage */
NULL, /* pStretchBlt */
......
......@@ -95,7 +95,6 @@ extern BOOL CDECL MFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT
extern BOOL CDECL MFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) 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;
extern BOOL CDECL MFDRV_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
......
......@@ -105,6 +105,7 @@ enum
NtGdiSetMapMode = 8,
/* not compatible with Windows */
NtGdiSetBkColor = 100,
NtGdiSetTextColor,
};
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