Author: fireball Date: Sun Aug 2 12:32:57 2009 New Revision: 42333
URL: http://svn.reactos.org/svn/reactos?rev=42333&view=rev Log: - Handle case when RosGdiSetDeviceClipping is being called without rects at all (with a respective DPRINT1). - Use combined clipping object everywhere to ensure drawing happens only in allowed rectangle, see arwinss nr. 15. As a side effect, it fixes FireFox and other apps which would corrupt memory if trying to blit to area outside of DC. - Enable commented out XLATE object creation in GreStretchBltMask. Start menu icons now get masked properly too, but still are black.
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c branches/arwinss/reactos/subsystems/win32/win32k/gre/lineto.c branches/arwinss/reactos/subsystems/win32/win32k/gre/polyfill.c branches/arwinss/reactos/subsystems/win32/win32k/gre/rect.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Sun Aug 2 12:32:57 2009 @@ -373,14 +373,17 @@ /* Capture the rects buffer */ _SEH2_TRY { - ProbeForRead(pRects, count * sizeof(RECTL), 1); - - /* Use pool allocated buffer if data doesn't fit */ - if (count > sizeof(*pStackBuf) / sizeof(RECTL)) - pSafeRects = ExAllocatePool(PagedPool, sizeof(RECTL) * count); - - /* Copy points data */ - RtlCopyMemory(pSafeRects, pRects, count * sizeof(RECTL)); + if (count > 0) + { + ProbeForRead(pRects, count * sizeof(RECTL), 1); + + /* Use pool allocated buffer if data doesn't fit */ + if (count > sizeof(*pStackBuf) / sizeof(RECTL)) + pSafeRects = ExAllocatePool(PagedPool, sizeof(RECTL) * count); + + /* Copy points data */ + RtlCopyMemory(pSafeRects, pRects, count * sizeof(RECTL)); + }
/* Copy bounding rect */ ProbeForRead(rcBounds, sizeof(RECTL), 1); @@ -421,8 +424,25 @@ if (pDC->CombinedClip) IntEngDeleteClipRegion(pDC->CombinedClip);
- /* Set the clipping object */ - pDC->CombinedClip = IntEngCreateClipRegion(count, pSafeRects, &rcSafeBounds); + if (count == 0) + { + /* Special case, set it to full screen then */ + RECTL_vSetRect(&rcSafeBounds, + pDC->rcVport.left, + pDC->rcVport.top, + pDC->rcVport.right, + pDC->rcVport.bottom); + + /* Set the clipping object */ + pDC->CombinedClip = IntEngCreateClipRegion(1, &rcSafeBounds, &rcSafeBounds); + + DPRINT1("FIXME: Setting device clipping to NULL region, using full screen instead\n"); + } + else + { + /* Set the clipping object */ + pDC->CombinedClip = IntEngCreateClipRegion(count, pSafeRects, &rcSafeBounds); + }
DPRINT("RosGdiSetDeviceClipping() for DC %x, bounding rect (%d,%d)-(%d, %d)\n", physDev, rcSafeBounds.left, rcSafeBounds.top, rcSafeBounds.right, rcSafeBounds.bottom);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c [iso-8859-1] Sun Aug 2 12:32:57 2009 @@ -71,7 +71,6 @@ BOOL APIENTRY RosGdiLineTo( HDC physDev, INT x1, INT y1, INT x2, INT y2 ) { PDC pDC; - CLIPOBJ *pClipObj; RECTL scrRect; POINT pt[2];
@@ -80,12 +79,7 @@ /* Get a pointer to the DC */ pDC = DC_Lock(physDev);
- scrRect.left = scrRect.top = 0; - scrRect.right = PrimarySurface.GDIInfo.ulHorzRes; - scrRect.bottom = PrimarySurface.GDIInfo.ulVertRes; - - pClipObj = IntEngCreateClipRegion(1, NULL, &scrRect); - + /* Set points */ pt[0].x = x1; pt[0].y = y1; pt[1].x = x2; pt[1].y = y2;
@@ -96,16 +90,13 @@ pt[1].y += pDC->rcVport.top + pDC->rcDcRect.top;
GreLineTo(&pDC->pBitmap->SurfObj, - pClipObj, - //pDC->CombinedClip, + pDC->CombinedClip, &(pDC->pLineBrush->BrushObj), pt[0].x, pt[0].y, pt[1].x, pt[1].y, &scrRect, 0);
- IntEngDeleteClipRegion(pClipObj); - /* Release the object */ DC_Unlock(pDC);
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] Sun Aug 2 12:32:57 2009 @@ -111,14 +111,12 @@ /* Is the source surface device managed? */ else if (psoSrc && psurfSrc->flHooks & HOOK_BITBLT) { - DPRINT1("psoSrc %p\n", psoSrc); pfnBitBlt = GDIDEVFUNCS(psoSrc).BitBlt; } else { pfnBitBlt = EngBitBlt; } - bResult = pfnBitBlt(psoTrg, psoSrc, psoMask, @@ -204,7 +202,7 @@ &pDest->pBitmap->SurfObj, pSrc ? &pSrc->pBitmap->SurfObj : NULL, NULL, - NULL,//dc->rosdc.CombinedClip, + pDest->CombinedClip, XlateObj, &DestRect, &SourcePoint, @@ -231,6 +229,8 @@ POINTL BrushOrigin = {0, 0}; BOOLEAN bRet = FALSE;
+ DPRINT("GrePatBlt %p %d %d %d %d %x %p\n", pDC, XLeft, YLeft, Width, Height, ROP, BrushObj); + if (!(BrushObj->flAttrs & GDIBRUSH_IS_NULL)) { if (Width > 0) @@ -267,7 +267,7 @@ &pDC->pBitmap->SurfObj, NULL, NULL, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, NULL, &DestRect, NULL, @@ -354,13 +354,13 @@ }
/* Create the XLATEOBJ. */ - XlateObj = NULL;/*IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc); + XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc); if (XlateObj == (XLATEOBJ*)-1) { SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); XlateObj = NULL; goto failed; - }*/ + } }
/* Offset the brush */ @@ -384,7 +384,7 @@ Status = EngpStretchBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, BitmapMask ? &BitmapMask->SurfObj : NULL, - NULL,//DCDest->CombinedClip, + DCDest->CombinedClip, XlateObj, &DestRect, &SourceRect,
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/lineto.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/lineto.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/lineto.c [iso-8859-1] Sun Aug 2 12:32:57 2009 @@ -124,7 +124,7 @@ for (i=0; i<count-1; i++) { bRet = GreLineTo(&pDC->pBitmap->SurfObj, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, &pDC->pLineBrush->BrushObj, ptPoints[i].x + pDC->rcDcRect.left + pDC->rcVport.left, ptPoints[i].y + pDC->rcDcRect.top + pDC->rcVport.top,
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/polyfill.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/polyfill.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/polyfill.c [iso-8859-1] Sun Aug 2 12:32:57 2009 @@ -431,7 +431,7 @@
//DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine); GreLineTo(&psurf->SurfObj, - NULL,//dc->rosdc.CombinedClip, + dc->CombinedClip, BrushObj, x1, ScanLine, @@ -503,7 +503,7 @@
//DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine); GreLineTo(&psurf->SurfObj, - NULL,//dc->rosdc.CombinedClip, + dc->CombinedClip, BrushObj, x1, ScanLine, @@ -526,7 +526,7 @@
//DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine); GreLineTo(&psurf->SurfObj, - NULL, //dc->rosdc.CombinedClip, + dc->CombinedClip, BrushObj, x1, ScanLine, @@ -649,7 +649,7 @@ GrepBitBltEx(psurf, NULL, NULL, - NULL,//dc->rosdc.CombinedClip, + dc->CombinedClip, NULL, &LineRect, NULL,
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/rect.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/rect.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/rect.c [iso-8859-1] Sun Aug 2 12:32:57 2009 @@ -45,7 +45,7 @@ bRet = GrepBitBltEx(&pDC->pBitmap->SurfObj, NULL, NULL, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, NULL, &DestRect, NULL, @@ -63,28 +63,28 @@ { Mix = ROP2_TO_MIX(R2_COPYPEN);/*pdcattr->jROP2*/ GreLineTo(&pDC->pBitmap->SurfObj, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, &pDC->pLineBrush->BrushObj, DestRect.left, DestRect.top, DestRect.right, DestRect.top, &DestRect, // Bounding rectangle Mix);
GreLineTo(&pDC->pBitmap->SurfObj, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, &pDC->pLineBrush->BrushObj, DestRect.right, DestRect.top, DestRect.right, DestRect.bottom, &DestRect, // Bounding rectangle Mix);
GreLineTo(&pDC->pBitmap->SurfObj, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, &pDC->pLineBrush->BrushObj, DestRect.right, DestRect.bottom, DestRect.left, DestRect.bottom, &DestRect, // Bounding rectangle Mix);
GreLineTo(&pDC->pBitmap->SurfObj, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, &pDC->pLineBrush->BrushObj, DestRect.left, DestRect.bottom, DestRect.left, DestRect.top, &DestRect, // Bounding rectangle @@ -135,7 +135,7 @@ for (i=0; i<count-1; i++) { bRet = GreLineTo(&pDC->pBitmap->SurfObj, - NULL,//dc->rosdc.CombinedClip, + pDC->CombinedClip, &pDC->pLineBrush->BrushObj, ptPoints[i].x, ptPoints[i].y,