Commit 1323ff84 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Use struct emf for EMF helpers.

parent 56efbd02
......@@ -28,7 +28,7 @@
#include "enhmetafiledrv.h"
/* Generate an EMRBITBLT, EMRSTRETCHBLT or EMRALPHABLEND record depending on the type parameter */
static BOOL emfdrv_stretchblt( PHYSDEV dev_dst, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
static BOOL emfdrv_stretchblt( struct emf *emf, INT x_dst, INT y_dst, INT width_dst, INT height_dst,
HDC hdc_src, INT x_src, INT y_src, INT width_src, INT height_src,
DWORD rop, DWORD type )
{
......@@ -147,8 +147,8 @@ static BOOL emfdrv_stretchblt( PHYSDEV dev_dst, INT x_dst, INT y_dst, INT width_
bmi, DIB_RGB_COLORS );
if (ret)
{
ret = EMFDRV_WriteRecord( dev_dst, (EMR *)emr );
if (ret) EMFDRV_UpdateBBox( dev_dst, &emr->rclBounds );
ret = emfdc_record( emf, (EMR *)emr );
if (ret) emfdc_update_bounds( emf, &emr->rclBounds );
}
err:
......@@ -198,9 +198,9 @@ BOOL EMFDC_PatBlt( DC_ATTR *dc_attr, INT left, INT top, INT width, INT height, D
emr.offBitsSrc = 0;
emr.cbBitsSrc = 0;
ret = EMFDRV_WriteRecord( &emf->dev, &emr.emr );
ret = emfdc_record( emf, &emr.emr );
if(ret)
EMFDRV_UpdateBBox( &emf->dev, &emr.rclBounds );
emfdc_update_bounds( emf, &emr.rclBounds );
return ret;
}
......@@ -275,9 +275,9 @@ BOOL EMFDC_StretchDIBits( DC_ATTR *dc_attr, INT x_dst, INT y_dst, INT width_dst,
emr->rclBounds.bottom = y_dst + height_dst;
/* save the record we just created */
ret = EMFDRV_WriteRecord( dc_attr->emf, &emr->emr );
ret = emfdc_record( dc_attr->emf, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dc_attr->emf, &emr->rclBounds );
emfdc_update_bounds( dc_attr->emf, &emr->rclBounds );
HeapFree(GetProcessHeap(), 0, emr);
......@@ -318,8 +318,8 @@ BOOL EMFDC_SetDIBitsToDevice( DC_ATTR *dc_attr, INT x_dst, INT y_dst, DWORD widt
memcpy((BYTE*)pEMR + pEMR->offBmiSrc, info, bmiSize);
memcpy((BYTE*)pEMR + pEMR->offBitsSrc, bits, info->bmiHeader.biSizeImage);
if ((ret = EMFDRV_WriteRecord( dc_attr->emf, (EMR*)pEMR )))
EMFDRV_UpdateBBox( dc_attr->emf, &pEMR->rclBounds );
if ((ret = emfdc_record( dc_attr->emf, (EMR*)pEMR )))
emfdc_update_bounds( dc_attr->emf, &pEMR->rclBounds );
HeapFree( GetProcessHeap(), 0, pEMR);
return ret;
......
......@@ -27,7 +27,7 @@ BOOL EMFDC_SaveDC( DC_ATTR *dc_attr )
EMRSAVEDC emr;
emr.emr.iType = EMR_SAVEDC;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_RestoreDC( DC_ATTR *dc_attr, INT level )
......@@ -42,7 +42,7 @@ BOOL EMFDC_RestoreDC( DC_ATTR *dc_attr, INT level )
emr.iRelative = level;
else
emr.iRelative = level - dc_attr->save_level - 1;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align )
......@@ -51,7 +51,7 @@ BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align )
emr.emr.iType = EMR_SETTEXTALIGN;
emr.emr.nSize = sizeof(emr);
emr.iMode = align;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetTextJustification( DC_ATTR *dc_attr, INT extra, INT breaks )
......@@ -61,7 +61,7 @@ BOOL EMFDC_SetTextJustification( DC_ATTR *dc_attr, INT extra, INT breaks )
emr.emr.nSize = sizeof(emr);
emr.nBreakExtra = extra;
emr.nBreakCount = breaks;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode )
......@@ -70,7 +70,7 @@ BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode )
emr.emr.iType = EMR_SETBKMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetBkColor( DC_ATTR *dc_attr, COLORREF color )
......@@ -80,7 +80,7 @@ BOOL EMFDC_SetBkColor( DC_ATTR *dc_attr, COLORREF color )
emr.emr.iType = EMR_SETBKCOLOR;
emr.emr.nSize = sizeof(emr);
emr.crColor = color;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
......@@ -91,7 +91,7 @@ BOOL EMFDC_SetTextColor( DC_ATTR *dc_attr, COLORREF color )
emr.emr.iType = EMR_SETTEXTCOLOR;
emr.emr.nSize = sizeof(emr);
emr.crColor = color;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetROP2( DC_ATTR *dc_attr, INT rop )
......@@ -100,7 +100,7 @@ BOOL EMFDC_SetROP2( DC_ATTR *dc_attr, INT rop )
emr.emr.iType = EMR_SETROP2;
emr.emr.nSize = sizeof(emr);
emr.iMode = rop;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetPolyFillMode( DC_ATTR *dc_attr, INT mode )
......@@ -109,7 +109,7 @@ BOOL EMFDC_SetPolyFillMode( DC_ATTR *dc_attr, INT mode )
emr.emr.iType = EMR_SETPOLYFILLMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetStretchBltMode( DC_ATTR *dc_attr, INT mode )
......@@ -118,7 +118,7 @@ BOOL EMFDC_SetStretchBltMode( DC_ATTR *dc_attr, INT mode )
emr.emr.iType = EMR_SETSTRETCHBLTMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetArcDirection( DC_ATTR *dc_attr, INT dir )
......@@ -128,7 +128,7 @@ BOOL EMFDC_SetArcDirection( DC_ATTR *dc_attr, INT dir )
emr.emr.iType = EMR_SETARCDIRECTION;
emr.emr.nSize = sizeof(emr);
emr.iArcDirection = dir;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
INT EMFDC_ExcludeClipRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom )
......@@ -141,7 +141,7 @@ INT EMFDC_ExcludeClipRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT b
emr.rclClip.top = top;
emr.rclClip.right = right;
emr.rclClip.bottom = bottom;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_IntersectClipRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom)
......@@ -154,7 +154,7 @@ BOOL EMFDC_IntersectClipRect( DC_ATTR *dc_attr, INT left, INT top, INT right, IN
emr.rclClip.top = top;
emr.rclClip.right = right;
emr.rclClip.bottom = bottom;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_OffsetClipRgn( DC_ATTR *dc_attr, INT x, INT y )
......@@ -165,7 +165,7 @@ BOOL EMFDC_OffsetClipRgn( DC_ATTR *dc_attr, INT x, INT y )
emr.emr.nSize = sizeof(emr);
emr.ptlOffset.x = x;
emr.ptlOffset.y = y;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_ExtSelectClipRgn( DC_ATTR *dc_attr, HRGN hrgn, INT mode )
......@@ -190,7 +190,7 @@ BOOL EMFDC_ExtSelectClipRgn( DC_ATTR *dc_attr, HRGN hrgn, INT mode )
emr->cbRgnData = rgnsize;
emr->iMode = mode;
ret = EMFDRV_WriteRecord( dc_attr->emf, &emr->emr );
ret = emfdc_record( dc_attr->emf, &emr->emr );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -202,7 +202,7 @@ BOOL EMFDC_SetMapMode( DC_ATTR *dc_attr, INT mode )
emr.emr.iType = EMR_SETMAPMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetViewportExtEx( DC_ATTR *dc_attr, INT cx, INT cy )
......@@ -213,7 +213,7 @@ BOOL EMFDC_SetViewportExtEx( DC_ATTR *dc_attr, INT cx, INT cy )
emr.emr.nSize = sizeof(emr);
emr.szlExtent.cx = cx;
emr.szlExtent.cy = cy;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetWindowExtEx( DC_ATTR *dc_attr, INT cx, INT cy )
......@@ -224,7 +224,7 @@ BOOL EMFDC_SetWindowExtEx( DC_ATTR *dc_attr, INT cx, INT cy )
emr.emr.nSize = sizeof(emr);
emr.szlExtent.cx = cx;
emr.szlExtent.cy = cy;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetViewportOrgEx( DC_ATTR *dc_attr, INT x, INT y )
......@@ -235,7 +235,7 @@ BOOL EMFDC_SetViewportOrgEx( DC_ATTR *dc_attr, INT x, INT y )
emr.emr.nSize = sizeof(emr);
emr.ptlOrigin.x = x;
emr.ptlOrigin.y = y;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetWindowOrgEx( DC_ATTR *dc_attr, INT x, INT y )
......@@ -246,7 +246,7 @@ BOOL EMFDC_SetWindowOrgEx( DC_ATTR *dc_attr, INT x, INT y )
emr.emr.nSize = sizeof(emr);
emr.ptlOrigin.x = x;
emr.ptlOrigin.y = y;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_ScaleViewportExtEx( DC_ATTR *dc_attr, INT x_num, INT x_denom, INT y_num, INT y_denom )
......@@ -259,7 +259,7 @@ BOOL EMFDC_ScaleViewportExtEx( DC_ATTR *dc_attr, INT x_num, INT x_denom, INT y_n
emr.xDenom = x_denom;
emr.yNum = y_num;
emr.yDenom = y_denom;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_ScaleWindowExtEx( DC_ATTR *dc_attr, INT x_num, INT x_denom, INT y_num, INT y_denom )
......@@ -272,7 +272,7 @@ BOOL EMFDC_ScaleWindowExtEx( DC_ATTR *dc_attr, INT x_num, INT x_denom, INT y_num
emr.xDenom = x_denom;
emr.yNum = y_num;
emr.yDenom = y_denom;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetLayout( DC_ATTR *dc_attr, DWORD layout )
......@@ -282,7 +282,7 @@ BOOL EMFDC_SetLayout( DC_ATTR *dc_attr, DWORD layout )
emr.emr.iType = EMR_SETLAYOUT;
emr.emr.nSize = sizeof(emr);
emr.iMode = layout;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetWorldTransform( DC_ATTR *dc_attr, const XFORM *xform )
......@@ -292,7 +292,7 @@ BOOL EMFDC_SetWorldTransform( DC_ATTR *dc_attr, const XFORM *xform )
emr.emr.iType = EMR_SETWORLDTRANSFORM;
emr.emr.nSize = sizeof(emr);
emr.xform = *xform;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_ModifyWorldTransform( DC_ATTR *dc_attr, const XFORM *xform, DWORD mode )
......@@ -315,7 +315,7 @@ BOOL EMFDC_ModifyWorldTransform( DC_ATTR *dc_attr, const XFORM *xform, DWORD mod
emr.xform = *xform;
}
emr.iMode = mode;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SetMapperFlags( DC_ATTR *dc_attr, DWORD flags )
......@@ -326,30 +326,30 @@ BOOL EMFDC_SetMapperFlags( DC_ATTR *dc_attr, DWORD flags )
emr.emr.nSize = sizeof(emr);
emr.dwFlags = flags;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_AbortPath( DC_ATTR *dc_attr )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
struct emf *emf = dc_attr->emf;
EMRABORTPATH emr;
emr.emr.iType = EMR_ABORTPATH;
emr.emr.nSize = sizeof(emr);
emf->path = FALSE;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_BeginPath( DC_ATTR *dc_attr )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
struct emf *emf = dc_attr->emf;
EMRBEGINPATH emr;
emr.emr.iType = EMR_BEGINPATH;
emr.emr.nSize = sizeof(emr);
if (!EMFDRV_WriteRecord( &emf->dev, &emr.emr )) return FALSE;
if (!emfdc_record( emf, &emr.emr )) return FALSE;
emf->path = TRUE;
return TRUE;
}
......@@ -361,19 +361,19 @@ BOOL EMFDC_CloseFigure( DC_ATTR *dc_attr )
emr.emr.iType = EMR_CLOSEFIGURE;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_EndPath( DC_ATTR *dc_attr )
{
EMFDRV_PDEVICE *emf = dc_attr->emf;
struct emf *emf = dc_attr->emf;
EMRENDPATH emr;
emr.emr.iType = EMR_ENDPATH;
emr.emr.nSize = sizeof(emr);
emf->path = FALSE;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
BOOL EMFDC_FlattenPath( DC_ATTR *dc_attr )
......@@ -382,7 +382,7 @@ BOOL EMFDC_FlattenPath( DC_ATTR *dc_attr )
emr.emr.iType = EMR_FLATTENPATH;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_SelectClipPath( DC_ATTR *dc_attr, INT mode )
......@@ -392,7 +392,7 @@ BOOL EMFDC_SelectClipPath( DC_ATTR *dc_attr, INT mode )
emr.emr.iType = EMR_SELECTCLIPPATH;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
BOOL EMFDC_WidenPath( DC_ATTR *dc_attr )
......@@ -401,5 +401,5 @@ BOOL EMFDC_WidenPath( DC_ATTR *dc_attr )
emr.emr.iType = EMR_WIDENPATH;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
......@@ -31,7 +31,7 @@
/* Enhanced Metafile driver physical DC */
typedef struct
typedef struct emf
{
struct gdi_physdev dev;
ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */
......@@ -50,9 +50,9 @@ 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;
extern DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) DECLSPEC_HIDDEN;
extern BOOL emfdc_record( struct emf *emf, EMR *emr ) DECLSPEC_HIDDEN;
extern void emfdc_update_bounds( struct emf *emf, RECTL *rect ) DECLSPEC_HIDDEN;
extern DWORD emfdc_create_brush( struct emf *emf, HBRUSH hBrush ) DECLSPEC_HIDDEN;
#define HANDLE_LIST_INC 20
......
......@@ -92,9 +92,9 @@ static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, DC_A
}
/* helper for path stroke and fill functions */
static BOOL emfdrv_stroke_and_fill_path( PHYSDEV dev, INT type )
static BOOL emfdrv_stroke_and_fill_path( struct emf *emf, INT type )
{
DC *dc = get_physdev_dc( dev );
DC *dc = get_physdev_dc( &emf->dev );
EMRSTROKEANDFILLPATH emr;
struct gdi_path *path;
POINT *points;
......@@ -111,9 +111,9 @@ static BOOL emfdrv_stroke_and_fill_path( PHYSDEV dev, INT type )
}
else emr.rclBounds = empty_bounds;
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
if (!emfdc_record( emf, &emr.emr )) return FALSE;
if (!path) return FALSE;
EMFDRV_UpdateBBox( dev, &emr.rclBounds );
emfdc_update_bounds( emf, &emr.rclBounds );
return TRUE;
}
......@@ -130,7 +130,7 @@ BOOL EMFDC_MoveTo( DC_ATTR *dc_attr, INT x, INT y )
emr.ptl.x = x;
emr.ptl.y = y;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/***********************************************************************
......@@ -144,7 +144,7 @@ BOOL EMFDC_LineTo( DC_ATTR *dc_attr, INT x, INT y )
emr.emr.nSize = sizeof(emr);
emr.ptl.x = x;
emr.ptl.y = y;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
......@@ -179,7 +179,7 @@ BOOL EMFDC_ArcChordPie( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bott
emr.ptlStart.y = ystart;
emr.ptlEnd.x = xend;
emr.ptlEnd.y = yend;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/***********************************************************************
......@@ -197,7 +197,7 @@ BOOL EMFDC_AngleArc( DC_ATTR *dc_attr, INT x, INT y, DWORD radius, FLOAT start,
emr.eStartAngle = start;
emr.eSweepAngle = sweep;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
/***********************************************************************
......@@ -222,7 +222,7 @@ BOOL EMFDC_Ellipse( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom )
emr.rclBox.bottom--;
}
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/***********************************************************************
......@@ -247,7 +247,7 @@ BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom
emr.rclBox.bottom--;
}
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/***********************************************************************
......@@ -275,7 +275,7 @@ BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right,
emr.rclBox.bottom--;
}
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/***********************************************************************
......@@ -290,7 +290,7 @@ BOOL EMFDC_SetPixel( DC_ATTR *dc_attr, INT x, INT y, COLORREF color )
emr.ptlPixel.x = x;
emr.ptlPixel.y = y;
emr.crColor = color;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
/**********************************************************************
......@@ -320,9 +320,9 @@ static BOOL EMFDC_Polylinegon( DC_ATTR *dc_attr, const POINT *points, INT count,
else
emr->rclBounds = empty_bounds;
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
ret = emfdc_record( emf, &emr->emr );
if (ret && !emf->path)
EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
emfdc_update_bounds( emf, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -413,14 +413,14 @@ static BOOL EMFDC_PolyPolylinegon( EMFDRV_PDEVICE *emf, const POINT *pt, const I
store_points( (POINTL *)(emr->aPolyCounts + polys), pt, cptl, use_small_emr );
}
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
ret = emfdc_record( emf, &emr->emr );
if(ret && !bounds_valid)
{
ret = FALSE;
SetLastError( ERROR_INVALID_PARAMETER );
}
if(ret && !emf->path)
EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
emfdc_update_bounds( emf, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -471,8 +471,8 @@ BOOL EMFDC_PolyDraw( DC_ATTR *dc_attr, const POINT *pts, const BYTE *types, DWOR
else
emr->rclBounds = empty_bounds;
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
if (ret && !emf->path) EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
ret = emfdc_record( emf, &emr->emr );
if (ret && !emf->path) emfdc_update_bounds( emf, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -492,7 +492,7 @@ BOOL EMFDC_ExtFloodFill( DC_ATTR *dc_attr, INT x, INT y, COLORREF color, UINT fi
emr.crColor = color;
emr.iMode = fill_type;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
return emfdc_record( dc_attr->emf, &emr.emr );
}
......@@ -506,7 +506,7 @@ BOOL EMFDC_FillRgn( DC_ATTR *dc_attr, HRGN hrgn, HBRUSH hbrush )
DWORD size, rgnsize, index;
BOOL ret;
index = EMFDRV_CreateBrushIndirect( &emf->dev, hbrush );
index = emfdc_create_brush( emf, hbrush );
if(!index) return FALSE;
rgnsize = NtGdiGetRegionData( hrgn, 0, NULL );
......@@ -524,9 +524,9 @@ BOOL EMFDC_FillRgn( DC_ATTR *dc_attr, HRGN hrgn, HBRUSH hbrush )
emr->cbRgnData = rgnsize;
emr->ihBrush = index;
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
ret = emfdc_record( emf, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
emfdc_update_bounds( emf, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -542,7 +542,7 @@ BOOL EMFDC_FrameRgn( DC_ATTR *dc_attr, HRGN hrgn, HBRUSH hbrush, INT width, INT
DWORD size, rgnsize, index;
BOOL ret;
index = EMFDRV_CreateBrushIndirect( &emf->dev, hbrush );
index = emfdc_create_brush( emf, hbrush );
if(!index) return FALSE;
rgnsize = NtGdiGetRegionData( hrgn, 0, NULL );
......@@ -562,9 +562,9 @@ BOOL EMFDC_FrameRgn( DC_ATTR *dc_attr, HRGN hrgn, HBRUSH hbrush, INT width, INT
emr->szlStroke.cx = width;
emr->szlStroke.cy = height;
ret = EMFDRV_WriteRecord( &emf->dev, &emr->emr );
ret = emfdc_record( emf, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( &emf->dev, &emr->rclBounds );
emfdc_update_bounds( emf, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -574,13 +574,12 @@ BOOL EMFDC_FrameRgn( DC_ATTR *dc_attr, HRGN hrgn, HBRUSH hbrush, INT width, INT
*
* Helper for EMFDRV_{Paint|Invert}Rgn
*/
static BOOL EMF_PaintInvertRgn( PHYSDEV dev, HRGN hrgn, DWORD iType )
static BOOL EMF_PaintInvertRgn( struct emf *emf, HRGN hrgn, DWORD iType )
{
EMRINVERTRGN *emr;
DWORD size, rgnsize;
BOOL ret;
rgnsize = NtGdiGetRegionData( hrgn, 0, NULL );
size = rgnsize + offsetof(EMRINVERTRGN,RgnData);
emr = HeapAlloc( GetProcessHeap(), 0, size );
......@@ -595,9 +594,9 @@ static BOOL EMF_PaintInvertRgn( PHYSDEV dev, HRGN hrgn, DWORD iType )
emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
emr->cbRgnData = rgnsize;
ret = EMFDRV_WriteRecord( dev, &emr->emr );
ret = emfdc_record( emf, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
emfdc_update_bounds( emf, &emr->rclBounds );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......@@ -752,10 +751,10 @@ BOOL EMFDC_ExtTextOut( DC_ATTR *dc_attr, INT x, INT y, UINT flags, const RECT *l
pemr->rclBounds.bottom = y + textHeight + 1;
}
}
EMFDRV_UpdateBBox( &emf->dev, &pemr->rclBounds );
emfdc_update_bounds( emf, &pemr->rclBounds );
no_bounds:
ret = EMFDRV_WriteRecord( &emf->dev, &pemr->emr );
ret = emfdc_record( emf, &pemr->emr );
HeapFree( GetProcessHeap(), 0, pemr );
return ret;
}
......@@ -808,8 +807,8 @@ BOOL EMFDC_GradientFill( DC_ATTR *dc_attr, TRIVERTEX *vert_array, ULONG nvert,
memcpy( emr->Ver, vert_array, nvert * sizeof(vert_array[0]) );
memcpy( emr->Ver + nvert, pts, num_pts * sizeof(pts[0]) );
EMFDRV_UpdateBBox( dc_attr->emf, &emr->rclBounds );
ret = EMFDRV_WriteRecord( dc_attr->emf, &emr->emr );
emfdc_update_bounds( dc_attr->emf, &emr->rclBounds );
ret = emfdc_record( dc_attr->emf, &emr->emr );
HeapFree( GetProcessHeap(), 0, emr );
return ret;
}
......
......@@ -51,44 +51,41 @@ void EMFDC_DeleteDC( DC_ATTR *dc_attr )
*
* Warning: this function can change the pointer to the metafile header.
*/
BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr )
BOOL emfdc_record( struct emf *emf, EMR *emr )
{
DWORD len, size;
ENHMETAHEADER *emh;
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
TRACE("record %d, size %d %s\n",
emr->iType, emr->nSize, physDev->hFile ? "(to disk)" : "");
TRACE( "record %d, size %d\n", emr->iType, emr->nSize );
assert( !(emr->nSize & 3) );
physDev->emh->nBytes += emr->nSize;
physDev->emh->nRecords++;
emf->emh->nBytes += emr->nSize;
emf->emh->nRecords++;
size = HeapSize(GetProcessHeap(), 0, physDev->emh);
len = physDev->emh->nBytes;
if (len > size) {
size = HeapSize( GetProcessHeap(), 0, emf->emh );
len = emf->emh->nBytes;
if (len > size)
{
size += (size / 2) + emr->nSize;
emh = HeapReAlloc(GetProcessHeap(), 0, physDev->emh, size);
emh = HeapReAlloc( GetProcessHeap(), 0, emf->emh, size );
if (!emh) return FALSE;
physDev->emh = emh;
emf->emh = emh;
}
memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
emr->nSize);
memcpy( (char *)emf->emh + emf->emh->nBytes - emr->nSize, emr, emr->nSize );
return TRUE;
}
/******************************************************************
* EMFDRV_UpdateBBox
* emfdc_update_bounds
*/
void EMFDRV_UpdateBBox( PHYSDEV dev, RECTL *rect )
void emfdc_update_bounds( struct emf *emf, RECTL *rect )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
RECTL *bounds = &physDev->dc_attr->emf_bounds;
RECTL *bounds = &emf->dc_attr->emf_bounds;
RECTL vportRect = *rect;
LPtoDP( dev->hdc, (LPPOINT)&vportRect, 2 );
LPtoDP( emf->dev.hdc, (POINT *)&vportRect, 2 );
/* The coordinate systems may be mirrored
(LPtoDP handles points, not rectangles) */
......@@ -274,7 +271,7 @@ HDC WINAPI CreateEnhMetaFileW(
HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
{
HENHMETAFILE hmf;
EMFDRV_PDEVICE *emf;
struct emf *emf;
DC_ATTR *dc_attr;
EMREOF emr;
HANDLE hMapping = 0;
......@@ -295,7 +292,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( &emf->dev, &emr.emr );
emfdc_record( emf, &emr.emr );
emf->emh->rclBounds = dc_attr->emf_bounds;
......
......@@ -32,24 +32,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
/******************************************************************
* EMFDRV_AddHandle
*/
static UINT EMFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj )
static UINT EMFDRV_AddHandle( struct emf *emf, HGDIOBJ obj )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
UINT index;
for(index = 0; index < physDev->handles_size; index++)
if(physDev->handles[index] == 0) break;
if(index == physDev->handles_size) {
physDev->handles_size += HANDLE_LIST_INC;
physDev->handles = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
physDev->handles,
physDev->handles_size * sizeof(physDev->handles[0]));
for (index = 0; index < emf->handles_size; index++)
if (emf->handles[index] == 0) break;
if (index == emf->handles_size)
{
emf->handles_size += HANDLE_LIST_INC;
emf->handles = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
emf->handles,
emf->handles_size * sizeof(emf->handles[0]) );
}
physDev->handles[index] = get_full_gdi_handle( obj );
emf->handles[index] = get_full_gdi_handle( obj );
physDev->cur_handles++;
if(physDev->cur_handles > physDev->emh->nHandles)
physDev->emh->nHandles++;
emf->cur_handles++;
if(emf->cur_handles > emf->emh->nHandles)
emf->emh->nHandles++;
return index + 1; /* index 0 is reserved for the hmf, so we increment everything by 1 */
}
......@@ -87,7 +87,7 @@ void EMFDC_DeleteObject( HDC hdc, HGDIOBJ obj )
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
EMFDRV_WriteRecord( &emf->dev, &emr.emr );
emfdc_record( emf, &emr.emr );
emf->handles[index - 1] = 0;
emf->cur_handles--;
......@@ -95,9 +95,9 @@ void EMFDC_DeleteObject( HDC hdc, HGDIOBJ obj )
/***********************************************************************
* EMFDRV_CreateBrushIndirect
* emfdc_create_brush
*/
DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
DWORD emfdc_create_brush( struct emf *emf, HBRUSH hBrush )
{
DWORD index = 0;
LOGBRUSH logbrush;
......@@ -112,12 +112,12 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
EMRCREATEBRUSHINDIRECT emr;
emr.emr.iType = EMR_CREATEBRUSHINDIRECT;
emr.emr.nSize = sizeof(emr);
emr.ihBrush = index = EMFDRV_AddHandle( dev, hBrush );
emr.ihBrush = index = EMFDRV_AddHandle( emf, hBrush );
emr.lb.lbStyle = logbrush.lbStyle;
emr.lb.lbColor = logbrush.lbColor;
emr.lb.lbHatch = logbrush.lbHatch;
if(!EMFDRV_WriteRecord( dev, &emr.emr ))
if(!emfdc_record( emf, &emr.emr ))
index = 0;
}
break;
......@@ -161,7 +161,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
emr->offBmi = sizeof( EMRCREATEDIBPATTERNBRUSHPT );
emr->cbBmi = info_size;
}
emr->ihBrush = index = EMFDRV_AddHandle( dev, hBrush );
emr->ihBrush = index = EMFDRV_AddHandle( emf, hBrush );
emr->iUsage = usage;
emr->offBits = emr->offBmi + emr->cbBmi;
emr->cbBits = info->bmiHeader.biSizeImage;
......@@ -170,7 +170,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
memcpy( (BYTE *)emr + emr->offBmi, info, emr->cbBmi );
memcpy( (BYTE *)emr + emr->offBits, bits, emr->cbBits );
if(!EMFDRV_WriteRecord( dev, &emr->emr ))
if(!emfdc_record( emf, &emr->emr ))
index = 0;
HeapFree( GetProcessHeap(), 0, emr );
}
......@@ -210,21 +210,21 @@ static BOOL EMFDC_SelectBrush( DC_ATTR *dc_attr, HBRUSH brush )
if((index = EMFDRV_FindObject( &emf->dev, brush )) != 0)
goto found;
if (!(index = EMFDRV_CreateBrushIndirect( &emf->dev, brush ))) return 0;
if (!(index = emfdc_create_brush( emf, brush ))) return 0;
GDI_hdc_using_object( brush, dc_attr->hdc, EMFDC_DeleteObject );
found:
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/******************************************************************
* EMFDRV_CreateFontIndirect
*/
static BOOL EMFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont )
static BOOL EMFDRV_CreateFontIndirect( struct emf *emf, HFONT hFont )
{
DWORD index = 0;
EMREXTCREATEFONTINDIRECTW emr;
......@@ -234,7 +234,7 @@ static BOOL EMFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont )
emr.emr.iType = EMR_EXTCREATEFONTINDIRECTW;
emr.emr.nSize = (sizeof(emr) + 3) / 4 * 4;
emr.ihFont = index = EMFDRV_AddHandle( dev, hFont );
emr.ihFont = index = EMFDRV_AddHandle( emf, hFont );
emr.elfw.elfFullName[0] = '\0';
emr.elfw.elfStyle[0] = '\0';
emr.elfw.elfVersion = 0;
......@@ -255,9 +255,7 @@ static BOOL EMFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont )
emr.elfw.elfPanose.bMidline = PAN_NO_FIT;
emr.elfw.elfPanose.bXHeight = PAN_NO_FIT;
if(!EMFDRV_WriteRecord( dev, &emr.emr ))
index = 0;
return index;
return emfdc_record( emf, &emr.emr ) ? index : 0;
}
......@@ -288,7 +286,7 @@ static BOOL EMFDC_SelectFont( DC_ATTR *dc_attr, HFONT font )
if (!(index = EMFDRV_FindObject( &emf->dev, font )))
{
if (!(index = EMFDRV_CreateFontIndirect( &emf->dev, font ))) return FALSE;
if (!(index = EMFDRV_CreateFontIndirect( emf, font ))) return FALSE;
GDI_hdc_using_object( font, emf->dev.hdc, EMFDC_DeleteObject );
}
......@@ -296,13 +294,13 @@ static BOOL EMFDC_SelectFont( DC_ATTR *dc_attr, HFONT font )
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/******************************************************************
* EMFDRV_CreatePenIndirect
*/
static DWORD EMFDRV_CreatePenIndirect(PHYSDEV dev, HPEN hPen)
static DWORD EMFDRV_CreatePenIndirect( struct emf *emf, HPEN hPen )
{
EMRCREATEPEN emr;
DWORD index = 0;
......@@ -329,9 +327,9 @@ static DWORD EMFDRV_CreatePenIndirect(PHYSDEV dev, HPEN hPen)
emr.emr.iType = EMR_CREATEPEN;
emr.emr.nSize = sizeof(emr);
emr.ihPen = index = EMFDRV_AddHandle( dev, hPen );
emr.ihPen = index = EMFDRV_AddHandle( emf, hPen );
if(!EMFDRV_WriteRecord( dev, &emr.emr ))
if(!emfdc_record( emf, &emr.emr ))
index = 0;
return index;
}
......@@ -363,21 +361,21 @@ static BOOL EMFDC_SelectPen( DC_ATTR *dc_attr, HPEN pen )
if((index = EMFDRV_FindObject( &emf->dev, pen )) != 0)
goto found;
if (!(index = EMFDRV_CreatePenIndirect( &emf->dev, pen ))) return FALSE;
if (!(index = EMFDRV_CreatePenIndirect( emf, pen ))) return FALSE;
GDI_hdc_using_object( pen, dc_attr->hdc, EMFDC_DeleteObject );
found:
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/******************************************************************
* EMFDRV_CreatePalette
*/
static DWORD EMFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPal)
static DWORD EMFDRV_CreatePalette( struct emf *emf, HPALETTE hPal )
{
WORD i;
struct {
......@@ -395,9 +393,9 @@ static DWORD EMFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPal)
pal.hdr.emr.iType = EMR_CREATEPALETTE;
pal.hdr.emr.nSize = sizeof(pal.hdr) + pal.hdr.lgpl.palNumEntries * sizeof(PALETTEENTRY);
pal.hdr.ihPal = EMFDRV_AddHandle( dev, hPal );
pal.hdr.ihPal = EMFDRV_AddHandle( emf, hPal );
if (!EMFDRV_WriteRecord( dev, &pal.hdr.emr ))
if (!emfdc_record( emf, &pal.hdr.emr ))
pal.hdr.ihPal = 0;
return pal.hdr.ihPal;
}
......@@ -420,14 +418,14 @@ BOOL EMFDC_SelectPalette( DC_ATTR *dc_attr, HPALETTE palette )
if ((index = EMFDRV_FindObject( &emf->dev, palette )) != 0)
goto found;
if (!(index = EMFDRV_CreatePalette( &emf->dev, palette ))) return 0;
if (!(index = EMFDRV_CreatePalette( emf, palette ))) return 0;
GDI_hdc_using_object( palette, dc_attr->hdc, EMFDC_DeleteObject );
found:
emr.emr.iType = EMR_SELECTPALETTE;
emr.emr.nSize = sizeof(emr);
emr.ihPal = index;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
BOOL EMFDC_SelectObject( DC_ATTR *dc_attr, HGDIOBJ obj )
......@@ -459,12 +457,12 @@ BOOL EMFDC_SetDCBrushColor( DC_ATTR *dc_attr, COLORREF color )
if (emf->dc_brush) DeleteObject( emf->dc_brush );
if (!(emf->dc_brush = CreateSolidBrush( color ))) return FALSE;
if (!(index = EMFDRV_CreateBrushIndirect( &emf->dev, emf->dc_brush ))) return FALSE;
if (!(index = emfdc_create_brush( emf, emf->dc_brush ))) return FALSE;
GDI_hdc_using_object( emf->dc_brush, dc_attr->hdc, EMFDC_DeleteObject );
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/******************************************************************
......@@ -481,12 +479,12 @@ BOOL EMFDC_SetDCPenColor( DC_ATTR *dc_attr, COLORREF color )
if (emf->dc_pen) DeleteObject( emf->dc_pen );
if (!(emf->dc_pen = CreatePenIndirect( &logpen ))) return FALSE;
if (!(index = EMFDRV_CreatePenIndirect( &emf->dev, emf->dc_pen ))) return FALSE;
if (!(index = EMFDRV_CreatePenIndirect( emf, emf->dc_pen ))) return FALSE;
GDI_hdc_using_object( emf->dc_pen, dc_attr->hdc, EMFDC_DeleteObject );
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
return EMFDRV_WriteRecord( &emf->dev, &emr.emr );
return emfdc_record( emf, &emr.emr );
}
/*******************************************************************
......@@ -511,7 +509,7 @@ BOOL WINAPI GdiComment( HDC hdc, UINT bytes, const BYTE *buffer )
memset(&emr->Data[bytes], 0, rounded_size - bytes);
memcpy(&emr->Data[0], buffer, bytes);
ret = EMFDRV_WriteRecord( dc_attr->emf, &emr->emr );
ret = emfdc_record( dc_attr->emf, &emr->emr );
HeapFree(GetProcessHeap(), 0, emr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment