From e72570afce19d7e19a685166012e80da416b5c94 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 30 Oct 2009 15:22:57 +0000 Subject: [PATCH] [WIN32K] EngCopyBits: Use goto cleanup / break instead of code duplication, fix leaking a bits lock, if the rect function fails, remove abundant MouseSafetyOnDrawEnd svn path=/trunk/; revision=43849 --- .../subsystems/win32/win32k/eng/copybits.c | 72 ++++++------------- 1 file changed, 21 insertions(+), 51 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/copybits.c b/reactos/subsystems/win32/win32k/eng/copybits.c index 6fcb67c3833..1cabfb955f2 100644 --- a/reactos/subsystems/win32/win32k/eng/copybits.c +++ b/reactos/subsystems/win32/win32k/eng/copybits.c @@ -42,7 +42,7 @@ EngCopyBits(SURFOBJ *psoDest, RECTL *DestRect, POINTL *SourcePoint) { - BOOLEAN ret; + BOOL ret; BYTE clippingType; RECT_ENUM RectEnum; BOOL EnumMore; @@ -78,13 +78,7 @@ EngCopyBits(SURFOBJ *psoDest, ret = GDIDEVFUNCS(psoDest).CopyBits( psoDest, psoSource, Clip, ColorTranslation, DestRect, SourcePoint); - if (psoDest != psoSource) - { - SURFACE_UnlockBitmapBits(psurfDest); - } - SURFACE_UnlockBitmapBits(psurfSource); - - return ret; + goto cleanup; } } @@ -97,13 +91,7 @@ EngCopyBits(SURFOBJ *psoDest, ret = GDIDEVFUNCS(psoSource).CopyBits( psoDest, psoSource, Clip, ColorTranslation, DestRect, SourcePoint); - if (psoDest != psoSource) - { - SURFACE_UnlockBitmapBits(psurfDest); - } - SURFACE_UnlockBitmapBits(psurfSource); - - return ret; + goto cleanup; } } @@ -112,17 +100,11 @@ EngCopyBits(SURFOBJ *psoDest, NULL, Clip, ColorTranslation, DestRect, SourcePoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY)); - if (psoDest != psoSource) - { - SURFACE_UnlockBitmapBits(psurfDest); - } - SURFACE_UnlockBitmapBits(psurfSource); - - return ret; + goto cleanup; } // Determine clipping type - if (Clip == (CLIPOBJ *) NULL) + if (!Clip) { clippingType = DC_TRIVIAL; } @@ -143,16 +125,8 @@ EngCopyBits(SURFOBJ *psoDest, BltInfo.DestRect = *DestRect; BltInfo.SourcePoint = *SourcePoint; - DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo); - - MouseSafetyOnDrawEnd(psoDest); - if (psoDest != psoSource) - { - SURFACE_UnlockBitmapBits(psurfDest); - } - SURFACE_UnlockBitmapBits(psurfSource); - - return TRUE; + ret = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo); + break; case DC_RECT: // Clip the blt to the clip rectangle @@ -161,15 +135,8 @@ EngCopyBits(SURFOBJ *psoDest, BltInfo.SourcePoint.x = SourcePoint->x + BltInfo.DestRect.left - DestRect->left; BltInfo.SourcePoint.y = SourcePoint->y + BltInfo.DestRect.top - DestRect->top; - DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo); - - if (psoDest != psoSource) - { - SURFACE_UnlockBitmapBits(psurfDest); - } - SURFACE_UnlockBitmapBits(psurfSource); - - return TRUE; + ret = DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo); + break; case DC_COMPLEX: @@ -192,7 +159,10 @@ EngCopyBits(SURFOBJ *psoDest, BltInfo.SourcePoint.y = SourcePoint->y + prcl->top - DestRect->top; if (!DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo)) - return FALSE; + { + ret = FALSE; + goto cleanup; + } prcl++; @@ -200,23 +170,23 @@ EngCopyBits(SURFOBJ *psoDest, } } while (EnumMore); + ret = TRUE; + break; - if (psoDest != psoSource) - { - SURFACE_UnlockBitmapBits(psurfDest); - } - SURFACE_UnlockBitmapBits(psurfSource); - - return TRUE; + default: + ASSERT(FALSE); + ret = FALSE; + break; } +cleanup: if (psoDest != psoSource) { SURFACE_UnlockBitmapBits(psurfDest); } SURFACE_UnlockBitmapBits(psurfSource); - return FALSE; + return ret; } BOOL APIENTRY