From b7a15ae7faa0541bbaf55074413e4c176ed4f852 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 14 Oct 2011 18:22:50 +0200 Subject: [PATCH] gdi32: Overlapping rectangles are not allowed in GdiAlphaBlend. --- dlls/gdi32/bitblt.c | 8 ++++++++ dlls/gdi32/tests/bitmap.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index e03a5c19069..eee6fa26fc0 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -774,6 +774,14 @@ BOOL WINAPI GdiAlphaBlend(HDC hdcDst, int xDst, int yDst, int widthDst, int heig SetLastError( ERROR_INVALID_PARAMETER ); ret = FALSE; } + else if (dcSrc == dcDst && src.x + src.width > dst.x && src.x < dst.x + dst.width && + src.y + src.height > dst.y && src.y < dst.y + dst.height) + { + WARN( "Overlapping coords: (%d,%d), %dx%d and (%d,%d), %dx%d\n", + src.x, src.y, src.width, src.height, dst.x, dst.y, dst.width, dst.height ); + SetLastError( ERROR_INVALID_PARAMETER ); + ret = FALSE; + } else if (!ret) ret = dst_dev->funcs->pAlphaBlend( dst_dev, &dst, src_dev, &src, blendFunction ); release_dc_ptr( dcDst ); diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index e069fa83dff..32fabb80879 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -3279,6 +3279,25 @@ static void test_GdiAlphaBlend(void) ok( !ret, "GdiAlphaBlend succeeded\n" ); ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() ); + /* overlapping source and dest not allowed */ + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcDst, 19, 19, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 20, 20, 20, 20, hdcDst, 1, 1, 20, 20, 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, hdcDst, 20, 10, 20, 20, blend); + ok( ret, "GdiAlphaBlend succeeded\n" ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcDst, 10, 20, 20, 20, blend); + ok( ret, "GdiAlphaBlend succeeded\n" ); + /* AC_SRC_ALPHA requires 32-bpp BI_RGB format */ blend.AlphaFormat = AC_SRC_ALPHA;