Remove DC_GET_VAL macro and friends. They were defining functions that we didn't use, except 4, but those were also quite useless, as the only returned a value from the dc structure that you pass in.

same for IntGetGraphicsMode. Also remove IntGetViewportExtEx and replace it with DC_vUpdateViewportExt

svn path=/trunk/; revision=40201
This commit is contained in:
Timo Kreuzer 2009-03-24 02:58:14 +00:00
parent c5a8c1281c
commit 0a1914e0b7
6 changed files with 40 additions and 188 deletions

View file

@ -10,10 +10,6 @@
#define XForm2MatrixS(m, x) XFORMOBJ_iSetXform((XFORMOBJ*)m, (XFORML*)x) #define XForm2MatrixS(m, x) XFORMOBJ_iSetXform((XFORMOBJ*)m, (XFORML*)x)
#define MatrixS2XForm(x, m) XFORMOBJ_iGetXform((XFORMOBJ*)m, (XFORML*)x) #define MatrixS2XForm(x, m) XFORMOBJ_iGetXform((XFORMOBJ*)m, (XFORML*)x)
int
FASTCALL
IntGetGraphicsMode ( PDC dc );
int APIENTRY IntGdiSetMapMode(PDC, int); int APIENTRY IntGdiSetMapMode(PDC, int);
BOOL BOOL

View file

@ -248,16 +248,12 @@ BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL);
VOID FASTCALL DC_UpdateXforms(PDC dc); VOID FASTCALL DC_UpdateXforms(PDC dc);
BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest); BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
VOID FASTCALL DC_vUpdateViewportExt(PDC pdc);
BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC); BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC);
BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC); BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC);
VOID FASTCALL DCU_SetDcUndeletable(HDC); VOID FASTCALL DCU_SetDcUndeletable(HDC);
VOID FASTCALL IntGetViewportExtEx(PDC dc, LPSIZE pt);
VOID FASTCALL IntGetViewportOrgEx(PDC dc, LPPOINT pt);
VOID FASTCALL IntGetWindowExtEx(PDC dc, LPSIZE pt);
VOID FASTCALL IntGetWindowOrgEx(PDC dc, LPPOINT pt);
COLORREF FASTCALL IntGdiSetBkColor (HDC hDC, COLORREF Color); COLORREF FASTCALL IntGdiSetBkColor (HDC hDC, COLORREF Color);
INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode); INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode);
COLORREF APIENTRY IntGdiGetBkColor(HDC hDC); COLORREF APIENTRY IntGdiGetBkColor(HDC hDC);

View file

@ -119,17 +119,6 @@ BOOL APIENTRY NtGdiCombineTransform(
return Ret; return Ret;
} }
// FIXME: remove me!
int
FASTCALL
IntGetGraphicsMode(PDC dc)
{
PDC_ATTR pdcattr;
ASSERT(dc);
pdcattr = dc->pdcattr;
return pdcattr->iGraphicsMode;
}
// FIXME: Don't use floating point in the kernel // FIXME: Don't use floating point in the kernel
BOOL BOOL
FASTCALL FASTCALL
@ -262,7 +251,8 @@ NtGdiTransformPoints(
Size = Count * sizeof(POINT); Size = Count * sizeof(POINT);
Points = (LPPOINT)ExAllocatePoolWithTag(PagedPool, Size, TAG_COORD); // FIXME: It would be wise to have a small stack buffer as optimization
Points = ExAllocatePoolWithTag(PagedPool, Size, TAG_COORD);
if (!Points) if (!Points)
{ {
DC_UnlockDc(dc); DC_UnlockDc(dc);
@ -1129,7 +1119,7 @@ GdiSetDCOrg(HDC hDC, LONG Left, LONG Top, PRECTL prc)
DC_UnlockDc(pdc); DC_UnlockDc(pdc);
} }
// FIXME: remove me
BOOL FASTCALL BOOL FASTCALL
IntGdiGetDCOrg(PDC pDc, PPOINTL ppt) IntGdiGetDCOrg(PDC pDc, PPOINTL ppt)
{ {
@ -1137,6 +1127,7 @@ IntGdiGetDCOrg(PDC pDc, PPOINTL ppt)
return TRUE; return TRUE;
} }
// FIXME: remove me
BOOL APIENTRY BOOL APIENTRY
GdiGetDCOrgEx(HDC hDC, PPOINTL ppt, PRECTL prc) GdiGetDCOrgEx(HDC hDC, PPOINTL ppt, PRECTL prc)
{ {
@ -1152,14 +1143,11 @@ GdiGetDCOrgEx(HDC hDC, PPOINTL ppt, PRECTL prc)
return TRUE; return TRUE;
} }
BOOL FASTCALL static
IntGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio) VOID FASTCALL
DC_vGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio)
{ {
PDC_ATTR pdcattr; if (pDC->pdcattr->flFontMapper & 1) // TRUE assume 1.
pdcattr = pDC->pdcattr;
if ( pdcattr->flFontMapper & 1 ) // TRUE assume 1.
{ {
// "This specifies that Windows should only match fonts that have the // "This specifies that Windows should only match fonts that have the
// same aspect ratio as the display.", Programming Windows, Fifth Ed. // same aspect ratio as the display.", Programming Windows, Fifth Ed.
@ -1171,12 +1159,11 @@ IntGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio)
AspectRatio->cx = 0; AspectRatio->cx = 0;
AspectRatio->cy = 0; AspectRatio->cy = 0;
} }
return TRUE;
} }
VOID VOID
FASTCALL FASTCALL
IntGetViewportExtEx(PDC pdc, LPSIZE pSize) DC_vUpdateViewportExt(PDC pdc)
{ {
PDC_ATTR pdcattr; PDC_ATTR pdcattr;
@ -1195,9 +1182,6 @@ IntGetViewportExtEx(PDC pdc, LPSIZE pSize)
/* Update xforms, CHECKME: really done here? */ /* Update xforms, CHECKME: really done here? */
DC_UpdateXforms(pdc); DC_UpdateXforms(pdc);
} }
/* Copy the viewport extension */
*pSize = pdcattr->szlViewportExt;
} }
BOOL APIENTRY BOOL APIENTRY
@ -1207,7 +1191,7 @@ NtGdiGetDCPoint(
PPOINTL Point) PPOINTL Point)
{ {
BOOL Ret = TRUE; BOOL Ret = TRUE;
DC *dc; DC *pdc;
POINTL SafePoint; POINTL SafePoint;
SIZE Size; SIZE Size;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
@ -1218,10 +1202,8 @@ NtGdiGetDCPoint(
return FALSE; return FALSE;
} }
RtlZeroMemory(&SafePoint, sizeof(POINT)); pdc = DC_LockDc(hDC);
if (!pdc)
dc = DC_LockDc(hDC);
if (!dc)
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
@ -1230,31 +1212,30 @@ NtGdiGetDCPoint(
switch (iPoint) switch (iPoint)
{ {
case GdiGetViewPortExt: case GdiGetViewPortExt:
IntGetViewportExtEx(dc, &Size); DC_vUpdateViewportExt(pdc);
SafePoint.x = Size.cx; SafePoint.x = pdc->pdcattr->szlViewportExt.cx;
SafePoint.y = Size.cy; SafePoint.y = pdc->pdcattr->szlViewportExt.cy;
break; break;
case GdiGetWindowExt: case GdiGetWindowExt:
IntGetWindowExtEx(dc, &Size); SafePoint.x = pdc->pdcattr->szlWindowExt.cx;
SafePoint.x = Size.cx; SafePoint.y = pdc->pdcattr->szlWindowExt.cy;
SafePoint.y = Size.cy;
break; break;
case GdiGetViewPortOrg: case GdiGetViewPortOrg:
IntGetViewportOrgEx(dc, &SafePoint); SafePoint = pdc->pdcattr->ptlViewportOrg;
break; break;
case GdiGetWindowOrg: case GdiGetWindowOrg:
IntGetWindowOrgEx(dc, &SafePoint); SafePoint = pdc->pdcattr->ptlWindowOrg;
break; break;
case GdiGetDCOrg: case GdiGetDCOrg:
Ret = IntGdiGetDCOrg(dc, &SafePoint); SafePoint = pdc->ptlDCOrig;
break; break;
case GdiGetAspectRatioFilter: case GdiGetAspectRatioFilter:
Ret = IntGetAspectRatioFilter(dc, &Size); DC_vGetAspectRatioFilter(pdc, &Size);
SafePoint.x = Size.cx; SafePoint.x = Size.cx;
SafePoint.y = Size.cy; SafePoint.y = Size.cy;
break; break;
@ -1269,9 +1250,7 @@ NtGdiGetDCPoint(
{ {
_SEH2_TRY _SEH2_TRY
{ {
ProbeForWrite(Point, ProbeForWrite(Point, sizeof(POINT), 1);
sizeof(POINT),
1);
*Point = SafePoint; *Point = SafePoint;
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@ -1279,16 +1258,15 @@ NtGdiGetDCPoint(
Status = _SEH2_GetExceptionCode(); Status = _SEH2_GetExceptionCode();
} }
_SEH2_END; _SEH2_END;
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
Ret = FALSE;
}
} }
if (!NT_SUCCESS(Status)) DC_UnlockDc(pdc);
{
SetLastNtError(Status);
DC_UnlockDc(dc);
return FALSE;
}
DC_UnlockDc(dc);
return Ret; return Ret;
} }

View file

@ -4,126 +4,6 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/*
* DC device-independent Get/SetXXX functions
* (RJJ) swiped from WINE
*/
#define DC_GET_VAL( func_type, func_name, dc_field ) \
func_type APIENTRY func_name( HDC hdc ) \
{ \
func_type ft; \
PDC dc = DC_LockDc( hdc ); \
PDC_ATTR pdcattr; \
if (!dc) \
{ \
SetLastWin32Error(ERROR_INVALID_HANDLE); \
return 0; \
} \
pdcattr = dc->pdcattr; \
ft = pdcattr->dc_field; \
DC_UnlockDc(dc); \
return ft; \
}
/* DC_GET_VAL_EX is used to define functions returning a POINT or a SIZE. It is
* important that the function has the right signature, for the implementation
* we can do whatever we want.
*/
#define DC_GET_VAL_EX( FuncName, ret_x, ret_y, type, ax, ay ) \
VOID FASTCALL Int##FuncName ( PDC dc, LP##type pt) \
{ \
PDC_ATTR pdcattr; \
ASSERT(dc); \
ASSERT(pt); \
pdcattr = dc->pdcattr; \
pt->ax = pdcattr->ret_x; \
pt->ay = pdcattr->ret_y; \
}
#if 0
BOOL APIENTRY NtGdi##FuncName ( HDC hdc, LP##type pt ) \
{ \
NTSTATUS Status = STATUS_SUCCESS; \
type Safept; \
PDC dc; \
if(!pt) \
{ \
SetLastWin32Error(ERROR_INVALID_PARAMETER); \
return FALSE; \
} \
if(!(dc = DC_LockDc(hdc))) \
{ \
SetLastWin32Error(ERROR_INVALID_HANDLE); \
return FALSE; \
} \
Int##FuncName( dc, &Safept); \
DC_UnlockDc(dc); \
_SEH2_TRY \
{ \
ProbeForWrite(pt, \
sizeof( type ), \
1); \
*pt = Safept; \
} \
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
{ \
Status = _SEH2_GetExceptionCode(); \
} \
_SEH2_END; \
if(!NT_SUCCESS(Status)) \
{ \
SetLastNtError(Status); \
return FALSE; \
} \
return TRUE; \
}
#endif
#define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \
INT APIENTRY func_name( HDC hdc, INT mode ) \
{ \
INT prevMode; \
PDC dc; \
PDC_ATTR pdcattr; \
if ((mode < min_val) || (mode > max_val)) \
{ \
SetLastWin32Error(ERROR_INVALID_PARAMETER); \
return 0; \
} \
dc = DC_LockDc ( hdc ); \
if ( !dc ) \
{ \
SetLastWin32Error(ERROR_INVALID_HANDLE); \
return 0; \
} \
pdcattr = dc->pdcattr; \
prevMode = pdcattr->dc_field; \
pdcattr->dc_field = mode; \
DC_UnlockDc ( dc ); \
return prevMode; \
}
DC_GET_VAL( INT, IntGdiGetMapMode, iMapMode )
DC_GET_VAL( INT, IntGdiGetPolyFillMode, jFillMode )
DC_GET_VAL( COLORREF, IntGdiGetBkColor, crBackgroundClr )
DC_GET_VAL( INT, IntGdiGetBkMode, jBkMode )
DC_GET_VAL( INT, IntGdiGetROP2, jROP2 )
DC_GET_VAL( INT, IntGdiGetStretchBltMode, jStretchBltMode )
DC_GET_VAL( UINT, IntGdiGetTextAlign, lTextAlign )
DC_GET_VAL( COLORREF, IntGdiGetTextColor, crForegroundClr )
DC_GET_VAL_EX( GetViewportOrgEx, ptlViewportOrg.x, ptlViewportOrg.y, POINT, x, y )
DC_GET_VAL_EX( GetWindowExtEx, szlWindowExt.cx, szlWindowExt.cy, SIZE, cx, cy )
DC_GET_VAL_EX( GetWindowOrgEx, ptlWindowOrg.x, ptlWindowOrg.y, POINT, x, y )
DC_SET_MODE( IntGdiSetPolyFillMode, jFillMode, ALTERNATE, WINDING )
DC_SET_MODE( IntGdiSetROP2, jROP2, R2_BLACK, R2_WHITE )
DC_SET_MODE( IntGdiSetStretchBltMode, jStretchBltMode, BLACKONWHITE, HALFTONE )
COLORREF FASTCALL COLORREF FASTCALL
IntGdiSetBkColor(HDC hDC, COLORREF color) IntGdiSetBkColor(HDC hDC, COLORREF color)
{ {

View file

@ -566,7 +566,7 @@ IntRectangle(PDC dc,
DestRect.bottom += dc->ptlDCOrig.y; DestRect.bottom += dc->ptlDCOrig.y;
/* In GM_COMPATIBLE, don't include bottom and right edges */ /* In GM_COMPATIBLE, don't include bottom and right edges */
if (IntGetGraphicsMode(dc) == GM_COMPATIBLE) if (pdcattr->iGraphicsMode == GM_COMPATIBLE)
{ {
DestRect.right--; DestRect.right--;
DestRect.bottom--; DestRect.bottom--;

View file

@ -350,7 +350,7 @@ PATH_Rectangle ( PDC dc, INT x1, INT y1, INT x2, INT y2 )
} }
/* In GM_COMPATIBLE, don't include bottom and right edges */ /* In GM_COMPATIBLE, don't include bottom and right edges */
if ( IntGetGraphicsMode(dc) == GM_COMPATIBLE ) if (dc->pdcattr->iGraphicsMode == GM_COMPATIBLE)
{ {
corners[1].x--; corners[1].x--;
corners[1].y--; corners[1].y--;
@ -606,7 +606,7 @@ PATH_Arc ( PDC dc, INT x1, INT y1, INT x2, INT y2,
} }
/* In GM_COMPATIBLE, don't include bottom and right edges */ /* In GM_COMPATIBLE, don't include bottom and right edges */
if ( IntGetGraphicsMode(dc) == GM_COMPATIBLE ) if (dc->pdcattr->iGraphicsMode == GM_COMPATIBLE )
{ {
corners[1].x--; corners[1].x--;
corners[1].y--; corners[1].y--;
@ -1343,11 +1343,13 @@ BOOL FASTCALL PATH_StrokePath(DC *dc, PPATH pPath)
/* Save the mapping mode info */ /* Save the mapping mode info */
mapMode = pdcattr->iMapMode; mapMode = pdcattr->iMapMode;
IntGetViewportExtEx(dc, &szViewportExt);
IntGetViewportOrgEx(dc, &ptViewportOrg); DC_vUpdateViewportExt(dc);
IntGetWindowExtEx(dc, &szWindowExt); szViewportExt = dc->pdcattr->szlViewportExt;
IntGetWindowOrgEx(dc, &ptWindowOrg); ptViewportOrg = dc->pdcattr->ptlViewportOrg;
szWindowExt = dc->pdcattr->szlWindowExt;
ptWindowOrg = dc->pdcattr->ptlWindowOrg;
MatrixS2XForm(&xform, &dc->dclevel.mxWorldToPage); MatrixS2XForm(&xform, &dc->dclevel.mxWorldToPage);
/* Set MM_TEXT */ /* Set MM_TEXT */