Author: tkreuzer Date: Sat Mar 24 17:19:34 2012 New Revision: 56220
URL: http://svn.reactos.org/svn/reactos?rev=56220&view=rev Log: [WIN32K] Modify EBRUSHOBJ_pvGetEngBrush to return a pointer to the SURFOBJ, instead of a handle, this simplifies the code
Modified: trunk/reactos/subsystems/win32/win32k/eng/bitblt.c trunk/reactos/subsystems/win32/win32k/eng/engbrush.c trunk/reactos/subsystems/win32/win32k/eng/mouse.c trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c trunk/reactos/subsystems/win32/win32k/include/brush.h
Modified: trunk/reactos/subsystems/win32/win32k/eng/bitblt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/bitblt.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/bitblt.c [iso-8859-1] Sat Mar 24 17:19:34 2012 @@ -39,16 +39,13 @@ 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 @@ /* 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 = &psurfPattern->SurfObj; + psoPattern = BRUSHOBJ_psoPattern(pbo); + if (psoPattern) + { 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 @@ SrcX = pptlSource->x; }
- if (psurfPattern) + if (psoPattern) { PatternY = (prclDest->top - pptlBrush->y) % PatternHeight; if (PatternY < 0) @@ -120,7 +113,7 @@ { Rop4 = (*pjMskCurrent & fjMaskBit) ? fgndRop : bkgndRop;
- if(psurfPattern) + if(psoPattern) { if(ROP4_USES_PATTERN(Rop4)) Pattern = fnPattern_GetPixel(psoPattern, PatternX, PatternY); @@ -152,7 +145,7 @@ pjMskCurrent += (fjMaskBit >> 7); } pjMskLine += psoMask->lDelta; - if(psurfPattern) + if(psoPattern) { PatternY++; PatternY %= PatternHeight; @@ -165,11 +158,10 @@ } }
- if (psurfPattern) - SURFACE_ShareUnlockSurface(psurfPattern); - return TRUE; } + +#ifndef _USE_DIBLIB_
static BOOLEAN APIENTRY BltPatCopy(SURFOBJ* Dest, @@ -204,10 +196,8 @@ 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 @@ /* 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) - { - BltInfo.PatternSurface = &psurfPattern->SurfObj; + psoPattern = BRUSHOBJ_psoPattern(pbo); + if (psoPattern) + { + BltInfo.PatternSurface = psoPattern; } else { @@ -240,16 +228,10 @@ } 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 @@ return bResult; }
+#endif // !_USE_DIBLIB_
/**** REACTOS FONT RENDERING CODE *********************************************/
Modified: trunk/reactos/subsystems/win32/win32k/eng/engbrush.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/engbrush.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/engbrush.c [iso-8859-1] Sat Mar 24 17:19:34 2012 @@ -97,7 +97,8 @@ /* 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 @@ EBRUSHOBJ *pebo; HBITMAP hbmpRealize; SURFOBJ *psoRealize; + PSURFACE psurfRealize; POINTL ptlSrc = {0, 0}; RECTL rclDest; ULONG lWidth; @@ -159,10 +161,13 @@ }
/* Lock the bitmap */ - psoRealize = EngLockSurface(hbmpRealize); - if (!psoRealize) - { - EngDeleteSurface(hbmpRealize); + psurfRealize = SURFACE_ShareLockSurface(hbmpRealize); + + /* Already delete the pattern bitmap (will be kept until dereferenced) */ + EngDeleteSurface(hbmpRealize); + + if (!psurfRealize) + { return FALSE; }
@@ -170,13 +175,12 @@ 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 @@ psurfMask = NULL;
/* Initialize XLATEOBJ for the brush */ - EXLATEOBJ_vInitialize(&exlo, + EXLATEOBJ_vInitialize(&exlo, psurfPattern->ppal, pebo->psurfTrg->ppal, 0, @@ -256,6 +260,17 @@ }
return pebo->pengbrush; +} + +SURFOBJ* +NTAPI +EBRUSHOBJ_psoPattern(EBRUSHOBJ *pebo) +{ + PSURFACE psurfPattern; + + psurfPattern = EBRUSHOBJ_pvGetEngBrush(pebo); + + return psurfPattern ? &psurfPattern->SurfObj : NULL; }
Modified: trunk/reactos/subsystems/win32/win32k/eng/mouse.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/mouse.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/mouse.c [iso-8859-1] Sat Mar 24 17:19:34 2012 @@ -337,7 +337,7 @@
/* 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,
Modified: trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/stretchblt.c [iso-8859-1] Sat Mar 24 17:19:34 2012 @@ -35,11 +35,8 @@ ROP4 Rop4) { POINTL RealBrushOrigin; - SURFACE* psurfPattern; - PEBRUSHOBJ GdiBrush = NULL; - SURFOBJ* PatternSurface = NULL; + SURFOBJ* psoPattern; BOOL bResult; - HBITMAP hbmPattern;
if (BrushOrigin == NULL) { @@ -53,33 +50,19 @@ /* 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; }
Modified: trunk/reactos/subsystems/win32/win32k/include/brush.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/brush.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/brush.h [iso-8859-1] Sat Mar 24 17:19:34 2012 @@ -122,6 +122,13 @@ 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);