Module: wine Branch: master Commit: 7e9d5a17710cf36e9fb67ba7639ee89539e17db3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7e9d5a17710cf36e9fb67ba763...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Jan 18 14:40:12 2012 +0100
gdi32: Negative destination sizes are allowed after coordinate mapping in GdiAlphaBlend.
---
dlls/gdi32/bitblt.c | 6 +++- dlls/gdi32/tests/bitmap.c | 52 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index 80a42ea..71b8e8f 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -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; } diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 7f609f2..d28b74f 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -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" );