[Win32SS]

- Implement DC Bounds support. It's close to what wine does and passes thousands of tests. Still WIP. See CORE-11582.

svn path=/trunk/; revision=73476
This commit is contained in:
James Tabor 2016-12-22 17:34:58 +00:00
parent 527c11cf4d
commit bb5564609a
11 changed files with 276 additions and 23 deletions

View file

@ -800,7 +800,7 @@ GetBoundsRect(
UINT flags
)
{
return NtGdiGetBoundsRect(hdc,lprcBounds,flags & DCB_RESET);
return NtGdiGetBoundsRect(hdc,lprcBounds,flags & ~DCB_WINDOWMGR);
}
@ -814,7 +814,7 @@ SetBoundsRect(HDC hdc,
UINT flags)
{
/* FIXME add check for validate the flags */
return NtGdiSetBoundsRect(hdc, (LPRECT)prc, flags);
return NtGdiSetBoundsRect(hdc, (LPRECT)prc, flags & ~DCB_WINDOWMGR);
}

View file

@ -78,6 +78,11 @@ NtGdiAlphaBlend(
DestRect.right += DCDest->ptlDCOrig.x;
DestRect.bottom += DCDest->ptlDCOrig.y;
if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(DCDest, &DestRect);
}
SourceRect.left = XOriginSrc;
SourceRect.top = YOriginSrc;
SourceRect.right = XOriginSrc + WidthSrc;
@ -262,6 +267,11 @@ NtGdiTransparentBlt(
rcSrc.right += DCSrc->ptlDCOrig.x;
rcSrc.bottom += DCSrc->ptlDCOrig.y;
if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(DCDest, &rcDest);
}
/* Prepare for blit */
DC_vPrepareDCsForBlit(DCDest, &rcDest, DCSrc, &rcSrc);
@ -420,6 +430,11 @@ NtGdiMaskBlt(
DestRect.right += DCDest->ptlDCOrig.x;
DestRect.bottom += DCDest->ptlDCOrig.y;
if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(DCDest, &DestRect);
}
SourcePoint.x = nXSrc;
SourcePoint.y = nYSrc;
@ -619,6 +634,11 @@ GreStretchBltMask(
DestRect.right += DCDest->ptlDCOrig.x;
DestRect.bottom += DCDest->ptlDCOrig.y;
if (DCDest->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(DCDest, &DestRect);
}
SourceRect.left = XOriginSrc;
SourceRect.top = YOriginSrc;
SourceRect.right = XOriginSrc+WidthSrc;
@ -807,6 +827,12 @@ IntPatBlt(
DestRect.top += pdc->ptlDCOrig.y;
DestRect.right += pdc->ptlDCOrig.x;
DestRect.bottom += pdc->ptlDCOrig.y;
if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(pdc, &DestRect);
}
#ifdef _USE_DIBLIB_
BrushOrigin.x = pbrush->ptOrigin.x + pdc->ptlDCOrig.x + XLeft;
BrushOrigin.y = pbrush->ptOrigin.y + pdc->ptlDCOrig.y + YLeft;
@ -1058,6 +1084,13 @@ IntGdiBitBltRgn(
return FALSE;
}
if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
RECTL rcrgn;
REGION_GetRgnBox(prgnClip, &rcrgn);
IntUpdateBoundsRect(pdc, &rcrgn);
}
/* Prepare the DC */
DC_vPrepareDCsForBlit(pdc, &prgnClip->rdh.rcBound, NULL, NULL);
@ -1137,6 +1170,13 @@ IntGdiFillRgn(
return FALSE;
}
if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
RECTL rcrgn;
REGION_GetRgnBox(prgnClip, &rcrgn);
IntUpdateBoundsRect(pdc, &rcrgn);
}
IntEngInitClipObj(&xcoClip);
IntEngUpdateClipRegion(&xcoClip,
prgnClip->rdh.nCount,
@ -1351,6 +1391,22 @@ NtGdiSetPixel(
return -1;
}
if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
RECTL rcDst;
RECTL_vSetRect(&rcDst, x, y, x+1, y+1);
IntLPtoDP(pdc, (LPPOINT)&rcDst, 2);
rcDst.left += pdc->ptlDCOrig.x;
rcDst.top += pdc->ptlDCOrig.y;
rcDst.right += pdc->ptlDCOrig.x;
rcDst.bottom += pdc->ptlDCOrig.y;
IntUpdateBoundsRect(pdc, &rcDst);
}
/* Translate the color to the target format */
iSolidColor = TranslateCOLORREF(pdc, crColor);

View file

@ -4,10 +4,16 @@
#define MIN_COORD (INT_MIN / 16)
#define MAX_COORD (INT_MAX / 16)
#define IntLPtoDP(pdc, ppt, count) DC_vXformWorldToDevice(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define CoordLPtoDP(pdc, ppt) DC_vXformWorldToDevice(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define IntDPtoLP(pdc, ppt, count) DC_vXformDeviceToWorld(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define CoordDPtoLP(pdc, ppt) DC_vXformDeviceToWorld(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define IntLPtoDP(pdc, ppt, count) \
DC_vUpdateWorldToDevice(pdc); \
DC_vXformWorldToDevice(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define CoordLPtoDP(pdc, ppt) \
DC_vXformWorldToDevice(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define IntDPtoLP(pdc, ppt, count) \
DC_vUpdateDeviceToWorld(pdc); \
DC_vXformDeviceToWorld(pdc, count, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define CoordDPtoLP(pdc, ppt) \
DC_vXformDeviceToWorld(pdc, 1, (PPOINTL)(ppt), (PPOINTL)(ppt));
#define XForm2MatrixS(m, x) XFormToMatrix(m, (XFORML*)x)
#define MatrixS2XForm(x, m) MatrixToXForm((XFORML*)x, m)

View file

@ -3,9 +3,6 @@
/* Constants ******************************************************************/
/* Get/SetBounds/Rect support. */
#define DCB_WINDOWMGR 0x8000 /* Queries the Windows bounding rectangle instead of the application's */
/* flFontState */
enum _FONT_STATE
{
@ -207,6 +204,7 @@ VOID FASTCALL IntGdiUnreferencePdev(PPDEVOBJ pPDev, DWORD CleanUpType);
HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
BOOL FASTCALL IntGdiCleanDC(HDC hDC);
VOID FASTCALL IntvGetDeviceCaps(PPDEVOBJ, PDEVCAPS);
VOID FASTCALL IntUpdateBoundsRect(PDC,PRECTL);
BOOL NTAPI GreSetDCOwner(HDC hdc, ULONG ulOwner);
HDC APIENTRY GreCreateCompatibleDC(HDC hdc, BOOL bAltDc);

View file

@ -189,8 +189,8 @@ IntGdiSetTextColor(HDC hDC,
}
DC_vUpdateTextBrush(pdc);
// DC_vUpdateLineBrush(pdc);
// DC_vUpdateFillBrush(pdc);
DC_vUpdateLineBrush(pdc);
DC_vUpdateFillBrush(pdc);
DC_UnlockDc(pdc);
@ -652,6 +652,20 @@ NtGdiGetAndSetDCDword(
return Ret;
}
VOID
FASTCALL
IntUpdateBoundsRect(PDC pdc, PRECTL pRect)
{
if (pdc->fs & DC_ACCUM_APP)
{
RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, pRect);
}
if (pdc->fs & DC_ACCUM_WMGR)
{
RECTL_bUnionRect(&pdc->erclBounds, &pdc->erclBounds, pRect);
}
}
DWORD
APIENTRY
NtGdiGetBoundsRect(
@ -661,19 +675,49 @@ NtGdiGetBoundsRect(
{
DWORD ret;
PDC pdc;
RECT rc;
/* Lock the DC */
if (!(pdc = DC_LockDc(hdc))) return 0;
/* Get the return value */
ret = pdc->fs & DC_ACCUM_APP ? DCB_ENABLE : DCB_DISABLE;
ret |= RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? DCB_RESET : DCB_SET;
if (!(flags & DCB_WINDOWMGR))
{
rc = pdc->erclBoundsApp;
if (RECTL_bIsEmptyRect(&rc))
{
rc.left = rc.top = rc.right = rc.bottom = 0;
ret = DCB_RESET;
}
else
{
RECTL rcRgn;
if (pdc->fs & DC_FLAG_DIRTY_RAO) CLIPPING_UpdateGCRegion(pdc);
if(!REGION_GetRgnBox(pdc->prgnRao, &rcRgn))
{
REGION_GetRgnBox(pdc->prgnVis, &rcRgn);
}
rc.left = max( rc.left, 0 );
rc.top = max( rc.top, 0 );
rc.right = min( rc.right, rcRgn.right - rcRgn.left );
rc.bottom = min( rc.bottom, rcRgn.bottom - rcRgn.top );
DPRINT1("Rao dc %p r %d b %d\n",pdc,rcRgn.right - rcRgn.left, rcRgn.bottom - rcRgn.top);
DPRINT1("rc l %d t %d\n",rc.left,rc.top);
DPRINT1(" r %d b %d\n",rc.right,rc.bottom);
ret = DCB_SET;
}
IntDPtoLP( pdc, &rc, 2 );
DPRINT1("rc1 l %d t %d\n",rc.left,rc.top);
DPRINT1(" r %d b %d\n",rc.right,rc.bottom);
}
else
rc = pdc->erclBounds;
/* Copy the rect to the caller */
_SEH2_TRY
{
ProbeForWrite(prc, sizeof(RECT), 1);
*prc = pdc->erclBoundsApp;
*prc = rc;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@ -683,14 +727,22 @@ NtGdiGetBoundsRect(
if (flags & DCB_RESET)
{
RECTL_vSetEmptyRect(&pdc->erclBoundsApp);
if (!(flags & DCB_WINDOWMGR))
{
pdc->erclBoundsApp.left = pdc->erclBoundsApp.top = INT_MAX;
pdc->erclBoundsApp.right = pdc->erclBoundsApp.bottom = INT_MIN;
}
else
{
pdc->erclBounds.left = pdc->erclBounds.top = INT_MAX;
pdc->erclBounds.right = pdc->erclBounds.bottom = INT_MIN;
}
}
DC_UnlockDc(pdc);
return ret;
}
DWORD
APIENTRY
NtGdiSetBoundsRect(
@ -709,12 +761,23 @@ NtGdiSetBoundsRect(
if (!(pdc = DC_LockDc(hdc))) return 0;
/* Get the return value */
ret = pdc->fs & DC_ACCUM_APP ? DCB_ENABLE : DCB_DISABLE;
ret |= RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? DCB_RESET : DCB_SET;
ret = DCB_RESET; /* we don't have device-specific bounds */
ret = (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR) ? DCB_ENABLE : DCB_DISABLE) |
(RECTL_bIsEmptyRect(&pdc->erclBoundsApp) ? ret & DCB_SET : DCB_SET );
ret |= (flags & DCB_WINDOWMGR);
if (flags & DCB_RESET)
{
RECTL_vSetEmptyRect(&pdc->erclBoundsApp);
if (!(flags & DCB_WINDOWMGR))
{
pdc->erclBoundsApp.left = pdc->erclBoundsApp.top = INT_MAX;
pdc->erclBoundsApp.right = pdc->erclBoundsApp.bottom = INT_MIN;
}
else
{
pdc->erclBounds.left = pdc->erclBounds.top = INT_MAX;
pdc->erclBounds.right = pdc->erclBounds.bottom = INT_MIN;
}
}
if (flags & DCB_ACCUMULATE && prc != NULL)
@ -733,11 +796,30 @@ NtGdiSetBoundsRect(
_SEH2_END;
RECTL_vMakeWellOrdered(&rcl);
RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, &rcl);
if (!(flags & DCB_WINDOWMGR))
{
IntLPtoDP( pdc, (POINT *)&rcl, 2 );
RECTL_bUnionRect(&pdc->erclBoundsApp, &pdc->erclBoundsApp, &rcl);
}
else
RECTL_bUnionRect(&pdc->erclBounds, &pdc->erclBounds, &rcl);
}
if (flags & DCB_ENABLE) pdc->fs |= DC_ACCUM_APP;
if (flags & DCB_DISABLE) pdc->fs &= ~DC_ACCUM_APP;
if (flags & DCB_ENABLE)
{
if (!(flags & DCB_WINDOWMGR))
pdc->fs |= DC_ACCUM_APP;
else
pdc->fs |= DC_ACCUM_WMGR;
}
if (flags & DCB_DISABLE)
{
if (!(flags & DCB_WINDOWMGR))
pdc->fs &= ~DC_ACCUM_APP;
else
pdc->fs &= ~DC_ACCUM_WMGR;
}
DC_UnlockDc(pdc);
return ret;
}

View file

@ -559,6 +559,11 @@ NtGdiSetDIBitsToDeviceInternal(
rcDest.bottom = rcDest.top + Height;
rcDest.top += StartScan;
if (pDC->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(pDC, &rcDest);
}
ptSource.x = XSrc;
ptSource.y = YSrc;
@ -1256,6 +1261,11 @@ NtGdiStretchDIBitsInternal(
IntLPtoDP(pdc, (POINTL*)&rcDst, 2);
RECTL_vOffsetRect(&rcDst, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(pdc, &rcDst);
}
hbmTmp = GreCreateBitmapEx(pbmi->bmiHeader.biWidth,
abs(pbmi->bmiHeader.biHeight),
0,

View file

@ -580,6 +580,11 @@ IntRectangle(PDC dc,
DestRect.top += dc->ptlDCOrig.y;
DestRect.bottom += dc->ptlDCOrig.y;
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(dc, &DestRect);
}
/* In GM_COMPATIBLE, don't include bottom and right edges */
if (pdcattr->iGraphicsMode == GM_COMPATIBLE)
{
@ -979,6 +984,11 @@ GreGradientFill(
ptlDitherOrg.x += pdc->ptlDCOrig.x;
ptlDitherOrg.y += pdc->ptlDCOrig.y;
if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(pdc, &rclExtent);
}
DC_vPrepareDCsForBlit(pdc, &rclExtent, NULL, NULL);
psurf = pdc->dclevel.pSurface;
@ -1146,6 +1156,11 @@ NtGdiExtFloodFill(
RECTL_vSetRect(&DestRect, 0, 0, psurf->SurfObj.sizlBitmap.cx, psurf->SurfObj.sizlBitmap.cy);
}
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(dc, &DestRect);
}
EXLATEOBJ_vInitialize(&exlo, &gpalRGB, psurf->ppal, 0, 0xffffff, 0);
/* Only solid fills supported for now

View file

@ -3446,6 +3446,11 @@ GreExtTextOutW(
DestRect.right += dc->ptlDCOrig.x;
DestRect.bottom += dc->ptlDCOrig.y;
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(dc, &DestRect);
}
DC_vPrepareDCsForBlit(dc, &DestRect, NULL, NULL);
if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
@ -3722,6 +3727,10 @@ GreExtTextOutW(
DestRect.top = TextTop + yoff - ((fixAscender + 32) >> 6);
DestRect.bottom = TextTop + yoff + ((32 - fixDescender) >> 6);
MouseSafetyOnDrawStart(dc->ppdev, DestRect.left, DestRect.top, DestRect.right, DestRect.bottom);
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
IntUpdateBoundsRect(dc, &DestRect);
}
IntEngBitBlt(
&psurf->SurfObj,
NULL,

View file

@ -13,6 +13,67 @@
// Some code from the WINE project source (www.winehq.com)
VOID FASTCALL
AddPenLinesBounds(PDC dc, int count, POINT *points)
{
DWORD join, endcap;
RECTL bounds, rect;
LONG lWidth;
PBRUSH pbrLine;
/* Get BRUSH from current pen. */
pbrLine = dc->dclevel.pbrLine;
ASSERT(pbrLine);
lWidth = pbrLine->lWidth;
// Setup bounds
bounds.left = bounds.top = INT_MAX;
bounds.right = bounds.bottom = INT_MIN;
if (((pbrLine->ulPenStyle & PS_TYPE_MASK) & PS_GEOMETRIC) || lWidth > 1)
{
/* Windows uses some heuristics to estimate the distance from the point that will be painted */
lWidth = lWidth + 2;
endcap = (PS_ENDCAP_MASK & pbrLine->ulPenStyle);
join = (PS_JOIN_MASK & pbrLine->ulPenStyle);
if (join == PS_JOIN_MITER)
{
lWidth *= 5;
if (endcap == PS_ENDCAP_SQUARE) lWidth = (lWidth * 3 + 1) / 2;
}
else
{
if (endcap == PS_ENDCAP_SQUARE) lWidth -= lWidth / 4;
else lWidth = (lWidth + 1) / 2;
}
}
while (count-- > 0)
{
rect.left = points->x - lWidth;
rect.top = points->y - lWidth;
rect.right = points->x + lWidth + 1;
rect.bottom = points->y + lWidth + 1;
RECTL_bUnionRect(&bounds, &bounds, &rect);
points++;
}
DPRINT1("APLB dc %p l %d t %d\n",dc,rect.left,rect.top);
DPRINT1(" r %d b %d\n",rect.right,rect.bottom);
{
RECTL rcRgn;
if (dc->fs & DC_FLAG_DIRTY_RAO) CLIPPING_UpdateGCRegion(dc);
if (REGION_GetRgnBox(dc->prgnRao, &rcRgn))
{
if (RECTL_bIntersectRect( &rcRgn, &rcRgn, &bounds )) IntUpdateBoundsRect(dc, &rcRgn);
}
else
IntUpdateBoundsRect(dc, &bounds);
}
}
// Should use Fx in Point
//
BOOL FASTCALL
@ -131,6 +192,13 @@ IntGdiLineTo(DC *dc,
pbrLine = dc->dclevel.pbrLine;
ASSERT(pbrLine);
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
DPRINT1("Bounds dc %p l %d t %d\n",dc,Bounds.left,Bounds.top);
DPRINT1(" r %d b %d\n",Bounds.right,Bounds.bottom);
AddPenLinesBounds(dc, 2, Points);
}
if (!(pbrLine->flAttrs & BR_IS_NULL))
{
Ret = IntEngLineTo(&psurf->SurfObj,
@ -260,6 +328,11 @@ IntGdiPolyline(DC *dc,
Points[i].y += dc->ptlDCOrig.y;
}
if (dc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
{
AddPenLinesBounds(dc, Count, Points);
}
Ret = IntEngPolyline(&psurf->SurfObj,
&dc->co.ClipObj,
&dc->eboLine.BrushObject,

View file

@ -27,3 +27,5 @@ PEN_GetObject(
_In_ PPEN pPen,
_In_ INT Count,
_Out_ PLOGPEN Buffer);
VOID FASTCALL AddPenLinesBounds(PDC,int,POINT *);

View file

@ -231,6 +231,8 @@ typedef DWORD LFTYPE;
/* New color use parameter. See support.microsoft.com/kb/kbview/108497 */
#define DIB_PAL_INDICES 2
/* Get/SetBounds/Rect support. */
#define DCB_WINDOWMGR 0x8000 /* Queries the Windows bounding rectangle instead of the application's */
/* TYPES *********************************************************************/