gdi32: Add a helper function to return the metafile device.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-06-21 14:52:43 +09:00
parent 234daa7522
commit 6bab6ad40d
5 changed files with 34 additions and 30 deletions

View File

@ -41,7 +41,7 @@ INT EMFDRV_SaveDC( PHYSDEV dev )
BOOL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pRestoreDC );
EMFDRV_PDEVICE* physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE* physDev = get_emf_physdev( dev );
DC *dc = get_dc_ptr( dev->hdc );
EMRRESTOREDC emr;
BOOL ret;
@ -94,7 +94,7 @@ INT EMFDRV_SetBkMode( PHYSDEV dev, INT mode )
COLORREF EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
{
EMRSETBKCOLOR emr;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
if (physDev->restoring) return color; /* don't output records during RestoreDC */
@ -108,7 +108,7 @@ COLORREF EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
COLORREF EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
{
EMRSETTEXTCOLOR emr;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
if (physDev->restoring) return color; /* don't output records during RestoreDC */
@ -420,7 +420,7 @@ BOOL EMFDRV_AbortPath( PHYSDEV dev )
BOOL EMFDRV_BeginPath( PHYSDEV dev )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRBEGINPATH emr;
physDev->path = TRUE;
@ -531,7 +531,7 @@ BOOL EMFDRV_WidenPath( PHYSDEV dev )
INT EMFDRV_GetDeviceCaps(PHYSDEV dev, INT cap)
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
return GetDeviceCaps( physDev->ref_dc, cap );
}

View File

@ -45,6 +45,10 @@ typedef struct
BOOL path;
} EMFDRV_PDEVICE;
static inline EMFDRV_PDEVICE *get_emf_physdev( PHYSDEV dev )
{
return CONTAINING_RECORD( dev, EMFDRV_PDEVICE, dev );
}
extern BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr ) DECLSPEC_HIDDEN;
extern void EMFDRV_UpdateBBox( PHYSDEV dev, RECTL *rect ) DECLSPEC_HIDDEN;

View File

@ -116,7 +116,7 @@ BOOL EMFDRV_MoveTo(PHYSDEV dev, INT x, INT y)
*/
BOOL EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
POINT pt;
EMRLINETO emr;
RECTL bounds;
@ -150,7 +150,7 @@ static BOOL
EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend, DWORD iType )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
INT temp, xCentre, yCentre, i;
double angleStart, angleEnd;
double xinterStart, yinterStart, xinterEnd, yinterEnd;
@ -321,7 +321,7 @@ BOOL EMFDRV_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT start, FLOA
*/
BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRELLIPSE emr;
INT temp;
@ -354,7 +354,7 @@ BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
*/
BOOL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRRECTANGLE emr;
INT temp;
@ -388,7 +388,7 @@ BOOL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
BOOL EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRROUNDRECT emr;
INT temp;
@ -447,7 +447,7 @@ COLORREF EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
static BOOL
EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRPOLYLINE *emr;
DWORD size;
BOOL ret, use_small_emr = can_use_short_points( pt, count );
@ -526,7 +526,7 @@ static BOOL
EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polys,
DWORD iType)
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRPOLYPOLYLINE *emr;
DWORD cptl = 0, poly, size;
BOOL ret, use_small_emr, bounds_valid = TRUE;
@ -598,7 +598,7 @@ BOOL EMFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT p
*/
BOOL EMFDRV_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD count )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRPOLYDRAW *emr;
BOOL ret;
BYTE *types_dest;
@ -772,7 +772,7 @@ BOOL EMFDRV_InvertRgn( PHYSDEV dev, HRGN hrgn )
BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect,
LPCWSTR str, UINT count, const INT *lpDx )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMREXTTEXTOUTW *pemr;
DWORD nSize;
BOOL ret;

View File

@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
static BOOL EMFDRV_DeleteDC( PHYSDEV dev );
static const struct gdi_dc_funcs EMFDRV_Funcs =
static const struct gdi_dc_funcs emfdrv_driver =
{
NULL, /* pAbortDoc */
EMFDRV_AbortPath, /* pAbortPath */
@ -172,7 +172,7 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
*/
static BOOL EMFDRV_DeleteDC( PHYSDEV dev )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
UINT index;
if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh );
@ -195,7 +195,7 @@ BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr )
DWORD len;
DWORD bytes_written;
ENHMETAHEADER *emh;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
TRACE("record %d, size %d %s\n",
emr->iType, emr->nSize, physDev->hFile ? "(to disk)" : "");
@ -229,7 +229,7 @@ BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr )
*/
void EMFDRV_UpdateBBox( PHYSDEV dev, RECTL *rect )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
RECTL *bounds = &physDev->emh->rclBounds;
RECTL vportRect = *rect;
@ -342,7 +342,7 @@ HDC WINAPI CreateEnhMetaFileW(
return 0;
}
push_dc_driver( &dc->physDev, &physDev->dev, &EMFDRV_Funcs );
push_dc_driver( &dc->physDev, &physDev->dev, &emfdrv_driver );
physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
physDev->handles_size = HANDLE_LIST_INC;
@ -450,7 +450,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
release_dc_ptr( dc );
return NULL;
}
physDev = (EMFDRV_PDEVICE *)dc->physDev;
physDev = get_emf_physdev( find_dc_driver( dc, &emfdrv_driver ));
if(dc->saveLevel)
RestoreDC(hdc, 1);
@ -464,7 +464,7 @@ HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
emr.nPalEntries = 0;
emr.offPalEntries = FIELD_OFFSET(EMREOF, nSizeLast);
emr.nSizeLast = emr.emr.nSize;
EMFDRV_WriteRecord( dc->physDev, &emr.emr );
EMFDRV_WriteRecord( &physDev->dev, &emr.emr );
/* Update rclFrame if not initialized in CreateEnhMetaFile */
if(physDev->emh->rclFrame.left > physDev->emh->rclFrame.right) {

View File

@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
*/
static UINT EMFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
UINT index;
for(index = 0; index < physDev->handles_size; index++)
@ -59,7 +59,7 @@ static UINT EMFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj )
*/
static UINT EMFDRV_FindObject( PHYSDEV dev, HGDIOBJ obj )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
UINT index;
for(index = 0; index < physDev->handles_size; index++)
@ -77,7 +77,7 @@ static UINT EMFDRV_FindObject( PHYSDEV dev, HGDIOBJ obj )
BOOL EMFDRV_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
{
EMRDELETEOBJECT emr;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
UINT index;
BOOL ret = TRUE;
@ -200,7 +200,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
*/
HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH hBrush, const struct brush_pattern *pattern )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSELECTOBJECT emr;
DWORD index;
int i;
@ -279,7 +279,7 @@ static BOOL EMFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont )
*/
HFONT EMFDRV_SelectFont( PHYSDEV dev, HFONT hFont, UINT *aa_flags )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSELECTOBJECT emr;
DWORD index;
int i;
@ -364,7 +364,7 @@ static DWORD EMFDRV_CreatePenIndirect(PHYSDEV dev, HPEN hPen)
*/
HPEN EMFDRV_SelectPen(PHYSDEV dev, HPEN hPen, const struct brush_pattern *pattern )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSELECTOBJECT emr;
DWORD index;
int i;
@ -432,7 +432,7 @@ static DWORD EMFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPal)
*/
HPALETTE EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSELECTPALETTE emr;
DWORD index;
@ -462,7 +462,7 @@ found:
*/
COLORREF EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSELECTOBJECT emr;
DWORD index;
@ -483,7 +483,7 @@ COLORREF EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
*/
COLORREF EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
EMRSELECTOBJECT emr;
DWORD index;
LOGPEN logpen = { PS_SOLID, { 0, 0 }, color };