Alexandre Julliard : gdi32/tests: Add some tests for behavior of 32-bit DDBs.
Alexandre Julliard
julliard at winehq.org
Wed Dec 14 13:23:33 CST 2011
Module: wine
Branch: master
Commit: 6752d3478f450deb1ba4489c47984abccdf892b9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6752d3478f450deb1ba4489c47984abccdf892b9
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Dec 14 17:34:58 2011 +0100
gdi32/tests: Add some tests for behavior of 32-bit DDBs.
---
dlls/gdi32/tests/bitmap.c | 72 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 58 insertions(+), 14 deletions(-)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index ba8ad84..9a34f63 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -3601,22 +3601,24 @@ static void test_clipping(void)
DeleteDC( hdcSrc );
}
-static void test_32bit_bitmap_blt(void)
+static void test_32bit_ddb(void)
{
- BITMAPINFO biDst;
+ char buffer[sizeof(BITMAPINFOHEADER) + sizeof(DWORD)];
+ BITMAPINFO *biDst = (BITMAPINFO *)buffer;
HBITMAP bmpSrc, bmpDst;
HBITMAP oldSrc, oldDst;
HDC hdcSrc, hdcDst, hdcScreen;
- UINT32 *dstBuffer;
- DWORD colorSrc = 0x11223344;
-
- memset(&biDst, 0, sizeof(BITMAPINFO));
- biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- biDst.bmiHeader.biWidth = 2;
- biDst.bmiHeader.biHeight = -2;
- biDst.bmiHeader.biPlanes = 1;
- biDst.bmiHeader.biBitCount = 32;
- biDst.bmiHeader.biCompression = BI_RGB;
+ HBRUSH brush;
+ DWORD *dstBuffer, *data;
+ DWORD colorSrc = 0x40201008;
+
+ memset(biDst, 0, sizeof(BITMAPINFOHEADER));
+ biDst->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ biDst->bmiHeader.biWidth = 1;
+ biDst->bmiHeader.biHeight = -1;
+ biDst->bmiHeader.biPlanes = 1;
+ biDst->bmiHeader.biBitCount = 32;
+ biDst->bmiHeader.biCompression = BI_RGB;
hdcScreen = CreateCompatibleDC(0);
if(GetDeviceCaps(hdcScreen, BITSPIXEL) != 32)
@@ -3631,12 +3633,54 @@ static void test_32bit_bitmap_blt(void)
oldSrc = SelectObject(hdcSrc, bmpSrc);
hdcDst = CreateCompatibleDC(hdcScreen);
- bmpDst = CreateDIBSection(hdcDst, &biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0);
+ bmpDst = CreateDIBSection(hdcDst, biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0);
oldDst = SelectObject(hdcDst, bmpDst);
StretchBlt(hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, SRCCOPY);
ok(dstBuffer[0] == colorSrc, "Expected color=%x, received color=%x\n", colorSrc, dstBuffer[0]);
+ if (pGdiAlphaBlend)
+ {
+ BLENDFUNCTION blend;
+ BOOL ret;
+
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 128;
+ blend.AlphaFormat = 0;
+ dstBuffer[0] = 0x80808080;
+ ret = pGdiAlphaBlend( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, blend );
+ ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
+ ok(dstBuffer[0] == 0x60504844, "wrong color %x\n", dstBuffer[0]);
+ blend.AlphaFormat = AC_SRC_ALPHA;
+ dstBuffer[0] = 0x80808080;
+ ret = pGdiAlphaBlend( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, blend );
+ ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
+ ok(dstBuffer[0] == 0x90807874, "wrong color %x\n", dstBuffer[0]);
+ }
+
+ data = (DWORD *)biDst->bmiColors;
+ data[0] = 0x20304050;
+ brush = CreateDIBPatternBrushPt( biDst, DIB_RGB_COLORS );
+ ok( brush != 0, "brush creation failed\n" );
+ SelectObject( hdcSrc, brush );
+ PatBlt( hdcSrc, 0, 0, 1, 1, PATCOPY );
+ BitBlt( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, SRCCOPY );
+ ok(dstBuffer[0] == data[0], "Expected color=%x, received color=%x\n", data[0], dstBuffer[0]);
+ SelectObject( hdcSrc, GetStockObject(BLACK_BRUSH) );
+ DeleteObject( brush );
+
+ biDst->bmiHeader.biBitCount = 24;
+ brush = CreateDIBPatternBrushPt( biDst, DIB_RGB_COLORS );
+ ok( brush != 0, "brush creation failed\n" );
+ SelectObject( hdcSrc, brush );
+ PatBlt( hdcSrc, 0, 0, 1, 1, PATCOPY );
+ BitBlt( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, SRCCOPY );
+ ok(dstBuffer[0] == (data[0] & ~0xff000000),
+ "Expected color=%x, received color=%x\n", data[0] & 0xff000000, dstBuffer[0]);
+ SelectObject( hdcSrc, GetStockObject(BLACK_BRUSH) );
+ DeleteObject( brush );
+
/* Tidy up */
SelectObject(hdcDst, oldDst);
DeleteObject(bmpDst);
@@ -5259,7 +5303,7 @@ START_TEST(bitmap)
test_StretchDIBits();
test_GdiAlphaBlend();
test_GdiGradientFill();
- test_32bit_bitmap_blt();
+ test_32bit_ddb();
test_bitmapinfoheadersize();
test_get16dibits();
test_clipping();
More information about the wine-cvs
mailing list