From 3f9294eaeefdc3cc3586b95a74cbbc2f85c0d0dc Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Fri, 14 May 2004 16:55:18 +0000 Subject: [PATCH] - Fix ExtSelectClipRgn and some other clipping functions. svn path=/trunk/; revision=9383 --- reactos/subsys/win32k/objects/cliprgn.c | 189 ++++++++--------------- reactos/subsys/win32k/objects/dc.c | 22 +-- reactos/subsys/win32k/objects/fillshap.c | 7 +- reactos/subsys/win32k/objects/line.c | 10 +- 4 files changed, 71 insertions(+), 157 deletions(-) diff --git a/reactos/subsys/win32k/objects/cliprgn.c b/reactos/subsys/win32k/objects/cliprgn.c index 649c9f2f3a8..bab184e0dff 100644 --- a/reactos/subsys/win32k/objects/cliprgn.c +++ b/reactos/subsys/win32k/objects/cliprgn.c @@ -16,67 +16,38 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cliprgn.c,v 1.37 2004/05/10 17:07:20 weiden Exp $ */ +/* $Id: cliprgn.c,v 1.38 2004/05/14 16:55:18 navaraf Exp $ */ #include VOID FASTCALL CLIPPING_UpdateGCRegion(DC* Dc) { - HRGN Combined; - PROSRGNDATA CombinedRegion; + PROSRGNDATA CombinedRegion; -#ifndef TODO - if (Dc->w.hGCClipRgn == NULL) - { + ASSERT(Dc->w.hGCClipRgn != NULL); + if (Dc->w.hGCClipRgn == NULL) Dc->w.hGCClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); - } - if (Dc->w.hGCClipRgn == NULL) - return; - - if (Dc->w.hClipRgn == NULL) - { + if (Dc->w.hClipRgn == NULL) NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hVisRgn, 0, RGN_COPY); - } - else - { - NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, - RGN_AND); - } -#endif + else + NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, RGN_AND); + NtGdiOffsetRgn(Dc->w.hGCClipRgn, Dc->w.DCOrgX, Dc->w.DCOrgY); - Combined = NtGdiCreateRectRgn(0, 0, 0, 0); - if(!Combined) - { - return; - } + CombinedRegion = RGNDATA_LockRgn(Dc->w.hGCClipRgn); + ASSERT(CombinedRegion != NULL); - if (Dc->w.hClipRgn == NULL) - { - NtGdiCombineRgn(Combined, Dc->w.hVisRgn, 0, RGN_COPY); - } - else - { - NtGdiCombineRgn(Combined, Dc->w.hClipRgn, Dc->w.hVisRgn, - RGN_AND); - } - NtGdiOffsetRgn(Combined, Dc->w.DCOrgX, Dc->w.DCOrgY); - - CombinedRegion = RGNDATA_LockRgn(Combined); - ASSERT(NULL != CombinedRegion); - - if (NULL != Dc->CombinedClip) - { + if (Dc->CombinedClip != NULL) IntEngDeleteClipRegion(Dc->CombinedClip); - } - Dc->CombinedClip = IntEngCreateClipRegion(CombinedRegion->rdh.nCount, - (PRECTL)CombinedRegion->Buffer, - (PRECTL)&CombinedRegion->rdh.rcBound); - ASSERT(NULL != Dc->CombinedClip); + Dc->CombinedClip = IntEngCreateClipRegion( + CombinedRegion->rdh.nCount, + (PRECTL)CombinedRegion->Buffer, + (PRECTL)&CombinedRegion->rdh.rcBound); + ASSERT(Dc->CombinedClip != NULL); - RGNDATA_UnlockRgn(Combined); - NtGdiDeleteObject(Combined); + RGNDATA_UnlockRgn(Dc->w.hGCClipRgn); + NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY); } HRGN WINAPI SaveVisRgn(HDC hdc) @@ -148,14 +119,17 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC, return ERROR; } - dc->w.flags &= ~DC_DIRTY; +// dc->w.flags &= ~DC_DIRTY; if (!hrgn) { if (fnMode == RGN_COPY) { - NtGdiDeleteObject(dc->w.hGCClipRgn); - dc->w.hGCClipRgn = NULL; + if (dc->w.hClipRgn != NULL) + { + NtGdiDeleteObject(dc->w.hClipRgn); + dc->w.hClipRgn = NULL; + } } else { @@ -166,7 +140,7 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC, } else { - if (!dc->w.hGCClipRgn) + if (!dc->w.hClipRgn) { PROSRGNDATA Rgn; RECT rect; @@ -174,55 +148,52 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC, { UnsafeIntGetRgnBox(Rgn, &rect); RGNDATA_UnlockRgn(dc->w.hVisRgn); - dc->w.hGCClipRgn = UnsafeIntCreateRectRgnIndirect(&rect); + dc->w.hClipRgn = UnsafeIntCreateRectRgnIndirect(&rect); } else { - dc->w.hGCClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); + dc->w.hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); } } if(fnMode == RGN_COPY) - NtGdiCombineRgn(dc->w.hGCClipRgn, hrgn, 0, fnMode); + { + NtGdiCombineRgn(dc->w.hClipRgn, hrgn, 0, fnMode); + } else - NtGdiCombineRgn(dc->w.hGCClipRgn, dc->w.hGCClipRgn, hrgn, fnMode); + NtGdiCombineRgn(dc->w.hClipRgn, dc->w.hClipRgn, hrgn, fnMode); } - if (dc->w.hVisRgn == NULL) - { - dc->w.hVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0); - GDIOBJ_CopyOwnership(hDC, dc->w.hVisRgn); - } - CLIPPING_UpdateGCRegion(dc); DC_UnlockDc( hDC ); return retval; } -int FASTCALL -IntGdiGetClipBox(HDC hDC, - LPRECT rc) +INT FASTCALL +IntGdiGetClipBox(HDC hDC, LPRECT rc) { - PROSRGNDATA Rgn; - int retval; - PDC dc; + PROSRGNDATA Rgn; + INT retval; + PDC dc; - if (!(dc = DC_LockDc(hDC))) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return ERROR; - } - if(!(Rgn = RGNDATA_LockRgn(dc->w.hGCClipRgn))) - { - DC_UnlockDc( hDC ); - SetLastWin32Error(ERROR_INVALID_HANDLE); - return ERROR; - } - retval = UnsafeIntGetRgnBox(Rgn, rc); - RGNDATA_UnlockRgn(dc->w.hGCClipRgn); - IntDPtoLP(dc, (LPPOINT)rc, 2); - DC_UnlockDc( hDC ); - return(retval); + if (!(dc = DC_LockDc(hDC))) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return ERROR; + } + + if (!(Rgn = RGNDATA_LockRgn(dc->w.hGCClipRgn))) + { + DC_UnlockDc( hDC ); + SetLastWin32Error(ERROR_INVALID_HANDLE); + return ERROR; + } + retval = UnsafeIntGetRgnBox(Rgn, rc); + RGNDATA_UnlockRgn(dc->w.hGCClipRgn); + IntDPtoLP(dc, (LPPOINT)rc, 2); + DC_UnlockDc(hDC); + + return retval; } int STDCALL NtGdiGetClipBox(HDC hDC, @@ -309,6 +280,9 @@ int STDCALL NtGdiIntersectClipRect(HDC hDC, HRGN NewRgn; PDC dc = DC_LockDc(hDC); + DPRINT("NtGdiIntersectClipRect(%x, %d,%d-%d,%d)\n", + hDC, LeftRect, TopRect, RightRect, BottomRect); + if (!dc) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -365,7 +339,7 @@ BOOL STDCALL NtGdiPtVisible(HDC hDC, return FALSE; } - rgn = dc->w.hClipRgn; + rgn = dc->w.hGCClipRgn; DC_UnlockDc(hDC); return (rgn ? NtGdiPtInRegion(rgn, X, Y) : FALSE); @@ -413,50 +387,10 @@ BOOL STDCALL NtGdiSelectClipPath(HDC hDC, UNIMPLEMENTED; } -int STDCALL NtGdiSelectClipRgn(HDC hDC, - HRGN hRgn) +INT STDCALL +NtGdiSelectClipRgn(HDC hDC, HRGN hRgn) { - int Type; - PDC dc; - HRGN Copy; - - dc = DC_LockDc(hDC); - if (NULL == dc) - { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return ERROR; - } - - if (NULL != hRgn) - { - Copy = NtGdiCreateRectRgn(0, 0, 0, 0); - if (NULL == Copy) - { - DC_UnlockDc(hDC); - return ERROR; - } - Type = NtGdiCombineRgn(Copy, hRgn, 0, RGN_COPY); - if (ERROR == Type) - { - NtGdiDeleteObject(Copy); - DC_UnlockDc(hDC); - return ERROR; - } - } - else - { - Copy = NULL; - } - - if (NULL != dc->w.hClipRgn) - { - NtGdiDeleteObject(dc->w.hClipRgn); - } - dc->w.hClipRgn = Copy; - CLIPPING_UpdateGCRegion(dc); - DC_UnlockDc(hDC); - - return ERROR; + return NtGdiExtSelectClipRgn(hDC, hRgn, RGN_COPY); } int STDCALL NtGdiSetMetaRgn(HDC hDC) @@ -464,5 +398,4 @@ int STDCALL NtGdiSetMetaRgn(HDC hDC) UNIMPLEMENTED; } - /* EOF */ diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index d715b43594d..360f3f6d63f 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dc.c,v 1.134 2004/05/10 17:07:20 weiden Exp $ +/* $Id: dc.c,v 1.135 2004/05/14 16:55:18 navaraf Exp $ * * DC.C - Device context functions * @@ -1120,18 +1120,12 @@ NtGdiGetDCState(HDC hDC) /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */ -#if 0 newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0; -#endif if (dc->w.hClipRgn) { newdc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 ); NtGdiCombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY ); } - else - { - newdc->w.hClipRgn = 0; - } DC_UnlockDc( hnewdc ); DC_UnlockDc( hDC ); return hnewdc; @@ -1634,25 +1628,23 @@ NtGdiResetDC(HDC hDC, CONST DEVMODEW *InitData) BOOL STDCALL NtGdiRestoreDC(HDC hDC, INT SaveLevel) { - PDC dc, dcs; - BOOL success; + PDC dc, dcs; + BOOL success; + + DPRINT("NtGdiRestoreDC(%lx, %d)\n", hDC, SaveLevel); dc = DC_LockDc(hDC); - if(!dc) + if (!dc) { SetLastWin32Error(ERROR_INVALID_HANDLE); return FALSE; } if (SaveLevel == -1) - { SaveLevel = dc->saveLevel; - } if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel)) - { return FALSE; - } success = TRUE; while (dc->saveLevel >= SaveLevel) @@ -1701,6 +1693,8 @@ NtGdiSaveDC(HDC hDC) PDC dc, dcs; INT ret; + DPRINT("NtGdiSaveDC(%lx)\n", hDC); + if (!(hdcs = NtGdiGetDCState(hDC))) { return 0; diff --git a/reactos/subsys/win32k/objects/fillshap.c b/reactos/subsys/win32k/objects/fillshap.c index c515088721c..9185a3e479d 100644 --- a/reactos/subsys/win32k/objects/fillshap.c +++ b/reactos/subsys/win32k/objects/fillshap.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: fillshap.c,v 1.48 2004/05/10 17:07:20 weiden Exp $ */ +/* $Id: fillshap.c,v 1.49 2004/05/14 16:55:18 navaraf Exp $ */ #include /* @@ -46,7 +46,6 @@ IntGdiPolygon(PDC dc, SURFOBJ *SurfObj; PGDIBRUSHOBJ PenBrushObj, FillBrushObj; BOOL ret = FALSE; // default to failure - PRECTL RectBounds; RECTL DestRect; int CurrentPoint; @@ -68,9 +67,6 @@ IntGdiPolygon(PDC dc, UnsafePoints[CurrentPoint].y += dc->w.DCOrgY; } - RectBounds = (PRECTL) RGNDATA_LockRgn(dc->w.hGCClipRgn); - //ei not yet implemented ASSERT(RectBounds); - if (PATH_IsPathOpen(dc->w.path)) ret = PATH_Polygon(dc, UnsafePoints, Count ); else @@ -140,7 +136,6 @@ IntGdiPolygon(PDC dc, } PENOBJ_UnlockPen( dc->w.hPen ); - RGNDATA_UnlockRgn(dc->w.hGCClipRgn); return ret; } diff --git a/reactos/subsys/win32k/objects/line.c b/reactos/subsys/win32k/objects/line.c index 16a2140ae53..cbd8598a69f 100644 --- a/reactos/subsys/win32k/objects/line.c +++ b/reactos/subsys/win32k/objects/line.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: line.c,v 1.30 2004/05/10 17:07:20 weiden Exp $ */ +/* $Id: line.c,v 1.31 2004/05/14 16:55:18 navaraf Exp $ */ #include // Some code from the WINE project source (www.winehq.com) @@ -196,7 +196,6 @@ IntGdiPolyline(DC *dc, SURFOBJ *SurfObj = NULL; BOOL ret = FALSE; // default to failure LONG i; - PROSRGNDATA reg; PGDIBRUSHOBJ PenBrushObj; POINT *pts; @@ -206,10 +205,6 @@ IntGdiPolyline(DC *dc, if ( PATH_IsPathOpen ( dc->w.path ) ) return PATH_Polyline ( dc, pt, Count ); - reg = RGNDATA_LockRgn(dc->w.hGCClipRgn); - - //FIXME: Do somthing with reg... - //Allocate "Count" bytes of memory to hold a safe copy of pt pts = (POINT*)ExAllocatePoolWithTag ( NonPagedPool, sizeof(POINT)*Count, TAG_SHAPE ); if ( pts ) @@ -245,9 +240,6 @@ IntGdiPolyline(DC *dc, ExFreePool ( pts ); } - //Clean up - RGNDATA_UnlockRgn(dc->w.hGCClipRgn); - return ret; }