mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:12:56 +00:00
[WIN32K]
Improve NtGdiStretchDIBitsInternal, use _SEH2_YIELT instead of saving an NTSTATUS and handle the fast path in place instead of setting a BOOL variable. Fixes warnings about uninitialized variables. svn path=/trunk/; revision=50342
This commit is contained in:
parent
e6182247f6
commit
3ecc17156e
1 changed files with 54 additions and 65 deletions
|
@ -1028,8 +1028,9 @@ NtGdiStretchDIBitsInternal(
|
|||
WORD planes, bpp;
|
||||
DWORD compr, size;
|
||||
HBITMAP hBitmap;
|
||||
BOOL fastpath = FALSE;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
HBITMAP hOldBitmap;
|
||||
HDC hdcMem;
|
||||
PVOID pvBits;
|
||||
PBYTE safeBits;
|
||||
|
||||
if (!Bits || !BitsInfo)
|
||||
|
@ -1056,22 +1057,17 @@ NtGdiStretchDIBitsInternal(
|
|||
if (DIB_GetBitmapInfo(&BitsInfo->bmiHeader, &width, &height, &planes, &bpp, &compr, &size) == -1)
|
||||
{
|
||||
DPRINT1("Invalid bitmap\n");
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
_SEH2_YIELD(goto cleanup;)
|
||||
}
|
||||
RtlCopyMemory(safeBits, Bits, cjMaxBits);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
DPRINT1("Error, failed to read the DIB bits\n");
|
||||
_SEH2_YIELD(goto cleanup;)
|
||||
}
|
||||
_SEH2_END
|
||||
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Error, failed to read the DIB bits\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (width < 0)
|
||||
{
|
||||
DPRINT1("Bitmap has a negative width\n");
|
||||
|
@ -1086,28 +1082,20 @@ NtGdiStretchDIBitsInternal(
|
|||
ROP == SRCCOPY)
|
||||
{
|
||||
BITMAP bmp;
|
||||
if (IntGdiGetObject(hBitmap, sizeof(bmp), &bmp) == sizeof(bmp))
|
||||
{
|
||||
if (bmp.bmBitsPixel == bpp &&
|
||||
ret = IntGdiGetObject(hBitmap, sizeof(bmp), &bmp) == sizeof(bmp);
|
||||
if (ret &&
|
||||
bmp.bmBitsPixel == bpp &&
|
||||
bmp.bmWidth == SrcWidth &&
|
||||
bmp.bmHeight == SrcHeight &&
|
||||
bmp.bmPlanes == planes)
|
||||
fastpath = TRUE;
|
||||
{
|
||||
/* fast path */
|
||||
ret = IntSetDIBits(pdc, hBitmap, 0, height, safeBits, BitsInfo, Usage);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if (fastpath)
|
||||
{
|
||||
/* fast path */
|
||||
DPRINT1("using fast path\n");
|
||||
ret = IntSetDIBits( pdc, hBitmap, 0, height, safeBits, BitsInfo, Usage);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* slow path - need to use StretchBlt */
|
||||
HBITMAP hOldBitmap;
|
||||
HDC hdcMem;
|
||||
PVOID pvBits;
|
||||
|
||||
hdcMem = NtGdiCreateCompatibleDC(hDC);
|
||||
hBitmap = DIB_CreateDIBSection(pdc, BitsInfo, Usage, &pvBits, NULL, 0, 0);
|
||||
|
@ -1117,6 +1105,7 @@ NtGdiStretchDIBitsInternal(
|
|||
NtGdiDeleteObjectApp(hdcMem);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
RtlCopyMemory(pvBits, safeBits, cjMaxBits);
|
||||
hOldBitmap = NtGdiSelectBitmap(hdcMem, hBitmap);
|
||||
|
||||
|
@ -1131,7 +1120,7 @@ NtGdiStretchDIBitsInternal(
|
|||
NtGdiSelectBitmap(hdcMem, hOldBitmap);
|
||||
NtGdiDeleteObjectApp(hdcMem);
|
||||
GreDeleteObject(hBitmap);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
ExFreePoolWithTag(safeBits, TAG_DIB);
|
||||
DC_UnlockDc(pdc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue