From 74cae571361c532b84d910df15a700c120f4ec12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 12 Jul 2010 16:52:10 +0000 Subject: [PATCH] [WIN32K] - Get rid of rosdc::hVisRgn, as in yarotows (r46372) svn path=/trunk/; revision=48007 --- reactos/subsystems/win32/win32k/include/dc.h | 8 +-- .../subsystems/win32/win32k/ntuser/monitor.c | 8 +-- .../subsystems/win32/win32k/ntuser/painting.c | 6 +- .../subsystems/win32/win32k/objects/cliprgn.c | 70 +++++++++---------- .../subsystems/win32/win32k/objects/dclife.c | 10 +-- .../subsystems/win32/win32k/objects/region.c | 65 ++++++++--------- 6 files changed, 79 insertions(+), 88 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/dc.h b/reactos/subsystems/win32/win32k/include/dc.h index 8b988d5c14f..41621f973c1 100644 --- a/reactos/subsystems/win32/win32k/include/dc.h +++ b/reactos/subsystems/win32/win32k/include/dc.h @@ -7,6 +7,7 @@ typedef struct _DC *PDC; #include "bitmaps.h" #include "pdevobj.h" #include "palette.h" +#include "region.h" /* Constants ******************************************************************/ @@ -26,7 +27,6 @@ typedef struct _DC *PDC; typedef struct _ROS_DC_INFO { HRGN hClipRgn; /* Clip region (may be 0) */ - HRGN hVisRgn; /* Visible region (must never be 0) */ HRGN hGCClipRgn; /* GC clip region (ClipRgn AND VisRgn) */ CLIPOBJ *CombinedClip; /* Use XCLIPOBJ in DC. */ @@ -101,9 +101,9 @@ typedef struct _DC RECTL erclWindow; RECTL erclBounds; RECTL erclBoundsApp; - PVOID prgnAPI; /* PROSRGNDATA */ - PVOID prgnVis; - PVOID prgnRao; + PROSRGNDATA prgnAPI; /* PROSRGNDATA */ + PROSRGNDATA prgnVis; /* Visible region (must never be 0) */ + PROSRGNDATA prgnRao; POINTL ptlFillOrigin; EBRUSHOBJ eboFill; EBRUSHOBJ eboLine; diff --git a/reactos/subsystems/win32/win32k/ntuser/monitor.c b/reactos/subsystems/win32/win32k/ntuser/monitor.c index 1d49cae6cba..dd20d9d16b3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/monitor.c +++ b/reactos/subsystems/win32/win32k/ntuser/monitor.c @@ -184,8 +184,8 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice, Monitor->GdiDevice = pGdiDevice; Monitor->rcMonitor.left = 0; - Monitor->rcMonitor.top = 0; - Monitor->rcMonitor.right = Monitor->rcMonitor.left + pGdiDevice->gdiinfo.ulHorzRes; + Monitor->rcMonitor.top = 0; + Monitor->rcMonitor.right = Monitor->rcMonitor.left + pGdiDevice->gdiinfo.ulHorzRes; Monitor->rcMonitor.bottom = Monitor->rcMonitor.top + pGdiDevice->gdiinfo.ulVertRes; Monitor->rcWork = Monitor->rcMonitor; Monitor->cWndStack = 0; @@ -492,7 +492,6 @@ NtUserEnumDisplayMonitors( if (hDC != NULL) { PDC dc; - HRGN dcVisRgn; INT regionType; /* get visible region bounding rect */ @@ -503,10 +502,9 @@ NtUserEnumDisplayMonitors( /* FIXME: setlasterror? */ return -1; } - dcVisRgn = dc->rosdc.hVisRgn; + regionType = REGION_GetRgnBox(dc->prgnVis, &dcRect); DC_UnlockDc(dc); - regionType = NtGdiGetRgnBox(dcVisRgn, &dcRect); if (regionType == 0) { DPRINT("NtGdiGetRgnBox() failed!\n"); diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index 2564bac103f..7aba2547a34 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1206,8 +1206,7 @@ UserScrollDC( { return FALSE; } - hrgnVisible = pDC->rosdc.hVisRgn; // pDC->prgnRao? - DC_UnlockDc(pDC); + hrgnVisible = ((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr; // pDC->prgnRao? /* Begin with the shifted and then clipped scroll rect */ rcDst = rcScroll; @@ -1235,6 +1234,9 @@ UserScrollDC( NtGdiOffsetRgn(hrgnTmp, dx, dy); Result = NtGdiCombineRgn(hrgnOwn, hrgnOwn, hrgnTmp, RGN_DIFF); + /* DO NOT Unlock DC while messing with prgnVis! */ + DC_UnlockDc(pDC); + REGION_FreeRgnByHandle(hrgnTmp); if (prcUpdate) diff --git a/reactos/subsystems/win32/win32k/objects/cliprgn.c b/reactos/subsystems/win32/win32k/objects/cliprgn.c index 77415e686b6..ea88cf3047c 100644 --- a/reactos/subsystems/win32/win32k/objects/cliprgn.c +++ b/reactos/subsystems/win32/win32k/objects/cliprgn.c @@ -26,6 +26,7 @@ int FASTCALL CLIPPING_UpdateGCRegion(DC* Dc) { PROSRGNDATA CombinedRegion; + HRGN hRgnVis = NULL; /* Experiment with API region based on wine.. */ if (Dc->rosdc.hClipRgn && Dc->dclevel.prgnMeta) @@ -50,13 +51,14 @@ CLIPPING_UpdateGCRegion(DC* Dc) Dc->prgnAPI = NULL; } + if (Dc->rosdc.hGCClipRgn == NULL) Dc->rosdc.hGCClipRgn = IntSysCreateRectRgn(0, 0, 0, 0); if (Dc->rosdc.hClipRgn == NULL) - NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hVisRgn, 0, RGN_COPY); + NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, ((PROSRGNDATA)Dc->prgnVis)->BaseObject.hHmgr, 0, RGN_COPY); else - NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hClipRgn, Dc->rosdc.hVisRgn, RGN_AND); + NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hClipRgn, hRgnVis, RGN_AND); NtGdiOffsetRgn(Dc->rosdc.hGCClipRgn, Dc->ptlDCOrig.x, Dc->ptlDCOrig.y); @@ -104,17 +106,17 @@ GdiSelectVisRgn(HDC hdc, HRGN hrgn) } dc->fs &= ~DC_FLAG_DIRTY_RAO; - - if (dc->rosdc.hVisRgn == NULL) + + if (dc->prgnVis == NULL) { - dc->rosdc.hVisRgn = IntSysCreateRectRgn(0, 0, 0, 0); - GDIOBJ_CopyOwnership(hdc, dc->rosdc.hVisRgn); + dc->prgnVis = IntSysCreateRectpRgn(0, 0, 0, 0); + GDIOBJ_CopyOwnership(hdc, ((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr); } - retval = NtGdiCombineRgn(dc->rosdc.hVisRgn, hrgn, 0, RGN_COPY); + retval = NtGdiCombineRgn(((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, hrgn, 0, RGN_COPY); if ( retval != ERROR ) { - NtGdiOffsetRgn(dc->rosdc.hVisRgn, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y); + NtGdiOffsetRgn(((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, -dc->ptlDCOrig.x, -dc->ptlDCOrig.y); CLIPPING_UpdateGCRegion(dc); } @@ -150,12 +152,10 @@ int FASTCALL GdiExtSelectClipRgn(PDC dc, { 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 @@ -196,10 +196,10 @@ int APIENTRY NtGdiExtSelectClipRgn(HDC hDC, 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))) { @@ -209,44 +209,40 @@ GdiGetClipBox(HDC hDC, PRECTL rc) /* 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 { - hRgn = dc->rosdc.hClipRgn; // CLIPRGN + Unlock = TRUE ; + pRgn = REGION_LockRgn(dc->rosdc.hClipRgn); // CLIPRGN } - if (hRgn) + if (pRgn) { - hRgnNew = IntSysCreateRectRgn( 0, 0, 0, 0 ); + pRgnNew = IntSysCreateRectpRgn( 0, 0, 0, 0 ); - NtGdiCombineRgn(hRgnNew, dc->rosdc.hVisRgn, hRgn, RGN_AND); - - 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); - REGION_FreeRgnByHandle(hRgnNew); - RGNOBJAPI_Unlock(Rgn); + retval = REGION_GetRgnBox(pRgnNew, rc); + + REGION_FreeRgnByHandle(pRgnNew->BaseObject.hHmgr); 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); @@ -318,7 +314,7 @@ int APIENTRY NtGdiExcludeClipRect(HDC hDC, if (!dc->rosdc.hClipRgn) { dc->rosdc.hClipRgn = IntSysCreateRectRgn(0, 0, 0, 0); - NtGdiCombineRgn(dc->rosdc.hClipRgn, dc->rosdc.hVisRgn, NewRgn, RGN_DIFF); + NtGdiCombineRgn(dc->rosdc.hClipRgn, ((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, NewRgn, RGN_DIFF); Result = SIMPLEREGION; } else @@ -483,7 +479,7 @@ BOOL APIENTRY NtGdiRectVisible(HDC hDC, } int -FASTCALL +FASTCALL IntGdiSetMetaRgn(PDC pDC) { INT Ret = ERROR; @@ -495,7 +491,7 @@ IntGdiSetMetaRgn(PDC pDC) { TempRgn = IntSysCreateRectpRgn(0,0,0,0); if (TempRgn) - { + { Ret = IntGdiCombineRgn( TempRgn, pDC->dclevel.prgnMeta, pDC->dclevel.prgnClip, @@ -531,7 +527,7 @@ IntGdiSetMetaRgn(PDC pDC) pDC->dclevel.prgnMeta = pDC->dclevel.prgnClip; pDC->dclevel.prgnClip = NULL; } - else + else Ret = SIMPLEREGION; } return Ret; @@ -572,7 +568,7 @@ NEW_CLIPPING_UpdateGCRegion(PDC pDC) REGION_Delete(pDC->prgnRao); pDC->prgnRao = IntSysCreateRectpRgn(0,0,0,0); } - + if (pDC->dclevel.prgnMeta && pDC->dclevel.prgnClip) { IntGdiCombineRgn( pDC->prgnAPI, diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index c4ba1ddcf19..1710dba108d 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -191,14 +191,14 @@ DC_SetOwnership(HDC hDC, PEPROCESS Owner) // if (!GDIOBJ_SetOwnership(pDC->rosdc.hClipRgn, Owner)) return FALSE; } - if (pDC->rosdc.hVisRgn) + if (pDC->prgnVis) { // FIXME! HAX!!! - Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hVisRgn); + Index = GDI_HANDLE_GET_INDEX(((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr); Entry = &GdiHandleTable->Entries[Index]; if (Entry->UserData) FreeObjectAttr(Entry->UserData); Entry->UserData = NULL; // - if (!GDIOBJ_SetOwnership(pDC->rosdc.hVisRgn, Owner)) return FALSE; + if (!GDIOBJ_SetOwnership(((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr, Owner)) return FALSE; } if (pDC->rosdc.hGCClipRgn) { // FIXME! HAX!!! @@ -525,9 +525,9 @@ IntGdiDeleteDC(HDC hDC, BOOL Force) { GreDeleteObject(DCToDelete->rosdc.hClipRgn); } - if (DCToDelete->rosdc.hVisRgn) + if (DCToDelete->prgnVis) { - GreDeleteObject(DCToDelete->rosdc.hVisRgn); + GreDeleteObject(DCToDelete->prgnVis->BaseObject.hHmgr); } if (NULL != DCToDelete->rosdc.CombinedClip) { diff --git a/reactos/subsystems/win32/win32k/objects/region.c b/reactos/subsystems/win32/win32k/objects/region.c index 165f86a1625..c7c6c4ae312 100644 --- a/reactos/subsystems/win32/win32k/objects/region.c +++ b/reactos/subsystems/win32/win32k/objects/region.c @@ -607,42 +607,38 @@ REGION_CropAndOffsetRegion( else { xrect = ExAllocatePoolWithTag(PagedPool, rgnSrc->rdh.nCount * sizeof(RECT), TAG_REGION); + if(!xrect) + return FALSE; if (rgnDst->Buffer && rgnDst->Buffer != &rgnDst->rdh.rcBound) ExFreePoolWithTag(rgnDst->Buffer, TAG_REGION); //free the old buffer. will be assigned to xrect below. } - if (xrect) + if (rgnDst != rgnSrc) { - ULONG i; + *rgnDst = *rgnSrc; + } - if (rgnDst != rgnSrc) + if (off->x || off->y) + { + ULONG i; + for (i = 0; i < rgnDst->rdh.nCount; i++) { - *rgnDst = *rgnSrc; + xrect[i].left = (rgnSrc->Buffer + i)->left + off->x; + xrect[i].right = (rgnSrc->Buffer + i)->right + off->x; + xrect[i].top = (rgnSrc->Buffer + i)->top + off->y; + xrect[i].bottom = (rgnSrc->Buffer + i)->bottom + off->y; } - - if (off->x || off->y) - { - for (i = 0; i < rgnDst->rdh.nCount; i++) - { - xrect[i].left = (rgnSrc->Buffer + i)->left + off->x; - xrect[i].right = (rgnSrc->Buffer + i)->right + off->x; - xrect[i].top = (rgnSrc->Buffer + i)->top + off->y; - xrect[i].bottom = (rgnSrc->Buffer + i)->bottom + off->y; - } - rgnDst->rdh.rcBound.left += off->x; - rgnDst->rdh.rcBound.right += off->x; - rgnDst->rdh.rcBound.top += off->y; - rgnDst->rdh.rcBound.bottom += off->y; - } - else - { - COPY_RECTS(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount); - } - - rgnDst->Buffer = xrect; + rgnDst->rdh.rcBound.left += off->x; + rgnDst->rdh.rcBound.right += off->x; + rgnDst->rdh.rcBound.top += off->y; + rgnDst->rdh.rcBound.bottom += off->y; } else - return FALSE; + { + COPY_RECTS(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount); + } + + rgnDst->Buffer = xrect; } else if ((rect->left >= rect->right) || (rect->top >= rect->bottom) || @@ -2035,13 +2031,13 @@ REGION_AllocRgnWithHandle(INT nReg) { HRGN hReg; PROSRGNDATA pReg; - + pReg = (PROSRGNDATA)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_REGION); if(!pReg) { return NULL; } - + hReg = pReg->BaseObject.hHmgr; if (nReg == 0 || nReg == 1) @@ -2228,7 +2224,7 @@ REGION_Cleanup(PVOID ObjectBody) { PROSRGNDATA pRgn = (PROSRGNDATA)ObjectBody; if (pRgn->Buffer && pRgn->Buffer != &pRgn->rdh.rcBound) - ExFreePool(pRgn->Buffer); + ExFreePoolWithTag(pRgn->Buffer, TAG_REGION); return TRUE; } @@ -2419,7 +2415,7 @@ IntGdiPaintRgn( if (!(tmpVisRgn = IntSysCreateRectRgn(0, 0, 0, 0))) return FALSE; // Transform region into device co-ords - if (!REGION_LPTODP(dc, tmpVisRgn, hRgn) || + if (!REGION_LPTODP(dc, tmpVisRgn, hRgn) || NtGdiOffsetRgn(tmpVisRgn, dc->ptlDCOrig.x, dc->ptlDCOrig.y) == ERROR) { REGION_FreeRgnByHandle(tmpVisRgn); @@ -2552,13 +2548,13 @@ REGION_SetRectRgn( } } -INT +INT FASTCALL IntGdiOffsetRgn( PROSRGNDATA rgn, INT XOffset, INT YOffset ) -{ +{ if (XOffset || YOffset) { int nbox = rgn->rdh.nCount; @@ -3444,7 +3440,7 @@ NtGdiEqualRgn( if ( rgn1->rdh.nCount == 0 ) { bRet = TRUE; - goto exit; + goto exit; } if ( rgn1->rdh.rcBound.left != rgn2->rdh.rcBound.left || @@ -3691,8 +3687,7 @@ NtGdiGetRandomRgn( else if (pDC->dclevel.prgnMeta) hSrc = ((PROSRGNDATA)pDC->dclevel.prgnMeta)->BaseObject.hHmgr; break; case SYSRGN: - hSrc = pDC->rosdc.hVisRgn; -// if (pDC->prgnVis) hSrc = ((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr; + if (pDC->prgnVis) hSrc = ((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr; break; default: hSrc = 0;