From 521b9caad999d5777ae20aa0c4c7b2fcb4a3f49f Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 21 Jun 2006 08:33:27 +0000 Subject: [PATCH] Implement the isometric mapping mode and call the mapping functions for Ellipse and Polygon drawing. Thanks MgW from IRC for testing. :) svn path=/trunk/; revision=22448 --- .../subsystems/win32/win32k/objects/coord.c | 77 ++++++++++++++++++- .../win32/win32k/objects/fillshap.c | 23 +++--- 2 files changed, 89 insertions(+), 11 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/coord.c b/reactos/subsystems/win32/win32k/objects/coord.c index 9097fa196fc..d6a8b888aaa 100644 --- a/reactos/subsystems/win32/win32k/objects/coord.c +++ b/reactos/subsystems/win32/win32k/objects/coord.c @@ -34,6 +34,24 @@ /* FUNCTIONS *****************************************************************/ +void FASTCALL +IntFixIsotropicMapping(PDC dc) +{ + ULONG xdim = EngMulDiv(dc->vportExtX, dc->GDIInfo->ulHorzSize, dc->GDIInfo->ulHorzRes) / dc->wndExtX; + ULONG ydim = EngMulDiv(dc->vportExtY, dc->GDIInfo->ulVertSize, dc->GDIInfo->ulVertRes) / dc->wndExtY; + + if (xdim > ydim) + { + dc->vportExtX = dc->vportExtX * abs(ydim / xdim); + if (!dc->vportExtX) dc->vportExtX = 1; + } + else + { + dc->vportExtY = dc->vportExtY * abs(xdim / ydim); + if (!dc->vportExtY) dc->vportExtY = 1; + } +} + BOOL FASTCALL IntGdiCombineTransform(LPXFORM XFormResult, LPXFORM xform1, @@ -668,7 +686,62 @@ NtGdiSetMapMode(HDC hDC, } PrevMapMode = dc->w.MapMode; - dc->w.MapMode = MapMode; + + if (MapMode != dc->w.MapMode || (MapMode != MM_ISOTROPIC && MapMode != MM_ANISOTROPIC)) + { + dc->w.MapMode = MapMode; + + switch (MapMode) + { + case MM_TEXT: + dc->wndExtX = 1; + dc->wndExtY = 1; + dc->vportExtX = 1; + dc->vportExtY = 1; + break; + + case MM_LOMETRIC: + case MM_ISOTROPIC: + dc->wndExtX = dc->GDIInfo->ulHorzSize * 10; + dc->wndExtY = dc->GDIInfo->ulVertSize * 10; + dc->vportExtX = dc->GDIInfo->ulHorzRes; + dc->vportExtY = -dc->GDIInfo->ulVertRes; + break; + + case MM_HIMETRIC: + dc->wndExtX = dc->GDIInfo->ulHorzSize * 100; + dc->wndExtY = dc->GDIInfo->ulVertSize * 100; + dc->vportExtX = dc->GDIInfo->ulHorzRes; + dc->vportExtY = -dc->GDIInfo->ulVertRes; + break; + + case MM_LOENGLISH: + dc->wndExtX = EngMulDiv(1000, dc->GDIInfo->ulHorzSize, 254); + dc->wndExtY = EngMulDiv(1000, dc->GDIInfo->ulVertSize, 254); + dc->vportExtX = dc->GDIInfo->ulHorzRes; + dc->vportExtY = -dc->GDIInfo->ulVertRes; + break; + + case MM_HIENGLISH: + dc->wndExtX = EngMulDiv(10000, dc->GDIInfo->ulHorzSize, 254); + dc->wndExtY = EngMulDiv(10000, dc->GDIInfo->ulVertSize, 254); + dc->vportExtX = dc->GDIInfo->ulHorzRes; + dc->vportExtY = -dc->GDIInfo->ulVertRes; + break; + + case MM_TWIPS: + dc->wndExtX = EngMulDiv(14400, dc->GDIInfo->ulHorzSize, 254); + dc->wndExtY = EngMulDiv(14400, dc->GDIInfo->ulVertSize, 254); + dc->vportExtX = dc->GDIInfo->ulHorzRes; + dc->vportExtY = -dc->GDIInfo->ulVertRes; + break; + + case MM_ANISOTROPIC: + break; + } + + DC_UpdateXforms(dc); + } DC_UnlockDc(dc); @@ -737,6 +810,8 @@ NtGdiSetViewportExtEx(HDC hDC, dc->vportExtX = XExtent; dc->vportExtY = YExtent; + if (dc->w.MapMode == MM_ISOTROPIC) + IntFixIsotropicMapping(dc); DC_UpdateXforms(dc); DC_UnlockDc(dc); diff --git a/reactos/subsystems/win32/win32k/objects/fillshap.c b/reactos/subsystems/win32/win32k/objects/fillshap.c index f98d1005500..a8964bb668a 100644 --- a/reactos/subsystems/win32/win32k/objects/fillshap.c +++ b/reactos/subsystems/win32/win32k/objects/fillshap.c @@ -66,6 +66,7 @@ IntGdiPolygon(PDC dc, ASSERT(BitmapObj); /* Convert to screen coordinates */ + IntLPtoDP(dc, UnsafePoints, Count); for (CurrentPoint = 0; CurrentPoint < Count; CurrentPoint++) { UnsafePoints[CurrentPoint].x += dc->w.DCOrgX; @@ -258,21 +259,23 @@ NtGdiEllipse( IntGdiInitBrushInstance(&FillBrushInst, FillBrush, dc->XlateBrush); IntGdiInitBrushInstance(&PenBrushInst, PenBrush, dc->XlatePen); - nLeftRect += dc->w.DCOrgX; - nRightRect += dc->w.DCOrgX - 1; - nTopRect += dc->w.DCOrgY; - nBottomRect += dc->w.DCOrgY - 1; - - RadiusX = max((nRightRect - nLeftRect) >> 1, 1); - RadiusY = max((nBottomRect - nTopRect) >> 1, 1); - CenterX = nLeftRect + RadiusX; - CenterY = nTopRect + RadiusY; - RectBounds.left = nLeftRect; RectBounds.right = nRightRect; RectBounds.top = nTopRect; RectBounds.bottom = nBottomRect; + IntLPtoDP(dc, (LPPOINT)&RectBounds, 2); + + RectBounds.left += dc->w.DCOrgX; + RectBounds.right += dc->w.DCOrgX; + RectBounds.top += dc->w.DCOrgY; + RectBounds.bottom += dc->w.DCOrgY; + + RadiusX = max((RectBounds.right - RectBounds.left) >> 1, 1); + RadiusY = max((RectBounds.bottom - RectBounds.top) >> 1, 1); + CenterX = RectBounds.left + RadiusX; + CenterY = RectBounds.top + RadiusY; + if (RadiusX > RadiusY) { nx = RadiusX;