OK, try this one. It has the BitBlt(..., WHITENESS) call if(0)'d out, so the test doesn't crash. I also fixed the issue with the other BitBlt() failing on Wine (I used a memory DC).
I also put some tests that depend on the WHITENESS call succeeding into todo_wine blocks. Oddly enough, the check for the bits being all 1s succeeds on wine, even though it's not supposed to.
I also fixed the increment of the number of BitBlt() records in test_BitBlt_record(). Now instead of incrementing the pointer, it actually increments the count. (How could I have been so blind?)
This should work on Windows, too.
Chip
From 2d5aa7c607496c1b05a7a08adfee09db446754cb Mon Sep 17 00:00:00 2001
From: Charles Davis cdavis@mymail.mines.edu Date: Tue, 17 Nov 2009 11:10:50 -0700 Subject: [PATCH] gdi32/tests: Test BitBlt() to a metafile. To: wine-patches wine-patches@winehq.org Reply-To: wine-devel wine-devel@winehq.org
--- dlls/gdi32/tests/metafile.c | 83 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c index b559901..19401ed 100644 --- a/dlls/gdi32/tests/metafile.c +++ b/dlls/gdi32/tests/metafile.c @@ -665,6 +665,88 @@ static void test_SaveDC(void) DestroyWindow(hwnd); }
+static int CALLBACK test_BitBlt_record(HDC hdc, HANDLETABLE *table, const ENHMETARECORD *emfr, int nobj, LPARAM data) +{ + UINT *pi = (UINT *)data; + EMRBITBLT *emrbb; + + if(emfr->iType != EMR_BITBLT) return 1; + emrbb = (EMRBITBLT *)emfr; + + (*pi)++; + if(*pi > 2) return 1; + ok( emrbb->xDest == 0, "wrong xDest for BitBlt record: got %d, expected 0\n", emrbb->xDest ); + ok( emrbb->yDest == 0, "wrong yDest for BitBlt record: got %d, expected 0\n", emrbb->yDest ); + ok( emrbb->xSrc == 0, "wrong xSrc for BitBlt record: got %d, expected 0\n", emrbb->xSrc ); + ok( emrbb->ySrc == 0, "wrong ySrc for BitBlt record: got %d, expected 0\n", emrbb->ySrc ); + ok( emrbb->cxDest == GetSystemMetrics(SM_CXSCREEN), "wrong cxDest for BitBlt record: got %d\n", emrbb->cxDest ); + ok( emrbb->cyDest == GetSystemMetrics(SM_CYSCREEN), "wrong cyDest for BitBlt record: got %d\n", emrbb->cyDest ); + if(*pi == 1) /* First BitBlt */ + { + ok( emrbb->dwRop == SRCCOPY, "wrong ROP for BitBlt record: got %x, expected SRCCOPY\n", emrbb->dwRop ); + } + else + { + todo_wine ok( emrbb->dwRop == WHITENESS, "wrong ROP for BitBlt record: got %x, expected WHITENESS\n", emrbb->dwRop ); + } + return 1; +} + +static void test_emf_BitBlt(void) +{ + HDC hdcDisplay, hdcMetafile, hdcBitmap; + HBITMAP hBitmap, hOldBitmap; + HENHMETAFILE hMetafile; + ENHMETAHEADER emh; + BYTE *bits; + BOOL ret; + UINT i; + + hdcDisplay = CreateDCA("DISPLAY", NULL, NULL, NULL); + ok( hdcDisplay != 0, "CreateDCA error %d\n", GetLastError() ); + hdcMetafile = CreateEnhMetaFileA(hdcDisplay, NULL, NULL, NULL); + ok( hdcMetafile != 0, "CreateEnhMetaFileA failed\n" ); + + hdcBitmap = CreateCompatibleDC(hdcDisplay); + ok( hdcBitmap != 0, "CreateCompatibleDC failed\n" ); + hBitmap = CreateCompatibleBitmap(hdcDisplay, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + ok( hBitmap != 0, "CreateCompatibleBitmap failed\n" ); + hOldBitmap = SelectObject(hdcBitmap, hBitmap); + + ret = BitBlt(hdcMetafile, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), hdcBitmap, 0, 0, SRCCOPY); + ok( ret, "BitBlt failed\n" ); + if(0) /* Crashes on wine */ + { + ret = BitBlt(hdcMetafile, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 0, 0, 0, WHITENESS); + ok( ret, "BitBlt failed\n" ); + } + + hMetafile = CloseEnhMetaFile(hdcMetafile); + ok( hMetafile != 0, "CloseEnhMetaFile failed\n" ); + + ret = GetEnhMetaFileHeader( hMetafile, sizeof(emh), &emh ); + ok( ret != 0, "GetEnhMetaFileHeader failed\n" ); + ok( emh.dSignature == ENHMETA_SIGNATURE, "bad metafile signature %x\n", emh.dSignature ); + + bits = HeapAlloc( GetProcessHeap(), 0, emh.nBytes ); + if(!bits) + { + skip( "not enough memory for EMF bits\n" ); + return; + } + ret = GetEnhMetaFileBits( hMetafile, emh.nBytes, bits ); + ok( ret != 0, "GetEnhMetaFileBits error %d\n", GetLastError() ); + for(i = 0; i < emh.nBytes; i++) + todo_wine ok( bits[i] == 0xff, "unexpected EMF bits: got %02x, expected 0xff\n", bits[i] ); + + EnumEnhMetaFile(0, hMetafile, test_BitBlt_record, &i, NULL); + todo_wine ok( i == 2, "too many/not enough BitBlt records: got %d, expected 2\n", i ); + + SelectObject(hdcBitmap, hOldBitmap); + DeleteObject(hBitmap); + DeleteDC(hdcBitmap); +} + static void test_mf_SaveDC(void) { HDC hdcMetafile; @@ -2628,6 +2710,7 @@ START_TEST(metafile) /* For enhanced metafiles (enhmfdrv) */ test_ExtTextOut(); test_SaveDC(); + test_emf_BitBlt();
/* For win-format metafiles (mfdrv) */ test_mf_SaveDC();