Modify EBRUSHOBJ_pvGetEngBrush to return a pointer to the SURFOBJ, instead of a handle, this simplifies the code

svn path=/trunk/; revision=56220
This commit is contained in:
Timo Kreuzer 2012-03-24 17:19:34 +00:00
parent 4ffc097ef2
commit a0dbbba584
5 changed files with 52 additions and 64 deletions

View file

@ -39,16 +39,13 @@ BltMask(SURFOBJ* psoDest,
BYTE *pjMskLine, *pjMskCurrent; BYTE *pjMskLine, *pjMskCurrent;
BYTE fjMaskBit0, fjMaskBit; BYTE fjMaskBit0, fjMaskBit;
/* Pattern brushes */ /* Pattern brushes */
PEBRUSHOBJ pebo = NULL; SURFOBJ *psoPattern;
SURFOBJ *psoPattern = NULL;
PSURFACE psurfPattern;
ULONG PatternWidth = 0, PatternHeight = 0; ULONG PatternWidth = 0, PatternHeight = 0;
LONG PatternX0 = 0, PatternX = 0, PatternY = 0; LONG PatternX0 = 0, PatternX = 0, PatternY = 0;
LONG SrcX = 0, SrcY = 0; LONG SrcX = 0, SrcY = 0;
PFN_DIB_PutPixel fnDest_PutPixel = NULL; PFN_DIB_PutPixel fnDest_PutPixel = NULL;
PFN_DIB_GetPixel fnPattern_GetPixel = NULL, fnSrc_GetPixel = NULL, fnDest_GetPixel; PFN_DIB_GetPixel fnPattern_GetPixel = NULL, fnSrc_GetPixel = NULL, fnDest_GetPixel;
ULONG Pattern = 0, Source = 0, Dest = 0; ULONG Pattern = 0, Source = 0, Dest = 0;
HBITMAP hbmPattern;
DWORD fgndRop, bkgndRop; DWORD fgndRop, bkgndRop;
ASSERT(IS_VALID_ROP4(Rop4)); ASSERT(IS_VALID_ROP4(Rop4));
@ -61,20 +58,16 @@ BltMask(SURFOBJ* psoDest,
/* Determine pattern */ /* Determine pattern */
if (pbo && pbo->iSolidColor == 0xFFFFFFFF) if (pbo && pbo->iSolidColor == 0xFFFFFFFF)
{ {
pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); psoPattern = BRUSHOBJ_psoPattern(pbo);
if (psoPattern)
hbmPattern = EBRUSHOBJ_pvGetEngBrush(pebo);
psurfPattern = SURFACE_ShareLockSurface(hbmPattern);
if (psurfPattern != NULL)
{ {
psoPattern = &psurfPattern->SurfObj;
PatternWidth = psoPattern->sizlBitmap.cx; PatternWidth = psoPattern->sizlBitmap.cx;
PatternHeight = psoPattern->sizlBitmap.cy; PatternHeight = psoPattern->sizlBitmap.cy;
fnPattern_GetPixel = DibFunctionsForBitmapFormat[psoPattern->iBitmapFormat].DIB_GetPixel; fnPattern_GetPixel = DibFunctionsForBitmapFormat[psoPattern->iBitmapFormat].DIB_GetPixel;
} }
} }
else else
psurfPattern = NULL; psoPattern = NULL;
pjMskLine = (PBYTE)psoMask->pvScan0 + pptlMask->y * psoMask->lDelta + (pptlMask->x >> 3); pjMskLine = (PBYTE)psoMask->pvScan0 + pptlMask->y * psoMask->lDelta + (pptlMask->x >> 3);
fjMaskBit0 = 0x80 >> (pptlMask->x & 0x07); fjMaskBit0 = 0x80 >> (pptlMask->x & 0x07);
@ -92,7 +85,7 @@ BltMask(SURFOBJ* psoDest,
SrcX = pptlSource->x; SrcX = pptlSource->x;
} }
if (psurfPattern) if (psoPattern)
{ {
PatternY = (prclDest->top - pptlBrush->y) % PatternHeight; PatternY = (prclDest->top - pptlBrush->y) % PatternHeight;
if (PatternY < 0) if (PatternY < 0)
@ -120,7 +113,7 @@ BltMask(SURFOBJ* psoDest,
{ {
Rop4 = (*pjMskCurrent & fjMaskBit) ? fgndRop : bkgndRop; Rop4 = (*pjMskCurrent & fjMaskBit) ? fgndRop : bkgndRop;
if(psurfPattern) if(psoPattern)
{ {
if(ROP4_USES_PATTERN(Rop4)) if(ROP4_USES_PATTERN(Rop4))
Pattern = fnPattern_GetPixel(psoPattern, PatternX, PatternY); Pattern = fnPattern_GetPixel(psoPattern, PatternX, PatternY);
@ -152,7 +145,7 @@ BltMask(SURFOBJ* psoDest,
pjMskCurrent += (fjMaskBit >> 7); pjMskCurrent += (fjMaskBit >> 7);
} }
pjMskLine += psoMask->lDelta; pjMskLine += psoMask->lDelta;
if(psurfPattern) if(psoPattern)
{ {
PatternY++; PatternY++;
PatternY %= PatternHeight; PatternY %= PatternHeight;
@ -165,12 +158,11 @@ BltMask(SURFOBJ* psoDest,
} }
} }
if (psurfPattern)
SURFACE_ShareUnlockSurface(psurfPattern);
return TRUE; return TRUE;
} }
#ifndef _USE_DIBLIB_
static BOOLEAN APIENTRY static BOOLEAN APIENTRY
BltPatCopy(SURFOBJ* Dest, BltPatCopy(SURFOBJ* Dest,
SURFOBJ* Source, SURFOBJ* Source,
@ -204,10 +196,8 @@ CallDibBitBlt(SURFOBJ* OutputObj,
ROP4 Rop4) ROP4 Rop4)
{ {
BLTINFO BltInfo; BLTINFO BltInfo;
PEBRUSHOBJ GdiBrush = NULL; SURFOBJ *psoPattern;
SURFACE *psurfPattern;
BOOLEAN Result; BOOLEAN Result;
HBITMAP hbmPattern;
BltInfo.DestSurface = OutputObj; BltInfo.DestSurface = OutputObj;
BltInfo.SourceSurface = InputObj; BltInfo.SourceSurface = InputObj;
@ -226,12 +216,10 @@ CallDibBitBlt(SURFOBJ* OutputObj,
/* Pattern brush */ /* Pattern brush */
if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF) if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF)
{ {
GdiBrush = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); psoPattern = BRUSHOBJ_psoPattern(pbo);
hbmPattern = EBRUSHOBJ_pvGetEngBrush(GdiBrush); if (psoPattern)
psurfPattern = SURFACE_ShareLockSurface(hbmPattern);
if (psurfPattern)
{ {
BltInfo.PatternSurface = &psurfPattern->SurfObj; BltInfo.PatternSurface = psoPattern;
} }
else else
{ {
@ -240,17 +228,11 @@ CallDibBitBlt(SURFOBJ* OutputObj,
} }
else else
{ {
psurfPattern = NULL; psoPattern = NULL;
} }
Result = DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBlt(&BltInfo); Result = DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBlt(&BltInfo);
/* Pattern brush */
if (psurfPattern)
{
SURFACE_ShareUnlockSurface(psurfPattern);
}
return Result; return Result;
} }
@ -649,6 +631,7 @@ IntEngBitBlt(
return bResult; return bResult;
} }
#endif // !_USE_DIBLIB_
/**** REACTOS FONT RENDERING CODE *********************************************/ /**** REACTOS FONT RENDERING CODE *********************************************/

View file

@ -97,7 +97,8 @@ EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo)
/* Check if there's a GDI realisation */ /* Check if there's a GDI realisation */
if (pebo->pengbrush) if (pebo->pengbrush)
{ {
EngDeleteSurface(pebo->pengbrush); /* Unlock the bitmap again */
SURFACE_ShareUnlockSurface(pebo->pengbrush);
pebo->pengbrush = NULL; pebo->pengbrush = NULL;
} }
@ -139,6 +140,7 @@ EngRealizeBrush(
EBRUSHOBJ *pebo; EBRUSHOBJ *pebo;
HBITMAP hbmpRealize; HBITMAP hbmpRealize;
SURFOBJ *psoRealize; SURFOBJ *psoRealize;
PSURFACE psurfRealize;
POINTL ptlSrc = {0, 0}; POINTL ptlSrc = {0, 0};
RECTL rclDest; RECTL rclDest;
ULONG lWidth; ULONG lWidth;
@ -159,10 +161,13 @@ EngRealizeBrush(
} }
/* Lock the bitmap */ /* Lock the bitmap */
psoRealize = EngLockSurface(hbmpRealize); psurfRealize = SURFACE_ShareLockSurface(hbmpRealize);
if (!psoRealize)
/* Already delete the pattern bitmap (will be kept until dereferenced) */
EngDeleteSurface(hbmpRealize);
if (!psurfRealize)
{ {
EngDeleteSurface(hbmpRealize);
return FALSE; return FALSE;
} }
@ -170,13 +175,12 @@ EngRealizeBrush(
rclDest.left = rclDest.top = 0; rclDest.left = rclDest.top = 0;
rclDest.right = psoPattern->sizlBitmap.cx; rclDest.right = psoPattern->sizlBitmap.cx;
rclDest.bottom = psoPattern->sizlBitmap.cy; rclDest.bottom = psoPattern->sizlBitmap.cy;
psoRealize = &psurfRealize->SurfObj;
EngCopyBits(psoRealize, psoPattern, NULL, pxlo, &rclDest, &ptlSrc); EngCopyBits(psoRealize, psoPattern, NULL, pxlo, &rclDest, &ptlSrc);
/* Unlock the bitmap again */
EngUnlockSurface(psoRealize);
pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject);
pebo->pengbrush = (PVOID)hbmpRealize; pebo->pengbrush = (PVOID)psurfRealize;
return TRUE; return TRUE;
} }
@ -211,7 +215,7 @@ EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo, BOOL bCallDriver)
psurfMask = NULL; psurfMask = NULL;
/* Initialize XLATEOBJ for the brush */ /* Initialize XLATEOBJ for the brush */
EXLATEOBJ_vInitialize(&exlo, EXLATEOBJ_vInitialize(&exlo,
psurfPattern->ppal, psurfPattern->ppal,
pebo->psurfTrg->ppal, pebo->psurfTrg->ppal,
0, 0,
@ -258,6 +262,17 @@ EBRUSHOBJ_pvGetEngBrush(EBRUSHOBJ *pebo)
return pebo->pengbrush; return pebo->pengbrush;
} }
SURFOBJ*
NTAPI
EBRUSHOBJ_psoPattern(EBRUSHOBJ *pebo)
{
PSURFACE psurfPattern;
psurfPattern = EBRUSHOBJ_pvGetEngBrush(pebo);
return psurfPattern ? &psurfPattern->SurfObj : NULL;
}
/** Exported DDI functions ****************************************************/ /** Exported DDI functions ****************************************************/

View file

@ -337,7 +337,7 @@ EngSetPointerShape(
/* Calculate lDelta for our surfaces. */ /* Calculate lDelta for our surfaces. */
lDelta = WIDTH_BYTES_ALIGN32(sizel.cx, lDelta = WIDTH_BYTES_ALIGN32(sizel.cx,
BitsPerFormat(pso->iBitmapFormat)); BitsPerFormat(pso->iBitmapFormat));
/* Create a bitmap for saving the pixels under the cursor. */ /* Create a bitmap for saving the pixels under the cursor. */
hbmSave = EngCreateBitmap(sizel, hbmSave = EngCreateBitmap(sizel,

View file

@ -35,11 +35,8 @@ CallDibStretchBlt(SURFOBJ* psoDest,
ROP4 Rop4) ROP4 Rop4)
{ {
POINTL RealBrushOrigin; POINTL RealBrushOrigin;
SURFACE* psurfPattern; SURFOBJ* psoPattern;
PEBRUSHOBJ GdiBrush = NULL;
SURFOBJ* PatternSurface = NULL;
BOOL bResult; BOOL bResult;
HBITMAP hbmPattern;
if (BrushOrigin == NULL) if (BrushOrigin == NULL)
{ {
@ -53,34 +50,20 @@ CallDibStretchBlt(SURFOBJ* psoDest,
/* Pattern brush */ /* Pattern brush */
if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF) if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF)
{ {
GdiBrush = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); psoPattern = BRUSHOBJ_psoPattern(pbo);
hbmPattern = EBRUSHOBJ_pvGetEngBrush(GdiBrush);
psurfPattern = SURFACE_ShareLockSurface(hbmPattern); if (!psoPattern) return FALSE;
if (psurfPattern)
{
PatternSurface = &psurfPattern->SurfObj;
}
else
{
/* FIXME: What to do here? */
}
} }
else else
{ {
psurfPattern = NULL; psoPattern = NULL;
} }
bResult = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_StretchBlt( bResult = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_StretchBlt(
psoDest, psoSource, Mask, PatternSurface, psoDest, psoSource, Mask, psoPattern,
OutputRect, InputRect, MaskOrigin, pbo, &RealBrushOrigin, OutputRect, InputRect, MaskOrigin, pbo, &RealBrushOrigin,
ColorTranslation, Rop4); ColorTranslation, Rop4);
/* Pattern brush */
if (psurfPattern)
{
SURFACE_ShareUnlockSurface(psurfPattern);
}
return bResult; return bResult;
} }

View file

@ -122,6 +122,13 @@ PVOID
NTAPI NTAPI
EBRUSHOBJ_pvGetEngBrush(EBRUSHOBJ *pebo); EBRUSHOBJ_pvGetEngBrush(EBRUSHOBJ *pebo);
SURFOBJ*
NTAPI
EBRUSHOBJ_psoPattern(EBRUSHOBJ *pebo);
#define BRUSHOBJ_psoPattern(pbo) \
EBRUSHOBJ_psoPattern(CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject))
BOOL FASTCALL IntGdiSetBrushOwner(PBRUSH,DWORD); BOOL FASTCALL IntGdiSetBrushOwner(PBRUSH,DWORD);
BOOL FASTCALL GreSetBrushOwner(HBRUSH,DWORD); BOOL FASTCALL GreSetBrushOwner(HBRUSH,DWORD);