gdi32: Optimise StretchBlt for the case where no stretching is being done and the whole image is being set.

In this case, we can just call SetDIBits which is likely to be a lot faster.
This commit is contained in:
Rob Shearman 2008-02-21 16:44:52 +00:00 committed by Alexandre Julliard
parent 42ad345852
commit 582de7ba0d
1 changed files with 74 additions and 42 deletions

View File

@ -205,13 +205,12 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
}
else /* use StretchBlt */
{
HBITMAP hBitmap, hOldBitmap;
HPALETTE hpal = NULL;
HDC hdcMem;
LONG height;
LONG width;
WORD planes, bpp;
DWORD compr, size;
HBITMAP hBitmap;
BOOL fastpath = FALSE;
release_dc_ptr( dc );
@ -227,6 +226,38 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
return 0;
}
hBitmap = GetCurrentObject(hdc, OBJ_BITMAP);
if (xDst == 0 && yDst == 0 && xSrc == 0 && ySrc == 0 &&
widthDst == widthSrc && heightDst == heightSrc &&
info->bmiHeader.biCompression == BI_RGB &&
dwRop == SRCCOPY)
{
BITMAPOBJ *bmp;
if ((bmp = (BITMAPOBJ *)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC )))
{
if (bmp->bitmap.bmBitsPixel == bpp &&
bmp->bitmap.bmWidth == widthSrc &&
bmp->bitmap.bmHeight == heightSrc &&
bmp->bitmap.bmPlanes == planes)
fastpath = TRUE;
GDI_ReleaseObj( hBitmap );
}
}
if (fastpath)
{
/* fast path */
TRACE("using fast path\n");
heightSrc = SetDIBits( hdc, hBitmap, 0, height, bits, info, wUsage);
}
else
{
/* slow path - need to use StretchBlt */
HBITMAP hOldBitmap;
HPALETTE hpal = NULL;
HDC hdcMem;
hdcMem = CreateCompatibleDC( hdc );
hBitmap = CreateCompatibleBitmap(hdc, width, height);
hOldBitmap = SelectObject( hdcMem, hBitmap );
@ -273,6 +304,7 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
DeleteDC( hdcMem );
DeleteObject( hBitmap );
}
}
return heightSrc;
}