diff --git a/reactos/subsystems/win32/win32k/eng/bitblt.c b/reactos/subsystems/win32/win32k/eng/bitblt.c index 55cafac1001..0c4e077b2b2 100644 --- a/reactos/subsystems/win32/win32k/eng/bitblt.c +++ b/reactos/subsystems/win32/win32k/eng/bitblt.c @@ -39,16 +39,13 @@ BltMask(SURFOBJ* psoDest, BYTE *pjMskLine, *pjMskCurrent; BYTE fjMaskBit0, fjMaskBit; /* Pattern brushes */ - PEBRUSHOBJ pebo = NULL; - SURFOBJ *psoPattern = NULL; - PSURFACE psurfPattern; + SURFOBJ *psoPattern; ULONG PatternWidth = 0, PatternHeight = 0; LONG PatternX0 = 0, PatternX = 0, PatternY = 0; LONG SrcX = 0, SrcY = 0; PFN_DIB_PutPixel fnDest_PutPixel = NULL; PFN_DIB_GetPixel fnPattern_GetPixel = NULL, fnSrc_GetPixel = NULL, fnDest_GetPixel; ULONG Pattern = 0, Source = 0, Dest = 0; - HBITMAP hbmPattern; DWORD fgndRop, bkgndRop; ASSERT(IS_VALID_ROP4(Rop4)); @@ -61,20 +58,16 @@ BltMask(SURFOBJ* psoDest, /* Determine pattern */ if (pbo && pbo->iSolidColor == 0xFFFFFFFF) { - pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); - - hbmPattern = EBRUSHOBJ_pvGetEngBrush(pebo); - psurfPattern = SURFACE_ShareLockSurface(hbmPattern); - if (psurfPattern != NULL) + psoPattern = BRUSHOBJ_psoPattern(pbo); + if (psoPattern) { - psoPattern = &psurfPattern->SurfObj; PatternWidth = psoPattern->sizlBitmap.cx; PatternHeight = psoPattern->sizlBitmap.cy; fnPattern_GetPixel = DibFunctionsForBitmapFormat[psoPattern->iBitmapFormat].DIB_GetPixel; } } else - psurfPattern = NULL; + psoPattern = NULL; pjMskLine = (PBYTE)psoMask->pvScan0 + pptlMask->y * psoMask->lDelta + (pptlMask->x >> 3); fjMaskBit0 = 0x80 >> (pptlMask->x & 0x07); @@ -92,7 +85,7 @@ BltMask(SURFOBJ* psoDest, SrcX = pptlSource->x; } - if (psurfPattern) + if (psoPattern) { PatternY = (prclDest->top - pptlBrush->y) % PatternHeight; if (PatternY < 0) @@ -120,7 +113,7 @@ BltMask(SURFOBJ* psoDest, { Rop4 = (*pjMskCurrent & fjMaskBit) ? fgndRop : bkgndRop; - if(psurfPattern) + if(psoPattern) { if(ROP4_USES_PATTERN(Rop4)) Pattern = fnPattern_GetPixel(psoPattern, PatternX, PatternY); @@ -152,7 +145,7 @@ BltMask(SURFOBJ* psoDest, pjMskCurrent += (fjMaskBit >> 7); } pjMskLine += psoMask->lDelta; - if(psurfPattern) + if(psoPattern) { PatternY++; PatternY %= PatternHeight; @@ -165,12 +158,11 @@ BltMask(SURFOBJ* psoDest, } } - if (psurfPattern) - SURFACE_ShareUnlockSurface(psurfPattern); - return TRUE; } +#ifndef _USE_DIBLIB_ + static BOOLEAN APIENTRY BltPatCopy(SURFOBJ* Dest, SURFOBJ* Source, @@ -204,10 +196,8 @@ CallDibBitBlt(SURFOBJ* OutputObj, ROP4 Rop4) { BLTINFO BltInfo; - PEBRUSHOBJ GdiBrush = NULL; - SURFACE *psurfPattern; + SURFOBJ *psoPattern; BOOLEAN Result; - HBITMAP hbmPattern; BltInfo.DestSurface = OutputObj; BltInfo.SourceSurface = InputObj; @@ -226,12 +216,10 @@ CallDibBitBlt(SURFOBJ* OutputObj, /* Pattern brush */ if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF) { - GdiBrush = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); - hbmPattern = EBRUSHOBJ_pvGetEngBrush(GdiBrush); - psurfPattern = SURFACE_ShareLockSurface(hbmPattern); - if (psurfPattern) + psoPattern = BRUSHOBJ_psoPattern(pbo); + if (psoPattern) { - BltInfo.PatternSurface = &psurfPattern->SurfObj; + BltInfo.PatternSurface = psoPattern; } else { @@ -240,17 +228,11 @@ CallDibBitBlt(SURFOBJ* OutputObj, } else { - psurfPattern = NULL; + psoPattern = NULL; } Result = DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBlt(&BltInfo); - /* Pattern brush */ - if (psurfPattern) - { - SURFACE_ShareUnlockSurface(psurfPattern); - } - return Result; } @@ -649,6 +631,7 @@ IntEngBitBlt( return bResult; } +#endif // !_USE_DIBLIB_ /**** REACTOS FONT RENDERING CODE *********************************************/ diff --git a/reactos/subsystems/win32/win32k/eng/engbrush.c b/reactos/subsystems/win32/win32k/eng/engbrush.c index c52d8481b3e..522a3333f8c 100644 --- a/reactos/subsystems/win32/win32k/eng/engbrush.c +++ b/reactos/subsystems/win32/win32k/eng/engbrush.c @@ -97,7 +97,8 @@ EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo) /* Check if there's a GDI realisation */ if (pebo->pengbrush) { - EngDeleteSurface(pebo->pengbrush); + /* Unlock the bitmap again */ + SURFACE_ShareUnlockSurface(pebo->pengbrush); pebo->pengbrush = NULL; } @@ -139,6 +140,7 @@ EngRealizeBrush( EBRUSHOBJ *pebo; HBITMAP hbmpRealize; SURFOBJ *psoRealize; + PSURFACE psurfRealize; POINTL ptlSrc = {0, 0}; RECTL rclDest; ULONG lWidth; @@ -159,10 +161,13 @@ EngRealizeBrush( } /* Lock the bitmap */ - psoRealize = EngLockSurface(hbmpRealize); - if (!psoRealize) + psurfRealize = SURFACE_ShareLockSurface(hbmpRealize); + + /* Already delete the pattern bitmap (will be kept until dereferenced) */ + EngDeleteSurface(hbmpRealize); + + if (!psurfRealize) { - EngDeleteSurface(hbmpRealize); return FALSE; } @@ -170,13 +175,12 @@ EngRealizeBrush( rclDest.left = rclDest.top = 0; rclDest.right = psoPattern->sizlBitmap.cx; rclDest.bottom = psoPattern->sizlBitmap.cy; + psoRealize = &psurfRealize->SurfObj; EngCopyBits(psoRealize, psoPattern, NULL, pxlo, &rclDest, &ptlSrc); - /* Unlock the bitmap again */ - EngUnlockSurface(psoRealize); pebo = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); - pebo->pengbrush = (PVOID)hbmpRealize; + pebo->pengbrush = (PVOID)psurfRealize; return TRUE; } @@ -211,7 +215,7 @@ EBRUSHOBJ_bRealizeBrush(EBRUSHOBJ *pebo, BOOL bCallDriver) psurfMask = NULL; /* Initialize XLATEOBJ for the brush */ - EXLATEOBJ_vInitialize(&exlo, + EXLATEOBJ_vInitialize(&exlo, psurfPattern->ppal, pebo->psurfTrg->ppal, 0, @@ -258,6 +262,17 @@ EBRUSHOBJ_pvGetEngBrush(EBRUSHOBJ *pebo) return pebo->pengbrush; } +SURFOBJ* +NTAPI +EBRUSHOBJ_psoPattern(EBRUSHOBJ *pebo) +{ + PSURFACE psurfPattern; + + psurfPattern = EBRUSHOBJ_pvGetEngBrush(pebo); + + return psurfPattern ? &psurfPattern->SurfObj : NULL; +} + /** Exported DDI functions ****************************************************/ diff --git a/reactos/subsystems/win32/win32k/eng/mouse.c b/reactos/subsystems/win32/win32k/eng/mouse.c index df660459888..ff3e36b172e 100644 --- a/reactos/subsystems/win32/win32k/eng/mouse.c +++ b/reactos/subsystems/win32/win32k/eng/mouse.c @@ -337,7 +337,7 @@ EngSetPointerShape( /* Calculate lDelta for our surfaces. */ lDelta = WIDTH_BYTES_ALIGN32(sizel.cx, - BitsPerFormat(pso->iBitmapFormat)); + BitsPerFormat(pso->iBitmapFormat)); /* Create a bitmap for saving the pixels under the cursor. */ hbmSave = EngCreateBitmap(sizel, diff --git a/reactos/subsystems/win32/win32k/eng/stretchblt.c b/reactos/subsystems/win32/win32k/eng/stretchblt.c index 56f22932cfa..ceb1ce8f7bc 100644 --- a/reactos/subsystems/win32/win32k/eng/stretchblt.c +++ b/reactos/subsystems/win32/win32k/eng/stretchblt.c @@ -35,11 +35,8 @@ CallDibStretchBlt(SURFOBJ* psoDest, ROP4 Rop4) { POINTL RealBrushOrigin; - SURFACE* psurfPattern; - PEBRUSHOBJ GdiBrush = NULL; - SURFOBJ* PatternSurface = NULL; + SURFOBJ* psoPattern; BOOL bResult; - HBITMAP hbmPattern; if (BrushOrigin == NULL) { @@ -53,34 +50,20 @@ CallDibStretchBlt(SURFOBJ* psoDest, /* Pattern brush */ if (ROP4_USES_PATTERN(Rop4) && pbo && pbo->iSolidColor == 0xFFFFFFFF) { - GdiBrush = CONTAINING_RECORD(pbo, EBRUSHOBJ, BrushObject); - hbmPattern = EBRUSHOBJ_pvGetEngBrush(GdiBrush); - psurfPattern = SURFACE_ShareLockSurface(hbmPattern); - if (psurfPattern) - { - PatternSurface = &psurfPattern->SurfObj; - } - else - { - /* FIXME: What to do here? */ - } + psoPattern = BRUSHOBJ_psoPattern(pbo); + + if (!psoPattern) return FALSE; } else { - psurfPattern = NULL; + psoPattern = NULL; } bResult = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_StretchBlt( - psoDest, psoSource, Mask, PatternSurface, + psoDest, psoSource, Mask, psoPattern, OutputRect, InputRect, MaskOrigin, pbo, &RealBrushOrigin, ColorTranslation, Rop4); - /* Pattern brush */ - if (psurfPattern) - { - SURFACE_ShareUnlockSurface(psurfPattern); - } - return bResult; } diff --git a/reactos/subsystems/win32/win32k/include/brush.h b/reactos/subsystems/win32/win32k/include/brush.h index b4956d3d972..64e161fe4a2 100644 --- a/reactos/subsystems/win32/win32k/include/brush.h +++ b/reactos/subsystems/win32/win32k/include/brush.h @@ -122,6 +122,13 @@ PVOID NTAPI 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 GreSetBrushOwner(HBRUSH,DWORD);