From 2818a676350b06842c432dc885bc40fac0ec623c Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 13 Oct 1999 15:40:17 +0000 Subject: [PATCH] Optimized StretchDIBits to call SetDIBitsToDevice (when src & dst dimensions are equal). --- objects/dib.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/objects/dib.c b/objects/dib.c index 9fbb0cee543..17efa78ac69 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -135,33 +135,39 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst, const BITMAPINFO *info, UINT wUsage, DWORD dwRop ) { DC *dc = DC_GetDCPtr( hdc ); + if(!dc) return FALSE; + if (widthDst == widthSrc && heightDst == heightSrc && dwRop == SRCCOPY) { + return SetDIBitsToDevice( hdc, xDst, yDst, widthDst, heightDst, + xSrc, ySrc, 0, info->bmiHeader.biHeight, + bits, info, 0/*FIXME coloruse*/ ); + } + if(dc->funcs->pStretchDIBits) return dc->funcs->pStretchDIBits(dc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, bits, info, wUsage, dwRop); else { /* use StretchBlt32 */ - HBITMAP hBitmap, hOldBitmap; - HDC hdcMem; - - hBitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT, - bits, info, wUsage ); - hdcMem = CreateCompatibleDC( hdc ); - hOldBitmap = SelectObject( hdcMem, hBitmap ); - /* Origin for DIBitmap is bottom left ! */ - StretchBlt( hdc, xDst, yDst, widthDst, heightDst, - hdcMem, xSrc, info->bmiHeader.biHeight - heightSrc - ySrc, - widthSrc, heightSrc, dwRop ); - SelectObject( hdcMem, hOldBitmap ); - DeleteDC( hdcMem ); - DeleteObject( hBitmap ); - return heightSrc; + HBITMAP hBitmap, hOldBitmap; + HDC hdcMem; + + hBitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT, + bits, info, wUsage ); + hdcMem = CreateCompatibleDC( hdc ); + hOldBitmap = SelectObject( hdcMem, hBitmap ); + /* Origin for DIBitmap is bottom left ! */ + StretchBlt( hdc, xDst, yDst, widthDst, heightDst, + hdcMem, xSrc, info->bmiHeader.biHeight - heightSrc - ySrc, + widthSrc, heightSrc, dwRop ); + SelectObject( hdcMem, hOldBitmap ); + DeleteDC( hdcMem ); + DeleteObject( hBitmap ); } + return heightSrc; } - /*********************************************************************** * SetDIBits16 (GDI.440) */ -- 2.11.4.GIT