Commit 99b59158 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Use get_dc_attr in SetBkMode.

parent 4a32a875
......@@ -1556,34 +1556,6 @@ INT WINAPI GetRelAbs( HDC hdc, DWORD dwIgnore )
/***********************************************************************
* SetBkMode (GDI32.@)
*/
INT WINAPI SetBkMode( HDC hdc, INT mode )
{
INT ret = 0;
DC *dc;
if ((mode <= 0) || (mode > BKMODE_LAST))
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if ((dc = get_dc_ptr( hdc )))
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkMode );
mode = physdev->funcs->pSetBkMode( physdev, mode );
if (mode)
{
ret = dc->attr->background_mode;
dc->attr->background_mode = mode;
}
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* GetROP2 (GDI32.@)
*/
INT WINAPI GetROP2( HDC hdc )
......
......@@ -80,13 +80,13 @@ BOOL CDECL EMFDRV_SetTextJustification(PHYSDEV dev, INT nBreakExtra, INT nBreakC
return EMFDRV_WriteRecord(dev, &emr.emr);
}
INT CDECL EMFDRV_SetBkMode( PHYSDEV dev, INT mode )
BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode )
{
EMRSETBKMODE emr;
emr.emr.iType = EMR_SETBKMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dev, &emr.emr ) ? mode : 0;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
COLORREF CDECL EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
......
......@@ -115,7 +115,6 @@ extern HPEN CDECL EMFDRV_SelectPen( PHYSDEV dev, HPEN handle, const struct b
extern HPALETTE CDECL EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_SetArcDirection( PHYSDEV dev, INT arcDirection ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_SetBkMode( PHYSDEV dev, INT mode ) 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,
......
......@@ -129,7 +129,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
EMFDRV_SelectPen, /* pSelectPen */
EMFDRV_SetArcDirection, /* pSetArcDirection */
EMFDRV_SetBkColor, /* pSetBkColor */
EMFDRV_SetBkMode, /* pSetBkMode */
NULL, /* pSetBkMode */
NULL, /* pSetBoundsRect */
EMFDRV_SetDCBrushColor, /* pSetDCBrushColor*/
EMFDRV_SetDCPenColor, /* pSetDCPenColor*/
......
......@@ -66,6 +66,7 @@ extern BOOL METADC_Polyline( HDC hdc, const POINT *points,INT count) DECLSPEC_HI
extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN;
extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetBkMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetPixel( HDC hdc, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetTextAlign( HDC hdc, UINT align ) DECLSPEC_HIDDEN;
......@@ -109,6 +110,7 @@ extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right,
INT bottom) DECLSPEC_HIDDEN;
extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetPixel( DC_ATTR *dc_attr, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align ) DECLSPEC_HIDDEN;
......
......@@ -75,6 +75,29 @@ INT WINAPI GetBkMode( HDC hdc )
}
/***********************************************************************
* SetBkMode (GDI32.@)
*/
INT WINAPI SetBkMode( HDC hdc, INT mode )
{
DC_ATTR *dc_attr;
INT ret;
if (mode <= 0 || mode > BKMODE_LAST)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (is_meta_dc( hdc )) return METADC_SetBkMode( hdc, mode );
if (!(dc_attr = get_dc_attr( hdc ))) return 0;
if (dc_attr->emf && !EMFDC_SetBkMode( dc_attr, mode )) return 0;
ret = dc_attr->background_mode;
dc_attr->background_mode = mode;
return ret;
}
/***********************************************************************
* GetCurrentPositionEx (GDI32.@)
*/
BOOL WINAPI GetCurrentPositionEx( HDC hdc, POINT *point )
......
......@@ -35,9 +35,9 @@ BOOL METADC_SetTextAlign( HDC hdc, UINT align )
return metadc_param2( hdc, META_SETTEXTALIGN, HIWORD(align), LOWORD(align) );
}
INT CDECL MFDRV_SetBkMode( PHYSDEV dev, INT mode )
BOOL METADC_SetBkMode( HDC hdc, INT mode )
{
return MFDRV_MetaParam1( dev, META_SETBKMODE, (WORD)mode) ? mode : 0;
return metadc_param1( hdc, META_SETBKMODE, (WORD)mode );
}
COLORREF CDECL MFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
......
......@@ -192,7 +192,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_SelectPen, /* pSelectPen */
NULL, /* pSetArcDirection */
MFDRV_SetBkColor, /* pSetBkColor */
MFDRV_SetBkMode, /* pSetBkMode */
NULL, /* pSetBkMode */
MFDRV_SetBoundsRect, /* pSetBoundsRect */
MFDRV_SetDCBrushColor, /* pSetDCBrushColor*/
MFDRV_SetDCPenColor, /* pSetDCPenColor*/
......@@ -612,6 +612,14 @@ BOOL metadc_record( HDC hdc, METARECORD *mr, DWORD rlen )
return MFDRV_WriteRecord( &dev->dev, mr, rlen );
}
BOOL metadc_param1( HDC hdc, short func, short param )
{
METAFILEDRV_PDEVICE *dev;
if (!(dev = get_metadc_ptr( hdc ))) return FALSE;
return MFDRV_MetaParam1( &dev->dev, func, param );
}
BOOL metadc_param2( HDC hdc, short func, short param1, short param2 )
{
METAFILEDRV_PDEVICE *dev;
......
......@@ -60,6 +60,7 @@ extern BOOL MFDRV_RemoveHandle( PHYSDEV dev, UINT index ) DECLSPEC_HIDDEN;
extern INT16 MFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) DECLSPEC_HIDDEN;
extern METAFILEDRV_PDEVICE *get_metadc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
extern BOOL metadc_param1( HDC hdc, short func, short param ) DECLSPEC_HIDDEN;
extern BOOL metadc_param2( HDC hdc, short func, short param1, short param2 ) DECLSPEC_HIDDEN;
extern BOOL metadc_param4( HDC hdc, short func, short param1, short param2,
short param3, short param4 ) DECLSPEC_HIDDEN;
......@@ -105,7 +106,6 @@ extern HPEN CDECL MFDRV_SelectPen( PHYSDEV dev, HPEN handle, const struct brush
extern HPALETTE CDECL MFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPalette, BOOL bForceBackground) DECLSPEC_HIDDEN;
extern UINT CDECL MFDRV_RealizePalette(PHYSDEV dev, HPALETTE hPalette, BOOL primary) DECLSPEC_HIDDEN;
extern COLORREF CDECL MFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_SetBkMode( PHYSDEV dev, INT mode ) 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 DWORD CDECL MFDRV_SetLayout( PHYSDEV dev, DWORD layout ) DECLSPEC_HIDDEN;
......
......@@ -40,7 +40,7 @@ static void test_dc_values(void)
{
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
COLORREF color;
int extra;
int extra, attr;
ok( hdc != NULL, "CreateDC failed\n" );
color = SetBkColor( hdc, 0x12345678 );
......@@ -81,6 +81,11 @@ static void test_dc_values(void)
extra = GetTextCharacterExtra( hdc );
ok( extra == 123, "initial extra %d\n", extra );
SetLastError(0xdeadbeef);
attr = SetBkMode(ULongToHandle(0xdeadbeef), OPAQUE);
ok(!attr, "attr = %x\n", attr);
ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError());
DeleteDC( hdc );
}
......
......@@ -3127,6 +3127,11 @@ static void test_mf_attrs(void)
attr = SetTextAlign(hdc, TA_TOP);
ok(attr == TRUE, "attr = %x\n", attr);
attr = SetBkMode(hdc, TRANSPARENT);
ok(attr == TRUE, "attr = %x\n", attr);
attr = SetBkMode(hdc, OPAQUE);
ok(attr == TRUE, "attr = %x\n", attr);
mf = CloseMetaFile(hdc);
ok(mf != 0, "CloseEnhMetaFile failed\n");
DeleteMetaFile(mf);
......@@ -3280,6 +3285,11 @@ static void test_emf_attrs(void)
attr = SetTextAlign(hdc, TA_TOP);
ok(attr == TA_BOTTOM, "attr = %x\n", attr);
attr = SetBkMode(hdc, TRANSPARENT);
ok(attr == OPAQUE, "attr = %x\n", attr);
attr = SetBkMode(hdc, OPAQUE);
ok(attr == TRANSPARENT, "attr = %x\n", attr);
mf = CloseEnhMetaFile(hdc);
ok(mf != 0, "CloseEnhMetaFile failed\n");
DeleteEnhMetaFile(mf);
......
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