gdi32: Store the reference DC in the enhanced metafile and use it to retrieve device caps.

This commit is contained in:
Alexandre Julliard 2012-04-10 14:42:50 +02:00
parent 2776a97931
commit 88bcd13d7f
4 changed files with 26 additions and 75 deletions

View File

@ -515,43 +515,5 @@ INT EMFDRV_GetDeviceCaps(PHYSDEV dev, INT cap)
{ {
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev; EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
switch(cap) { return GetDeviceCaps( physDev->ref_dc, cap );
case HORZRES:
return physDev->horzres;
case VERTRES:
return physDev->vertres;
case LOGPIXELSX:
return physDev->logpixelsx;
case LOGPIXELSY:
return physDev->logpixelsy;
case HORZSIZE:
return physDev->horzsize;
case VERTSIZE:
return physDev->vertsize;
case BITSPIXEL:
return physDev->bitspixel;
case TEXTCAPS:
return physDev->textcaps;
case RASTERCAPS:
return physDev->rastercaps;
case TECHNOLOGY:
return physDev->technology;
case PLANES:
return physDev->planes;
case NUMCOLORS:
return physDev->numcolors;
case CURVECAPS:
return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
case LINECAPS:
return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
case POLYGONALCAPS:
return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
default:
FIXME("Unimplemented cap %d\n", cap);
return 0;
}
} }

View File

@ -39,15 +39,8 @@ typedef struct
HANDLE hFile; /* Handle for disk based MetaFile */ HANDLE hFile; /* Handle for disk based MetaFile */
HBRUSH dc_brush; HBRUSH dc_brush;
HPEN dc_pen; HPEN dc_pen;
INT horzres, vertres; HDC ref_dc; /* Reference device */
INT horzsize, vertsize; HDC screen_dc; /* Screen DC if no reference device specified */
INT logpixelsx, logpixelsy;
INT bitspixel;
INT textcaps;
INT rastercaps;
INT technology;
INT planes;
INT numcolors;
INT restoring; /* RestoreDC counter */ INT restoring; /* RestoreDC counter */
} EMFDRV_PDEVICE; } EMFDRV_PDEVICE;

View File

@ -317,8 +317,6 @@ HDC WINAPI CreateEnhMetaFileW(
static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0}; static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
HDC ret; HDC ret;
DC *dc; DC *dc;
HDC hRefDC = hdc ? hdc : CreateDCW(displayW,NULL,NULL,NULL);
/* If no ref, use current display */
EMFDRV_PDEVICE *physDev; EMFDRV_PDEVICE *physDev;
HANDLE hFile; HANDLE hFile;
DWORD size = 0, length = 0; DWORD size = 0, length = 0;
@ -354,19 +352,12 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->hFile = 0; physDev->hFile = 0;
physDev->dc_brush = 0; physDev->dc_brush = 0;
physDev->dc_pen = 0; physDev->dc_pen = 0;
physDev->horzres = GetDeviceCaps(hRefDC, HORZRES); physDev->screen_dc = 0;
physDev->vertres = GetDeviceCaps(hRefDC, VERTRES);
physDev->logpixelsx = GetDeviceCaps(hRefDC, LOGPIXELSX);
physDev->logpixelsy = GetDeviceCaps(hRefDC, LOGPIXELSY);
physDev->horzsize = GetDeviceCaps(hRefDC, HORZSIZE);
physDev->vertsize = GetDeviceCaps(hRefDC, VERTSIZE);
physDev->bitspixel = GetDeviceCaps(hRefDC, BITSPIXEL);
physDev->textcaps = GetDeviceCaps(hRefDC, TEXTCAPS);
physDev->rastercaps = GetDeviceCaps(hRefDC, RASTERCAPS);
physDev->technology = GetDeviceCaps(hRefDC, TECHNOLOGY);
physDev->planes = GetDeviceCaps(hRefDC, PLANES);
physDev->numcolors = GetDeviceCaps(hRefDC, NUMCOLORS);
physDev->restoring = 0; physDev->restoring = 0;
if (hdc) /* if no ref, use current display */
physDev->ref_dc = hdc;
else
physDev->ref_dc = physDev->screen_dc = CreateDCW( displayW, NULL, NULL, NULL );
SetVirtualResolution(physDev->dev.hdc, 0, 0, 0, 0); SetVirtualResolution(physDev->dev.hdc, 0, 0, 0, 0);
@ -400,16 +391,16 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */ physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */
/* Size in pixels */ /* Size in pixels */
physDev->emh->szlDevice.cx = physDev->horzres; physDev->emh->szlDevice.cx = GetDeviceCaps( physDev->ref_dc, HORZRES );
physDev->emh->szlDevice.cy = physDev->vertres; physDev->emh->szlDevice.cy = GetDeviceCaps( physDev->ref_dc, VERTRES );
/* Size in millimeters */ /* Size in millimeters */
physDev->emh->szlMillimeters.cx = physDev->horzsize; physDev->emh->szlMillimeters.cx = GetDeviceCaps( physDev->ref_dc, HORZSIZE );
physDev->emh->szlMillimeters.cy = physDev->vertsize; physDev->emh->szlMillimeters.cy = GetDeviceCaps( physDev->ref_dc, VERTSIZE );
/* Size in micrometers */ /* Size in micrometers */
physDev->emh->szlMicrometers.cx = physDev->horzsize * 1000; physDev->emh->szlMicrometers.cx = physDev->emh->szlMillimeters.cx * 1000;
physDev->emh->szlMicrometers.cy = physDev->vertsize * 1000; physDev->emh->szlMicrometers.cy = physDev->emh->szlMillimeters.cy * 1000;
memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length); memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);
@ -431,9 +422,6 @@ HDC WINAPI CreateEnhMetaFileW(
ret = physDev->dev.hdc; ret = physDev->dev.hdc;
release_dc_ptr( dc ); release_dc_ptr( dc );
if( !hdc )
DeleteDC( hRefDC );
return ret; return ret;
} }
@ -469,6 +457,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
if (physDev->dc_brush) DeleteObject( physDev->dc_brush ); if (physDev->dc_brush) DeleteObject( physDev->dc_brush );
if (physDev->dc_pen) DeleteObject( physDev->dc_pen ); if (physDev->dc_pen) DeleteObject( physDev->dc_pen );
if (physDev->screen_dc) DeleteDC( physDev->screen_dc );
emr.emr.iType = EMR_EOF; emr.emr.iType = EMR_EOF;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);

View File

@ -383,6 +383,9 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr )
ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef), /* nt4 */ ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef), /* nt4 */
"wrong error %u on %s\n", GetLastError(), descr ); "wrong error %u on %s\n", GetLastError(), descr );
type = GetClipBox( hdc, &rect ); 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 ); ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
SetBoundsRect( hdc, NULL, DCB_RESET | DCB_ENABLE ); SetBoundsRect( hdc, NULL, DCB_RESET | DCB_ENABLE );
@ -494,8 +497,7 @@ static void test_CreateCompatibleDC(void)
ok( SelectObject( hNewDC, bitmap ) != 0, "SelectObject failed\n" ); ok( SelectObject( hNewDC, bitmap ) != 0, "SelectObject failed\n" );
caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY ); caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps ); ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
caps = GetDeviceCaps( hNewDC, TECHNOLOGY ); test_device_caps( hdcMetafile, hdc, "enhmetafile dc" );
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
DeleteDC( hNewDC ); DeleteDC( hNewDC );
DeleteEnhMetaFile( CloseEnhMetaFile( hdcMetafile )); DeleteEnhMetaFile( CloseEnhMetaFile( hdcMetafile ));
ReleaseDC( 0, hdc ); ReleaseDC( 0, hdc );
@ -1144,7 +1146,7 @@ done:
static void test_printer_dc(void) static void test_printer_dc(void)
{ {
HDC memdc, display_memdc; HDC memdc, display_memdc, enhmf_dc;
HBITMAP orig, bmp; HBITMAP orig, bmp;
DWORD ret; DWORD ret;
HDC hdc = create_printer_dc(); HDC hdc = create_printer_dc();
@ -1188,6 +1190,11 @@ static void test_printer_dc(void)
ret = GetPixel( hdc, 0, 0 ); ret = GetPixel( hdc, 0, 0 );
ok( ret == CLR_INVALID, "wrong pixel value %x\n", ret ); ok( ret == CLR_INVALID, "wrong pixel value %x\n", ret );
enhmf_dc = CreateEnhMetaFileA( hdc, NULL, NULL, NULL );
ok(enhmf_dc != 0, "CreateEnhMetaFileA failed\n");
test_device_caps( enhmf_dc, hdc, "enhmetafile printer dc" );
DeleteEnhMetaFile( CloseEnhMetaFile( enhmf_dc ));
DeleteDC( memdc ); DeleteDC( memdc );
DeleteDC( display_memdc ); DeleteDC( display_memdc );
DeleteDC( hdc ); DeleteDC( hdc );