gdi32: Use NtGdiGetAndSetDCDword for SetGraphicsMode.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9c03e8ae8c
commit
55849cd428
|
@ -1019,7 +1019,7 @@ BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
|
|||
HDC hdcSrc, INT nXSrc, INT nYSrc, INT nWidth,
|
||||
INT nHeight, HBITMAP hbmMask, INT xMask, INT yMask)
|
||||
{
|
||||
int oldgMode;
|
||||
DWORD prev_mode;
|
||||
/* parallelogram coords */
|
||||
POINT plg[3];
|
||||
/* rect coords */
|
||||
|
@ -1030,8 +1030,7 @@ BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
|
|||
double det;
|
||||
|
||||
/* save actual mode, set GM_ADVANCED */
|
||||
oldgMode = SetGraphicsMode(hdcDest,GM_ADVANCED);
|
||||
if (oldgMode == 0)
|
||||
if (!NtGdiGetAndSetDCDword( hdcDest, NtGdiSetGraphicsMode, GM_ADVANCED, &prev_mode ))
|
||||
return FALSE;
|
||||
|
||||
memcpy(plg,lpPoint,sizeof(POINT)*3);
|
||||
|
@ -1047,7 +1046,7 @@ BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
|
|||
|
||||
if (fabs(det) < 1e-5)
|
||||
{
|
||||
SetGraphicsMode(hdcDest,oldgMode);
|
||||
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetGraphicsMode, prev_mode, NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1083,7 @@ BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
|
|||
SRCCOPY);
|
||||
/* restore dest DC */
|
||||
SetWorldTransform(hdcDest,&oldDestXf);
|
||||
SetGraphicsMode(hdcDest,oldgMode);
|
||||
NtGdiGetAndSetDCDword( hdcDest, NtGdiSetGraphicsMode, prev_mode, NULL );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -806,6 +806,24 @@ INT WINAPI NtGdiGetDeviceCaps( HDC hdc, INT cap )
|
|||
}
|
||||
|
||||
|
||||
static BOOL set_graphics_mode( DC *dc, int mode )
|
||||
{
|
||||
if (mode == dc->attr->graphics_mode) return TRUE;
|
||||
if (mode <= 0 || mode > GM_LAST) return FALSE;
|
||||
|
||||
/* One would think that setting the graphics mode to GM_COMPATIBLE
|
||||
* would also reset the world transformation matrix to the unity
|
||||
* matrix. However, in Windows, this is not the case. This doesn't
|
||||
* make a lot of sense to me, but that's the way it is.
|
||||
*/
|
||||
dc->attr->graphics_mode = mode;
|
||||
|
||||
/* font metrics depend on the graphics mode */
|
||||
NtGdiSelectFont(dc->hSelf, dc->hFont);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* NtGdiGetAndSetDCDword (win32u.@)
|
||||
*/
|
||||
|
@ -848,6 +866,11 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
|
|||
if (value != CLR_INVALID) dc->attr->pen_color = value;
|
||||
break;
|
||||
|
||||
case NtGdiSetGraphicsMode:
|
||||
if (prev_value) *prev_value = dc->attr->graphics_mode;
|
||||
ret = set_graphics_mode( dc, value );
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN( "unknown method %u\n", method );
|
||||
ret = FALSE;
|
||||
|
@ -859,32 +882,6 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetGraphicsMode (GDI32.@)
|
||||
*/
|
||||
INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
|
||||
{
|
||||
INT ret = 0;
|
||||
DC *dc = get_dc_ptr( hdc );
|
||||
|
||||
/* One would think that setting the graphics mode to GM_COMPATIBLE
|
||||
* would also reset the world transformation matrix to the unity
|
||||
* matrix. However, in Windows, this is not the case. This doesn't
|
||||
* make a lot of sense to me, but that's the way it is.
|
||||
*/
|
||||
if (!dc) return 0;
|
||||
if ((mode > 0) && (mode <= GM_LAST))
|
||||
{
|
||||
ret = dc->attr->graphics_mode;
|
||||
dc->attr->graphics_mode = mode;
|
||||
}
|
||||
/* font metrics depend on the graphics mode */
|
||||
if (ret != mode) NtGdiSelectFont(dc->hSelf, dc->hFont);
|
||||
release_dc_ptr( dc );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* NtGdiGetTransform (win32u.@)
|
||||
*
|
||||
|
|
|
@ -436,6 +436,15 @@ INT WINAPI GetGraphicsMode( HDC hdc )
|
|||
return dc_attr ? dc_attr->graphics_mode : 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetGraphicsMode (GDI32.@)
|
||||
*/
|
||||
INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
|
||||
{
|
||||
DWORD ret;
|
||||
return NtGdiGetAndSetDCDword( hdc, NtGdiSetGraphicsMode, mode, &ret ) ? ret : 0;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetArcDirection (GDI32.@)
|
||||
*/
|
||||
|
|
|
@ -111,6 +111,7 @@ enum
|
|||
NtGdiSetTextColor,
|
||||
NtGdiSetDCBrushColor,
|
||||
NtGdiSetDCPenColor,
|
||||
NtGdiSetGraphicsMode,
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in New Issue