gdi32: Negative destination sizes are allowed after coordinate mapping in GdiAlphaBlend.

This commit is contained in:
Alexandre Julliard 2012-01-18 14:40:12 +01:00
parent 0e3bfb8951
commit 7e9d5a1771
2 changed files with 54 additions and 4 deletions

View File

@ -932,6 +932,7 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
blendFunction.SourceConstantAlpha, blendFunction.AlphaFormat );
if (src.x < 0 || src.y < 0 || src.width < 0 || src.height < 0 ||
src.log_width < 0 || src.log_height < 0 ||
(dcSrc->header.type == OBJ_MEMDC &&
(src.width > dcSrc->vis_rect.right - dcSrc->vis_rect.left - src.x ||
src.height > dcSrc->vis_rect.bottom - dcSrc->vis_rect.top - src.y)))
@ -940,9 +941,10 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig
SetLastError( ERROR_INVALID_PARAMETER );
ret = FALSE;
}
else if (dst.width < 0 || dst.height < 0)
else if (dst.log_width < 0 || dst.log_height < 0)
{
WARN( "Invalid dst coords: (%d,%d), size %dx%d\n", dst.x, dst.y, dst.width, dst.height );
WARN( "Invalid dst coords: (%d,%d), size %dx%d\n",
dst.log_x, dst.log_y, dst.log_width, dst.log_height );
SetLastError( ERROR_INVALID_PARAMETER );
ret = FALSE;
}

View File

@ -2747,7 +2747,6 @@ static void check_BitBlt_pixel(HDC hdcDst, HDC hdcSrc, UINT32 *dstBuffer, UINT32
{
*srcBuffer = 0xFEDCBA98;
*dstBuffer = 0x89ABCDEF;
Rectangle(hdcSrc, 0, 0, 1, 1); /* A null operation to ensure dibs are coerced to X11 */
BitBlt(hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, dwRop);
ok(expected == *dstBuffer,
"BitBlt with dwRop %06X. Expected 0x%08X, got 0x%08X from line %d\n",
@ -2781,7 +2780,7 @@ static void test_BitBlt(void)
NULL, 0);
oldDst = SelectObject(hdcDst, bmpDst);
hBrush = CreateSolidBrush(0x012345678);
hBrush = CreateSolidBrush(0x12345678);
hOldBrush = SelectObject(hdcDst, hBrush);
/* Setup the source dib section */
@ -3394,6 +3393,55 @@ static void test_GdiAlphaBlend(void)
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 30, 30, blend);
ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
SetMapMode(hdcDst, MM_ANISOTROPIC);
SetViewportExtEx(hdcDst, -1, -1, NULL);
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 50, 50, blend);
ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, -20, -20, 20, 20, hdcSrc, 0, -1, 50, 50, blend);
ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, -20, -20, -20, -20, hdcSrc, 0, -1, 50, 50, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, -20, 0, -20, 20, hdcSrc, 0, -1, 50, 50, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, -20, 20, -20, hdcSrc, 0, -1, 50, 50, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetMapMode(hdcDst, MM_TEXT);
SetViewportExtEx(hdcSrc, -1, -1, NULL);
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, -30, -30, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, 30, -30, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, -30, 30, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, 30, 30, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 20, 20, 30, 30, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -60, -60, 30, 30, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetViewportExtEx(hdcSrc, 1, 1, NULL);
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, NULL, 0, 0, 20, 20, blend);
ok( !ret, "GdiAlphaBlend succeeded\n" );