- Fix ExtSelectClipRgn and some other clipping functions.

svn path=/trunk/; revision=9383
This commit is contained in:
Filip Navara 2004-05-14 16:55:18 +00:00
parent 1e4d1cd885
commit 3f9294eaee
4 changed files with 71 additions and 157 deletions

View file

@ -16,67 +16,38 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 <w32k.h> #include <w32k.h>
VOID FASTCALL VOID FASTCALL
CLIPPING_UpdateGCRegion(DC* Dc) CLIPPING_UpdateGCRegion(DC* Dc)
{ {
HRGN Combined; PROSRGNDATA CombinedRegion;
PROSRGNDATA CombinedRegion;
#ifndef TODO ASSERT(Dc->w.hGCClipRgn != NULL);
if (Dc->w.hGCClipRgn == NULL) if (Dc->w.hGCClipRgn == NULL)
{
Dc->w.hGCClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); Dc->w.hGCClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
}
if (Dc->w.hGCClipRgn == NULL) if (Dc->w.hClipRgn == NULL)
return;
if (Dc->w.hClipRgn == NULL)
{
NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hVisRgn, 0, RGN_COPY); NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hVisRgn, 0, RGN_COPY);
} else
else NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn, RGN_AND);
{ NtGdiOffsetRgn(Dc->w.hGCClipRgn, Dc->w.DCOrgX, Dc->w.DCOrgY);
NtGdiCombineRgn(Dc->w.hGCClipRgn, Dc->w.hClipRgn, Dc->w.hVisRgn,
RGN_AND);
}
#endif
Combined = NtGdiCreateRectRgn(0, 0, 0, 0); CombinedRegion = RGNDATA_LockRgn(Dc->w.hGCClipRgn);
if(!Combined) ASSERT(CombinedRegion != NULL);
{
return;
}
if (Dc->w.hClipRgn == NULL) if (Dc->CombinedClip != 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)
{
IntEngDeleteClipRegion(Dc->CombinedClip); IntEngDeleteClipRegion(Dc->CombinedClip);
}
Dc->CombinedClip = IntEngCreateClipRegion(CombinedRegion->rdh.nCount, Dc->CombinedClip = IntEngCreateClipRegion(
(PRECTL)CombinedRegion->Buffer, CombinedRegion->rdh.nCount,
(PRECTL)&CombinedRegion->rdh.rcBound); (PRECTL)CombinedRegion->Buffer,
ASSERT(NULL != Dc->CombinedClip); (PRECTL)&CombinedRegion->rdh.rcBound);
ASSERT(Dc->CombinedClip != NULL);
RGNDATA_UnlockRgn(Combined); RGNDATA_UnlockRgn(Dc->w.hGCClipRgn);
NtGdiDeleteObject(Combined); NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY);
} }
HRGN WINAPI SaveVisRgn(HDC hdc) HRGN WINAPI SaveVisRgn(HDC hdc)
@ -148,14 +119,17 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC,
return ERROR; return ERROR;
} }
dc->w.flags &= ~DC_DIRTY; // dc->w.flags &= ~DC_DIRTY;
if (!hrgn) if (!hrgn)
{ {
if (fnMode == RGN_COPY) if (fnMode == RGN_COPY)
{ {
NtGdiDeleteObject(dc->w.hGCClipRgn); if (dc->w.hClipRgn != NULL)
dc->w.hGCClipRgn = NULL; {
NtGdiDeleteObject(dc->w.hClipRgn);
dc->w.hClipRgn = NULL;
}
} }
else else
{ {
@ -166,7 +140,7 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC,
} }
else else
{ {
if (!dc->w.hGCClipRgn) if (!dc->w.hClipRgn)
{ {
PROSRGNDATA Rgn; PROSRGNDATA Rgn;
RECT rect; RECT rect;
@ -174,24 +148,20 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC,
{ {
UnsafeIntGetRgnBox(Rgn, &rect); UnsafeIntGetRgnBox(Rgn, &rect);
RGNDATA_UnlockRgn(dc->w.hVisRgn); RGNDATA_UnlockRgn(dc->w.hVisRgn);
dc->w.hGCClipRgn = UnsafeIntCreateRectRgnIndirect(&rect); dc->w.hClipRgn = UnsafeIntCreateRectRgnIndirect(&rect);
} }
else else
{ {
dc->w.hGCClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); dc->w.hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
} }
} }
if(fnMode == RGN_COPY) if(fnMode == RGN_COPY)
NtGdiCombineRgn(dc->w.hGCClipRgn, hrgn, 0, fnMode);
else
NtGdiCombineRgn(dc->w.hGCClipRgn, dc->w.hGCClipRgn, hrgn, fnMode);
}
if (dc->w.hVisRgn == NULL)
{ {
dc->w.hVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0); NtGdiCombineRgn(dc->w.hClipRgn, hrgn, 0, fnMode);
GDIOBJ_CopyOwnership(hDC, dc->w.hVisRgn);
} }
else
NtGdiCombineRgn(dc->w.hClipRgn, dc->w.hClipRgn, hrgn, fnMode);
}
CLIPPING_UpdateGCRegion(dc); CLIPPING_UpdateGCRegion(dc);
DC_UnlockDc( hDC ); DC_UnlockDc( hDC );
@ -199,30 +169,31 @@ int STDCALL NtGdiExtSelectClipRgn(HDC hDC,
return retval; return retval;
} }
int FASTCALL INT FASTCALL
IntGdiGetClipBox(HDC hDC, IntGdiGetClipBox(HDC hDC, LPRECT rc)
LPRECT rc)
{ {
PROSRGNDATA Rgn; PROSRGNDATA Rgn;
int retval; INT retval;
PDC dc; PDC dc;
if (!(dc = DC_LockDc(hDC))) if (!(dc = DC_LockDc(hDC)))
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return ERROR; return ERROR;
} }
if(!(Rgn = RGNDATA_LockRgn(dc->w.hGCClipRgn)))
{ if (!(Rgn = RGNDATA_LockRgn(dc->w.hGCClipRgn)))
DC_UnlockDc( hDC ); {
SetLastWin32Error(ERROR_INVALID_HANDLE); DC_UnlockDc( hDC );
return ERROR; SetLastWin32Error(ERROR_INVALID_HANDLE);
} return ERROR;
retval = UnsafeIntGetRgnBox(Rgn, rc); }
RGNDATA_UnlockRgn(dc->w.hGCClipRgn); retval = UnsafeIntGetRgnBox(Rgn, rc);
IntDPtoLP(dc, (LPPOINT)rc, 2); RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
DC_UnlockDc( hDC ); IntDPtoLP(dc, (LPPOINT)rc, 2);
return(retval); DC_UnlockDc(hDC);
return retval;
} }
int STDCALL NtGdiGetClipBox(HDC hDC, int STDCALL NtGdiGetClipBox(HDC hDC,
@ -309,6 +280,9 @@ int STDCALL NtGdiIntersectClipRect(HDC hDC,
HRGN NewRgn; HRGN NewRgn;
PDC dc = DC_LockDc(hDC); PDC dc = DC_LockDc(hDC);
DPRINT("NtGdiIntersectClipRect(%x, %d,%d-%d,%d)\n",
hDC, LeftRect, TopRect, RightRect, BottomRect);
if (!dc) if (!dc)
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
@ -365,7 +339,7 @@ BOOL STDCALL NtGdiPtVisible(HDC hDC,
return FALSE; return FALSE;
} }
rgn = dc->w.hClipRgn; rgn = dc->w.hGCClipRgn;
DC_UnlockDc(hDC); DC_UnlockDc(hDC);
return (rgn ? NtGdiPtInRegion(rgn, X, Y) : FALSE); return (rgn ? NtGdiPtInRegion(rgn, X, Y) : FALSE);
@ -413,50 +387,10 @@ BOOL STDCALL NtGdiSelectClipPath(HDC hDC,
UNIMPLEMENTED; UNIMPLEMENTED;
} }
int STDCALL NtGdiSelectClipRgn(HDC hDC, INT STDCALL
HRGN hRgn) NtGdiSelectClipRgn(HDC hDC, HRGN hRgn)
{ {
int Type; return NtGdiExtSelectClipRgn(hDC, hRgn, RGN_COPY);
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;
} }
int STDCALL NtGdiSetMetaRgn(HDC hDC) int STDCALL NtGdiSetMetaRgn(HDC hDC)
@ -464,5 +398,4 @@ int STDCALL NtGdiSetMetaRgn(HDC hDC)
UNIMPLEMENTED; UNIMPLEMENTED;
} }
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * DC.C - Device context functions
* *
@ -1120,18 +1120,12 @@ NtGdiGetDCState(HDC hDC)
/* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */ /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
#if 0
newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0; newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0;
#endif
if (dc->w.hClipRgn) if (dc->w.hClipRgn)
{ {
newdc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 ); newdc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY ); NtGdiCombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
} }
else
{
newdc->w.hClipRgn = 0;
}
DC_UnlockDc( hnewdc ); DC_UnlockDc( hnewdc );
DC_UnlockDc( hDC ); DC_UnlockDc( hDC );
return hnewdc; return hnewdc;
@ -1634,25 +1628,23 @@ NtGdiResetDC(HDC hDC, CONST DEVMODEW *InitData)
BOOL STDCALL BOOL STDCALL
NtGdiRestoreDC(HDC hDC, INT SaveLevel) NtGdiRestoreDC(HDC hDC, INT SaveLevel)
{ {
PDC dc, dcs; PDC dc, dcs;
BOOL success; BOOL success;
DPRINT("NtGdiRestoreDC(%lx, %d)\n", hDC, SaveLevel);
dc = DC_LockDc(hDC); dc = DC_LockDc(hDC);
if(!dc) if (!dc)
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
} }
if (SaveLevel == -1) if (SaveLevel == -1)
{
SaveLevel = dc->saveLevel; SaveLevel = dc->saveLevel;
}
if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel)) if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel))
{
return FALSE; return FALSE;
}
success = TRUE; success = TRUE;
while (dc->saveLevel >= SaveLevel) while (dc->saveLevel >= SaveLevel)
@ -1701,6 +1693,8 @@ NtGdiSaveDC(HDC hDC)
PDC dc, dcs; PDC dc, dcs;
INT ret; INT ret;
DPRINT("NtGdiSaveDC(%lx)\n", hDC);
if (!(hdcs = NtGdiGetDCState(hDC))) if (!(hdcs = NtGdiGetDCState(hDC)))
{ {
return 0; return 0;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 <w32k.h> #include <w32k.h>
/* /*
@ -46,7 +46,6 @@ IntGdiPolygon(PDC dc,
SURFOBJ *SurfObj; SURFOBJ *SurfObj;
PGDIBRUSHOBJ PenBrushObj, FillBrushObj; PGDIBRUSHOBJ PenBrushObj, FillBrushObj;
BOOL ret = FALSE; // default to failure BOOL ret = FALSE; // default to failure
PRECTL RectBounds;
RECTL DestRect; RECTL DestRect;
int CurrentPoint; int CurrentPoint;
@ -68,9 +67,6 @@ IntGdiPolygon(PDC dc,
UnsafePoints[CurrentPoint].y += dc->w.DCOrgY; 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)) if (PATH_IsPathOpen(dc->w.path))
ret = PATH_Polygon(dc, UnsafePoints, Count ); ret = PATH_Polygon(dc, UnsafePoints, Count );
else else
@ -140,7 +136,6 @@ IntGdiPolygon(PDC dc,
} }
PENOBJ_UnlockPen( dc->w.hPen ); PENOBJ_UnlockPen( dc->w.hPen );
RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
return ret; return ret;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 <w32k.h> #include <w32k.h>
// Some code from the WINE project source (www.winehq.com) // Some code from the WINE project source (www.winehq.com)
@ -196,7 +196,6 @@ IntGdiPolyline(DC *dc,
SURFOBJ *SurfObj = NULL; SURFOBJ *SurfObj = NULL;
BOOL ret = FALSE; // default to failure BOOL ret = FALSE; // default to failure
LONG i; LONG i;
PROSRGNDATA reg;
PGDIBRUSHOBJ PenBrushObj; PGDIBRUSHOBJ PenBrushObj;
POINT *pts; POINT *pts;
@ -206,10 +205,6 @@ IntGdiPolyline(DC *dc,
if ( PATH_IsPathOpen ( dc->w.path ) ) if ( PATH_IsPathOpen ( dc->w.path ) )
return PATH_Polyline ( dc, pt, Count ); 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 //Allocate "Count" bytes of memory to hold a safe copy of pt
pts = (POINT*)ExAllocatePoolWithTag ( NonPagedPool, sizeof(POINT)*Count, TAG_SHAPE ); pts = (POINT*)ExAllocatePoolWithTag ( NonPagedPool, sizeof(POINT)*Count, TAG_SHAPE );
if ( pts ) if ( pts )
@ -245,9 +240,6 @@ IntGdiPolyline(DC *dc,
ExFreePool ( pts ); ExFreePool ( pts );
} }
//Clean up
RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
return ret; return ret;
} }