diff --git a/reactos/dll/win32/gdi32/objects/coord.c b/reactos/dll/win32/gdi32/objects/coord.c index 2050b023c0e..c56791c3932 100644 --- a/reactos/dll/win32/gdi32/objects/coord.c +++ b/reactos/dll/win32/gdi32/objects/coord.c @@ -327,7 +327,6 @@ SetViewportExtEx(HDC hdc, 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 @@ SetViewportExtEx(HDC hdc, } } #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; + lpSize->cx = Dc_Attr->szlViewportExt.cx; + lpSize->cy = Dc_Attr->szlViewportExt.cy; } - if ((Dc_Attr->ptlWindowExt.cx == nXExtent) && (Dc_Attr->ptlWindowExt.cy == nYExtent)) + 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 ((Dc_Attr->iMapMode == MM_ISOTROPIC) || (Dc_Attr->iMapMode == MM_ANISOTROPIC)) { - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) { @@ -370,14 +372,12 @@ SetViewportExtEx(HDC hdc, 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 @@ SetWindowExtEx(HDC hdc, 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 @@ SetWindowExtEx(HDC hdc, 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 ((!nXExtent) || (!nYExtent)) return FALSE; - if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc) + if (NtCurrentTeb()->GdiTebBatch.HDC == hdc) { if (Dc_Attr->ulDirty_ & DC_FONTTEXT_DIRTY) { @@ -509,8 +508,6 @@ SetWindowExtEx(HDC hdc, Dc_Attr->flXform |= (PAGE_EXTENTS_CHANGED|INVALIDATE_ATTRIBUTES|DEVICE_TO_WORLD_INVALID); } return TRUE; // Return TRUE. -#endif - return NtGdiSetWindowExtEx(hdc, nXExtent, nYExtent, lpSize); } /* diff --git a/reactos/include/reactos/win32k/ntgdibad.h b/reactos/include/reactos/win32k/ntgdibad.h index 8b43f46cb8f..3bbc3338c7e 100644 --- a/reactos/include/reactos/win32k/ntgdibad.h +++ b/reactos/include/reactos/win32k/ntgdibad.h @@ -91,16 +91,6 @@ NtGdiOffsetWindowOrgEx ( LPPOINT Point ); -/* 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 @@ -111,16 +101,6 @@ NtGdiSetViewportOrgEx ( 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. */ BOOL APIENTRY diff --git a/reactos/subsystems/win32/win32k/include/coord.h b/reactos/subsystems/win32/win32k/include/coord.h index e518102a9e1..418e623fa8f 100644 --- a/reactos/subsystems/win32/win32k/include/coord.h +++ b/reactos/subsystems/win32/win32k/include/coord.h @@ -23,5 +23,6 @@ IntGdiModifyWorldTransform(PDC pDc, DWORD Mode); VOID FASTCALL IntMirrorWindowOrg(PDC); +void FASTCALL IntFixIsotropicMapping(PDC dc); #endif diff --git a/reactos/subsystems/win32/win32k/objects/coord.c b/reactos/subsystems/win32/win32k/objects/coord.c index ff4b216d04a..1a1c9261391 100644 --- a/reactos/subsystems/win32/win32k/objects/coord.c +++ b/reactos/subsystems/win32/win32k/objects/coord.c @@ -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; + PDC_ATTR pDcAttr; + LONG fx, fy, s; - 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; + /* Get a pointer to the DC_ATTR */ + pDcAttr = dc->pDc_Attr; + if (!pDcAttr) pDcAttr = &dc->Dc_Attr; - if (xdim > ydim) + /* Check if all values are valid */ + if (pDcAttr->szlWindowExt.cx == 0 || pDcAttr->szlWindowExt.cy == 0 || + pDcAttr->szlViewportExt.cx == 0 || pDcAttr->szlViewportExt.cy == 0) { - Dc_Attr->szlViewportExt.cx = Dc_Attr->szlViewportExt.cx * abs(ydim / xdim); - if (!Dc_Attr->szlViewportExt.cx) Dc_Attr->szlViewportExt.cx = 1; + /* Don't recalculate */ + return; } - else + + fx = abs(pDcAttr->szlWindowExt.cx * pDcAttr->szlViewportExt.cy); + fy = abs(pDcAttr->szlWindowExt.cy * pDcAttr->szlViewportExt.cx); + + if (fy > fx) { - Dc_Attr->szlViewportExt.cy = Dc_Attr->szlViewportExt.cy * abs(xdim / ydim); - if (!Dc_Attr->szlViewportExt.cy) Dc_Attr->szlViewportExt.cy = 1; + 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 @@ IntGdiSetMapMode(PDC dc, 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 @@ -841,70 +773,6 @@ NtGdiSetViewportOrgEx(HDC hDC, 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); - - return TRUE; -} - BOOL APIENTRY NtGdiSetWindowOrgEx(HDC hDC, diff --git a/reactos/subsystems/win32/win32k/objects/dc.c b/reactos/subsystems/win32/win32k/objects/dc.c index 0a54a783ec4..ce67fb23d4e 100644 --- a/reactos/subsystems/win32/win32k/objects/dc.c +++ b/reactos/subsystems/win32/win32k/objects/dc.c @@ -65,7 +65,6 @@ NtGdiCreateCompatibleDC(HDC hDC) UNICODE_STRING DriverName; DWORD Layout = 0; - DisplayDC = NULL; if (hDC == NULL) { RtlInitUnicodeString(&DriverName, L"DISPLAY"); @@ -1266,6 +1265,33 @@ IntGetAspectRatioFilter(PDC pDC, 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 NtGdiGetDCPoint( HDC hDC, UINT iPoint, PPOINTL Point) { diff --git a/reactos/subsystems/win32/win32k/objects/dcutil.c b/reactos/subsystems/win32/win32k/objects/dcutil.c index 881d7a8bac0..19c53bfb5ef 100644 --- a/reactos/subsystems/win32/win32k/objects/dcutil.c +++ b/reactos/subsystems/win32/win32k/objects/dcutil.c @@ -170,7 +170,6 @@ DC_GET_VAL( INT, IntGdiGetStretchBltMode, jStretchBltMode ) 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 ) diff --git a/reactos/subsystems/win32/win32k/w32ksvc.db b/reactos/subsystems/win32/win32k/w32ksvc.db index bedb28e2cc8..3a8e5e71f94 100644 --- a/reactos/subsystems/win32/win32k/w32ksvc.db +++ b/reactos/subsystems/win32/win32k/w32ksvc.db @@ -675,9 +675,7 @@ NtGdiDrawStream 3 # #ReactOS specific syscalls NtGdiSetDIBits 7 -NtGdiSetViewportExtEx 4 NtGdiSetViewportOrgEx 4 -NtGdiSetWindowExtEx 4 NtGdiSetWindowOrgEx 4 NtGdiGetFontFamilyInfo 4 NtGdiOffsetViewportOrgEx 4