* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
CLIPPING_UpdateGCRegion(DC* Dc)
{
PROSRGNDATA CombinedRegion;
+ HRGN hRgnVis;
+ PREGION prgnClip, prgnGCClip;
- /* Experiment with API region based on wine.. */
- if (Dc->rosdc.hClipRgn && Dc->dclevel.prgnMeta)
- {
- PROSRGNDATA pClipRgn;
-
- if ((pClipRgn = RGNOBJAPI_Lock(Dc->rosdc.hClipRgn, NULL)))
- {
- if (!Dc->prgnAPI) Dc->prgnAPI = IntSysCreateRectpRgn( 0, 0, 0, 0 );
-
- IntGdiCombineRgn( Dc->prgnAPI,
- pClipRgn,
- Dc->dclevel.prgnMeta,
- RGN_AND );
- RGNOBJAPI_Unlock(pClipRgn);
- }
- }
- else
- {
- if (Dc->prgnAPI)
- GreDeleteObject(((PROSRGNDATA)Dc->prgnAPI)->BaseObject.hHmgr);
- Dc->prgnAPI = NULL;
- }
+ // would prefer this, but the rest of the code sucks
+// ASSERT(Dc->rosdc.hGCClipRgn);
+// ASSERT(Dc->rosdc.hClipRgn);
+ ASSERT(Dc->prgnVis);
+ hRgnVis = Dc->prgnVis->BaseObject.hHmgr;
if (Dc->rosdc.hGCClipRgn == NULL)
Dc->rosdc.hGCClipRgn = IntSysCreateRectRgn(0, 0, 0, 0);
+ prgnGCClip = REGION_LockRgn(Dc->rosdc.hGCClipRgn);
+ ASSERT(prgnGCClip);
+
if (Dc->rosdc.hClipRgn == NULL)
- NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hVisRgn, 0, RGN_COPY);
+ IntGdiCombineRgn(prgnGCClip, Dc->prgnVis, NULL, RGN_COPY);
else
- NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hClipRgn, Dc->rosdc.hVisRgn, RGN_AND);
+ {
+ prgnClip = REGION_LockRgn(Dc->rosdc.hClipRgn); // FIXME: locking order, ugh
+ IntGdiCombineRgn(prgnGCClip, Dc->prgnVis, prgnClip, RGN_AND);
+ REGION_UnlockRgn(prgnClip);
+ }
+ REGION_UnlockRgn(prgnGCClip);
NtGdiOffsetRgn(Dc->rosdc.hGCClipRgn, Dc->ptlDCOrig.x, Dc->ptlDCOrig.y);
if((CombinedRegion = RGNOBJAPI_Lock(Dc->rosdc.hGCClipRgn, NULL)))
{
- if (Dc->rosdc.CombinedClip != NULL)
- IntEngDeleteClipRegion(Dc->rosdc.CombinedClip);
+ CLIPOBJ *CombinedClip;
- Dc->rosdc.CombinedClip = IntEngCreateClipRegion(
- CombinedRegion->rdh.nCount,
+ CombinedClip = IntEngCreateClipRegion(CombinedRegion->rdh.nCount,
CombinedRegion->Buffer,
&CombinedRegion->rdh.rcBound);
RGNOBJAPI_Unlock(CombinedRegion);
- }
- if ( NULL == Dc->rosdc.CombinedClip )
- {
+ if ( !CombinedClip )
+ {
DPRINT1("IntEngCreateClipRegion() failed\n");
return ERROR;
+ }
+
+ if(Dc->rosdc.CombinedClip != NULL)
+ IntEngDeleteClipRegion(Dc->rosdc.CombinedClip);
+
+ Dc->rosdc.CombinedClip = CombinedClip ;
}
return NtGdiOffsetRgn(Dc->rosdc.hGCClipRgn, -Dc->ptlDCOrig.x, -Dc->ptlDCOrig.y);
{
int retval;
DC *dc;
+ PREGION prgn;
if (!hrgn)
{
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ EngSetLastError(ERROR_INVALID_PARAMETER);
return ERROR;
}
if (!(dc = DC_LockDc(hdc)))
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return ERROR;
}
dc->fs &= ~DC_FLAG_DIRTY_RAO;
-
- if (dc->rosdc.hVisRgn == NULL)
- {
- dc->rosdc.hVisRgn = IntSysCreateRectRgn(0, 0, 0, 0);
- GDIOBJ_CopyOwnership(hdc, dc->rosdc.hVisRgn);
- }
- retval = NtGdiCombineRgn(dc->rosdc.hVisRgn, hrgn, 0, RGN_COPY);
+ ASSERT (dc->prgnVis != NULL);
+
+ prgn = RGNOBJAPI_Lock(hrgn, NULL);
+ retval = prgn ? IntGdiCombineRgn(dc->prgnVis, prgn, NULL, RGN_COPY) : ERROR;
+ RGNOBJAPI_Unlock(prgn);
if ( retval != ERROR )
{
- NtGdiOffsetRgn(dc->rosdc.hVisRgn, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y);
+ IntGdiOffsetRgn(dc->prgnVis, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y);
CLIPPING_UpdateGCRegion(dc);
}
-
DC_UnlockDc(dc);
return retval;
{
if (dc->rosdc.hClipRgn != NULL)
{
- REGION_FreeRgnByHandle(dc->rosdc.hClipRgn);
+ GreDeleteObject(dc->rosdc.hClipRgn);
dc->rosdc.hClipRgn = NULL;
}
}
else
{
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ EngSetLastError(ERROR_INVALID_PARAMETER);
return ERROR;
}
}
{
if (!dc->rosdc.hClipRgn)
{
- PROSRGNDATA Rgn;
RECTL rect;
- if((Rgn = RGNOBJAPI_Lock(dc->rosdc.hVisRgn, NULL)))
+ if(dc->prgnVis)
{
- REGION_GetRgnBox(Rgn, &rect);
- RGNOBJAPI_Unlock(Rgn);
+ REGION_GetRgnBox(dc->prgnVis, &rect);
dc->rosdc.hClipRgn = IntSysCreateRectRgnIndirect(&rect);
}
else
else
NtGdiCombineRgn(dc->rosdc.hClipRgn, dc->rosdc.hClipRgn, hrgn, fnMode);
}
+
return CLIPPING_UpdateGCRegion(dc);
}
if (!(dc = DC_LockDc(hDC)))
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return ERROR;
}
INT FASTCALL
GdiGetClipBox(HDC hDC, PRECTL rc)
{
- PROSRGNDATA Rgn;
INT retval;
PDC dc;
- HRGN hRgnNew, hRgn = NULL;
+ PROSRGNDATA pRgnNew, pRgn = NULL;
+ BOOL Unlock = FALSE; //Small hack
if (!(dc = DC_LockDc(hDC)))
{
/* FIXME! Rao and Vis only! */
if (dc->prgnAPI) // APIRGN
{
- hRgn = ((PROSRGNDATA)dc->prgnAPI)->BaseObject.hHmgr;
+ pRgn = dc->prgnAPI;
}
else if (dc->dclevel.prgnMeta) // METARGN
{
- hRgn = ((PROSRGNDATA)dc->dclevel.prgnMeta)->BaseObject.hHmgr;
+ pRgn = dc->dclevel.prgnMeta;
}
- else
+ else if (dc->rosdc.hClipRgn)
{
- hRgn = dc->rosdc.hClipRgn; // CLIPRGN
+ Unlock = TRUE ;
+ pRgn = REGION_LockRgn(dc->rosdc.hClipRgn); // CLIPRGN
}
- if (hRgn)
+ if (pRgn)
{
- hRgnNew = IntSysCreateRectRgn( 0, 0, 0, 0 );
-
- NtGdiCombineRgn(hRgnNew, dc->rosdc.hVisRgn, hRgn, RGN_AND);
+ pRgnNew = IntSysCreateRectpRgn( 0, 0, 0, 0 );
- if (!(Rgn = RGNOBJAPI_Lock(hRgnNew, NULL)))
+ if (!pRgnNew)
{
DC_UnlockDc(dc);
+ if(Unlock) REGION_UnlockRgn(pRgn);
return ERROR;
}
- retval = REGION_GetRgnBox(Rgn, rc);
+ IntGdiCombineRgn(pRgnNew, dc->prgnVis, pRgn, RGN_AND);
+
+ retval = REGION_GetRgnBox(pRgnNew, rc);
+
+ REGION_Delete(pRgnNew);
- REGION_FreeRgnByHandle(hRgnNew);
- RGNOBJAPI_Unlock(Rgn);
DC_UnlockDc(dc);
+ if(Unlock) REGION_UnlockRgn(pRgn);
return retval;
}
- if (!(Rgn = RGNOBJAPI_Lock(dc->rosdc.hVisRgn, NULL)))
- {
- DC_UnlockDc(dc);
- return ERROR;
- }
- retval = REGION_GetRgnBox(Rgn, rc);
- RGNOBJAPI_Unlock(Rgn);
+ retval = REGION_GetRgnBox(dc->prgnVis, rc);
IntDPtoLP(dc, (LPPOINT)rc, 2);
DC_UnlockDc(dc);
{
INT Result;
RECTL Rect;
- HRGN NewRgn;
+ PREGION prgnNew, prgnClip;
PDC dc = DC_LockDc(hDC);
if (!dc)
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return ERROR;
}
IntLPtoDP(dc, (LPPOINT)&Rect, 2);
- NewRgn = IntSysCreateRectRgnIndirect(&Rect);
- if (!NewRgn)
+ prgnNew = IntSysCreateRectpRgnIndirect(&Rect);
+ if (!prgnNew)
{
Result = ERROR;
}
if (!dc->rosdc.hClipRgn)
{
dc->rosdc.hClipRgn = IntSysCreateRectRgn(0, 0, 0, 0);
- NtGdiCombineRgn(dc->rosdc.hClipRgn, dc->rosdc.hVisRgn, NewRgn, RGN_DIFF);
+ prgnClip = REGION_LockRgn(dc->rosdc.hClipRgn);
+ IntGdiCombineRgn(prgnClip, dc->prgnVis, prgnNew, RGN_DIFF);
+ REGION_UnlockRgn(prgnClip);
Result = SIMPLEREGION;
}
else
{
- Result = NtGdiCombineRgn(dc->rosdc.hClipRgn, dc->rosdc.hClipRgn, NewRgn, RGN_DIFF);
+ prgnClip = REGION_LockRgn(dc->rosdc.hClipRgn);
+ Result = IntGdiCombineRgn(prgnClip, prgnClip, prgnNew, RGN_DIFF);
+ REGION_UnlockRgn(prgnClip);
}
- REGION_FreeRgnByHandle(NewRgn);
+ REGION_Delete(prgnNew);
}
if (Result != ERROR)
CLIPPING_UpdateGCRegion(dc);
if (!dc)
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return ERROR;
}
else
{
Result = NtGdiCombineRgn(dc->rosdc.hClipRgn, dc->rosdc.hClipRgn, NewRgn, RGN_AND);
- REGION_FreeRgnByHandle(NewRgn);
+ GreDeleteObject(NewRgn);
}
if (Result != ERROR)
CLIPPING_UpdateGCRegion(dc);
if(!(dc = DC_LockDc(hDC)))
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return ERROR;
}
if(!(dc = DC_LockDc(hDC)))
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (!dc)
{
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
}
int
-FASTCALL
+FASTCALL
IntGdiSetMetaRgn(PDC pDC)
{
INT Ret = ERROR;
{
TempRgn = IntSysCreateRectpRgn(0,0,0,0);
if (TempRgn)
- {
+ {
Ret = IntGdiCombineRgn( TempRgn,
pDC->dclevel.prgnMeta,
pDC->dclevel.prgnClip,
RGN_AND);
if ( Ret )
{
- GDIOBJ_ShareUnlockObjByPtr(pDC->dclevel.prgnMeta);
+ GDIOBJ_vDereferenceObject(&pDC->dclevel.prgnMeta->BaseObject);
if (!((PROSRGNDATA)pDC->dclevel.prgnMeta)->BaseObject.ulShareCount)
REGION_Delete(pDC->dclevel.prgnMeta);
pDC->dclevel.prgnMeta = TempRgn;
- GDIOBJ_ShareUnlockObjByPtr(pDC->dclevel.prgnClip);
+ GDIOBJ_vDereferenceObject(&pDC->dclevel.prgnClip->BaseObject);
if (!((PROSRGNDATA)pDC->dclevel.prgnClip)->BaseObject.ulShareCount)
REGION_Delete(pDC->dclevel.prgnClip);
pDC->dclevel.prgnMeta = pDC->dclevel.prgnClip;
pDC->dclevel.prgnClip = NULL;
}
- else
+ else
Ret = SIMPLEREGION;
}
return Ret;
}
+
int APIENTRY NtGdiSetMetaRgn(HDC hDC)
{
INT Ret;
if (!pDC)
{
- SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ EngSetLastError(ERROR_INVALID_PARAMETER);
return ERROR;
}
Ret = IntGdiSetMetaRgn(pDC);
CLIPOBJ * co;
/* Must have VisRgn set to a valid state! */
- if (!pDC->prgnVis) return ERROR;
+ ASSERT (pDC->prgnVis);
if (pDC->prgnAPI)
{
REGION_Delete(pDC->prgnRao);
pDC->prgnRao = IntSysCreateRectpRgn(0,0,0,0);
}
-
+
if (pDC->dclevel.prgnMeta && pDC->dclevel.prgnClip)
{
IntGdiCombineRgn( pDC->prgnAPI,
pDC->dclevel.prgnClip,
pDC->dclevel.prgnMeta,
- RGN_AND );
+ RGN_AND);
}
else
{
IntGdiCombineRgn( pDC->prgnAPI,
pDC->dclevel.prgnClip,
NULL,
- RGN_COPY );
+ RGN_COPY);
}
else if (pDC->dclevel.prgnMeta)
{
IntGdiCombineRgn( pDC->prgnAPI,
pDC->dclevel.prgnMeta,
NULL,
- RGN_COPY );
+ RGN_COPY);
}
}
IntGdiCombineRgn( pDC->prgnRao,
pDC->prgnVis,
pDC->prgnAPI,
- RGN_AND );
+ RGN_AND);
- RtlCopyMemory( &pDC->erclClip,
- &((PROSRGNDATA)pDC->prgnRao)->rdh.rcBound,
- sizeof(RECTL));
+ RtlCopyMemory(&pDC->erclClip,
+ &((PROSRGNDATA)pDC->prgnRao)->rdh.rcBound,
+ sizeof(RECTL));
pDC->fs &= ~DC_FLAG_DIRTY_RAO;
IntGdiOffsetRgn(pDC->prgnRao, pDC->ptlDCOrig.x, pDC->ptlDCOrig.y);
- if (pDC->rosdc.CombinedClip != NULL)
- IntEngDeleteClipRegion(pDC->rosdc.CombinedClip);
-
// pDC->co should be used. Example, CLIPOBJ_cEnumStart uses XCLIPOBJ to build
- // the rects from region objects rects in pClipRgn->Buffer.
+ // the rects from region objects rects in pClipRgn->Buffer.
// With pDC->co.pClipRgn->Buffer,
// pDC->co.pClipRgn = pDC->prgnRao ? pDC->prgnRao : pDC->prgnVis;
co = IntEngCreateClipRegion( ((PROSRGNDATA)pDC->prgnRao)->rdh.nCount,
((PROSRGNDATA)pDC->prgnRao)->Buffer,
- &pDC->erclClip);
+ &pDC->erclClip);
+ if (co)
+ {
+ if (pDC->rosdc.CombinedClip != NULL)
+ IntEngDeleteClipRegion(pDC->rosdc.CombinedClip);
- pDC->rosdc.CombinedClip = co;
+ pDC->rosdc.CombinedClip = co;
+ }
return IntGdiOffsetRgn(pDC->prgnRao, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y);
}