[GDI32_WINETEST]

* Sync with Wine 1.5.26.

svn path=/trunk/; revision=58518
This commit is contained in:
Amine Khaldi 2013-03-16 15:01:33 +00:00
parent 05a927e9e3
commit 0b0a413710
10 changed files with 1363 additions and 144 deletions

View file

@ -1,7 +1,7 @@
add_definitions(
-D__ROS_LONG64__
-D_DLL -D__USE_CRTIMP)
-D__WINESRC__)
remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502)
@ -22,9 +22,7 @@ list(APPEND SOURCE
pen.c
testlist.c)
add_executable(gdi32_winetest
${SOURCE}
resource.rc)
add_executable(gdi32_winetest ${SOURCE} resource.rc)
if(NOT MSVC)
# FIXME: http://www.cmake.org/Bug/view.php?id=12998

View file

@ -339,16 +339,18 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
ok(ret == 0, "%d != 0\n", ret);
}
#define test_color(hdc, color, exp) \
{ \
COLORREF c; \
c = SetPixel(hdc, 0, 0, color); \
ok(c == exp, "SetPixel failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \
c = GetPixel(hdc, 0, 0); \
ok(c == exp, "GetPixel failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \
c = GetNearestColor(hdc, color); \
ok(c == exp, "GetNearestColor failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \
static void _test_color( int line, HDC hdc, COLORREF color, COLORREF exp )
{
COLORREF c;
c = SetPixel(hdc, 0, 0, color);
ok_(__FILE__, line)(c == exp, "SetPixel failed: got 0x%06x expected 0x%06x\n", c, exp);
c = GetPixel(hdc, 0, 0);
ok_(__FILE__, line)(c == exp, "GetPixel failed: got 0x%06x expected 0x%06x\n", c, exp);
c = GetNearestColor(hdc, color);
ok_(__FILE__, line)(c == exp, "GetNearestColor failed: got 0x%06x expected 0x%06x\n", c, exp);
}
#define test_color(hdc, color, exp) _test_color( __LINE__, hdc, color, exp )
static void test_dib_bits_access( HBITMAP hdib, void *bits )
{
@ -892,7 +894,7 @@ static void test_dib_formats(void)
memset( data, 0xaa, sizeof(data) );
#if 0 // FIXME: ReactOS Bug 6527
#if 0 // FIXME: CORE-5922
for (bpp = 0; bpp <= 64; bpp++)
{
for (planes = 0; planes <= 64; planes++)
@ -1516,6 +1518,189 @@ static void test_bitmap(void)
DeleteDC(hdc);
}
static COLORREF get_nearest( int r, int g, int b )
{
return (r*r + g*g + b*b < (255-r)*(255-r) + (255-g)*(255-g) + (255-b)*(255-b)) ? 0x000000 : 0xffffff;
}
static int is_black_pen( COLORREF fg, COLORREF bg, int r, int g, int b )
{
if (fg == 0 || bg == 0xffffff) return RGB(r,g,b) != 0xffffff && RGB(r,g,b) != bg;
return RGB(r,g,b) == 0x000000 || RGB(r,g,b) == bg;
}
static void test_bitmap_colors( HDC hdc, COLORREF fg, COLORREF bg, int r, int g, int b )
{
static const WORD pattern_bits[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
BITMAPINFO *info;
RGBQUAD *colors;
WORD bits[16];
void *bits_ptr;
COLORREF res;
HBRUSH old_brush;
HPEN old_pen;
HBITMAP bitmap;
HDC memdc;
res = SetPixel( hdc, 0, 0, RGB(r,g,b) );
ok( res == get_nearest( r, g, b ),
"wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
res = GetPixel( hdc, 0, 0 );
ok( res == get_nearest( r, g, b ),
"wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
res = GetNearestColor( hdc, RGB(r,g,b) );
ok( res == get_nearest( r, g, b ),
"wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
/* solid pen */
old_pen = SelectObject( hdc, CreatePen( PS_SOLID, 1, RGB(r,g,b) ));
MoveToEx( hdc, 0, 0, NULL );
LineTo( hdc, 16, 0 );
res = GetPixel( hdc, 0, 0 );
ok( res == (is_black_pen( fg, bg, r, g, b ) ? 0 : 0xffffff),
"wrong result %06x for %02x,%02x,%02x fg %06x bg %06x\n", res, r, g, b, fg, bg );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == (is_black_pen( fg, bg, r, g, b ) ? 0x00 : 0xffff),
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
DeleteObject( SelectObject( hdc, old_pen ));
/* mono DDB pattern brush */
bitmap = CreateBitmap( 16, 8, 1, 1, pattern_bits );
old_brush = SelectObject( hdc, CreatePatternBrush( bitmap ));
PatBlt( hdc, 0, 0, 16, 16, PATCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0x5555,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
DeleteObject( SelectObject( hdc, old_brush ));
/* mono DDB bitmap */
memdc = CreateCompatibleDC( hdc );
SelectObject( memdc, bitmap );
BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0x5555,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
SetTextColor( memdc, RGB(255,255,255) );
SetBkColor( memdc, RGB(0,0,0) );
BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0x5555,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
/* mono DIB section */
info = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET( BITMAPINFO, bmiColors[256] ) );
colors = info->bmiColors;
info->bmiHeader.biSize = sizeof(info->bmiHeader);
info->bmiHeader.biHeight = -16;
info->bmiHeader.biWidth = 16;
info->bmiHeader.biBitCount = 1;
info->bmiHeader.biPlanes = 1;
info->bmiHeader.biCompression = BI_RGB;
colors[0].rgbRed = 0xff;
colors[0].rgbGreen = 0xff;
colors[0].rgbBlue = 0xf0;
colors[1].rgbRed = 0x20;
colors[1].rgbGreen = 0x0;
colors[1].rgbBlue = 0x0;
bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, &bits_ptr, NULL, 0 );
memset( bits_ptr, 0x55, 64 );
DeleteObject( SelectObject( memdc, bitmap ));
BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0x5555,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
colors[0].rgbRed = 0x0;
colors[0].rgbGreen = 0x0;
colors[0].rgbBlue = 0x10;
colors[1].rgbRed = 0xff;
colors[1].rgbGreen = 0xf0;
colors[1].rgbBlue = 0xff;
bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, &bits_ptr, NULL, 0 );
memset( bits_ptr, 0x55, 64 );
DeleteObject( SelectObject( memdc, bitmap ));
BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0xaaaa,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
SetTextColor( memdc, RGB(0,20,0) );
SetBkColor( memdc, RGB(240,240,240) );
BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0x5555,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
SetTextColor( memdc, RGB(250,250,250) );
SetBkColor( memdc, RGB(10,10,10) );
BitBlt( hdc, 0, 0, 16, 8, memdc, 0, 0, SRCCOPY );
GetBitmapBits( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(bits), bits );
ok( bits[0] == 0xaaaa,
"wrong bits %04x for %02x,%02x,%02x fg %06x bg %06x\n", bits[0], r, g, b, fg, bg );
DeleteDC( memdc );
DeleteObject( bitmap );
HeapFree( GetProcessHeap(), 0, info );
}
static void test_mono_bitmap(void)
{
static const COLORREF colors[][2] =
{
{ RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff) },
{ RGB(0xff,0xff,0xff), RGB(0x00,0x00,0x00) },
{ RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xfe) },
{ RGB(0x00,0x01,0x00), RGB(0xff,0xff,0xff) },
{ RGB(0x00,0x00,0x00), RGB(0x80,0x80,0x80) },
{ RGB(0x80,0x80,0x80), RGB(0xff,0xff,0xff) },
{ RGB(0x30,0x40,0x50), RGB(0x60,0x70,0x80) },
{ RGB(0xa0,0xa0,0xa0), RGB(0x20,0x30,0x10) },
{ PALETTEINDEX(0), PALETTEINDEX(255) },
{ PALETTEINDEX(1), PALETTEINDEX(2) },
};
HBITMAP hbmp;
HDC hdc;
DWORD col;
int i, r, g, b;
if (!winetest_interactive)
{
skip("test_mono_bitmap skipped, CORE-5922\n");
return;
}
hdc = CreateCompatibleDC(0);
assert(hdc != 0);
hbmp = CreateBitmap(16, 16, 1, 1, NULL);
assert(hbmp != NULL);
SelectObject( hdc, hbmp );
for (col = 0; col < sizeof(colors) / sizeof(colors[0]); col++)
{
SetTextColor( hdc, colors[col][0] );
SetBkColor( hdc, colors[col][1] );
for (i = 0; i < 256; i++)
{
HPALETTE pal = GetCurrentObject( hdc, OBJ_PAL );
PALETTEENTRY ent;
if (!GetPaletteEntries( pal, i, 1, &ent )) GetPaletteEntries( pal, 0, 1, &ent );
test_color( hdc, PALETTEINDEX(i), get_nearest( ent.peRed, ent.peGreen, ent.peBlue ));
test_color( hdc, DIBINDEX(i), (i == 1) ? 0xffffff : 0x000000 );
}
for (r = 0; r < 256; r += 15)
for (g = 0; g < 256; g += 15)
for (b = 0; b < 256; b += 15)
test_bitmap_colors( hdc, colors[col][0], colors[col][1], r, g, b );
}
DeleteDC(hdc);
DeleteObject(hbmp);
}
static void test_bmBits(void)
{
BYTE bits[4];
@ -3176,12 +3361,13 @@ static void check_StretchDIBits_pixel(HDC hdcDst, UINT32 *dstBuffer, UINT32 *src
dwRop, expected, *dstBuffer, line);
}
static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer,
static INT check_StretchDIBits_stretch( HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer,
int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest,
int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc,
UINT32 expected[4], int line)
{
BITMAPINFO bitmapInfo;
INT ret;
memset(&bitmapInfo, 0, sizeof(BITMAPINFO));
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@ -3192,9 +3378,9 @@ static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *s
bitmapInfo.bmiHeader.biCompression = BI_RGB;
memset(dstBuffer, 0, 16);
StretchDIBits(hdcDst, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
srcBuffer, &bitmapInfo, DIB_RGB_COLORS, SRCCOPY);
ret = StretchDIBits(hdcDst, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
srcBuffer, &bitmapInfo, DIB_RGB_COLORS, SRCCOPY);
ok(memcmp(dstBuffer, expected, 16) == 0,
"StretchDIBits expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X } "
"stretching { %d, %d, %d, %d } to { %d, %d, %d, %d } from line %d\n",
@ -3202,6 +3388,7 @@ static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *s
dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3],
nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, line);
return ret;
}
static void test_StretchDIBits(void)
@ -3213,6 +3400,7 @@ static void test_StretchDIBits(void)
HBRUSH hBrush, hOldBrush;
BITMAPINFO biDst;
UINT32 expected[4];
INT ret;
memset(&biDst, 0, sizeof(BITMAPINFO));
biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@ -3258,43 +3446,63 @@ static void test_StretchDIBits(void)
expected[0] = 0xCAFED00D, expected[1] = 0xFEEDFACE;
expected[2] = 0xFEDCBA98, expected[3] = 0x76543210;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 0, 0, 2, 2, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0xCAFED00D, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 1, 1, 0, 0, 1, 1, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 1, 1, 0, 0, 1, 1, expected, __LINE__);
todo_wine ok( ret == 1, "got ret %d\n", ret );
expected[0] = 0xFEDCBA98, expected[1] = 0xFEDCBA98;
expected[2] = 0xFEDCBA98, expected[3] = 0xFEDCBA98;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 0, 0, 1, 1, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 0, 0, 1, 1, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x42441000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 1, 1, 0, 0, 2, 2, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 1, 1, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__);
ok( ret == 0, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__);
ok( ret == 0, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
1, 1, -2, -2, 1, 1, -2, -2, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
1, 1, -2, -2, 1, 1, -2, -2, expected, __LINE__);
ok( ret == 0, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0xCAFED00D;
check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
1, 1, 2, 2, 0, 0, 2, 2, expected, __LINE__);
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
1, 1, 2, 2, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
2, 2, 4, 4, 0, 0, 2, 2, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
expected[0] = 0x00000000, expected[1] = 0x00000000;
expected[2] = 0x00000000, expected[3] = 0x00000000;
ret = check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
-4, -4, 4, 4, 0, 0, 4, 4, expected, __LINE__);
ok( ret == 2, "got ret %d\n", ret );
SelectObject(hdcDst, oldDst);
DeleteObject(bmpDst);
@ -3323,7 +3531,6 @@ static void test_GdiAlphaBlend(void)
HDC hdcNull;
HDC hdcDst;
HBITMAP bmpDst;
HBITMAP oldDst;
BITMAPINFO *bmi;
HDC hdcSrc;
HBITMAP bmpSrc;
@ -3353,7 +3560,7 @@ static void test_GdiAlphaBlend(void)
bmpSrc = CreateDIBSection(hdcDst, bmi, DIB_RGB_COLORS, &bits, NULL, 0);
ok(bmpSrc != NULL, "Couldn't create source bitmap\n");
oldDst = SelectObject(hdcDst, bmpDst);
SelectObject(hdcDst, bmpDst);
oldSrc = SelectObject(hdcSrc, bmpSrc);
blend.BlendOp = AC_SRC_OVER;
@ -3399,6 +3606,7 @@ static void test_GdiAlphaBlend(void)
SetViewportExtEx(hdcDst, -1, -1, NULL);
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 50, 50, blend);
todo_wine
ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() );
SetLastError(0xdeadbeef);
ret = pGdiAlphaBlend(hdcDst, -20, -20, 20, 20, hdcSrc, 0, -1, 50, 50, blend);
@ -3535,15 +3743,13 @@ static void test_GdiAlphaBlend(void)
ok( !ret, "GdiAlphaBlend succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SelectObject(hdcDst, oldDst);
SelectObject(hdcSrc, oldSrc);
DeleteObject(bmpSrc);
DeleteObject(bmpDst);
DeleteDC(hdcDst);
DeleteDC(hdcSrc);
DeleteObject(bmpSrc);
DeleteObject(bmpDst);
ReleaseDC(NULL, hdcNull);
HeapFree(GetProcessHeap(), 0, bmi);
}
static void test_GdiGradientFill(void)
@ -3656,6 +3862,7 @@ static void test_GdiGradientFill(void)
DeleteDC( hdc );
DeleteObject( bmp );
HeapFree(GetProcessHeap(), 0, bmi);
}
static void test_clipping(void)
@ -5388,6 +5595,7 @@ START_TEST(bitmap)
test_dib_formats();
test_mono_dibsection();
test_bitmap();
test_mono_bitmap();
test_bmBits();
test_GetDIBits_selected_DIB(1);
test_GetDIBits_selected_DIB(4);

View file

@ -401,6 +401,14 @@ static void test_memory_dc_clipping(void)
ok(rc.left == 0 && rc.top == 0 && rc.right == 100 && rc.bottom == 100,
"expected 0,0-100,100, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
SetRect( &rc, 10, 10, 20, 20 );
ret = RectVisible( hdc, &rc );
ok( ret, "RectVisible failed for %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom );
SetRect( &rc, 20, 20, 10, 10 );
ret = RectVisible( hdc, &rc );
ok( ret, "RectVisible failed for %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom );
DeleteDC(hdc);
DeleteObject(hrgn);
DeleteObject(hrgn_empty);
@ -446,6 +454,14 @@ static void test_window_dc_clipping(void)
"expected 0,0-%d,%d, got %d,%d-%d,%d\n", screen_width, screen_height,
rc.left, rc.top, rc.right, rc.bottom);
SetRect( &rc, 10, 10, 20, 20 );
ret = RectVisible( hdc, &rc );
ok( ret, "RectVisible failed for %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom );
SetRect( &rc, 20, 20, 10, 10 );
ret = RectVisible( hdc, &rc );
ok( ret, "RectVisible failed for %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom );
ret = ExtSelectClipRgn(hdc, 0, RGN_COPY);
ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1),
"expected SIMPLEREGION, got %d\n", ret);

View file

@ -19,7 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define WINVER 0x0501 /* request latest DEVMODE */
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
#include <assert.h>
#include <stdio.h>
@ -31,6 +34,10 @@
#include "winspool.h"
#include "winerror.h"
#ifndef LAYOUT_LTR
#define LAYOUT_LTR 0
#endif
static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
static void dump_region(HRGN hrgn)
@ -58,6 +65,7 @@ static void test_dc_values(void)
{
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
COLORREF color;
int extra;
ok( hdc != NULL, "CreateDC failed\n" );
color = SetBkColor( hdc, 0x12345678 );
@ -86,6 +94,18 @@ static void test_dc_values(void)
color = GetTextColor( hdc );
ok( color == 0, "wrong color %08x\n", color );
extra = GetTextCharacterExtra( hdc );
ok( extra == 0, "initial extra %d\n", extra );
SetTextCharacterExtra( hdc, 123 );
extra = GetTextCharacterExtra( hdc );
ok( extra == 123, "initial extra %d\n", extra );
SetMapMode( hdc, MM_LOMETRIC );
extra = GetTextCharacterExtra( hdc );
ok( extra == 123, "initial extra %d\n", extra );
SetMapMode( hdc, MM_TEXT );
extra = GetTextCharacterExtra( hdc );
ok( extra == 123, "initial extra %d\n", extra );
DeleteDC( hdc );
}
@ -124,10 +144,7 @@ static void test_savedc_2(void)
rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
ret = SaveDC(hdc);
todo_wine
{
ok(ret == 1, "ret = %d\n", ret);
}
ret = IntersectClipRect(hdc, 0, 0, 50, 50);
if (ret == COMPLEXREGION)
@ -298,7 +315,7 @@ static void test_GdiConvertToDevmodeW(void)
HeapFree(GetProcessHeap(), 0, dmW);
}
static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale )
{
static const int caps[] =
{
@ -374,27 +391,59 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
else
{
for (i = 0; i < sizeof(caps)/sizeof(caps[0]); i++)
ok( GetDeviceCaps( hdc, caps[i] ) == GetDeviceCaps( ref_dc, caps[i] ),
"mismatched caps on %s for %u: %u/%u\n", descr, caps[i],
GetDeviceCaps( hdc, caps[i] ), GetDeviceCaps( ref_dc, caps[i] ) );
{
INT precision = 0;
INT hdc_caps = GetDeviceCaps( hdc, caps[i] );
switch (caps[i])
{
case HORZSIZE:
case VERTSIZE:
hdc_caps /= scale;
precision = 1;
break;
case LOGPIXELSX:
case LOGPIXELSY:
hdc_caps *= scale;
break;
}
ok( abs(hdc_caps - GetDeviceCaps( ref_dc, caps[i] )) <= precision,
"mismatched caps on %s for %u: %u/%u (scale %d)\n", descr, caps[i],
hdc_caps, GetDeviceCaps( ref_dc, caps[i] ), scale );
}
SetLastError( 0xdeadbeef );
ret = GetDeviceGammaRamp( hdc, &ramp );
ok( !ret, "GetDeviceGammaRamp succeeded on %s\n", descr );
ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef), /* nt4 */
"wrong error %u on %s\n", GetLastError(), descr );
if (GetObjectType( hdc ) != OBJ_DC || GetDeviceCaps( hdc, TECHNOLOGY ) == DT_RASPRINTER)
{
ok( !ret, "GetDeviceGammaRamp succeeded on %s (type %d)\n", descr, GetObjectType( hdc ) );
ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef), /* nt4 */
"wrong error %u on %s\n", GetLastError(), descr );
}
else
ok( ret || broken(!ret) /* NT4 */, "GetDeviceGammaRamp failed on %s (type %d), error %u\n", descr, GetObjectType( hdc ), GetLastError() );
type = GetClipBox( hdc, &rect );
if (GetObjectType( hdc ) == OBJ_ENHMETADC)
todo_wine ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
else
ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
type = GetBoundsRect( hdc, &rect, 0 );
ok( type == DCB_RESET || broken(type == DCB_SET) /* XP */,
"GetBoundsRect returned type %x for %s\n", type, descr );
if (type == DCB_RESET)
ok( rect.left == 0 && rect.top == 0 && rect.right == 0 && rect.bottom == 0,
"GetBoundsRect returned %d,%d,%d,%d type %x for %s\n",
rect.left, rect.top, rect.right, rect.bottom, type, descr );
type = SetBoundsRect( hdc, NULL, DCB_RESET | DCB_ENABLE );
ok( type == (DCB_RESET | DCB_DISABLE), "SetBoundsRect returned %x\n", type );
ok( type == (DCB_RESET | DCB_DISABLE) || broken(type == (DCB_SET | DCB_ENABLE)) /* XP */,
"SetBoundsRect returned %x for %s (hdc type %d)\n", type, descr, GetObjectType( hdc ) );
SetMapMode( hdc, MM_TEXT );
Rectangle( hdc, 2, 2, 4, 4 );
type = GetBoundsRect( hdc, &rect, DCB_RESET );
if (GetObjectType( hdc ) == OBJ_ENHMETADC)
if (GetObjectType( hdc ) == OBJ_ENHMETADC || (GetObjectType( hdc ) == OBJ_DC && GetDeviceCaps( hdc, TECHNOLOGY ) == DT_RASPRINTER))
todo_wine
ok( rect.left == 2 && rect.top == 2 && rect.right == 4 && rect.bottom == 4 && type == DCB_SET,
"GetBoundsRect returned %d,%d,%d,%d type %x for %s\n",
@ -406,7 +455,7 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
}
type = GetClipBox( ref_dc, &rect );
if (type != COMPLEXREGION) /* region can be complex on multi-monitor setups */
if (type != COMPLEXREGION && type != ERROR) /* region can be complex on multi-monitor setups */
{
ok( type == SIMPLEREGION, "GetClipBox returned %d on %s\n", type, descr );
ok( rect.left == 0 && rect.top == 0 &&
@ -470,6 +519,10 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
SelectObject( hdc, old );
DeleteObject( dib );
}
/* restore hdc state */
SetBoundsRect( hdc, NULL, DCB_RESET | DCB_DISABLE );
SetBoundsRect( ref_dc, NULL, DCB_RESET | DCB_DISABLE );
}
static void test_CreateCompatibleDC(void)
@ -478,9 +531,21 @@ static void test_CreateCompatibleDC(void)
HDC hdc, hNewDC, hdcMetafile, screen_dc;
HBITMAP bitmap;
INT caps;
DEVMODE dm;
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
bRet = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
ok(bRet, "EnumDisplaySettingsEx failed\n");
dm.u1.s1.dmScale = 200;
dm.dmFields |= DM_SCALE;
hdc = CreateDC( "DISPLAY", NULL, NULL, &dm );
screen_dc = CreateDC( "DISPLAY", NULL, NULL, NULL );
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
test_device_caps( hdc, screen_dc, "display dc", 1 );
ResetDC( hdc, &dm );
test_device_caps( hdc, screen_dc, "display dc", 1 );
DeleteDC( hdc );
/* Create a DC compatible with the screen */
hdc = CreateCompatibleDC(NULL);
@ -489,7 +554,7 @@ static void test_CreateCompatibleDC(void)
caps = GetDeviceCaps( hdc, TECHNOLOGY );
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
test_device_caps( hdc, screen_dc, "display dc" );
test_device_caps( hdc, screen_dc, "display dc", 1 );
/* Delete this DC, this should succeed */
bRet = DeleteDC(hdc);
@ -507,7 +572,9 @@ static void test_CreateCompatibleDC(void)
ok( SelectObject( hNewDC, bitmap ) != 0, "SelectObject failed\n" );
caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
test_device_caps( hdcMetafile, hdc, "enhmetafile dc" );
test_device_caps( hdcMetafile, hdc, "enhmetafile dc", 1 );
ResetDC( hdcMetafile, &dm );
test_device_caps( hdcMetafile, hdc, "enhmetafile dc", 1 );
DeleteDC( hNewDC );
DeleteEnhMetaFile( CloseEnhMetaFile( hdcMetafile ));
ReleaseDC( 0, hdc );
@ -518,7 +585,9 @@ static void test_CreateCompatibleDC(void)
ok(hNewDC == NULL, "CreateCompatibleDC succeeded\n");
caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
ok( caps == DT_METAFILE, "wrong caps %u\n", caps );
test_device_caps( hdcMetafile, screen_dc, "metafile dc" );
test_device_caps( hdcMetafile, screen_dc, "metafile dc", 1 );
ResetDC( hdcMetafile, &dm );
test_device_caps( hdcMetafile, screen_dc, "metafile dc", 1 );
DeleteMetaFile( CloseMetaFile( hdcMetafile ));
DeleteObject( bitmap );
@ -1139,7 +1208,17 @@ done:
ReleaseDC(NULL, hdc);
}
static HDC create_printer_dc(void)
static BOOL is_postscript_printer(HDC hdc)
{
char tech[256];
if (ExtEscape(hdc, GETTECHNOLOGY, 0, NULL, sizeof(tech), tech) > 0)
return strcmp(tech, "PostScript") == 0;
return FALSE;
}
static HDC create_printer_dc(int scale, BOOL reset)
{
char buffer[260];
DWORD len;
@ -1175,9 +1254,15 @@ static HDC create_printer_dc(void)
dbuf = HeapAlloc( GetProcessHeap(), 0, len );
if (!pGetPrinterDriverA( hprn, NULL, 3, (LPBYTE)dbuf, len, &len )) goto done;
pbuf->pDevMode->u1.s1.dmScale = scale;
pbuf->pDevMode->dmFields |= DM_SCALE;
hdc = CreateDCA( dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName, pbuf->pDevMode );
trace( "hdc %p for driver '%s' printer '%s' port '%s'\n", hdc,
dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName );
trace( "hdc %p for driver '%s' printer '%s' port '%s' is %sPostScript\n", hdc,
dbuf->pDriverPath, pbuf->pPrinterName, pbuf->pPortName,
is_postscript_printer(hdc) ? "" : "NOT " );
if (reset) ResetDC( hdc, pbuf->pDevMode );
done:
HeapFree( GetProcessHeap(), 0, dbuf );
HeapFree( GetProcessHeap(), 0, pbuf );
@ -1192,9 +1277,19 @@ static void test_printer_dc(void)
HDC memdc, display_memdc, enhmf_dc;
HBITMAP orig, bmp;
DWORD ret;
HDC hdc = create_printer_dc();
HDC hdc, hdc_200;
if (!hdc) return;
hdc = create_printer_dc(100, FALSE);
hdc_200 = create_printer_dc(200, FALSE);
if (!hdc || !hdc_200) return;
test_device_caps( hdc, hdc_200, "printer dc", is_postscript_printer(hdc) ? 2 : 1 );
DeleteDC( hdc_200 );
hdc_200 = create_printer_dc(200, TRUE);
test_device_caps( hdc, hdc_200, "printer dc", is_postscript_printer(hdc) ? 2 : 1 );
DeleteDC( hdc_200 );
memdc = CreateCompatibleDC( hdc );
display_memdc = CreateCompatibleDC( 0 );
@ -1216,7 +1311,7 @@ static void test_printer_dc(void)
ok( orig != NULL, "SelectObject failed\n" );
ok( BitBlt( hdc, 10, 10, 20, 20, memdc, 0, 0, SRCCOPY ), "BitBlt failed\n" );
test_device_caps( memdc, hdc, "printer dc" );
test_device_caps( memdc, hdc, "printer dc", 1 );
ok( !SelectObject( display_memdc, bmp ), "SelectObject succeeded\n" );
SelectObject( memdc, orig );
@ -1235,7 +1330,12 @@ static void test_printer_dc(void)
enhmf_dc = CreateEnhMetaFileA( hdc, NULL, NULL, NULL );
ok(enhmf_dc != 0, "CreateEnhMetaFileA failed\n");
test_device_caps( enhmf_dc, hdc, "enhmetafile printer dc" );
test_device_caps( enhmf_dc, hdc, "enhmetafile printer dc", 1 );
DeleteEnhMetaFile( CloseEnhMetaFile( enhmf_dc ));
enhmf_dc = CreateEnhMetaFileA( hdc, NULL, NULL, NULL );
ok(enhmf_dc != 0, "CreateEnhMetaFileA failed\n");
test_device_caps( enhmf_dc, hdc, "enhmetafile printer dc", 1 );
DeleteEnhMetaFile( CloseEnhMetaFile( enhmf_dc ));
DeleteDC( memdc );

View file

@ -1312,6 +1312,7 @@ static void compare_hash_broken_todo(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const
if(current_sha1[i] == NULL)
{
ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash);
HeapFree(GetProcessHeap(), 0, hash);
return;
}
}
@ -1908,6 +1909,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits)
DeleteObject(bmp);
SelectObject(hdc, orig_brush);
DeleteObject( dib_brush );
SetBrushOrgEx(hdc, 0, 0, NULL);
SetTextColor(hdc, old_text);
SetBkColor(hdc, old_bkgnd);
@ -2660,7 +2662,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits)
SelectObject(hdc, orig_brush);
SelectObject(hdc, orig_pen);
DeleteObject(dib_brush);
DeleteObject(solid_brush);
DeleteObject(wide_pen);
DeleteObject(dashed_pen);

File diff suppressed because it is too large Load diff

View file

@ -319,10 +319,54 @@ static void test_region(void)
DeleteObject(hrgn);
}
static void test_handles_on_win64(void)
{
int i;
BOOL ret;
DWORD type;
HRGN hrgn, hrgn_test;
static const struct
{
ULONG high;
ULONG low;
BOOL ret;
} cases[] =
{
{ 0x00000000, 0x00000000, TRUE },
{ 0x00000000, 0x0000ffe0, FALSE }, /* just over MAX_LARGE_HANDLES */
{ 0x00000000, 0x0000ffb0, FALSE }, /* just under MAX_LARGE_HANDLES */
{ 0xffffffff, 0xffff0000, FALSE },
{ 0xffffffff, 0x00000000, TRUE },
{ 0xdeadbeef, 0x00000000, TRUE },
{ 0xcccccccc, 0xcccccccc, FALSE }
};
if (sizeof(void*) != 8)
return;
for (i = 0; i < sizeof(cases)/sizeof(cases[0]); i++)
{
hrgn = CreateRectRgn(10, 10, 20, 20);
hrgn_test = (HRGN)(ULONG_PTR)((ULONG_PTR)hrgn | ((ULONGLONG)cases[i].high << 32) | cases[i].low);
type = GetObjectType( hrgn_test );
if (cases[i].ret)
ok( type == OBJ_REGION, "wrong type %u\n", type );
else
ok( type == 0, "wrong type %u\n", type );
ret = DeleteObject(hrgn_test);
ok( cases[i].ret == ret, "DeleteObject should return %s (%p)\n",
cases[i].ret ? "TRUE" : "FALSE", hrgn_test);
/* actually free it if above is expected to fail */
if (!ret) DeleteObject(hrgn);
}
}
START_TEST(gdiobj)
{
test_gdi_objects();
test_thread_objects();
test_GetCurrentObject();
test_region();
test_handles_on_win64();
}

View file

@ -60,6 +60,20 @@ static void init_function_pointers(void)
GDI_GET_PROC(SetDCPenColor);
}
static DWORD rgn_rect_count(HRGN hrgn)
{
DWORD size;
RGNDATA *data;
if (!hrgn) return 0;
if (!(size = GetRegionData(hrgn, 0, NULL))) return 0;
if (!(data = HeapAlloc(GetProcessHeap(), 0, size))) return 0;
GetRegionData(hrgn, size, data);
size = data->rdh.nCount;
HeapFree(GetProcessHeap(), 0, data);
return size;
}
static int CALLBACK eto_emf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
const ENHMETARECORD *emr, int n_objs, LPARAM param)
{
@ -2483,19 +2497,183 @@ static void test_emf_clipping(void)
SetRect(&rc_sclip, 100, 100, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
hrgn = CreateRectRgn(rc_sclip.left, rc_sclip.top, rc_sclip.right, rc_sclip.bottom);
SelectClipRgn(hdc, hrgn);
SetRect(&rc_res, -1, -1, -1, -1);
ret = GetClipBox(hdc, &rc_res);
todo_wine
ok(ret == SIMPLEREGION, "got %d\n", ret);
if(ret == SIMPLEREGION)
ok(EqualRect(&rc_res, &rc_sclip),
"expected rc_res (%d, %d) - (%d, %d), got (%d, %d) - (%d, %d)\n",
rc_sclip.left, rc_sclip.top, rc_sclip.right, rc_sclip.bottom,
rc_res.left, rc_res.top, rc_res.right, rc_res.bottom);
ok(EqualRect(&rc_res, &rc_sclip),
"expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
rc_sclip.left, rc_sclip.top, rc_sclip.right, rc_sclip.bottom,
rc_res.left, rc_res.top, rc_res.right, rc_res.bottom);
OffsetRect(&rc_sclip, -100, -100);
ret = OffsetClipRgn(hdc, -100, -100);
ok(ret == SIMPLEREGION, "got %d\n", ret);
SetRect(&rc_res, -1, -1, -1, -1);
ret = GetClipBox(hdc, &rc_res);
ok(ret == SIMPLEREGION, "got %d\n", ret);
ok(EqualRect(&rc_res, &rc_sclip),
"expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
rc_sclip.left, rc_sclip.top, rc_sclip.right, rc_sclip.bottom,
rc_res.left, rc_res.top, rc_res.right, rc_res.bottom);
ret = IntersectClipRect(hdc, 0, 0, 100, 100);
ok(ret == SIMPLEREGION || broken(ret == COMPLEXREGION) /* XP */, "got %d\n", ret);
if (ret == COMPLEXREGION)
{
/* XP returns COMPLEXREGION although region contains only 1 rect */
ret = GetClipRgn(hdc, hrgn);
ok(ret == 1, "expected 1, got %d\n", ret);
ret = rgn_rect_count(hrgn);
ok(ret == 1, "expected 1, got %d\n", ret);
}
SetRect(&rc_res, -1, -1, -1, -1);
ret = GetClipBox(hdc, &rc_res);
ok(ret == SIMPLEREGION, "got %d\n", ret);
ok(EqualRect(&rc_res, &rc),
"expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
rc.left, rc.top, rc.right, rc.bottom,
rc_res.left, rc_res.top, rc_res.right, rc_res.bottom);
SetRect(&rc_sclip, 0, 0, 100, 50);
ret = ExcludeClipRect(hdc, 0, 50, 100, 100);
ok(ret == SIMPLEREGION || broken(ret == COMPLEXREGION) /* XP */, "got %d\n", ret);
if (ret == COMPLEXREGION)
{
/* XP returns COMPLEXREGION although region contains only 1 rect */
ret = GetClipRgn(hdc, hrgn);
ok(ret == 1, "expected 1, got %d\n", ret);
ret = rgn_rect_count(hrgn);
ok(ret == 1, "expected 1, got %d\n", ret);
}
SetRect(&rc_res, -1, -1, -1, -1);
ret = GetClipBox(hdc, &rc_res);
ok(ret == SIMPLEREGION, "got %d\n", ret);
ok(EqualRect(&rc_res, &rc_sclip),
"expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
rc_sclip.left, rc_sclip.top, rc_sclip.right, rc_sclip.bottom,
rc_res.left, rc_res.top, rc_res.right, rc_res.bottom);
hemf = CloseEnhMetaFile(hdc);
DeleteEnhMetaFile(hemf);
DeleteObject(hrgn);
DeleteDC(hdc);
}
static const unsigned char MF_CLIP_BITS[] = {
/* METAHEADER */
0x01, 0x00, /* mtType */
0x09, 0x00, /* mtHeaderSize */
0x00, 0x03, /* mtVersion */
0x32, 0x00, 0x00, 0x00, /* mtSize */
0x01, 0x00, /* mtNoObjects */
0x14, 0x00, 0x00, 0x00, /* mtMaxRecord (size in words of longest record) */
0x00, 0x00, /* reserved */
/* METARECORD for CreateRectRgn(0x11, 0x22, 0x33, 0x44) */
0x14, 0x00, 0x00, 0x00, /* rdSize in words */
0xff, 0x06, /* META_CREATEREGION */
0x00, 0x00, 0x06, 0x00, 0xf6, 0x02, 0x00, 0x00,
0x24, 0x00, 0x01, 0x00, 0x02, 0x00, 0x11, 0x00,
0x22, 0x00, 0x33, 0x00, 0x44, 0x00, 0x02, 0x00,
0x22, 0x00, 0x44, 0x00, 0x11, 0x00, 0x33, 0x00,
0x02, 0x00,
/* METARECORD for SelectObject */
0x04, 0x00, 0x00, 0x00,
0x2d, 0x01, /* META_SELECTOBJECT (not META_SELECTCLIPREGION?!) */
0x00, 0x00,
/* METARECORD */
0x04, 0x00, 0x00, 0x00,
0xf0, 0x01, /* META_DELETEOBJECT */
0x00, 0x00,
/* METARECORD for MoveTo(1,0x30) */
0x05, 0x00, 0x00, 0x00, /* rdSize in words */
0x14, 0x02, /* META_MOVETO */
0x30, 0x00, /* y */
0x01, 0x00, /* x */
/* METARECORD for LineTo(0x20, 0x30) */
0x05, 0x00, 0x00, 0x00, /* rdSize in words */
0x13, 0x02, /* META_LINETO */
0x30, 0x00, /* y */
0x20, 0x00, /* x */
/* EOF */
0x03, 0x00, 0x00, 0x00,
0x00, 0x00
};
static int clip_mf_enum_proc_seen_selectclipregion;
static int clip_mf_enum_proc_seen_selectobject;
static int CALLBACK clip_mf_enum_proc(HDC hdc, HANDLETABLE *handle_table,
METARECORD *mr, int n_objs, LPARAM param)
{
switch (mr->rdFunction) {
case META_SELECTCLIPREGION:
clip_mf_enum_proc_seen_selectclipregion++;
break;
case META_SELECTOBJECT:
clip_mf_enum_proc_seen_selectobject++;
break;
}
return 1;
}
static void test_mf_clipping(void)
{
/* left top right bottom */
static RECT rc_clip = { 0x11, 0x22, 0x33, 0x44 };
HWND hwnd;
HDC hdc;
HMETAFILE hmf;
HRGN hrgn;
INT ret;
SetLastError(0xdeadbeef);
hdc = CreateMetaFileA(NULL);
ok(hdc != 0, "CreateMetaFileA error %d\n", GetLastError());
hrgn = CreateRectRgn(rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
ret = SelectClipRgn(hdc, hrgn);
/* Seems like it should be SIMPLEREGION, but windows returns NULLREGION? */
ok(ret == NULLREGION, "expected NULLREGION, got %d\n", ret);
/* Draw a line that starts off left of the clip region and ends inside it */
MoveToEx(hdc, 0x1, 0x30, NULL);
LineTo(hdc, 0x20, 0x30);
SetLastError(0xdeadbeef);
hmf = CloseMetaFile(hdc);
ok(hmf != 0, "CloseMetaFile error %d\n", GetLastError());
if (compare_mf_bits(hmf, MF_CLIP_BITS, sizeof(MF_CLIP_BITS),
"mf_clipping") != 0)
{
dump_mf_bits(hmf, "mf_clipping");
}
DeleteObject(hrgn);
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
0, 0, 200, 200, 0, 0, 0, NULL);
ok(hwnd != 0, "CreateWindowExA error %d\n", GetLastError());
hdc = GetDC(hwnd);
ret = EnumMetaFile(hdc, hmf, clip_mf_enum_proc, (LPARAM)&rc_clip);
ok(ret, "EnumMetaFile error %d\n", GetLastError());
/* Oddly, windows doesn't seem to use META_SELECTCLIPREGION */
ok(clip_mf_enum_proc_seen_selectclipregion == 0,
"expected 0 selectclipregion, saw %d\n", clip_mf_enum_proc_seen_selectclipregion);
ok(clip_mf_enum_proc_seen_selectobject == 1,
"expected 1 selectobject, saw %d\n", clip_mf_enum_proc_seen_selectobject);
DeleteMetaFile(hmf);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
}
static INT CALLBACK EmfEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData)
@ -3211,6 +3389,9 @@ START_TEST(metafile)
test_SaveDC();
test_emf_BitBlt();
test_emf_DCBrush();
test_emf_ExtTextOut_on_path();
test_emf_clipping();
test_emf_polybezier();
/* For win-format metafiles (mfdrv) */
test_mf_SaveDC();
@ -3221,9 +3402,7 @@ START_TEST(metafile)
test_CopyMetaFile();
test_SetMetaFileBits();
test_mf_ExtTextOut_on_path();
test_emf_ExtTextOut_on_path();
test_emf_clipping();
test_emf_polybezier();
test_mf_clipping();
/* For metafile conversions */
test_mf_conversions();

View file

@ -20,7 +20,7 @@ OS2Version: 2
OS2_WeightWidthSlopeOnly: 0
OS2_UseTypoMetrics: 1
CreationTime: 1288336343
ModificationTime: 1288336873
ModificationTime: 1352483620
PfmFamily: 17
TTFWeight: 500
TTFWidth: 5
@ -86,7 +86,7 @@ DisplaySize: -24
AntiAlias: 1
FitToEm: 1
WinInfo: 65 65 19
BeginChars: 65539 4
BeginChars: 65539 5
StartChar: .notdef
Encoding: 65536 -1 0
@ -176,5 +176,30 @@ Width: 0
Flags: W
LayerCount: 2
EndChar
StartChar: dieresis
Encoding: 168 168 0
Width: 1000
VWidth: 0
Flags: HW
LayerCount: 2
Fore
SplineSet
620.215 824.429 m 1,0,1
760.84 777.554 760.84 777.554 713.965 636.929 c 1,2,-1
620.215 824.429 l 1,0,1
154.883 324.971 m 0,3,-1
254.492 773.213 m 1,4,5
310.707 834.805 310.707 834.805 374.609 767.354 c 1,6,7
410.471 728.672 410.471 728.672 374.609 691.182 c 0,8,9
308.375 621.934 308.375 621.934 254.492 688.252 c 0,10,11
216.406 735.127 216.406 735.127 254.492 773.213 c 1,4,5
254.492 773.213 m 1,12,13
216.406 735.127 216.406 735.127 254.492 688.252 c 0,14,15
308.375 621.934 308.375 621.934 374.609 691.182 c 0,16,17
410.471 728.672 410.471 728.672 374.609 767.354 c 1,18,19
310.707 834.805 310.707 834.805 254.492 773.213 c 1,12,13
EndSplineSet
EndChar
EndChars
EndSplineFont