gdi32: Add null driver entry point for world transform functions, and move them to mapping.c.

This commit is contained in:
Alexandre Julliard 2011-03-15 14:03:02 +01:00
parent 64d18bc1f0
commit 29c3c528db
5 changed files with 93 additions and 114 deletions

View File

@ -1265,116 +1265,6 @@ BOOL WINAPI GetTransform( HDC hdc, DWORD which, XFORM *xform )
}
/***********************************************************************
* SetWorldTransform (GDI32.@)
*/
BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform )
{
BOOL ret = FALSE;
DC *dc;
if (!xform) return FALSE;
dc = get_dc_ptr( hdc );
if (!dc) return FALSE;
/* Check that graphics mode is GM_ADVANCED */
if (dc->GraphicsMode!=GM_ADVANCED) goto done;
TRACE("eM11 %f eM12 %f eM21 %f eM22 %f eDx %f eDy %f\n",
xform->eM11, xform->eM12, xform->eM21, xform->eM22, xform->eDx, xform->eDy);
/* The transform must conform to (eM11 * eM22 != eM12 * eM21) requirement */
if (xform->eM11 * xform->eM22 == xform->eM12 * xform->eM21) goto done;
if (dc->funcs->pSetWorldTransform)
{
ret = dc->funcs->pSetWorldTransform(dc->physDev, xform);
if (!ret) goto done;
}
dc->xformWorld2Wnd = *xform;
DC_UpdateXforms( dc );
ret = TRUE;
done:
release_dc_ptr( dc );
return ret;
}
/****************************************************************************
* ModifyWorldTransform [GDI32.@]
* Modifies the world transformation for a device context.
*
* PARAMS
* hdc [I] Handle to device context
* xform [I] XFORM structure that will be used to modify the world
* transformation
* iMode [I] Specifies in what way to modify the world transformation
* Possible values:
* MWT_IDENTITY
* Resets the world transformation to the identity matrix.
* The parameter xform is ignored.
* MWT_LEFTMULTIPLY
* Multiplies xform into the world transformation matrix from
* the left.
* MWT_RIGHTMULTIPLY
* Multiplies xform into the world transformation matrix from
* the right.
*
* RETURNS
* Success: TRUE.
* Failure: FALSE. Use GetLastError() to determine the cause.
*/
BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform,
DWORD iMode )
{
BOOL ret = FALSE;
DC *dc = get_dc_ptr( hdc );
/* Check for illegal parameters */
if (!dc) return FALSE;
if (!xform && iMode != MWT_IDENTITY) goto done;
/* Check that graphics mode is GM_ADVANCED */
if (dc->GraphicsMode!=GM_ADVANCED) goto done;
if (dc->funcs->pModifyWorldTransform)
{
ret = dc->funcs->pModifyWorldTransform(dc->physDev, xform, iMode);
if (!ret) goto done;
}
switch (iMode)
{
case MWT_IDENTITY:
dc->xformWorld2Wnd.eM11 = 1.0f;
dc->xformWorld2Wnd.eM12 = 0.0f;
dc->xformWorld2Wnd.eM21 = 0.0f;
dc->xformWorld2Wnd.eM22 = 1.0f;
dc->xformWorld2Wnd.eDx = 0.0f;
dc->xformWorld2Wnd.eDy = 0.0f;
break;
case MWT_LEFTMULTIPLY:
CombineTransform( &dc->xformWorld2Wnd, xform,
&dc->xformWorld2Wnd );
break;
case MWT_RIGHTMULTIPLY:
CombineTransform( &dc->xformWorld2Wnd, &dc->xformWorld2Wnd,
xform );
break;
default:
goto done;
}
DC_UpdateXforms( dc );
ret = TRUE;
done:
release_dc_ptr( dc );
return ret;
}
/****************************************************************************
* CombineTransform [GDI32.@]
* Combines two transformation matrices.

View File

@ -731,7 +731,7 @@ const DC_FUNCTIONS null_driver =
nulldrv_IntersectClipRect, /* pIntersectClipRect */
nulldrv_InvertRgn, /* pInvertRgn */
nulldrv_LineTo, /* pLineTo */
NULL, /* pModifyWorldTransform */
nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
nulldrv_MoveTo, /* pMoveTo */
nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
@ -790,7 +790,7 @@ const DC_FUNCTIONS null_driver =
nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
nulldrv_SetWindowExtEx, /* pSetWindowExt */
nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
NULL, /* pSetWorldTransform */
nulldrv_SetWorldTransform, /* pSetWorldTransform */
nulldrv_StartDoc, /* pStartDoc */
nulldrv_StartPage, /* pStartPage */
NULL, /* pStretchBlt */

View File

@ -327,17 +327,20 @@ DWORD CDECL EMFDRV_SetLayout( PHYSDEV dev, DWORD layout )
BOOL CDECL EMFDRV_SetWorldTransform( PHYSDEV dev, const XFORM *xform)
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetWorldTransform );
EMRSETWORLDTRANSFORM emr;
emr.emr.iType = EMR_SETWORLDTRANSFORM;
emr.emr.nSize = sizeof(emr);
emr.xform = *xform;
return EMFDRV_WriteRecord( dev, &emr.emr );
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
return next->funcs->pSetWorldTransform( next, xform );
}
BOOL CDECL EMFDRV_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD mode)
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pModifyWorldTransform );
EMRMODIFYWORLDTRANSFORM emr;
emr.emr.iType = EMR_MODIFYWORLDTRANSFORM;
@ -345,7 +348,8 @@ BOOL CDECL EMFDRV_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD m
emr.xform = *xform;
emr.iMode = mode;
return EMFDRV_WriteRecord( dev, &emr.emr );
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
return next->funcs->pModifyWorldTransform( next, xform, mode );
}
BOOL CDECL EMFDRV_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )

View File

@ -529,6 +529,7 @@ extern BOOL CDECL nulldrv_FrameRgn( PHYSDEV dev, HRGN rgn, HBRUSH brush, INT wid
extern COLORREF CDECL nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT CDECL nulldrv_IntersectClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD mode ) DECLSPEC_HIDDEN;
extern INT CDECL nulldrv_OffsetClipRgn( PHYSDEV dev, INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_OffsetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_OffsetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
@ -544,6 +545,7 @@ extern BOOL CDECL nulldrv_SetViewportExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *s
extern BOOL CDECL nulldrv_SetViewportOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_SetWindowExtEx( PHYSDEV dev, INT cx, INT cy, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_SetWorldTransform( PHYSDEV dev, const XFORM *xform ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_StrokePath( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_WidenPath( PHYSDEV dev ) DECLSPEC_HIDDEN;

View File

@ -265,6 +265,42 @@ BOOL CDECL nulldrv_SetWindowOrgEx( PHYSDEV dev, INT x, INT y, POINT *pt )
return TRUE;
}
BOOL CDECL nulldrv_ModifyWorldTransform( PHYSDEV dev, const XFORM *xform, DWORD mode )
{
DC *dc = get_nulldrv_dc( dev );
switch (mode)
{
case MWT_IDENTITY:
dc->xformWorld2Wnd.eM11 = 1.0f;
dc->xformWorld2Wnd.eM12 = 0.0f;
dc->xformWorld2Wnd.eM21 = 0.0f;
dc->xformWorld2Wnd.eM22 = 1.0f;
dc->xformWorld2Wnd.eDx = 0.0f;
dc->xformWorld2Wnd.eDy = 0.0f;
break;
case MWT_LEFTMULTIPLY:
CombineTransform( &dc->xformWorld2Wnd, xform, &dc->xformWorld2Wnd );
break;
case MWT_RIGHTMULTIPLY:
CombineTransform( &dc->xformWorld2Wnd, &dc->xformWorld2Wnd, xform );
break;
default:
return FALSE;
}
DC_UpdateXforms( dc );
return TRUE;
}
BOOL CDECL nulldrv_SetWorldTransform( PHYSDEV dev, const XFORM *xform )
{
DC *dc = get_nulldrv_dc( dev );
dc->xformWorld2Wnd = *xform;
DC_UpdateXforms( dc );
return TRUE;
}
/***********************************************************************
* DPtoLP (GDI32.@)
*/
@ -483,6 +519,53 @@ BOOL WINAPI ScaleWindowExtEx( HDC hdc, INT xNum, INT xDenom,
return ret;
}
/****************************************************************************
* ModifyWorldTransform (GDI32.@)
*/
BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform, DWORD mode )
{
BOOL ret = FALSE;
DC *dc;
if (!xform && mode != MWT_IDENTITY) return FALSE;
if ((dc = get_dc_ptr( hdc )))
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pModifyWorldTransform );
if (dc->GraphicsMode == GM_ADVANCED)
ret = physdev->funcs->pModifyWorldTransform( physdev, xform, mode );
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* SetWorldTransform (GDI32.@)
*/
BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform )
{
BOOL ret = FALSE;
DC *dc;
if (!xform) return FALSE;
/* The transform must conform to (eM11 * eM22 != eM12 * eM21) requirement */
if (xform->eM11 * xform->eM22 == xform->eM12 * xform->eM21) return FALSE;
TRACE("eM11 %f eM12 %f eM21 %f eM22 %f eDx %f eDy %f\n",
xform->eM11, xform->eM12, xform->eM21, xform->eM22, xform->eDx, xform->eDy);
if ((dc = get_dc_ptr( hdc )))
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetWorldTransform );
if (dc->GraphicsMode == GM_ADVANCED)
ret = physdev->funcs->pSetWorldTransform( physdev, xform );
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* SetVirtualResolution (GDI32.@)
*