From 0a1914e0b74565994978f7858f93247e6903dbb1 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 24 Mar 2009 02:58:14 +0000 Subject: [PATCH] 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 --- .../subsystems/win32/win32k/include/coord.h | 4 - reactos/subsystems/win32/win32k/include/dc.h | 6 +- .../subsystems/win32/win32k/objects/coord.c | 80 +++++------- .../subsystems/win32/win32k/objects/dcutil.c | 120 ------------------ .../win32/win32k/objects/fillshap.c | 2 +- .../subsystems/win32/win32k/objects/path.c | 16 ++- 6 files changed, 40 insertions(+), 188 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/coord.h b/reactos/subsystems/win32/win32k/include/coord.h index 66cd4fb1e0c..bec402026cb 100644 --- a/reactos/subsystems/win32/win32k/include/coord.h +++ b/reactos/subsystems/win32/win32k/include/coord.h @@ -10,10 +10,6 @@ #define XForm2MatrixS(m, x) XFORMOBJ_iSetXform((XFORMOBJ*)m, (XFORML*)x) #define MatrixS2XForm(x, m) XFORMOBJ_iGetXform((XFORMOBJ*)m, (XFORML*)x) -int -FASTCALL -IntGetGraphicsMode ( PDC dc ); - int APIENTRY IntGdiSetMapMode(PDC, int); BOOL diff --git a/reactos/subsystems/win32/win32k/include/dc.h b/reactos/subsystems/win32/win32k/include/dc.h index 97200ba59ff..781d4f02126 100644 --- a/reactos/subsystems/win32/win32k/include/dc.h +++ b/reactos/subsystems/win32/win32k/include/dc.h @@ -248,16 +248,12 @@ BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL); VOID FASTCALL DC_UpdateXforms(PDC dc); BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest); +VOID FASTCALL DC_vUpdateViewportExt(PDC pdc); BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC); BOOL FASTCALL DCU_SynchDcAttrtoUser(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); INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode); COLORREF APIENTRY IntGdiGetBkColor(HDC hDC); diff --git a/reactos/subsystems/win32/win32k/objects/coord.c b/reactos/subsystems/win32/win32k/objects/coord.c index 2f5f1ff813b..53aa30a683a 100644 --- a/reactos/subsystems/win32/win32k/objects/coord.c +++ b/reactos/subsystems/win32/win32k/objects/coord.c @@ -119,17 +119,6 @@ BOOL APIENTRY NtGdiCombineTransform( 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 BOOL FASTCALL @@ -262,7 +251,8 @@ NtGdiTransformPoints( 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) { DC_UnlockDc(dc); @@ -1129,7 +1119,7 @@ GdiSetDCOrg(HDC hDC, LONG Left, LONG Top, PRECTL prc) DC_UnlockDc(pdc); } - +// FIXME: remove me BOOL FASTCALL IntGdiGetDCOrg(PDC pDc, PPOINTL ppt) { @@ -1137,6 +1127,7 @@ IntGdiGetDCOrg(PDC pDc, PPOINTL ppt) return TRUE; } +// FIXME: remove me BOOL APIENTRY GdiGetDCOrgEx(HDC hDC, PPOINTL ppt, PRECTL prc) { @@ -1152,14 +1143,11 @@ GdiGetDCOrgEx(HDC hDC, PPOINTL ppt, PRECTL prc) return TRUE; } -BOOL FASTCALL -IntGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio) +static +VOID FASTCALL +DC_vGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio) { - PDC_ATTR pdcattr; - - pdcattr = pDC->pdcattr; - - if ( pdcattr->flFontMapper & 1 ) // TRUE assume 1. + if (pDC->pdcattr->flFontMapper & 1) // TRUE assume 1. { // "This specifies that Windows should only match fonts that have the // same aspect ratio as the display.", Programming Windows, Fifth Ed. @@ -1171,12 +1159,11 @@ IntGetAspectRatioFilter(PDC pDC, LPSIZE AspectRatio) AspectRatio->cx = 0; AspectRatio->cy = 0; } - return TRUE; } VOID FASTCALL -IntGetViewportExtEx(PDC pdc, LPSIZE pSize) +DC_vUpdateViewportExt(PDC pdc) { PDC_ATTR pdcattr; @@ -1195,9 +1182,6 @@ IntGetViewportExtEx(PDC pdc, LPSIZE pSize) /* Update xforms, CHECKME: really done here? */ DC_UpdateXforms(pdc); } - - /* Copy the viewport extension */ - *pSize = pdcattr->szlViewportExt; } BOOL APIENTRY @@ -1207,7 +1191,7 @@ NtGdiGetDCPoint( PPOINTL Point) { BOOL Ret = TRUE; - DC *dc; + DC *pdc; POINTL SafePoint; SIZE Size; NTSTATUS Status = STATUS_SUCCESS; @@ -1218,10 +1202,8 @@ NtGdiGetDCPoint( return FALSE; } - RtlZeroMemory(&SafePoint, sizeof(POINT)); - - dc = DC_LockDc(hDC); - if (!dc) + pdc = DC_LockDc(hDC); + if (!pdc) { SetLastWin32Error(ERROR_INVALID_HANDLE); return FALSE; @@ -1230,31 +1212,30 @@ NtGdiGetDCPoint( switch (iPoint) { case GdiGetViewPortExt: - IntGetViewportExtEx(dc, &Size); - SafePoint.x = Size.cx; - SafePoint.y = Size.cy; + DC_vUpdateViewportExt(pdc); + SafePoint.x = pdc->pdcattr->szlViewportExt.cx; + SafePoint.y = pdc->pdcattr->szlViewportExt.cy; break; case GdiGetWindowExt: - IntGetWindowExtEx(dc, &Size); - SafePoint.x = Size.cx; - SafePoint.y = Size.cy; + SafePoint.x = pdc->pdcattr->szlWindowExt.cx; + SafePoint.y = pdc->pdcattr->szlWindowExt.cy; break; case GdiGetViewPortOrg: - IntGetViewportOrgEx(dc, &SafePoint); + SafePoint = pdc->pdcattr->ptlViewportOrg; break; case GdiGetWindowOrg: - IntGetWindowOrgEx(dc, &SafePoint); + SafePoint = pdc->pdcattr->ptlWindowOrg; break; case GdiGetDCOrg: - Ret = IntGdiGetDCOrg(dc, &SafePoint); + SafePoint = pdc->ptlDCOrig; break; case GdiGetAspectRatioFilter: - Ret = IntGetAspectRatioFilter(dc, &Size); + DC_vGetAspectRatioFilter(pdc, &Size); SafePoint.x = Size.cx; SafePoint.y = Size.cy; break; @@ -1269,9 +1250,7 @@ NtGdiGetDCPoint( { _SEH2_TRY { - ProbeForWrite(Point, - sizeof(POINT), - 1); + ProbeForWrite(Point, sizeof(POINT), 1); *Point = SafePoint; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) @@ -1279,16 +1258,15 @@ NtGdiGetDCPoint( Status = _SEH2_GetExceptionCode(); } _SEH2_END; + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + Ret = FALSE; + } } - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - DC_UnlockDc(dc); - return FALSE; - } - - DC_UnlockDc(dc); + DC_UnlockDc(pdc); return Ret; } diff --git a/reactos/subsystems/win32/win32k/objects/dcutil.c b/reactos/subsystems/win32/win32k/objects/dcutil.c index b6eb9061ad2..401c2eef0e9 100644 --- a/reactos/subsystems/win32/win32k/objects/dcutil.c +++ b/reactos/subsystems/win32/win32k/objects/dcutil.c @@ -4,126 +4,6 @@ #define NDEBUG #include -/* - * 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 IntGdiSetBkColor(HDC hDC, COLORREF color) { diff --git a/reactos/subsystems/win32/win32k/objects/fillshap.c b/reactos/subsystems/win32/win32k/objects/fillshap.c index 38796f22a71..15af40a5162 100644 --- a/reactos/subsystems/win32/win32k/objects/fillshap.c +++ b/reactos/subsystems/win32/win32k/objects/fillshap.c @@ -566,7 +566,7 @@ IntRectangle(PDC dc, DestRect.bottom += dc->ptlDCOrig.y; /* In GM_COMPATIBLE, don't include bottom and right edges */ - if (IntGetGraphicsMode(dc) == GM_COMPATIBLE) + if (pdcattr->iGraphicsMode == GM_COMPATIBLE) { DestRect.right--; DestRect.bottom--; diff --git a/reactos/subsystems/win32/win32k/objects/path.c b/reactos/subsystems/win32/win32k/objects/path.c index cebcc0ccc33..bd40b500931 100644 --- a/reactos/subsystems/win32/win32k/objects/path.c +++ b/reactos/subsystems/win32/win32k/objects/path.c @@ -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 */ - if ( IntGetGraphicsMode(dc) == GM_COMPATIBLE ) + if (dc->pdcattr->iGraphicsMode == GM_COMPATIBLE) { corners[1].x--; 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 */ - if ( IntGetGraphicsMode(dc) == GM_COMPATIBLE ) + if (dc->pdcattr->iGraphicsMode == GM_COMPATIBLE ) { corners[1].x--; corners[1].y--; @@ -1343,11 +1343,13 @@ BOOL FASTCALL PATH_StrokePath(DC *dc, PPATH pPath) /* Save the mapping mode info */ mapMode = pdcattr->iMapMode; - IntGetViewportExtEx(dc, &szViewportExt); - IntGetViewportOrgEx(dc, &ptViewportOrg); - IntGetWindowExtEx(dc, &szWindowExt); - IntGetWindowOrgEx(dc, &ptWindowOrg); - + + DC_vUpdateViewportExt(dc); + szViewportExt = dc->pdcattr->szlViewportExt; + ptViewportOrg = dc->pdcattr->ptlViewportOrg; + szWindowExt = dc->pdcattr->szlWindowExt; + ptWindowOrg = dc->pdcattr->ptlWindowOrg; + MatrixS2XForm(&xform, &dc->dclevel.mxWorldToPage); /* Set MM_TEXT */