Alexandre Julliard : gdi32: Fix GetClipBox return value for non-memory DCs.
Alexandre Julliard
julliard at winehq.org
Mon Apr 9 13:09:15 CDT 2012
Module: wine
Branch: master
Commit: 1ca6ed774835187d14a4b536812bb9fb38e57ac0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1ca6ed774835187d14a4b536812bb9fb38e57ac0
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Apr 9 15:13:31 2012 +0200
gdi32: Fix GetClipBox return value for non-memory DCs.
---
dlls/gdi32/clipping.c | 6 +++++-
dlls/gdi32/tests/dc.c | 23 +++++++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/gdi32/clipping.c b/dlls/gdi32/clipping.c
index ef2dc12..c413e1a 100644
--- a/dlls/gdi32/clipping.c
+++ b/dlls/gdi32/clipping.c
@@ -409,7 +409,11 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect )
if (get_dc_visrect( dc, &visrect ) && !intersect_rect( rect, rect, &visrect ))
ret = NULLREGION;
}
- else ret = get_dc_visrect( dc, rect ) ? SIMPLEREGION : NULLREGION;
+ else
+ {
+ ret = is_rect_empty( &dc->vis_rect ) ? ERROR : SIMPLEREGION;
+ *rect = dc->vis_rect;
+ }
if (dc->layout & LAYOUT_RTL)
{
diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index d8276f4..da2c31b 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -345,6 +345,8 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
unsigned int i;
WORD ramp[3][256];
BOOL ret;
+ RECT clip;
+ UINT type;
if (GetObjectType( hdc ) == OBJ_METADC)
{
@@ -358,6 +360,8 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
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 );
+ type = GetClipBox( hdc, &clip );
+ ok( type == ERROR, "GetClipBox returned %d on %s\n", type, descr );
}
else
{
@@ -371,8 +375,17 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
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 );
+ type = GetClipBox( hdc, &clip );
+ ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
}
+ type = GetClipBox( ref_dc, &clip );
+ ok( type == SIMPLEREGION, "GetClipBox returned %d on %s\n", type, descr );
+ ok( clip.left == 0 && clip.top == 0 &&
+ clip.right == GetDeviceCaps( ref_dc, DESKTOPHORZRES ) &&
+ clip.bottom == GetDeviceCaps( ref_dc, DESKTOPVERTRES ),
+ "GetClipBox returned %d,%d,%d,%d on %s\n", clip.left, clip.top, clip.right, clip.bottom, descr );
+
if (GetObjectType( hdc ) == OBJ_MEMDC)
{
char buffer[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
@@ -400,6 +413,12 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef), /* nt4 */
"wrong error %u on %s\n", GetLastError(), descr );
+ type = GetClipBox( hdc, &clip );
+ ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
+ ok( clip.left == 0 && clip.top == 0 && clip.right == 16 && clip.bottom == 16,
+ "GetClipBox returned %d,%d,%d,%d on memdc for %s\n",
+ clip.left, clip.top, clip.right, clip.bottom, descr );
+
SelectObject( hdc, old );
DeleteObject( dib );
}
@@ -412,7 +431,7 @@ static void test_CreateCompatibleDC(void)
HBITMAP bitmap;
INT caps;
- screen_dc = GetDC( 0 );
+ screen_dc = CreateDC( "DISPLAY", NULL, NULL, NULL );
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
/* Create a DC compatible with the screen */
@@ -456,7 +475,7 @@ static void test_CreateCompatibleDC(void)
DeleteMetaFile( CloseMetaFile( hdcMetafile ));
DeleteObject( bitmap );
- ReleaseDC( 0, screen_dc );
+ DeleteDC( screen_dc );
}
static void test_DC_bitmap(void)
More information about the wine-cvs
mailing list