mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 04:35:07 +00:00
gdi32: Fix and enable usermode implementation of SetWindowExtEx and SetViewportExtEx.
Win32k: remove NtGdiSetWindowExtEx and NtGdiSetViewportExtEx, rewrite IntFixIsotropicMapping, implement IntGetViewportExtEx svn path=/trunk/; revision=39281
This commit is contained in:
parent
849e2133ac
commit
e02dd69903
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -23,5 +23,6 @@ IntGdiModifyWorldTransform(PDC pDc,
|
|||
DWORD Mode);
|
||||
|
||||
VOID FASTCALL IntMirrorWindowOrg(PDC);
|
||||
void FASTCALL IntFixIsotropicMapping(PDC dc);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -675,9 +675,7 @@ NtGdiDrawStream 3
|
|||
#
|
||||
#ReactOS specific syscalls
|
||||
NtGdiSetDIBits 7
|
||||
NtGdiSetViewportExtEx 4
|
||||
NtGdiSetViewportOrgEx 4
|
||||
NtGdiSetWindowExtEx 4
|
||||
NtGdiSetWindowOrgEx 4
|
||||
NtGdiGetFontFamilyInfo 4
|
||||
NtGdiOffsetViewportOrgEx 4
|
||||
|
|
Loading…
Reference in a new issue