Alexandre Julliard : gdi32: Don't allow CreateCompatibleDC on a metafile DC .
Alexandre Julliard
julliard at winehq.org
Wed Sep 7 12:35:30 CDT 2011
Module: wine
Branch: master
Commit: c331a1a6cd1df3da30da29c56f699e7512e49b1c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c331a1a6cd1df3da30da29c56f699e7512e49b1c
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Sep 7 16:31:19 2011 +0200
gdi32: Don't allow CreateCompatibleDC on a metafile DC.
---
dlls/gdi32/mfdrv/init.c | 13 ++++++++++++-
dlls/gdi32/tests/dc.c | 42 ++++++++++++++++++++++++++++++++++++------
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c
index bb36a85..2139b98 100644
--- a/dlls/gdi32/mfdrv/init.c
+++ b/dlls/gdi32/mfdrv/init.c
@@ -30,6 +30,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(metafile);
+static BOOL MFDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev );
static BOOL MFDRV_DeleteDC( PHYSDEV dev );
@@ -91,7 +92,7 @@ static const DC_FUNCTIONS MFDRV_Funcs =
MFDRV_Chord, /* pChord */
MFDRV_CloseFigure, /* pCloseFigure */
NULL, /* pCreateBitmap */
- NULL, /* pCreateCompatibleDC */
+ MFDRV_CreateCompatibleDC, /* pCreateCompatibleDC */
NULL, /* pCreateDC */
NULL, /* pCreateDIBSection */
NULL, /* pDeleteBitmap */
@@ -247,6 +248,16 @@ static DC *MFDRV_AllocMetaFile(void)
/**********************************************************************
+ * MFDRV_CreateCompatibleDC
+ */
+static BOOL MFDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
+{
+ /* not supported on metafile DCs */
+ return FALSE;
+}
+
+
+/**********************************************************************
* MFDRV_DeleteDC
*/
static BOOL MFDRV_DeleteDC( PHYSDEV dev )
diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index 12a875a..efa7d53 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -265,20 +265,50 @@ static void test_GdiConvertToDevmodeW(void)
static void test_CreateCompatibleDC(void)
{
BOOL bRet;
- HDC hDC;
- HDC hNewDC;
+ HDC hdc, hNewDC, hdcMetafile;
+ HBITMAP bitmap;
+ INT caps;
+
+ bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
/* Create a DC compatible with the screen */
- hDC = CreateCompatibleDC(NULL);
- ok(hDC != NULL, "CreateCompatibleDC returned %p\n", hDC);
+ hdc = CreateCompatibleDC(NULL);
+ ok(hdc != NULL, "CreateCompatibleDC returned %p\n", hdc);
+ ok( SelectObject( hdc, bitmap ) != 0, "SelectObject failed\n" );
+ caps = GetDeviceCaps( hdc, TECHNOLOGY );
+ ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
/* Delete this DC, this should succeed */
- bRet = DeleteDC(hDC);
+ bRet = DeleteDC(hdc);
ok(bRet == TRUE, "DeleteDC returned %u\n", bRet);
/* Try to create a DC compatible to the deleted DC. This has to fail */
- hNewDC = CreateCompatibleDC(hDC);
+ hNewDC = CreateCompatibleDC(hdc);
ok(hNewDC == NULL, "CreateCompatibleDC returned %p\n", hNewDC);
+
+ hdc = GetDC( 0 );
+ hdcMetafile = CreateEnhMetaFileA(hdc, NULL, NULL, NULL);
+ ok(hdcMetafile != 0, "CreateEnhMetaFileA failed\n");
+ hNewDC = CreateCompatibleDC( hdcMetafile );
+ ok(hNewDC != NULL, "CreateCompatibleDC failed\n");
+ ok( SelectObject( hNewDC, bitmap ) != 0, "SelectObject failed\n" );
+ caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
+ ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
+ caps = GetDeviceCaps( hNewDC, TECHNOLOGY );
+ ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
+ DeleteDC( hNewDC );
+ DeleteEnhMetaFile( CloseEnhMetaFile( hdcMetafile ));
+ ReleaseDC( 0, hdc );
+
+ hdcMetafile = CreateMetaFileA(NULL);
+ ok(hdcMetafile != 0, "CreateEnhMetaFileA failed\n");
+ hNewDC = CreateCompatibleDC( hdcMetafile );
+ ok(hNewDC == NULL, "CreateCompatibleDC succeeded\n");
+ caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
+ ok( caps == DT_METAFILE, "wrong caps %u\n", caps );
+ DeleteMetaFile( CloseMetaFile( hdcMetafile ));
+
+ DeleteObject( bitmap );
}
static void test_DC_bitmap(void)
More information about the wine-cvs
mailing list