Commit 1c2f9255 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Fix StretchDIBits return value when destination is clipped.

parent 0773ed8d
...@@ -544,6 +544,9 @@ INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT he ...@@ -544,6 +544,9 @@ INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT he
src.visrect.bottom = height; src.visrect.bottom = height;
if (!intersect_rect( &src.visrect, &src.visrect, &rect )) goto done; if (!intersect_rect( &src.visrect, &src.visrect, &rect )) goto done;
if (rop == SRCCOPY) ret = height;
else ret = src_info->bmiHeader.biHeight;
get_bounding_rect( &rect, dst.x, dst.y, dst.width, dst.height ); get_bounding_rect( &rect, dst.x, dst.y, dst.width, dst.height );
if (!clip_visrect( dc, &dst.visrect, &rect )) goto done; if (!clip_visrect( dc, &dst.visrect, &rect )) goto done;
...@@ -584,8 +587,6 @@ INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT he ...@@ -584,8 +587,6 @@ INT nulldrv_StretchDIBits( PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT he
if (!err) err = dev->funcs->pPutImage( dev, NULL, dst_info, &src_bits, &src, &dst, rop ); if (!err) err = dev->funcs->pPutImage( dev, NULL, dst_info, &src_bits, &src, &dst, rop );
} }
if (err) ret = 0; if (err) ret = 0;
else if (rop == SRCCOPY) ret = height;
else ret = src_info->bmiHeader.biHeight;
done: done:
if (src_bits.free) src_bits.free( &src_bits ); if (src_bits.free) src_bits.free( &src_bits );
......
...@@ -3353,12 +3353,13 @@ static void check_StretchDIBits_pixel(HDC hdcDst, UINT32 *dstBuffer, UINT32 *src ...@@ -3353,12 +3353,13 @@ static void check_StretchDIBits_pixel(HDC hdcDst, UINT32 *dstBuffer, UINT32 *src
dwRop, expected, *dstBuffer, line); dwRop, expected, *dstBuffer, line);
} }
static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer, static INT check_StretchDIBits_stretch( HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer,
int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest,
int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc,
UINT32 expected[4], int line) UINT32 expected[4], int line)
{ {
BITMAPINFO bitmapInfo; BITMAPINFO bitmapInfo;
INT ret;
memset(&bitmapInfo, 0, sizeof(BITMAPINFO)); memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
...@@ -3369,9 +3370,9 @@ static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *s ...@@ -3369,9 +3370,9 @@ static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *s
bitmapInfo.bmiHeader.biCompression = BI_RGB; bitmapInfo.bmiHeader.biCompression = BI_RGB;
memset(dstBuffer, 0, 16); memset(dstBuffer, 0, 16);
StretchDIBits(hdcDst, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, ret = StretchDIBits(hdcDst, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
srcBuffer, &bitmapInfo, DIB_RGB_COLORS, SRCCOPY); srcBuffer, &bitmapInfo, DIB_RGB_COLORS, SRCCOPY);
ok(memcmp(dstBuffer, expected, 16) == 0, ok(memcmp(dstBuffer, expected, 16) == 0,
"StretchDIBits expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X } " "StretchDIBits expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X } "
"stretching { %d, %d, %d, %d } to { %d, %d, %d, %d } from line %d\n", "stretching { %d, %d, %d, %d } to { %d, %d, %d, %d } from line %d\n",
...@@ -3379,6 +3380,7 @@ static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *s ...@@ -3379,6 +3380,7 @@ static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *s
dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3], dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3],
nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, line); nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, line);
return ret;
} }
static void test_StretchDIBits(void) static void test_StretchDIBits(void)
...@@ -3390,6 +3392,7 @@ static void test_StretchDIBits(void) ...@@ -3390,6 +3392,7 @@ static void test_StretchDIBits(void)
HBRUSH hBrush, hOldBrush; HBRUSH hBrush, hOldBrush;
BITMAPINFO biDst; BITMAPINFO biDst;
UINT32 expected[4]; UINT32 expected[4];
INT ret;
memset(&biDst, 0, sizeof(BITMAPINFO)); memset(&biDst, 0, sizeof(BITMAPINFO));
biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
...@@ -3435,43 +3438,63 @@ static void test_StretchDIBits(void) ...@@ -3435,43 +3438,63 @@ static void test_StretchDIBits(void)
expected[0] = 0xCAFED00D, expected[1] = 0xFEEDFACE; expected[0] = 0xCAFED00D, expected[1] = 0xFEEDFACE;
expected[2] = 0xFEDCBA98, expected[3] = 0x76543210; expected[2] = 0xFEDCBA98, expected[3] = 0x76543210;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 0, 0, 2, 2, expected, __LINE__); 0, 0, 2, 2, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0xCAFED00D, expected[1] = 0x00000000; expected[0] = 0xCAFED00D, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 1, 1, 0, 0, 1, 1, expected, __LINE__); 0, 0, 1, 1, 0, 0, 1, 1, expected, __LINE__);
todo_wine ok( ret == 1, "got ret %d\n", ret );
expected[0] = 0xFEDCBA98, expected[1] = 0xFEDCBA98; expected[0] = 0xFEDCBA98, expected[1] = 0xFEDCBA98;
expected[2] = 0xFEDCBA98, expected[3] = 0xFEDCBA98; expected[2] = 0xFEDCBA98, expected[3] = 0xFEDCBA98;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 0, 0, 1, 1, expected, __LINE__); 0, 0, 2, 2, 0, 0, 1, 1, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x42441000, expected[1] = 0x00000000; expected[0] = 0x42441000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 1, 1, 0, 0, 2, 2, expected, __LINE__); 0, 0, 1, 1, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000; expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__); 0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__);
ok( ret == 0, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000; expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__); 0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__);
ok( ret == 0, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000; expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
1, 1, -2, -2, 1, 1, -2, -2, expected, __LINE__); 1, 1, -2, -2, 1, 1, -2, -2, expected, __LINE__);
ok( ret == 0, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000; expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0xCAFED00D; expected[2] = 0x00000000, expected[3] = 0xCAFED00D;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
1, 1, 2, 2, 0, 0, 2, 2, expected, __LINE__); 1, 1, 2, 2, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
2, 2, 4, 4, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
-4, -4, 4, 4, 0, 0, 4, 4, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
SelectObject(hdcDst, oldDst); SelectObject(hdcDst, oldDst);
DeleteObject(bmpDst); DeleteObject(bmpDst);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment