From: Jérôme Gardou Date: Sat, 26 Jul 2014 15:41:08 +0000 (+0000) Subject: [WIN32K] X-Git-Tag: backups/0.3.17@66124~883 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=4069d63c30225d869768c99245cc85f0b9096714 [WIN32K] - Improve the WNDOBJ/CLIPOBJ hack by using the same internal structure for both object. This way a driver can enumerate WNDOBJ::coClient safely. Also take this as an opportunity to get rid of DC::ros_dc. svn path=/trunk/; revision=63739 --- diff --git a/reactos/win32ss/gdi/eng/bitblt.c b/reactos/win32ss/gdi/eng/bitblt.c index 5753000b24a..96b031f1acf 100644 --- a/reactos/win32ss/gdi/eng/bitblt.c +++ b/reactos/win32ss/gdi/eng/bitblt.c @@ -14,7 +14,17 @@ XCLIPOBJ gxcoTrivial = { - {0, {LONG_MIN, LONG_MIN, LONG_MAX, LONG_MAX}, DC_TRIVIAL, FC_RECT, TC_RECTANGLES, 0}, + /* CLIPOBJ */ + { + { + 0, /* iUniq */ + {LONG_MIN, LONG_MIN, LONG_MAX, LONG_MAX}, /* rclBounds */ + DC_TRIVIAL, /* idCOmplexity */ + FC_RECT, /* iFComplexity */ + TC_RECTANGLES, /* iMode */ + 0 /* fjOptions */ + }, + }, 0, 0, 0 }; diff --git a/reactos/win32ss/gdi/eng/clip.c b/reactos/win32ss/gdi/eng/clip.c index bce0502cf45..7a7381581e1 100644 --- a/reactos/win32ss/gdi/eng/clip.c +++ b/reactos/win32ss/gdi/eng/clip.c @@ -190,63 +190,63 @@ CompareSpans( VOID FASTCALL -IntEngDeleteClipRegion(CLIPOBJ *ClipObj) +IntEngInitClipObj(XCLIPOBJ *Clip) { - EngFreeMem(ObjToGDI(ClipObj, CLIP)); + Clip->Rects = &Clip->ClipObj.rclBounds; } -CLIPOBJ* -FASTCALL -IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds) +VOID FASTCALL +IntEngFreeClipResources(XCLIPOBJ *Clip) { - CLIPGDI *Clip; + if (Clip->Rects != &Clip->ClipObj.rclBounds) + EngFreeMem(Clip->Rects); +} + +VOID +FASTCALL +IntEngUpdateClipRegion( + XCLIPOBJ* Clip, + ULONG count, + const RECTL* pRect, + const RECTL* rcBounds) +{ if(count > 1) { - RECTL *dest; - - Clip = EngAllocMem(0, sizeof(CLIPGDI) + ((count - 1) * sizeof(RECTL)), GDITAG_CLIPOBJ); + RECTL* NewRects = EngAllocMem(0, FIELD_OFFSET(ENUMRECTS, arcl[count]), GDITAG_CLIPOBJ); - if(Clip != NULL) + if(NewRects != NULL) { - Clip->EnumRects.c = count; + Clip->RectCount = count; Clip->EnumOrder = CD_ANY; - for(dest = Clip->EnumRects.arcl;count > 0; count--, dest++, pRect++) - { - *dest = *pRect; - } + RtlCopyMemory(NewRects, pRect, count * sizeof(RECTL)); Clip->ClipObj.iDComplexity = DC_COMPLEX; - Clip->ClipObj.iFComplexity = ((Clip->EnumRects.c <= 4) ? FC_RECT4 : FC_COMPLEX); + Clip->ClipObj.iFComplexity = ((Clip->RectCount <= 4) ? FC_RECT4 : FC_COMPLEX); Clip->ClipObj.iMode = TC_RECTANGLES; Clip->ClipObj.rclBounds = *rcBounds; - return GDIToObj(Clip, CLIP); + if (Clip->Rects != &Clip->ClipObj.rclBounds) + EngFreeMem(Clip->Rects); + Clip->Rects = NewRects; } } else { - Clip = EngAllocMem(0, sizeof(CLIPGDI), GDITAG_CLIPOBJ); - - if(Clip != NULL) - { - Clip->EnumRects.c = 1; - Clip->EnumOrder = CD_ANY; - Clip->EnumRects.arcl[0] = *rcBounds; - - Clip->ClipObj.iDComplexity = (((rcBounds->top == rcBounds->bottom) && - (rcBounds->left == rcBounds->right)) - ? DC_TRIVIAL : DC_RECT); - - Clip->ClipObj.iFComplexity = FC_RECT; - Clip->ClipObj.iMode = TC_RECTANGLES; - Clip->ClipObj.rclBounds = *rcBounds; - - return GDIToObj(Clip, CLIP); - } + Clip->EnumOrder = CD_ANY; + + Clip->ClipObj.iDComplexity = (((rcBounds->top == rcBounds->bottom) && + (rcBounds->left == rcBounds->right)) + ? DC_TRIVIAL : DC_RECT); + + Clip->ClipObj.iFComplexity = FC_RECT; + Clip->ClipObj.iMode = TC_RECTANGLES; + Clip->ClipObj.rclBounds = *rcBounds; + Clip->RectCount = 1; + if (Clip->Rects != &Clip->ClipObj.rclBounds) + EngFreeMem(Clip->Rects); + Clip->Rects = &Clip->ClipObj.rclBounds; } - - return NULL; } /* @@ -259,7 +259,8 @@ EngCreateClip(VOID) CLIPGDI *Clip = EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPGDI), GDITAG_CLIPOBJ); if(Clip != NULL) { - return GDIToObj(Clip, CLIP); + Clip->Rects = &Clip->ClipObj.rclBounds; + return &Clip->ClipObj; } return NULL; @@ -273,7 +274,10 @@ APIENTRY EngDeleteClip( _In_ _Post_ptr_invalid_ CLIPOBJ *pco) { - EngFreeMem(ObjToGDI(pco, CLIP)); + XCLIPOBJ* Clip = CONTAINING_RECORD(pco, XCLIPOBJ, ClipObj); + if (Clip->Rects != &Clip->ClipObj.rclBounds) + EngFreeMem(Clip->Rects); + EngFreeMem(Clip); } /* @@ -288,13 +292,13 @@ CLIPOBJ_cEnumStart( _In_ ULONG iDirection, _In_ ULONG cMaxRects) { - CLIPGDI *ClipGDI = ObjToGDI(pco, CLIP); + XCLIPOBJ* Clip = CONTAINING_RECORD(pco, XCLIPOBJ, ClipObj); SORTCOMP CompareFunc; - ClipGDI->EnumPos = 0; - ClipGDI->EnumMax = (cMaxRects > 0) ? cMaxRects : ClipGDI->EnumRects.c; + Clip->EnumPos = 0; + Clip->EnumMax = (cMaxRects > 0) ? cMaxRects : Clip->RectCount; - if (CD_ANY != iDirection && ClipGDI->EnumOrder != iDirection) + if (CD_ANY != iDirection && Clip->EnumOrder != iDirection) { switch (iDirection) { @@ -316,26 +320,26 @@ CLIPOBJ_cEnumStart( default: DPRINT1("Invalid iDirection %lu\n", iDirection); - iDirection = ClipGDI->EnumOrder; + iDirection = Clip->EnumOrder; CompareFunc = NULL; break; } if (NULL != CompareFunc) { - EngSort((PBYTE) ClipGDI->EnumRects.arcl, sizeof(RECTL), ClipGDI->EnumRects.c, CompareFunc); + EngSort((PBYTE) Clip->Rects, sizeof(RECTL), Clip->RectCount, CompareFunc); } - ClipGDI->EnumOrder = iDirection; + Clip->EnumOrder = iDirection; } /* Return the number of rectangles enumerated */ - if ((cMaxRects > 0) && (ClipGDI->EnumRects.c > cMaxRects)) + if ((cMaxRects > 0) && (Clip->RectCount > cMaxRects)) { return 0xFFFFFFFF; } - return ClipGDI->EnumRects.c; + return Clip->RectCount; } /* @@ -348,14 +352,14 @@ CLIPOBJ_bEnum( _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pulEnumRects) { - RECTL *dest, *src; - CLIPGDI *ClipGDI = ObjToGDI(pco, CLIP); - ULONG nCopy, i; + const RECTL* src; + XCLIPOBJ* Clip = CONTAINING_RECORD(pco, XCLIPOBJ, ClipObj); + ULONG nCopy; ENUMRECTS* pERects = (ENUMRECTS*)pulEnumRects; // Calculate how many rectangles we should copy - nCopy = min( ClipGDI->EnumMax - ClipGDI->EnumPos, - min( ClipGDI->EnumRects.c - ClipGDI->EnumPos, + nCopy = min( Clip->EnumMax - Clip->EnumPos, + min( Clip->RectCount - Clip->EnumPos, (cj - sizeof(ULONG)) / sizeof(RECTL))); if(nCopy == 0) @@ -364,17 +368,14 @@ CLIPOBJ_bEnum( } /* Copy rectangles */ - src = ClipGDI->EnumRects.arcl + ClipGDI->EnumPos; - for(i = 0, dest = pERects->arcl; i < nCopy; i++, dest++, src++) - { - *dest = *src; - } + src = &Clip->Rects[Clip->EnumPos]; + RtlCopyMemory(pERects->arcl, src, nCopy * sizeof(RECTL)); pERects->c = nCopy; - ClipGDI->EnumPos+=nCopy; + Clip->EnumPos+=nCopy; - return ClipGDI->EnumPos < ClipGDI->EnumRects.c; + return Clip->EnumPos < Clip->RectCount; } /* EOF */ diff --git a/reactos/win32ss/gdi/eng/engobjects.h b/reactos/win32ss/gdi/eng/engobjects.h index 12840a84a3d..a65772d4d60 100644 --- a/reactos/win32ss/gdi/eng/engobjects.h +++ b/reactos/win32ss/gdi/eng/engobjects.h @@ -68,11 +68,22 @@ typedef struct _XCLIPOBJ } */ typedef struct _CLIPGDI { - CLIPOBJ ClipObj; - ULONG EnumPos; - ULONG EnumOrder; - ULONG EnumMax; - ENUMRECTS EnumRects; + union + { + CLIPOBJ ClipObj; + WNDOBJ WndObj; + }; + /* WNDOBJ part */ + HWND Hwnd; + WNDOBJCHANGEPROC ChangeProc; + FLONG Flags; + int PixelFormat; + /* CLIPOBJ part */ + ULONG EnumPos; + ULONG EnumOrder; + ULONG EnumMax; + ULONG RectCount; + RECTL* Rects; } CLIPGDI, *PCLIPGDI; // HACK, until we use the original structure @@ -112,15 +123,6 @@ typedef struct _PATHGDI { PATHOBJ PathObj; } PATHGDI; -typedef struct _WNDGDI { - WNDOBJ WndObj; - HWND Hwnd; - CLIPOBJ *ClientClipObj; - WNDOBJCHANGEPROC ChangeProc; - FLONG Flags; - int PixelFormat; -} WNDGDI, *PWNDGDI; - typedef struct _XFORMGDI { ULONG Dummy; /* XFORMOBJ has no public members */ diff --git a/reactos/win32ss/gdi/eng/engwindow.c b/reactos/win32ss/gdi/eng/engwindow.c index c5b4d937814..34003ceff5a 100644 --- a/reactos/win32ss/gdi/eng/engwindow.c +++ b/reactos/win32ss/gdi/eng/engwindow.c @@ -21,15 +21,15 @@ IntEngWndCallChangeProc( IN WNDOBJ *pwo, IN FLONG flChanged) { - WNDGDI *WndObjInt = ObjToGDI(pwo, WND); + XCLIPOBJ* Clip = CONTAINING_RECORD(pwo, XCLIPOBJ, WndObj); - if (WndObjInt->ChangeProc == NULL) + if (Clip->ChangeProc == NULL) { return; } /* check flags of the WNDOBJ */ - flChanged &= WndObjInt->Flags; + flChanged &= Clip->Flags; if (flChanged == 0) { return; @@ -42,8 +42,8 @@ IntEngWndCallChangeProc( } TRACE("Calling WNDOBJCHANGEPROC (0x%p), Changed = 0x%x\n", - WndObjInt->ChangeProc, flChanged); - WndObjInt->ChangeProc(pwo, flChanged); + Clip->ChangeProc, flChanged); + Clip->ChangeProc(pwo, flChanged); } /* @@ -52,13 +52,11 @@ IntEngWndCallChangeProc( BOOLEAN FASTCALL IntEngWndUpdateClipObj( - WNDGDI *WndObjInt, + XCLIPOBJ* Clip, PWND Window) { HRGN hVisRgn; PROSRGNDATA visRgn; - CLIPOBJ *ClipObj = NULL; - CLIPOBJ *OldClipObj; TRACE("IntEngWndUpdateClipObj\n"); @@ -70,8 +68,7 @@ IntEngWndUpdateClipObj( { if (visRgn->rdh.nCount > 0) { - ClipObj = IntEngCreateClipRegion(visRgn->rdh.nCount, visRgn->Buffer, - &visRgn->rdh.rcBound); + IntEngUpdateClipRegion(Clip, visRgn->rdh.nCount, visRgn->Buffer, &visRgn->rdh.rcBound); TRACE("Created visible region with %lu rects\n", visRgn->rdh.nCount); TRACE(" BoundingRect: %d, %d %d, %d\n", visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top, @@ -95,28 +92,13 @@ IntEngWndUpdateClipObj( GreDeleteObject(hVisRgn); } else - { - WARN("VIS_ComputeVisibleRegion failed!\n"); - } - - if (ClipObj == NULL) { /* Fall back to client rect */ - ClipObj = IntEngCreateClipRegion(1, &Window->rcClient, - &Window->rcClient); - } - - if (ClipObj == NULL) - { - ERR("IntEngCreateClipRegion() failed!\n"); - return FALSE; + IntEngUpdateClipRegion(Clip, 1, &Window->rcClient, &Window->rcClient); } - RtlCopyMemory(&WndObjInt->WndObj.coClient, ClipObj, sizeof (CLIPOBJ)); - RtlCopyMemory(&WndObjInt->WndObj.rclClient, &Window->rcClient, sizeof (RECT)); - OldClipObj = InterlockedExchangePointer((PVOID*)&WndObjInt->ClientClipObj, ClipObj); - if (OldClipObj != NULL) - IntEngDeleteClipRegion(OldClipObj); + /* Update the WNDOBJ */ + Clip->WndObj.rclClient = Window->rcClient; return TRUE; } @@ -131,7 +113,7 @@ IntEngWindowChanged( _In_ FLONG flChanged) { PPROPERTY pprop; - WNDGDI *Current; + XCLIPOBJ *Current; HWND hWnd; ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL); @@ -142,7 +124,7 @@ IntEngWindowChanged( { return; } - Current = (WNDGDI *)pprop->Data; + Current = (XCLIPOBJ *)pprop->Data; if ( gcountPWO && Current && Current->Hwnd == hWnd && @@ -184,7 +166,7 @@ EngCreateWnd( FLONG fl, int iPixelFormat) { - WNDGDI *WndObjInt = NULL; + XCLIPOBJ *Clip = NULL; WNDOBJ *WndObjUser = NULL; PWND Window; BOOL calledFromUser; @@ -206,34 +188,34 @@ EngCreateWnd( } /* Create WNDOBJ */ - WndObjInt = EngAllocMem(0, sizeof (WNDGDI), GDITAG_WNDOBJ); - if (WndObjInt == NULL) + Clip = EngAllocMem(FL_ZERO_MEMORY, sizeof (XCLIPOBJ), GDITAG_WNDOBJ); + if (Clip == NULL) { ERR("Failed to allocate memory for a WND structure!\n"); RETURN( NULL); } + IntEngInitClipObj(Clip); /* Fill the clipobj */ - WndObjInt->ClientClipObj = NULL; - if (!IntEngWndUpdateClipObj(WndObjInt, Window)) + if (!IntEngWndUpdateClipObj(Clip, Window)) { - EngFreeMem(WndObjInt); + EngFreeMem(Clip); RETURN( NULL); } /* Fill user object */ - WndObjUser = GDIToObj(WndObjInt, WND); + WndObjUser = &Clip->WndObj; WndObjUser->psoOwner = pso; WndObjUser->pvConsumer = NULL; /* Fill internal object */ - WndObjInt->Hwnd = hWnd; - WndObjInt->ChangeProc = pfn; - WndObjInt->Flags = fl; - WndObjInt->PixelFormat = iPixelFormat; + Clip->Hwnd = hWnd; + Clip->ChangeProc = pfn; + Clip->Flags = fl; + Clip->PixelFormat = iPixelFormat; /* associate object with window */ - IntSetProp(Window, AtomWndObj, WndObjInt); + IntSetProp(Window, AtomWndObj, Clip); ++gcountPWO; TRACE("EngCreateWnd: SUCCESS!\n"); @@ -258,7 +240,7 @@ APIENTRY EngDeleteWnd( IN WNDOBJ *pwo) { - WNDGDI *WndObjInt = ObjToGDI(pwo, WND); + XCLIPOBJ* Clip = CONTAINING_RECORD(pwo, XCLIPOBJ, WndObj); PWND Window; BOOL calledFromUser; @@ -270,7 +252,7 @@ EngDeleteWnd( } /* Get window object */ - Window = UserGetWindowObject(WndObjInt->Hwnd); + Window = UserGetWindowObject(Clip->Hwnd); if (Window == NULL) { ERR("Couldnt get window object for WndObjInt->Hwnd!!!\n"); @@ -287,8 +269,8 @@ EngDeleteWnd( } /* Free resources */ - IntEngDeleteClipRegion(WndObjInt->ClientClipObj); - EngFreeMem(WndObjInt); + IntEngFreeClipResources(Clip); + EngFreeMem(Clip); } @@ -302,14 +284,8 @@ WNDOBJ_bEnum( IN ULONG cj, OUT ULONG *pul) { - WNDGDI *WndObjInt = ObjToGDI(pwo, WND); - BOOL Ret; - - TRACE("WNDOBJ_bEnum: pwo = 0x%p, cj = %lu, pul = 0x%p\n", pwo, cj, pul); - Ret = CLIPOBJ_bEnum(WndObjInt->ClientClipObj, cj, pul); - - TRACE("WNDOBJ_bEnum: Returning %s\n", Ret ? "True" : "False"); - return Ret; + /* Relay */ + return CLIPOBJ_bEnum(&pwo->coClient, cj, pul); } @@ -324,17 +300,9 @@ WNDOBJ_cEnumStart( IN ULONG iDirection, IN ULONG cLimit) { - WNDGDI *WndObjInt = ObjToGDI(pwo, WND); - ULONG Ret; - - TRACE("WNDOBJ_cEnumStart: pwo = 0x%p, iType = %lu, iDirection = %lu, cLimit = %lu\n", - pwo, iType, iDirection, cLimit); - - /* FIXME: Should we enumerate all rectangles or not? */ - Ret = CLIPOBJ_cEnumStart(WndObjInt->ClientClipObj, FALSE, iType, iDirection, cLimit); - - TRACE("WNDOBJ_cEnumStart: Returning 0x%lx\n", Ret); - return Ret; + /* Relay */ + // FIXME: Should we enumerate all rectangles or not? + return CLIPOBJ_cEnumStart(&pwo->coClient, FALSE, iType, iDirection, cLimit); } diff --git a/reactos/win32ss/gdi/eng/inteng.h b/reactos/win32ss/gdi/eng/inteng.h index a2e48e5f7a3..55b4fe2da05 100644 --- a/reactos/win32ss/gdi/eng/inteng.h +++ b/reactos/win32ss/gdi/eng/inteng.h @@ -114,13 +114,17 @@ IntEngPolyline(SURFOBJ *DestSurf, LONG dCount, MIX mix); -CLIPOBJ* FASTCALL -IntEngCreateClipRegion(ULONG count, - PRECTL pRect, - PRECTL rcBounds); +VOID FASTCALL +IntEngUpdateClipRegion(XCLIPOBJ* Clip, + ULONG count, + const RECTL* pRect, + const RECTL* rcBounds); + +VOID FASTCALL +IntEngInitClipObj(XCLIPOBJ *Clip); VOID FASTCALL -IntEngDeleteClipRegion(CLIPOBJ *ClipObj); +IntEngFreeClipResources(XCLIPOBJ *Clip); BOOL FASTCALL diff --git a/reactos/win32ss/gdi/eng/lineto.c b/reactos/win32ss/gdi/eng/lineto.c index 31b45c84dc5..c26ec9bbe62 100644 --- a/reactos/win32ss/gdi/eng/lineto.c +++ b/reactos/win32ss/gdi/eng/lineto.c @@ -366,11 +366,12 @@ EngLineTo( if (!Clip) { - Clip = pcoPriv = IntEngCreateClipRegion(0, 0, RectBounds); + Clip = pcoPriv = EngCreateClip(); if (!Clip) { return FALSE; } + IntEngUpdateClipRegion((XCLIPOBJ*)Clip, 0, 0, RectBounds); } x1 += Translate.x; @@ -487,7 +488,7 @@ EngLineTo( if (pcoPriv) { - IntEngDeleteClipRegion(pcoPriv); + EngDeleteClip(pcoPriv); } return IntEngLeave(&EnterLeave); diff --git a/reactos/win32ss/gdi/ntgdi/arc.c b/reactos/win32ss/gdi/ntgdi/arc.c index 5d65235fc45..7e329601ae5 100644 --- a/reactos/win32ss/gdi/ntgdi/arc.c +++ b/reactos/win32ss/gdi/ntgdi/arc.c @@ -8,7 +8,7 @@ */ #define PUTPIXEL(x,y,BrushInst) \ ret = ret && IntEngLineTo(&psurf->SurfObj, \ - dc->rosdc.CombinedClip, \ + &dc->co.ClipObj, \ &BrushInst.BrushObject, \ x, y, (x)+1, y, \ &RectBounds, \ @@ -16,7 +16,7 @@ #define PUTLINE(x1,y1,x2,y2,BrushInst) \ ret = ret && IntEngLineTo(&psurf->SurfObj, \ - dc->rosdc.CombinedClip, \ + &dc->co.ClipObj, \ &BrushInst.BrushObject, \ x1, y1, x2, y2, \ &RectBounds, \ diff --git a/reactos/win32ss/gdi/ntgdi/bitblt.c b/reactos/win32ss/gdi/ntgdi/bitblt.c index 7193d7723e0..ba86c99f072 100644 --- a/reactos/win32ss/gdi/ntgdi/bitblt.c +++ b/reactos/win32ss/gdi/ntgdi/bitblt.c @@ -131,7 +131,7 @@ NtGdiAlphaBlend( TRACE("Performing the alpha blend\n"); bResult = IntEngAlphaBlend(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, - DCDest->rosdc.CombinedClip, + &DCDest->co.ClipObj, &exlo.xlo, &DestRect, &SourceRect, @@ -290,7 +290,7 @@ NtGdiTransparentBlt( EXLATEOBJ_vInitXlateFromDCs(&exlo, DCSrc, DCDest); Ret = IntEngTransparentBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, - DCDest->rosdc.CombinedClip, &exlo.xlo, &rcDest, &rcSrc, + &DCDest->co.ClipObj, &exlo.xlo, &rcDest, &rcSrc, TransparentColor, 0); EXLATEOBJ_vCleanup(&exlo); @@ -487,7 +487,7 @@ NtGdiMaskBlt( Status = IntEngBitBlt(&BitmapDest->SurfObj, BitmapSrc ? &BitmapSrc->SurfObj : NULL, psurfMask ? &psurfMask->SurfObj : NULL, - DCDest->rosdc.CombinedClip, + &DCDest->co.ClipObj, XlateObj, &DestRect, &SourcePoint, @@ -697,7 +697,7 @@ GreStretchBltMask( Status = IntEngStretchBlt(&BitmapDest->SurfObj, BitmapSrc ? &BitmapSrc->SurfObj : NULL, BitmapMask ? &BitmapMask->SurfObj : NULL, - DCDest->rosdc.CombinedClip, + &DCDest->co.ClipObj, XlateObj, &DCDest->dclevel.ca, &DestRect, @@ -834,7 +834,7 @@ IntPatBlt( &psurf->SurfObj, NULL, NULL, - pdc->rosdc.CombinedClip, + &pdc->co.ClipObj, NULL, &DestRect, NULL, diff --git a/reactos/win32ss/gdi/ntgdi/cliprgn.c b/reactos/win32ss/gdi/ntgdi/cliprgn.c index 42d5d29ae3b..67fa4dfa9dd 100644 --- a/reactos/win32ss/gdi/ntgdi/cliprgn.c +++ b/reactos/win32ss/gdi/ntgdi/cliprgn.c @@ -467,8 +467,6 @@ VOID FASTCALL CLIPPING_UpdateGCRegion(PDC pDC) { - CLIPOBJ * co; - /* Must have VisRgn set to a valid state! */ ASSERT (pDC->prgnVis); @@ -540,16 +538,10 @@ CLIPPING_UpdateGCRegion(PDC pDC) // With pDC->co.pClipRgn->Buffer, // pDC->co.pClipRgn = pDC->prgnRao ? pDC->prgnRao : pDC->prgnVis; - co = IntEngCreateClipRegion(pDC->prgnRao->rdh.nCount, - pDC->prgnRao->Buffer, - &pDC->erclClip); - if (co) - { - if (pDC->rosdc.CombinedClip != NULL) - IntEngDeleteClipRegion(pDC->rosdc.CombinedClip); - - pDC->rosdc.CombinedClip = co; - } + IntEngUpdateClipRegion(&pDC->co, + pDC->prgnRao->rdh.nCount, + pDC->prgnRao->Buffer, + &pDC->erclClip); IntGdiOffsetRgn(pDC->prgnRao, -pDC->ptlDCOrig.x, -pDC->ptlDCOrig.y); } diff --git a/reactos/win32ss/gdi/ntgdi/dc.h b/reactos/win32ss/gdi/ntgdi/dc.h index fbb76775cfe..bced3bf0640 100644 --- a/reactos/win32ss/gdi/ntgdi/dc.h +++ b/reactos/win32ss/gdi/ntgdi/dc.h @@ -46,11 +46,6 @@ typedef enum _DCTYPE /* Type definitions ***********************************************************/ -typedef struct _ROS_DC_INFO -{ - CLIPOBJ *CombinedClip; -} ROS_DC_INFO; - typedef struct _DCLEVEL { HPALETTE hpal; @@ -136,9 +131,6 @@ typedef struct _DC ULONG ulCopyCount; PVOID pSurfInfo; POINTL ptlDoBanding; - - /* Reactos specific members */ - ROS_DC_INFO rosdc; } DC; extern PDC defaultDCstate; diff --git a/reactos/win32ss/gdi/ntgdi/dclife.c b/reactos/win32ss/gdi/ntgdi/dclife.c index e9aa7b0bca8..67ce491a2ab 100644 --- a/reactos/win32ss/gdi/ntgdi/dclife.c +++ b/reactos/win32ss/gdi/ntgdi/dclife.c @@ -232,6 +232,9 @@ DC_vInitDc( pdc->prgnVis = IntSysCreateRectpRgn(0, 0, pdc->dclevel.sizl.cx, pdc->dclevel.sizl.cy); ASSERT(pdc->prgnVis); + /* Initialize Clip object */ + IntEngInitClipObj(&pdc->co); + /* Setup palette */ pdc->dclevel.hpal = StockObjects[DEFAULT_PALETTE]; pdc->dclevel.ppal = PALETTE_ShareLockPalette(pdc->dclevel.hpal); @@ -373,8 +376,9 @@ DC_vCleanup(PVOID ObjectBody) REGION_Delete(pdc->prgnRao); if (pdc->prgnAPI) REGION_Delete(pdc->prgnAPI); - if (pdc->rosdc.CombinedClip) - IntEngDeleteClipRegion(pdc->rosdc.CombinedClip); + + /* Free CLIPOBJ resources */ + IntEngFreeClipResources(&pdc->co); PATH_Delete(pdc->dclevel.hPath); diff --git a/reactos/win32ss/gdi/ntgdi/dibobj.c b/reactos/win32ss/gdi/ntgdi/dibobj.c index 65fbdd9dc9f..e391290ffe0 100644 --- a/reactos/win32ss/gdi/ntgdi/dibobj.c +++ b/reactos/win32ss/gdi/ntgdi/dibobj.c @@ -530,7 +530,7 @@ NtGdiSetDIBitsToDeviceInternal( Status = IntEngBitBlt(pDestSurf, pSourceSurf, NULL, - pDC->rosdc.CombinedClip, + &pDC->co.ClipObj, &exlo.xlo, &rcDest, &ptSource, @@ -1200,7 +1200,7 @@ NtGdiStretchDIBitsInternal( bResult = IntEngStretchBlt(&psurfDst->SurfObj, &psurfTmp->SurfObj, NULL, - pdc->rosdc.CombinedClip, + &pdc->co.ClipObj, &exlo.xlo, &pdc->dclevel.ca, &rcDst, diff --git a/reactos/win32ss/gdi/ntgdi/drawing.c b/reactos/win32ss/gdi/ntgdi/drawing.c index 0d28de08a22..76b0a722f73 100644 --- a/reactos/win32ss/gdi/ntgdi/drawing.c +++ b/reactos/win32ss/gdi/ntgdi/drawing.c @@ -1295,7 +1295,7 @@ IntFillRect( DC *dc, &psurf->SurfObj, NULL, NULL, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, NULL, &DestRect, NULL, diff --git a/reactos/win32ss/gdi/ntgdi/fillshap.c b/reactos/win32ss/gdi/ntgdi/fillshap.c index 1c3f374ac82..a5dd2e3bb9a 100644 --- a/reactos/win32ss/gdi/ntgdi/fillshap.c +++ b/reactos/win32ss/gdi/ntgdi/fillshap.c @@ -112,7 +112,7 @@ IntGdiPolygon(PDC dc, // Points[1].x, Points[1].y ); ret = IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, Points[i].x, /* From */ Points[i].y, @@ -126,7 +126,7 @@ IntGdiPolygon(PDC dc, if (ret) { ret = IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, Points[Count-1].x, /* From */ Points[Count-1].y, @@ -599,7 +599,7 @@ IntRectangle(PDC dc, ret = IntEngBitBlt(&psurf->SurfObj, NULL, NULL, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, NULL, &DestRect, NULL, @@ -618,28 +618,28 @@ IntRectangle(PDC dc, { Mix = ROP2_TO_MIX(pdcattr->jROP2); ret = ret && IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, DestRect.left, DestRect.top, DestRect.right, DestRect.top, &DestRect, // Bounding rectangle Mix); ret = ret && IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, DestRect.right, DestRect.top, DestRect.right, DestRect.bottom, &DestRect, // Bounding rectangle Mix); ret = ret && IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, DestRect.right, DestRect.bottom, DestRect.left, DestRect.bottom, &DestRect, // Bounding rectangle Mix); ret = ret && IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, DestRect.left, DestRect.bottom, DestRect.left, DestRect.top, &DestRect, // Bounding rectangle @@ -963,10 +963,8 @@ GreGradientFill( DC_vPrepareDCsForBlit(pdc, &rclExtent, NULL, NULL); - ASSERT(pdc->rosdc.CombinedClip); - bRet = IntEngGradientFill(&psurf->SurfObj, - pdc->rosdc.CombinedClip, + &pdc->co.ClipObj, &exlo.xlo, pVertex, nVertex, diff --git a/reactos/win32ss/gdi/ntgdi/freetype.c b/reactos/win32ss/gdi/ntgdi/freetype.c index 560d12e58ab..aa2d36fac5a 100644 --- a/reactos/win32ss/gdi/ntgdi/freetype.c +++ b/reactos/win32ss/gdi/ntgdi/freetype.c @@ -3317,7 +3317,7 @@ GreExtTextOutW( &dc->dclevel.pSurface->SurfObj, NULL, NULL, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, NULL, &DestRect, &SourcePoint, @@ -3577,7 +3577,7 @@ GreExtTextOutW( &psurf->SurfObj, NULL, NULL, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, NULL, &DestRect, &SourcePoint, @@ -3650,7 +3650,7 @@ GreExtTextOutW( IntEngMaskBlt( SurfObj, SourceGlyphSurf, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &exloRGB2Dst.xlo, &exloDst2RGB.xlo, &DestRect, diff --git a/reactos/win32ss/gdi/ntgdi/line.c b/reactos/win32ss/gdi/ntgdi/line.c index 93c89be562c..2a5d541b6c3 100644 --- a/reactos/win32ss/gdi/ntgdi/line.c +++ b/reactos/win32ss/gdi/ntgdi/line.c @@ -149,7 +149,7 @@ IntGdiLineTo(DC *dc, if (!(pbrLine->flAttrs & BR_IS_NULL)) { Ret = IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, Points[0].x, Points[0].y, Points[1].x, Points[1].y, @@ -285,7 +285,7 @@ IntGdiPolyline(DC *dc, } Ret = IntEngPolyline(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, &dc->eboLine.BrushObject, Points, Count, diff --git a/reactos/win32ss/gdi/ntgdi/polyfill.c b/reactos/win32ss/gdi/ntgdi/polyfill.c index f8c8aed8bab..5e19d8be69c 100644 --- a/reactos/win32ss/gdi/ntgdi/polyfill.c +++ b/reactos/win32ss/gdi/ntgdi/polyfill.c @@ -408,7 +408,7 @@ POLYGONFILL_FillScanLineAlternate( //DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine); IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, BrushObj, x1, ScanLine, @@ -481,7 +481,7 @@ POLYGONFILL_FillScanLineWinding( //DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine); IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, BrushObj, x1, ScanLine, @@ -504,7 +504,7 @@ POLYGONFILL_FillScanLineWinding( //DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine); IntEngLineTo(&psurf->SurfObj, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, BrushObj, x1, ScanLine, @@ -627,7 +627,7 @@ IntFillPolygon( IntEngBitBlt(&psurf->SurfObj, NULL, NULL, - dc->rosdc.CombinedClip, + &dc->co.ClipObj, NULL, &LineRect, NULL, diff --git a/reactos/win32ss/gdi/ntgdi/region.c b/reactos/win32ss/gdi/ntgdi/region.c index 08a0cdd0c45..dcea7d3dbea 100644 --- a/reactos/win32ss/gdi/ntgdi/region.c +++ b/reactos/win32ss/gdi/ntgdi/region.c @@ -2484,7 +2484,7 @@ IntGdiPaintRgn( { HRGN tmpVisRgn; PROSRGNDATA visrgn; - CLIPOBJ* ClipRegion; + XCLIPOBJ ClipRegion; BOOL bRet = FALSE; POINTL BrushOrigin; SURFACE *psurf; @@ -2515,10 +2515,8 @@ IntGdiPaintRgn( if (dc->prgnRao) IntGdiCombineRgn(visrgn, visrgn, dc->prgnRao, RGN_AND); - ClipRegion = IntEngCreateClipRegion(visrgn->rdh.nCount, - visrgn->Buffer, - &visrgn->rdh.rcBound ); - ASSERT(ClipRegion); + IntEngInitClipObj(&ClipRegion); + IntEngUpdateClipRegion(&ClipRegion, visrgn->rdh.nCount, visrgn->Buffer, &visrgn->rdh.rcBound ); BrushOrigin.x = pdcattr->ptlBrushOrigin.x; BrushOrigin.y = pdcattr->ptlBrushOrigin.y; @@ -2526,13 +2524,14 @@ IntGdiPaintRgn( /* FIXME: Handle psurf == NULL !!!! */ bRet = IntEngPaint(&psurf->SurfObj, - ClipRegion, + &ClipRegion.ClipObj, &dc->eboFill.BrushObject, &BrushOrigin, 0xFFFF); // FIXME: Don't know what to put here RGNOBJAPI_Unlock(visrgn); GreDeleteObject(tmpVisRgn); + IntEngFreeClipResources(&ClipRegion); // Fill the region return bRet; diff --git a/reactos/win32ss/gdi/ntgdi/wingl.c b/reactos/win32ss/gdi/ntgdi/wingl.c index 18023431702..7225b5d71c2 100644 --- a/reactos/win32ss/gdi/ntgdi/wingl.c +++ b/reactos/win32ss/gdi/ntgdi/wingl.c @@ -121,6 +121,8 @@ NtGdiSetPixelFormat( SURFOBJ *pso = NULL; BOOL Ret = FALSE; + DPRINT1("Setting pixel format from win32k!\n"); + pdc = DC_LockDc(hdc); if (!pdc) { diff --git a/reactos/win32ss/user/ntuser/cursoricon.c b/reactos/win32ss/user/ntuser/cursoricon.c index e730c585b38..0476291e8fa 100644 --- a/reactos/win32ss/user/ntuser/cursoricon.c +++ b/reactos/win32ss/user/ntuser/cursoricon.c @@ -1290,7 +1290,7 @@ UserDrawIconEx( DC_vPrepareDCsForBlit(pdc, &rcDest, NULL, NULL); /* Get the clip object */ - pdcClipObj = pdc->rosdc.CombinedClip; + pdcClipObj = &pdc->co.ClipObj; /* We now have our destination surface and rectangle */ psurfDest = pdc->dclevel.pSurface; @@ -1475,7 +1475,7 @@ done: DC_vPrepareDCsForBlit(pdc, &rcDest, NULL, NULL); /* Get the clip object */ - pdcClipObj = pdc->rosdc.CombinedClip; + pdcClipObj = &pdc->co.ClipObj; /* We now have our destination surface and rectangle */ psurfDest = pdc->dclevel.pSurface; diff --git a/reactos/win32ss/user/ntuser/windc.c b/reactos/win32ss/user/ntuser/windc.c index 492e09e66a4..5ff495c9950 100644 --- a/reactos/win32ss/user/ntuser/windc.c +++ b/reactos/win32ss/user/ntuser/windc.c @@ -1015,22 +1015,22 @@ UserGetWindowDC(PWND Wnd) HWND FASTCALL UserGethWnd( HDC hdc, PWNDOBJ *pwndo) { - PWNDGDI pWndgdi; + XCLIPOBJ* Clip; PWND Wnd; HWND hWnd; PPROPERTY pprop; hWnd = IntWindowFromDC(hdc); - if (hWnd && !(Wnd = UserGetWindowObject(hWnd))) + if (hWnd && (Wnd = UserGetWindowObject(hWnd))) { pprop = IntGetProp(Wnd, AtomWndObj); - pWndgdi = (WNDGDI *)pprop->Data; + Clip = (XCLIPOBJ*)pprop->Data; - if ( pWndgdi && pWndgdi->Hwnd == hWnd ) + if ( Clip && Clip->Hwnd == hWnd ) { - if (pwndo) *pwndo = (PWNDOBJ)pWndgdi; + if (pwndo) *pwndo = &Clip->WndObj; } } return hWnd;