Author: tkreuzer Date: Sun Feb 1 18:49:19 2009 New Revision: 39281
URL: http://svn.reactos.org/svn/reactos?rev=39281&view=rev Log: gdi32: Fix and enable usermode implementation of SetWindowExtEx and SetViewportExtEx. Win32k: remove NtGdiSetWindowExtEx and NtGdiSetViewportExtEx, rewrite IntFixIsotropicMapping, implement IntGetViewportExtEx
Modified: trunk/reactos/dll/win32/gdi32/objects/coord.c trunk/reactos/include/reactos/win32k/ntgdibad.h trunk/reactos/subsystems/win32/win32k/include/coord.h trunk/reactos/subsystems/win32/win32k/objects/coord.c trunk/reactos/subsystems/win32/win32k/objects/dc.c trunk/reactos/subsystems/win32/win32k/objects/dcutil.c trunk/reactos/subsystems/win32/win32k/w32ksvc.db
Modified: trunk/reactos/dll/win32/gdi32/objects/coord.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/coo... ============================================================================== --- trunk/reactos/dll/win32/gdi32/objects/coord.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdi32/objects/coord.c [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -327,7 +327,6 @@ int nYExtent, LPSIZE lpSize) { -#if 0 PDC_ATTR Dc_Attr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) @@ -349,20 +348,23 @@ } } #endif - if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) return FALSE; + if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr)) + { + return FALSE; + }
if (lpSize) { - lpSize->cx = Dc_Attr->szlWindowExt.cx; - lpSize->cy = Dc_Attr->szlWindowExt.cy; - } - - if ((Dc_Attr->ptlWindowExt.cx == nXExtent) && (Dc_Attr->ptlWindowExt.cy == nYExtent)) + lpSize->cx = Dc_Attr->szlViewportExt.cx; + lpSize->cy = Dc_Attr->szlViewportExt.cy; + } + + if ((Dc_Attr->szlViewportExt.cx == nXExtent) && (Dc_Attr->szlViewportExt.cy == nYExtent)) return TRUE;
- if ((Dc_Attr->iMapMode == MM_ISOTROPIC) && (Dc_Attr->iMapMode == MM_ANISOTROPIC)) - { - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) + { + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) { @@ -370,14 +372,12 @@ Dc_Attr->ulDirty_ &= ~(DC_MODE_DIRTY|DC_FONTTEXT_DIRTY); } } - Dc_Attr->szlWindowExt.cx = nXExtent; - Dc_Attr->szlWindowExt.cy = nYExtent; + Dc_Attr->szlViewportExt.cx = nXExtent; + Dc_Attr->szlViewportExt.cy = nYExtent; if (Dc_Attr->dwLayout & LAYOUT_RTL) NtGdiMirrorWindowOrg(hdc); Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } return TRUE; -#endif - return NtGdiSetViewportExtEx(hdc, nXExtent, nYExtent, lpSize); }
/* @@ -452,7 +452,6 @@ int nYExtent, LPSIZE lpSize) { -#if 0 PDC_ATTR Dc_Attr; #if 0 if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC) @@ -488,14 +487,14 @@ NtGdiMirrorWindowOrg(hdc); Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } - else if ((Dc_Attr->iMapMode == MM_ISOTROPIC) && (Dc_Attr->iMapMode == MM_ANISOTROPIC)) + else if ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) { if ((Dc_Attr->szlWindowExt.cx == nXExtent) && (Dc_Attr->szlWindowExt.cy == nYExtent)) return TRUE;
- if ((!nXExtent) && (!nYExtent)) return FALSE; - - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + if ((!nXExtent) || (!nYExtent)) return FALSE; + + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) { @@ -509,8 +508,6 @@ Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } return TRUE; // Return TRUE. -#endif - return NtGdiSetWindowExtEx(hdc, nXExtent, nYExtent, lpSize); }
/*
Modified: trunk/reactos/include/reactos/win32k/ntgdibad.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntgd... ============================================================================== --- trunk/reactos/include/reactos/win32k/ntgdibad.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntgdibad.h [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -94,31 +94,11 @@ /* Needs to be done in user-mode. */ BOOL APIENTRY -NtGdiSetWindowExtEx ( - HDC hDC, - int XExtent, - int YExtent, - LPSIZE Size - ); - -/* Needs to be done in user-mode. */ -BOOL -APIENTRY NtGdiSetViewportOrgEx ( HDC hDC, int X, int Y, LPPOINT Point - ); - -/* Needs to be done in user-mode. */ -BOOL -APIENTRY -NtGdiSetViewportExtEx ( - HDC hDC, - int XExtent, - int YExtent, - LPSIZE Size );
/* Needs to be done in user-mode. */
Modified: trunk/reactos/subsystems/win32/win32k/include/coord.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/coord.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/coord.h [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -23,5 +23,6 @@ DWORD Mode);
VOID FASTCALL IntMirrorWindowOrg(PDC); +void FASTCALL IntFixIsotropicMapping(PDC dc);
#endif
Modified: trunk/reactos/subsystems/win32/win32k/objects/coord.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/coord.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/coord.c [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -37,29 +37,33 @@ void FASTCALL IntFixIsotropicMapping(PDC dc) { - ULONG xdim; - ULONG ydim; - PDC_ATTR Dc_Attr = dc->pDc_Attr; - if (!Dc_Attr) Dc_Attr = &dc->Dc_Attr; - - xdim = EngMulDiv(Dc_Attr->szlViewportExt.cx, - ((PGDIDEVICE)dc->pPDev)->GDIInfo.ulHorzSize, - ((PGDIDEVICE)dc->pPDev)->GDIInfo.ulHorzRes) / - Dc_Attr->szlWindowExt.cx; - ydim = EngMulDiv(Dc_Attr->szlViewportExt.cy, - ((PGDIDEVICE)dc->pPDev)->GDIInfo.ulVertSize, - ((PGDIDEVICE)dc->pPDev)->GDIInfo.ulVertRes) / - Dc_Attr->szlWindowExt.cy; - - if (xdim > ydim) - { - Dc_Attr->szlViewportExt.cx = Dc_Attr->szlViewportExt.cx * abs(ydim / xdim); - if (!Dc_Attr->szlViewportExt.cx) Dc_Attr->szlViewportExt.cx = 1; - } - else - { - Dc_Attr->szlViewportExt.cy = Dc_Attr->szlViewportExt.cy * abs(xdim / ydim); - if (!Dc_Attr->szlViewportExt.cy) Dc_Attr->szlViewportExt.cy = 1; + PDC_ATTR pDcAttr; + LONG fx, fy, s; + + /* Get a pointer to the DC_ATTR */ + pDcAttr = dc->pDc_Attr; + if (!pDcAttr) pDcAttr = &dc->Dc_Attr; + + /* Check if all values are valid */ + if (pDcAttr->szlWindowExt.cx == 0 || pDcAttr->szlWindowExt.cy == 0 || + pDcAttr->szlViewportExt.cx == 0 || pDcAttr->szlViewportExt.cy == 0) + { + /* Don't recalculate */ + return; + } + + fx = abs(pDcAttr->szlWindowExt.cx * pDcAttr->szlViewportExt.cy); + fy = abs(pDcAttr->szlWindowExt.cy * pDcAttr->szlViewportExt.cx); + + if (fy > fx) + { + s = pDcAttr->szlWindowExt.cy * pDcAttr->szlViewportExt.cx > 0 ? 1 : -1; + pDcAttr->szlViewportExt.cx = s * fx / pDcAttr->szlWindowExt.cy; + } + else if (fx > fy) + { + s = pDcAttr->szlWindowExt.cx * pDcAttr->szlViewportExt.cy > 0 ? 1 : -1; + pDcAttr->szlViewportExt.cy = s * fy / pDcAttr->szlWindowExt.cx; } }
@@ -716,78 +720,6 @@ return PrevMapMode; }
-BOOL -APIENTRY -NtGdiSetViewportExtEx(HDC hDC, - int XExtent, - int YExtent, - LPSIZE Size) -{ - PDC dc; - PDC_ATTR Dc_Attr; - - dc = DC_LockDc(hDC); - if (!dc) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return FALSE; - } - Dc_Attr = dc->pDc_Attr; - if (!Dc_Attr) Dc_Attr = &dc->Dc_Attr; - - switch (Dc_Attr->iMapMode) - { - case MM_HIENGLISH: - case MM_HIMETRIC: - case MM_LOENGLISH: - case MM_LOMETRIC: - case MM_TEXT: - case MM_TWIPS: - DC_UnlockDc(dc); - return FALSE; - - case MM_ISOTROPIC: - // Here we should (probably) check that SetWindowExtEx *really* has - // been called - break; - } - - if (Size) - { - NTSTATUS Status = STATUS_SUCCESS; - - _SEH2_TRY - { - ProbeForWrite(Size, sizeof(SIZE), 1); - Size->cx = Dc_Attr->szlViewportExt.cx; - Size->cy = Dc_Attr->szlViewportExt.cy; - - Dc_Attr->szlViewportExt.cx = XExtent; - Dc_Attr->szlViewportExt.cy = YExtent; - - if (Dc_Attr->iMapMode == MM_ISOTROPIC) - IntFixIsotropicMapping(dc); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; - - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - DC_UnlockDc(dc); - return FALSE; - } - } - - - DC_UpdateXforms(dc); - DC_UnlockDc(dc); - - return TRUE; -}
BOOL APIENTRY @@ -834,70 +766,6 @@
Dc_Attr->ptlViewportOrg.x = X; Dc_Attr->ptlViewportOrg.y = Y; - - DC_UpdateXforms(dc); - DC_UnlockDc(dc); - - return TRUE; -} - -BOOL -APIENTRY -NtGdiSetWindowExtEx(HDC hDC, - int XExtent, - int YExtent, - LPSIZE Size) -{ - PDC dc; - PDC_ATTR Dc_Attr; - - dc = DC_LockDc(hDC); - if (!dc) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return FALSE; - } - Dc_Attr = dc->pDc_Attr; - if (!Dc_Attr) Dc_Attr = &dc->Dc_Attr; - - switch (Dc_Attr->iMapMode) - { - case MM_HIENGLISH: - case MM_HIMETRIC: - case MM_LOENGLISH: - case MM_LOMETRIC: - case MM_TEXT: - case MM_TWIPS: - DC_UnlockDc(dc); - return FALSE; - } - - if (Size) - { - NTSTATUS Status = STATUS_SUCCESS; - - _SEH2_TRY - { - ProbeForWrite(Size, sizeof(SIZE), 1); - Size->cx = Dc_Attr->szlWindowExt.cx; - Size->cy = Dc_Attr->szlWindowExt.cy; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Status = _SEH2_GetExceptionCode(); - } - _SEH2_END; - - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - DC_UnlockDc(dc); - return FALSE; - } - } - - Dc_Attr->szlWindowExt.cx = XExtent; - Dc_Attr->szlWindowExt.cy = YExtent;
DC_UpdateXforms(dc); DC_UnlockDc(dc);
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -65,7 +65,6 @@ UNICODE_STRING DriverName; DWORD Layout = 0;
- DisplayDC = NULL; if (hDC == NULL) { RtlInitUnicodeString(&DriverName, L"DISPLAY"); @@ -1264,6 +1263,33 @@ AspectRatio->cy = 0; } return TRUE; +} + +VOID +FASTCALL +IntGetViewportExtEx(PDC pdc, LPSIZE pSize) +{ + PDC_ATTR pDc_Attr; + + /* Get a pointer to the dc attribute */ + pDc_Attr = pdc->pDc_Attr; + if (!pDc_Attr) pDc_Attr = &pdc->Dc_Attr; + + /* Check if we need to recalculate */ + if (pDc_Attr->flXform & PAGE_EXTENTS_CHANGED) + { + /* Check if we need to do isotropic fixup */ + if (pDc_Attr->iMapMode == MM_ISOTROPIC) + { + IntFixIsotropicMapping(pdc); + } + + /* Update xforms, CHECKME: really done here? */ + DC_UpdateXforms(pdc); + } + + /* Copy the viewport extension */ + *pSize = pDc_Attr->szlViewportExt; }
BOOL APIENTRY
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcutil.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dcutil.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dcutil.c [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -170,7 +170,6 @@ DC_GET_VAL( UINT, IntGdiGetTextAlign, lTextAlign ) DC_GET_VAL( COLORREF, IntGdiGetTextColor, crForegroundClr )
-DC_GET_VAL_EX( GetViewportExtEx, szlViewportExt.cx, szlViewportExt.cy, SIZE, cx, cy ) 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 )
Modified: trunk/reactos/subsystems/win32/win32k/w32ksvc.db URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/w32... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sun Feb 1 18:49:19 2009 @@ -675,9 +675,7 @@ # #ReactOS specific syscalls NtGdiSetDIBits 7 -NtGdiSetViewportExtEx 4 NtGdiSetViewportOrgEx 4 -NtGdiSetWindowExtEx 4 NtGdiSetWindowOrgEx 4 NtGdiGetFontFamilyInfo 4 NtGdiOffsetViewportOrgEx 4