From 85b693d42d030e38ef8846a8eb1708a18d829181 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 21 Apr 2012 21:00:08 +0000 Subject: [PATCH] [DIBLIB] Fix calculation of pattern pointer [WIN32K] Fix (almost) calculation of pattern origin. There's still a bugger left. svn path=/trunk/; revision=56388 --- reactos/win32ss/gdi/diblib/DibLib_BitBlt.h | 8 +++--- reactos/win32ss/gdi/eng/bitblt_new.c | 30 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/reactos/win32ss/gdi/diblib/DibLib_BitBlt.h b/reactos/win32ss/gdi/diblib/DibLib_BitBlt.h index ed5ab244d89..f56949813df 100644 --- a/reactos/win32ss/gdi/diblib/DibLib_BitBlt.h +++ b/reactos/win32ss/gdi/diblib/DibLib_BitBlt.h @@ -44,10 +44,7 @@ _DibFunction(PBLTDATA pBltData) #if __USES_PATTERN pjPatBase = pBltData->siPat.pjBase; pjPatBase += pBltData->siPat.ptOrig.y * pBltData->siPat.lDelta; - pjPattern = pjPatBase + pBltData->siPat.ptOrig.x * _DEST_BPP / 8; - _CALCSHIFT(_DEST_BPP, &jPatShift, pBltData->siPat.ptOrig.x); cPatLines = pBltData->ulPatHeight - pBltData->siPat.ptOrig.y; - cPatRows = pBltData->ulPatWidth - pBltData->siPat.ptOrig.x; #endif pjDestBase = pBltData->siDst.pjBase; #if __USES_SOURCE @@ -69,6 +66,11 @@ _DibFunction(PBLTDATA pBltData) pjMask = pjMaskBase; _CALCSHIFT_1(&jMskShift, pBltData->siMsk.ptOrig.x); #endif +#if __USES_PATTERN + pjPattern = pjPatBase + pBltData->siPat.ptOrig.x * _DEST_BPP / 8; + _CALCSHIFT(_DEST_BPP, &jPatShift, pBltData->siPat.ptOrig.x); + cPatRows = pBltData->ulPatWidth - pBltData->siPat.ptOrig.x; +#endif /* Loop all rows */ cRows = pBltData->ulWidth; diff --git a/reactos/win32ss/gdi/eng/bitblt_new.c b/reactos/win32ss/gdi/eng/bitblt_new.c index f2ae3cde4ad..9f4dc4024e0 100644 --- a/reactos/win32ss/gdi/eng/bitblt_new.c +++ b/reactos/win32ss/gdi/eng/bitblt_new.c @@ -72,10 +72,22 @@ CalculateCoordinates( { /* Calculate start point and bitpointer for pattern */ pbltdata->siPat.ptOrig.x = (pptlPat->x + cx) % psizlPat->cx; - pbltdata->siPat.ptOrig.y = (pptlPat->x + cy) % psizlPat->cy; + pbltdata->siPat.ptOrig.y = (pptlPat->y + cy) % psizlPat->cy; pbltdata->siPat.pjBase = pbltdata->siPat.pvScan0; - pbltdata->siPat.pjBase += pbltdata->siPat.ptOrig.y * pbltdata->siPat.lDelta; - pbltdata->siPat.pjBase += pbltdata->siPat.ptOrig.x * pbltdata->siPat.jBpp / 8; + + /* Check for bottom-up case */ + if (pbltdata->dy < 0) + { + pbltdata->siPat.pjBase += (psizlPat->cy - 1) * pbltdata->siPat.lDelta; + pbltdata->siPat.ptOrig.y = psizlPat->cy - 1 - pbltdata->siPat.ptOrig.y; + } + + /* Check for right-to-left case */ + if (pbltdata->siDst.iFormat == 0) + { + pbltdata->siPat.pjBase += (psizlPat->cx - 1) * pbltdata->siMsk.jBpp / 8; + pbltdata->siPat.ptOrig.x = psizlPat->cx - 1 - pbltdata->siPat.ptOrig.x; + } } } @@ -369,7 +381,7 @@ IntEngBitBlt( { BOOL bResult; RECTL rcClipped; - POINTL ptOffset, ptSrc, ptMask; + POINTL ptOffset, ptSrc, ptMask, ptBrush; SIZEL sizTrg; PFN_DrvBitBlt pfnBitBlt; @@ -461,6 +473,14 @@ IntEngBitBlt( ptMask.x += ptOffset.x; ptMask.y += ptOffset.y; + /* Check if we have a brush origin */ + if (pptlBrush) + { + /* calculate the new brush origin */ + ptBrush.x = pptlBrush->x + ptOffset.x; + ptBrush.y = pptlBrush->y + ptOffset.y; + } + /* Recalculate the target rect */ rcClipped.left = prclTrg->left + ptOffset.x; rcClipped.top = prclTrg->top + ptOffset.y; @@ -499,7 +519,7 @@ IntEngBitBlt( psoSrc ? &ptSrc : NULL, psoMask ? &ptMask : NULL, pbo, - pptlBrush, + pptlBrush ? &ptBrush : NULL, rop4); // FIXME: cleanup temp surface!