Commit b94e4330 authored by Huw D M Davies's avatar Huw D M Davies Committed by Alexandre Julliard

Change (32 bit) HMETAFILEs to GDI objects (HMETAFILE16s remain as

global memory handles). Fixed disk-based MetaFiles. Better separation between MetaFile playback and the metafiledrv.
parent 9c1a05ab
......@@ -5,8 +5,9 @@
*/
#include "gdi.h"
#include "metafile.h"
#include "metafiledrv.h"
#include "heap.h"
#include "debug.h"
/***********************************************************************
* MFDRV_PatBlt
......@@ -14,8 +15,8 @@
BOOL MFDRV_PatBlt( DC *dc, INT left, INT top,
INT width, INT height, DWORD rop )
{
MF_MetaParam6( dc, META_PATBLT, left, top, width, height,
HIWORD(rop), LOWORD(rop) );
MFDRV_MetaParam6( dc, META_PATBLT, left, top, width, height,
HIWORD(rop), LOWORD(rop) );
return TRUE;
}
......@@ -23,23 +24,127 @@ BOOL MFDRV_PatBlt( DC *dc, INT left, INT top,
/***********************************************************************
* MFDRV_BitBlt
*/
BOOL MFDRV_BitBlt( DC *dcDst, INT xDst, INT yDst,
INT width, INT height, DC *dcSrc,
INT xSrc, INT ySrc, DWORD rop )
BOOL MFDRV_BitBlt( DC *dcDst, INT xDst, INT yDst, INT width, INT height,
DC *dcSrc, INT xSrc, INT ySrc, DWORD rop )
{
return MF_BitBlt( dcDst, xDst, yDst, width, height,
dcSrc, xSrc, ySrc, rop );
BOOL ret;
DWORD len;
METARECORD *mr;
BITMAP16 BM;
GetObject16(dcSrc->w.hBitmap, sizeof(BITMAP16), &BM);
len = sizeof(METARECORD) + 12 * sizeof(INT16) + BM.bmWidthBytes * BM.bmHeight;
if (!(mr = HeapAlloc(SystemHeap, 0, len)))
return FALSE;
mr->rdFunction = META_BITBLT;
*(mr->rdParm + 7) = BM.bmWidth;
*(mr->rdParm + 8) = BM.bmHeight;
*(mr->rdParm + 9) = BM.bmWidthBytes;
*(mr->rdParm +10) = BM.bmPlanes;
*(mr->rdParm +11) = BM.bmBitsPixel;
TRACE(metafile,"len = %ld rop=%lx \n",len,rop);
if (GetBitmapBits(dcSrc->w.hBitmap,BM.bmWidthBytes * BM.bmHeight,
mr->rdParm +12))
{
mr->rdSize = len / sizeof(INT16);
*(mr->rdParm) = HIWORD(rop);
*(mr->rdParm + 1) = ySrc;
*(mr->rdParm + 2) = xSrc;
*(mr->rdParm + 3) = height;
*(mr->rdParm + 4) = width;
*(mr->rdParm + 5) = yDst;
*(mr->rdParm + 6) = xDst;
ret = MFDRV_WriteRecord( dcDst, mr, mr->rdSize * 2);
}
else
ret = FALSE;
HeapFree( SystemHeap, 0, mr);
return ret;
}
/***********************************************************************
* MFDRV_StretchBlt
* this function contains TWO ways for procesing StretchBlt in metafiles,
* decide between rdFunction values META_STRETCHBLT or META_DIBSTRETCHBLT
* via #define STRETCH_VIA_DIB
*/
BOOL MFDRV_StretchBlt( DC *dcDst, INT xDst, INT yDst,
INT widthDst, INT heightDst,
DC *dcSrc, INT xSrc, INT ySrc,
INT widthSrc, INT heightSrc, DWORD rop )
#define STRETCH_VIA_DIB
#undef STRETCH_VIA_DIB
BOOL MFDRV_StretchBlt( DC *dcDst, INT xDst, INT yDst, INT widthDst,
INT heightDst, DC *dcSrc, INT xSrc, INT ySrc,
INT widthSrc, INT heightSrc, DWORD rop )
{
return MF_StretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
dcSrc, xSrc, ySrc, widthSrc, heightSrc, rop );
BOOL ret;
DWORD len;
METARECORD *mr;
BITMAP16 BM;
#ifdef STRETCH_VIA_DIB
LPBITMAPINFOHEADER lpBMI;
WORD nBPP;
#endif
GetObject16(dcSrc->w.hBitmap, sizeof(BITMAP16), &BM);
#ifdef STRETCH_VIA_DIB
nBPP = BM.bmPlanes * BM.bmBitsPixel;
len = sizeof(METARECORD) + 10 * sizeof(INT16)
+ sizeof(BITMAPINFOHEADER) + (nBPP != 24 ? 1 << nBPP: 0) * sizeof(RGBQUAD)
+ ((BM.bmWidth * nBPP + 31) / 32) * 4 * BM.bmHeight;
if (!(mr = HeapAlloc( SystemHeap, 0, len)))
return FALSE;
mr->rdFunction = META_DIBSTRETCHBLT;
lpBMI=(LPBITMAPINFOHEADER)(mr->rdParm+10);
lpBMI->biSize = sizeof(BITMAPINFOHEADER);
lpBMI->biWidth = BM.bmWidth;
lpBMI->biHeight = BM.bmHeight;
lpBMI->biPlanes = 1;
lpBMI->biBitCount = nBPP; /* 1,4,8 or 24 */
lpBMI->biClrUsed = nBPP != 24 ? 1 << nBPP : 0;
lpBMI->biSizeImage = ((lpBMI->biWidth * nBPP + 31) / 32) * 4 * lpBMI->biHeight;
lpBMI->biCompression = BI_RGB;
lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSX),3937,100);
lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(dcSrc->hSelf,LOGPIXELSY),3937,100);
lpBMI->biClrImportant = 0; /* 1 meter = 39.37 inch */
TRACE(metafile,"MF_StretchBltViaDIB->len = %ld rop=%lx PixYPM=%ld Caps=%d\n",
len,rop,lpBMI->biYPelsPerMeter,GetDeviceCaps(hdcSrc,LOGPIXELSY));
if (GetDIBits(hdcSrc,dcSrc->w.hBitmap,0,(UINT)lpBMI->biHeight,
(LPSTR)lpBMI + DIB_BitmapInfoSize( (BITMAPINFO *)lpBMI,
DIB_RGB_COLORS ),
(LPBITMAPINFO)lpBMI, DIB_RGB_COLORS))
#else
len = sizeof(METARECORD) + 15 * sizeof(INT16) + BM.bmWidthBytes * BM.bmHeight;
if (!(mr = HeapAlloc( SystemHeap, 0, len )))
return FALSE;
mr->rdFunction = META_STRETCHBLT;
*(mr->rdParm +10) = BM.bmWidth;
*(mr->rdParm +11) = BM.bmHeight;
*(mr->rdParm +12) = BM.bmWidthBytes;
*(mr->rdParm +13) = BM.bmPlanes;
*(mr->rdParm +14) = BM.bmBitsPixel;
TRACE(metafile,"len = %ld rop=%lx \n",len,rop);
if (GetBitmapBits( dcSrc->w.hBitmap, BM.bmWidthBytes * BM.bmHeight,
mr->rdParm +15))
#endif
{
mr->rdSize = len / sizeof(INT16);
*(mr->rdParm) = LOWORD(rop);
*(mr->rdParm + 1) = HIWORD(rop);
*(mr->rdParm + 2) = heightSrc;
*(mr->rdParm + 3) = widthSrc;
*(mr->rdParm + 4) = ySrc;
*(mr->rdParm + 5) = xSrc;
*(mr->rdParm + 6) = heightDst;
*(mr->rdParm + 7) = widthDst;
*(mr->rdParm + 8) = yDst;
*(mr->rdParm + 9) = xDst;
ret = MFDRV_WriteRecord( dcDst, mr, mr->rdSize * 2);
}
else
ret = FALSE;
HeapFree( SystemHeap, 0, mr);
return ret;
}
......@@ -7,10 +7,10 @@
#include <stdlib.h>
#include "gdi.h"
#include "dc.h"
#include "metafile.h"
#include "region.h"
#include "xmalloc.h"
#include "metafiledrv.h"
#include "heap.h"
#include "debug.h"
/**********************************************************************
......@@ -19,7 +19,7 @@
BOOL
MFDRV_MoveToEx(DC *dc,INT x,INT y,LPPOINT pt)
{
if (!MF_MetaParam2(dc,META_MOVETO,x,y))
if (!MFDRV_MetaParam2(dc,META_MOVETO,x,y))
return FALSE;
if (pt)
......@@ -38,7 +38,7 @@ MFDRV_MoveToEx(DC *dc,INT x,INT y,LPPOINT pt)
BOOL
MFDRV_LineTo( DC *dc, INT x, INT y )
{
return MF_MetaParam2(dc, META_LINETO, x, y);
return MFDRV_MetaParam2(dc, META_LINETO, x, y);
}
......@@ -49,8 +49,8 @@ BOOL
MFDRV_Arc( DC *dc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return MF_MetaParam8(dc, META_ARC, left, top, right, bottom,
xstart, ystart, xend, yend);
return MFDRV_MetaParam8(dc, META_ARC, left, top, right, bottom,
xstart, ystart, xend, yend);
}
......@@ -61,8 +61,8 @@ BOOL
MFDRV_Pie( DC *dc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return MF_MetaParam8(dc, META_PIE, left, top, right, bottom,
xstart, ystart, xend, yend);
return MFDRV_MetaParam8(dc, META_PIE, left, top, right, bottom,
xstart, ystart, xend, yend);
}
......@@ -73,8 +73,8 @@ BOOL
MFDRV_Chord( DC *dc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return MF_MetaParam8(dc, META_CHORD, left, top, right, bottom,
xstart, ystart, xend, yend);
return MFDRV_MetaParam8(dc, META_CHORD, left, top, right, bottom,
xstart, ystart, xend, yend);
}
/***********************************************************************
......@@ -83,7 +83,7 @@ MFDRV_Chord( DC *dc, INT left, INT top, INT right, INT bottom,
BOOL
MFDRV_Ellipse( DC *dc, INT left, INT top, INT right, INT bottom )
{
return MF_MetaParam4(dc, META_ELLIPSE, left, top, right, bottom);
return MFDRV_MetaParam4(dc, META_ELLIPSE, left, top, right, bottom);
}
/***********************************************************************
......@@ -92,7 +92,7 @@ MFDRV_Ellipse( DC *dc, INT left, INT top, INT right, INT bottom )
BOOL
MFDRV_Rectangle(DC *dc, INT left, INT top, INT right, INT bottom)
{
return MF_MetaParam4(dc, META_RECTANGLE, left, top, right, bottom);
return MFDRV_MetaParam4(dc, META_RECTANGLE, left, top, right, bottom);
}
/***********************************************************************
......@@ -102,8 +102,8 @@ BOOL
MFDRV_RoundRect( DC *dc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
return MF_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom,
ell_width, ell_height);
return MFDRV_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom,
ell_width, ell_height);
}
/***********************************************************************
......@@ -112,7 +112,31 @@ MFDRV_RoundRect( DC *dc, INT left, INT top, INT right,
COLORREF
MFDRV_SetPixel( DC *dc, INT x, INT y, COLORREF color )
{
return MF_MetaParam4(dc, META_SETPIXEL, x, y,HIWORD(color),LOWORD(color));
return MFDRV_MetaParam4(dc, META_SETPIXEL, x, y,HIWORD(color),
LOWORD(color));
}
/******************************************************************
* MFDRV_MetaPoly - implements Polygon and Polyline
*/
static BOOL MFDRV_MetaPoly(DC *dc, short func, LPPOINT16 pt, short count)
{
BOOL ret;
DWORD len;
METARECORD *mr;
len = sizeof(METARECORD) + (count * 4);
if (!(mr = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, len )))
return FALSE;
mr->rdSize = len / 2;
mr->rdFunction = func;
*(mr->rdParm) = count;
memcpy(mr->rdParm + 1, pt, count * 4);
ret = MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
HeapFree( SystemHeap, 0, mr);
return ret;
}
......@@ -128,7 +152,7 @@ MFDRV_Polyline( DC *dc, const POINT* pt, INT count )
pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
ret = MF_MetaPoly(dc, META_POLYLINE, pt16, count);
ret = MFDRV_MetaPoly(dc, META_POLYLINE, pt16, count);
free(pt16);
return ret;
......@@ -147,7 +171,7 @@ MFDRV_Polygon( DC *dc, const POINT* pt, INT count )
pt16 = (LPPOINT16)xmalloc(sizeof(POINT16)*count);
for (i=count;i--;) CONV_POINT32TO16(&(pt[i]),&(pt16[i]));
ret = MF_MetaPoly(dc, META_POLYGON, pt16, count);
ret = MFDRV_MetaPoly(dc, META_POLYGON, pt16, count);
free(pt16);
return ret;
......@@ -155,7 +179,7 @@ MFDRV_Polygon( DC *dc, const POINT* pt, INT count )
/**********************************************************************
* PolyPolygon
* MFDRV_PolyPolygon
*/
BOOL
MFDRV_PolyPolygon( DC *dc, const POINT* pt, const INT* counts, UINT polygons)
......@@ -168,7 +192,7 @@ MFDRV_PolyPolygon( DC *dc, const POINT* pt, const INT* counts, UINT polygons)
for (i=0;i<polygons;i++) {
pt16=(LPPOINT16)xmalloc(sizeof(POINT16)*counts[i]);
for (j=counts[i];j--;) CONV_POINT32TO16(&(curpt[j]),&(pt16[j]));
ret = MF_MetaPoly(dc, META_POLYGON, pt16, counts[i]);
ret = MFDRV_MetaPoly(dc, META_POLYGON, pt16, counts[i]);
free(pt16);
if (!ret)
return FALSE;
......@@ -184,7 +208,96 @@ MFDRV_PolyPolygon( DC *dc, const POINT* pt, const INT* counts, UINT polygons)
BOOL
MFDRV_ExtFloodFill( DC *dc, INT x, INT y, COLORREF color, UINT fillType )
{
return MF_MetaParam4(dc,META_FLOODFILL,x,y,HIWORD(color),LOWORD(color));
return MFDRV_MetaParam4(dc,META_FLOODFILL,x,y,HIWORD(color),
LOWORD(color));
}
/******************************************************************
* MFDRV_CreateRegion
*
* For explanation of the format of the record see MF_Play_MetaCreateRegion in
* objects/metafile.c
*/
static INT16 MFDRV_CreateRegion(DC *dc, HRGN hrgn)
{
DWORD len;
METARECORD *mr;
RGNDATA *rgndata;
RECT *pCurRect, *pEndRect;
WORD Bands = 0, MaxBands = 0;
WORD *Param, *StartBand;
BOOL ret;
len = GetRegionData( hrgn, 0, NULL );
if( !(rgndata = HeapAlloc( SystemHeap, 0, len )) ) {
WARN(metafile, "Can't alloc rgndata buffer\n");
return -1;
}
GetRegionData( hrgn, len, rgndata );
/* Overestimate of length:
* Assume every rect is a separate band -> 6 WORDs per rect
*/
len = sizeof(METARECORD) + 20 + (rgndata->rdh.nCount * 12);
if( !(mr = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, len )) ) {
WARN(metafile, "Can't alloc METARECORD buffer\n");
HeapFree( SystemHeap, 0, rgndata );
return -1;
}
Param = mr->rdParm + 11;
StartBand = NULL;
pEndRect = (RECT *)rgndata->Buffer + rgndata->rdh.nCount;
for(pCurRect = (RECT *)rgndata->Buffer; pCurRect < pEndRect; pCurRect++)
{
if( StartBand && pCurRect->top == *(StartBand + 1) )
{
*Param++ = pCurRect->left;
*Param++ = pCurRect->right;
}
else
{
if(StartBand)
{
*StartBand = Param - StartBand - 3;
*Param++ = *StartBand;
if(*StartBand > MaxBands)
MaxBands = *StartBand;
Bands++;
}
StartBand = Param++;
*Param++ = pCurRect->top;
*Param++ = pCurRect->bottom;
*Param++ = pCurRect->left;
*Param++ = pCurRect->right;
}
}
len = Param - (WORD *)mr;
mr->rdParm[0] = 0;
mr->rdParm[1] = 6;
mr->rdParm[2] = 0x1234;
mr->rdParm[3] = 0;
mr->rdParm[4] = len * 2;
mr->rdParm[5] = Bands;
mr->rdParm[6] = MaxBands;
mr->rdParm[7] = rgndata->rdh.rcBound.left;
mr->rdParm[8] = rgndata->rdh.rcBound.top;
mr->rdParm[9] = rgndata->rdh.rcBound.right;
mr->rdParm[10] = rgndata->rdh.rcBound.bottom;
mr->rdFunction = META_CREATEREGION;
mr->rdSize = len / 2;
ret = MFDRV_WriteRecord( dc, mr, mr->rdSize * 2 );
HeapFree( SystemHeap, 0, mr );
HeapFree( SystemHeap, 0, rgndata );
if(!ret)
{
WARN(metafile, "MFDRV_WriteRecord failed\n");
return -1;
}
return MFDRV_AddHandleDC( dc );
}
......@@ -195,10 +308,10 @@ BOOL
MFDRV_PaintRgn( DC *dc, HRGN hrgn )
{
INT16 index;
index = MF_CreateRegion( dc, hrgn );
index = MFDRV_CreateRegion( dc, hrgn );
if(index == -1)
return FALSE;
return MF_MetaParam1( dc, META_PAINTREGION, index );
return MFDRV_MetaParam1( dc, META_PAINTREGION, index );
}
......@@ -208,7 +321,7 @@ MFDRV_PaintRgn( DC *dc, HRGN hrgn )
COLORREF
MFDRV_SetBkColor( DC *dc, COLORREF color )
{
return MF_MetaParam2(dc, META_SETBKCOLOR, HIWORD(color), LOWORD(color));
return MFDRV_MetaParam2(dc, META_SETBKCOLOR, HIWORD(color), LOWORD(color));
}
......@@ -218,6 +331,7 @@ MFDRV_SetBkColor( DC *dc, COLORREF color )
COLORREF
MFDRV_SetTextColor( DC *dc, COLORREF color )
{
return MF_MetaParam2(dc, META_SETTEXTCOLOR, HIWORD(color), LOWORD(color));
return MFDRV_MetaParam2(dc, META_SETTEXTCOLOR, HIWORD(color),
LOWORD(color));
}
......@@ -5,7 +5,6 @@
*/
#include "gdi.h"
#include "metafile.h"
#include "metafiledrv.h"
......@@ -15,7 +14,7 @@
INT MFDRV_SetMapMode( DC *dc, INT mode )
{
INT prevMode = dc->w.MapMode;
MF_MetaParam1( dc, META_SETMAPMODE, mode );
MFDRV_MetaParam1( dc, META_SETMAPMODE, mode );
return prevMode;
}
......@@ -25,7 +24,7 @@ INT MFDRV_SetMapMode( DC *dc, INT mode )
*/
BOOL MFDRV_SetViewportExt( DC *dc, INT x, INT y )
{
MF_MetaParam2( dc, META_SETVIEWPORTEXT, x, y );
MFDRV_MetaParam2( dc, META_SETVIEWPORTEXT, x, y );
return TRUE;
}
......@@ -35,7 +34,7 @@ BOOL MFDRV_SetViewportExt( DC *dc, INT x, INT y )
*/
BOOL MFDRV_SetViewportOrg( DC *dc, INT x, INT y )
{
MF_MetaParam2( dc, META_SETVIEWPORTORG, x, y );
MFDRV_MetaParam2( dc, META_SETVIEWPORTORG, x, y );
return TRUE;
}
......@@ -45,7 +44,7 @@ BOOL MFDRV_SetViewportOrg( DC *dc, INT x, INT y )
*/
BOOL MFDRV_SetWindowExt( DC *dc, INT x, INT y )
{
MF_MetaParam2( dc, META_SETWINDOWEXT, x, y );
MFDRV_MetaParam2( dc, META_SETWINDOWEXT, x, y );
return TRUE;
}
......@@ -55,7 +54,7 @@ BOOL MFDRV_SetWindowExt( DC *dc, INT x, INT y )
*/
BOOL MFDRV_SetWindowOrg( DC *dc, INT x, INT y )
{
MF_MetaParam2( dc, META_SETWINDOWORG, x, y );
MFDRV_MetaParam2( dc, META_SETWINDOWORG, x, y );
return TRUE;
}
......@@ -65,7 +64,7 @@ BOOL MFDRV_SetWindowOrg( DC *dc, INT x, INT y )
*/
BOOL MFDRV_OffsetViewportOrg( DC *dc, INT x, INT y )
{
MF_MetaParam2( dc, META_OFFSETVIEWPORTORG, x, y );
MFDRV_MetaParam2( dc, META_OFFSETVIEWPORTORG, x, y );
return TRUE;
}
......@@ -75,7 +74,7 @@ BOOL MFDRV_OffsetViewportOrg( DC *dc, INT x, INT y )
*/
BOOL MFDRV_OffsetWindowOrg( DC *dc, INT x, INT y )
{
MF_MetaParam2( dc, META_OFFSETWINDOWORG, x, y );
MFDRV_MetaParam2( dc, META_OFFSETWINDOWORG, x, y );
return TRUE;
}
......@@ -86,7 +85,7 @@ BOOL MFDRV_OffsetWindowOrg( DC *dc, INT x, INT y )
BOOL MFDRV_ScaleViewportExt( DC *dc, INT xNum, INT xDenom,
INT yNum, INT yDenom )
{
MF_MetaParam4( dc, META_SCALEVIEWPORTEXT, xNum, xDenom, yNum, yDenom );
MFDRV_MetaParam4( dc, META_SCALEVIEWPORTEXT, xNum, xDenom, yNum, yDenom );
return TRUE;
}
......@@ -97,6 +96,7 @@ BOOL MFDRV_ScaleViewportExt( DC *dc, INT xNum, INT xDenom,
BOOL MFDRV_ScaleWindowExt( DC *dc, INT xNum, INT xDenom,
INT yNum, INT yDenom )
{
MF_MetaParam4( dc, META_SCALEWINDOWEXT, xNum, xDenom, yNum, yDenom );
MFDRV_MetaParam4( dc, META_SCALEWINDOWEXT, xNum, xDenom, yNum, yDenom );
return TRUE;
}
......@@ -9,11 +9,10 @@
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "metafile.h"
#include "metafiledrv.h"
#include "pen.h"
#include "debug.h"
#include "heap.h"
/***********************************************************************
* MFDRV_BITMAP_SelectObject
......@@ -25,6 +24,121 @@ static HBITMAP16 MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
}
/******************************************************************
* MFDRV_CreateBrushIndirect
*/
static BOOL MFDRV_CreateBrushIndirect(DC *dc, HBRUSH16 hBrush,
LOGBRUSH16 *logbrush)
{
int index;
char buffer[sizeof(METARECORD) - 2 + sizeof(*logbrush)];
METARECORD *mr = (METARECORD *)&buffer;
mr->rdSize = (sizeof(METARECORD) + sizeof(*logbrush) - 2) / 2;
mr->rdFunction = META_CREATEBRUSHINDIRECT;
memcpy(&(mr->rdParm), logbrush, sizeof(*logbrush));
if (!(MFDRV_WriteRecord( dc, mr, mr->rdSize * 2))) return FALSE;
mr->rdSize = sizeof(METARECORD) / 2;
mr->rdFunction = META_SELECTOBJECT;
if ((index = MFDRV_AddHandleDC( dc )) == -1) return FALSE;
*(mr->rdParm) = index;
return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
}
/******************************************************************
* MFDRV_CreatePatternBrush
*/
static BOOL MFDRV_CreatePatternBrush(DC *dc, HBRUSH16 hBrush,
LOGBRUSH16 *logbrush)
{
DWORD len, bmSize, biSize;
METARECORD *mr;
BITMAPINFO *info;
int index;
char buffer[sizeof(METARECORD)];
switch (logbrush->lbStyle)
{
case BS_PATTERN:
{
BITMAP bm;
BYTE *bits;
GetObjectA(logbrush->lbHatch, sizeof(bm), &bm);
if(bm.bmBitsPixel != 1 || bm.bmPlanes != 1) {
FIXME(metafile, "Trying to store a colour pattern brush\n");
return FALSE;
}
bmSize = bm.bmHeight * DIB_GetDIBWidthBytes(bm.bmWidth, 1);
len = sizeof(METARECORD) + sizeof(WORD) + sizeof(BITMAPINFO) +
sizeof(RGBQUAD) + bmSize;
mr = HeapAlloc(SystemHeap, HEAP_ZERO_MEMORY, len);
if(!mr) return FALSE;
mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
mr->rdSize = len / 2;
mr->rdParm[0] = BS_PATTERN;
mr->rdParm[1] = DIB_RGB_COLORS;
info = (BITMAPINFO *)(mr->rdParm + 2);
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
info->bmiHeader.biWidth = bm.bmWidth;
info->bmiHeader.biHeight = bm.bmHeight;
info->bmiHeader.biPlanes = 1;
info->bmiHeader.biBitCount = 1;
bits = ((BYTE *)info) + sizeof(BITMAPINFO) + sizeof(RGBQUAD);
GetDIBits(dc->hSelf, logbrush->lbHatch, 0, bm.bmHeight, bits,
info, DIB_RGB_COLORS);
*(DWORD *)info->bmiColors = 0;
*(DWORD *)(info->bmiColors + 1) = 0xffffff;
break;
}
case BS_DIBPATTERN:
info = (BITMAPINFO *)GlobalLock16((HGLOBAL16)logbrush->lbHatch);
if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage;
else
bmSize = DIB_GetDIBWidthBytes(info->bmiHeader.biWidth,
info->bmiHeader.biBitCount)
* info->bmiHeader.biHeight;
biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush->lbColor));
len = sizeof(METARECORD) + biSize + bmSize + 2;
mr = HeapAlloc(SystemHeap, HEAP_ZERO_MEMORY, len);
if(!mr) return FALSE;
mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
mr->rdSize = len / 2;
*(mr->rdParm) = logbrush->lbStyle;
*(mr->rdParm + 1) = LOWORD(logbrush->lbColor);
memcpy(mr->rdParm + 2, info, biSize + bmSize);
break;
default:
return FALSE;
}
if (!(MFDRV_WriteRecord(dc, mr, len)))
{
HeapFree(SystemHeap, 0, mr);
return FALSE;
}
HeapFree(SystemHeap, 0, mr);
mr = (METARECORD *)&buffer;
mr->rdSize = sizeof(METARECORD) / 2;
mr->rdFunction = META_SELECTOBJECT;
if ((index = MFDRV_AddHandleDC( dc )) == -1) return FALSE;
*(mr->rdParm) = index;
return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
}
/***********************************************************************
* MFDRV_BRUSH_SelectObject
*/
......@@ -39,16 +153,39 @@ static HBRUSH MFDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
case BS_SOLID:
case BS_HATCHED:
case BS_HOLLOW:
if (!MF_CreateBrushIndirect( dc, hbrush, &logbrush )) return 0;
if (!MFDRV_CreateBrushIndirect( dc, hbrush, &logbrush )) return 0;
break;
case BS_PATTERN:
case BS_DIBPATTERN:
if (!MF_CreatePatternBrush( dc, hbrush, &logbrush )) return 0;
if (!MFDRV_CreatePatternBrush( dc, hbrush, &logbrush )) return 0;
break;
}
return 1; /* FIXME? */
}
/******************************************************************
* MFDRV_CreateFontIndirect
*/
static BOOL MFDRV_CreateFontIndirect(DC *dc, HFONT16 hFont, LOGFONT16 *logfont)
{
int index;
char buffer[sizeof(METARECORD) - 2 + sizeof(LOGFONT16)];
METARECORD *mr = (METARECORD *)&buffer;
mr->rdSize = (sizeof(METARECORD) + sizeof(LOGFONT16) - 2) / 2;
mr->rdFunction = META_CREATEFONTINDIRECT;
memcpy(&(mr->rdParm), logfont, sizeof(LOGFONT16));
if (!(MFDRV_WriteRecord( dc, mr, mr->rdSize * 2))) return FALSE;
mr->rdSize = sizeof(METARECORD) / 2;
mr->rdFunction = META_SELECTOBJECT;
if ((index = MFDRV_AddHandleDC( dc )) == -1) return FALSE;
*(mr->rdParm) = index;
return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
}
/***********************************************************************
* MFDRV_FONT_SelectObject
......@@ -57,10 +194,33 @@ static HFONT16 MFDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
FONTOBJ * font )
{
HFONT16 prevHandle = dc->w.hFont;
if (MF_CreateFontIndirect(dc, hfont, &(font->logfont))) return prevHandle;
if (MFDRV_CreateFontIndirect(dc, hfont, &(font->logfont)))
return prevHandle;
return 0;
}
/******************************************************************
* MFDRV_CreatePenIndirect
*/
static BOOL MFDRV_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen)
{
int index;
char buffer[sizeof(METARECORD) - 2 + sizeof(*logpen)];
METARECORD *mr = (METARECORD *)&buffer;
mr->rdSize = (sizeof(METARECORD) + sizeof(*logpen) - 2) / 2;
mr->rdFunction = META_CREATEPENINDIRECT;
memcpy(&(mr->rdParm), logpen, sizeof(*logpen));
if (!(MFDRV_WriteRecord( dc, mr, mr->rdSize * 2))) return FALSE;
mr->rdSize = sizeof(METARECORD) / 2;
mr->rdFunction = META_SELECTOBJECT;
if ((index = MFDRV_AddHandleDC( dc )) == -1) return FALSE;
*(mr->rdParm) = index;
return MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
}
/***********************************************************************
* MFDRV_PEN_SelectObject
......@@ -71,7 +231,7 @@ static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
LOGPEN16 logpen = { pen->logpen.lopnStyle,
{ pen->logpen.lopnWidth.x, pen->logpen.lopnWidth.y },
pen->logpen.lopnColor };
if (MF_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle;
if (MFDRV_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle;
return 0;
}
......@@ -108,3 +268,5 @@ HGDIOBJ MFDRV_SelectObject( DC *dc, HGDIOBJ handle )
GDI_HEAP_UNLOCK( handle );
return ret;
}
......@@ -5,11 +5,50 @@
*
*/
#include <stdlib.h>
#include "windef.h"
#include "metafile.h"
#include "metafiledrv.h"
#include "debug.h"
#include "xmalloc.h"
#include "heap.h"
/******************************************************************
* MFDRV_MetaExtTextOut
*/
static BOOL MFDRV_MetaExtTextOut(DC*dc, short x, short y, UINT16 flags,
const RECT16 *rect, LPCSTR str, short count,
const INT16 *lpDx)
{
BOOL ret;
DWORD len;
METARECORD *mr;
if((!flags && rect) || (flags && !rect))
WARN(metafile, "Inconsistent flags and rect\n");
len = sizeof(METARECORD) + (((count + 1) >> 1) * 2) + 2 * sizeof(short)
+ sizeof(UINT16);
if(rect)
len += sizeof(RECT16);
if (lpDx)
len+=count*sizeof(INT16);
if (!(mr = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, len)))
return FALSE;
mr->rdSize = len / 2;
mr->rdFunction = META_EXTTEXTOUT;
*(mr->rdParm) = y;
*(mr->rdParm + 1) = x;
*(mr->rdParm + 2) = count;
*(mr->rdParm + 3) = flags;
if (rect) memcpy(mr->rdParm + 4, rect, sizeof(RECT16));
memcpy(mr->rdParm + (rect ? 8 : 4), str, count);
if (lpDx)
memcpy(mr->rdParm + (rect ? 8 : 4) + ((count + 1) >> 1),lpDx,
count*sizeof(INT16));
ret = MFDRV_WriteRecord( dc, mr, mr->rdSize * 2);
HeapFree( SystemHeap, 0, mr);
return ret;
}
/***********************************************************************
......@@ -21,13 +60,21 @@ MFDRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
const INT *lpDx )
{
RECT16 rect16;
LPINT16 lpdx16 = lpDx?(LPINT16)xmalloc(sizeof(INT16)*count):NULL;
LPINT16 lpdx16 = NULL;
BOOL ret;
int i;
if(lpDx)
lpdx16 = HeapAlloc( SystemHeap, 0, sizeof(INT16)*count );
if (lprect) CONV_RECT32TO16(lprect,&rect16);
if (lpdx16) for (i=count;i--;) lpdx16[i]=lpDx[i];
ret=MF_ExtTextOut(dc,x,y,flags,lprect?&rect16:NULL,str,count,lpdx16);
if (lpdx16) free(lpdx16);
if (lpdx16)
for (i=count;i--;)
lpdx16[i]=lpDx[i];
ret = MFDRV_MetaExtTextOut(dc,x,y,flags,lprect?&rect16:NULL,str,count,
lpdx16);
if (lpdx16) HeapFree( SystemHeap, 0, lpdx16 );
return ret;
}
......@@ -10,33 +10,34 @@
#include "wingdi.h"
#include "gdi.h"
/* GDI32 metafile object */
typedef struct
{
GDIOBJHDR header;
METAHEADER *mh;
} METAFILEOBJ;
#pragma pack(1)
typedef struct {
DWORD dw1, dw2, dw3;
WORD w4;
CHAR filename[0x100];
} METAHEADERDISK;
#pragma pack(4)
#define MFHEADERSIZE (sizeof(METAHEADER))
#define MFVERSION 0x300
#define META_EOF 0x0000
BOOL MF_MetaParam0(DC *dc, short func);
BOOL MF_MetaParam1(DC *dc, short func, short param1);
BOOL MF_MetaParam2(DC *dc, short func, short param1, short param2);
BOOL MF_MetaParam4(DC *dc, short func, short param1, short param2,
short param3, short param4);
BOOL MF_MetaParam6(DC *dc, short func, short param1, short param2,
short param3, short param4, short param5, short param6);
BOOL MF_MetaParam8(DC *dc, short func, short param1, short param2,
short param3, short param4, short param5,
short param6, short param7, short param8);
BOOL MF_CreateBrushIndirect(DC *dc, HBRUSH16 hBrush, LOGBRUSH16 *logbrush);
BOOL MF_CreatePatternBrush(DC *dc, HBRUSH16 hBrush, LOGBRUSH16 *logbrush);
BOOL MF_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen);
BOOL MF_CreateFontIndirect(DC *dc, HFONT16 hFont, LOGFONT16 *logfont);
BOOL MF_TextOut(DC *dc, short x, short y, LPCSTR str, short count);
BOOL MF_ExtTextOut(DC *dc, short x, short y, UINT16 flags, const RECT16 *rect,
LPCSTR str, short count, const INT16 *lpDx);
BOOL MF_MetaPoly(DC *dc, short func, LPPOINT16 pt, short count);
BOOL MF_BitBlt(DC *dcDest, short xDest, short yDest, short width,
short height, DC *dcSrc, short xSrc, short ySrc, DWORD rop);
BOOL MF_StretchBlt(DC *dcDest, short xDest, short yDest, short widthDest,
short heightDest, DC *dcSrc, short xSrc, short ySrc,
short widthSrc, short heightSrc, DWORD rop);
INT16 MF_CreateRegion(DC *dc, HRGN hrgn);
/* values of mtType in METAHEADER. Note however that the disk image of a disk
based metafile has mtType == 1 */
#define METAFILE_MEMORY 1
#define METAFILE_DISK 2
extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh);
extern HMETAFILE16 MF_Create_HMETAFILE16(METAHEADER *mh);
extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename);
#endif /* __WINE_METAFILE_H */
......@@ -8,20 +8,30 @@
#include "wingdi.h"
#include "gdi.h"
/* FIXME: SDK docs says these should be 1 and 2 */
/* DR 980322: most wmf's have 1, so I think 0 and 1 is correct */
#define METAFILE_MEMORY 0
#define METAFILE_DISK 1
/* Metafile driver physical DC */
typedef struct
{
METAHEADER *mh; /* Pointer to metafile header */
UINT nextHandle; /* Next handle number */
UINT nextHandle; /* Next handle number */
HFILE hFile; /* HFILE for disk based MetaFile */
} METAFILEDRV_PDEVICE;
extern BOOL MFDRV_MetaParam0(DC *dc, short func);
extern BOOL MFDRV_MetaParam1(DC *dc, short func, short param1);
extern BOOL MFDRV_MetaParam2(DC *dc, short func, short param1, short param2);
extern BOOL MFDRV_MetaParam4(DC *dc, short func, short param1, short param2,
short param3, short param4);
extern BOOL MFDRV_MetaParam6(DC *dc, short func, short param1, short param2,
short param3, short param4, short param5,
short param6);
extern BOOL MFDRV_MetaParam8(DC *dc, short func, short param1, short param2,
short param3, short param4, short param5,
short param6, short param7, short param8);
extern BOOL MFDRV_WriteRecord(DC *dc, METARECORD *mr, DWORD rlen);
extern int MFDRV_AddHandleDC( DC *dc );
/* Metafile driver functions */
extern BOOL MFDRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
......
......@@ -6,7 +6,7 @@
#include <stdlib.h>
#include "dc.h"
#include "metafile.h"
#include "metafiledrv.h"
#include "region.h"
#include "debug.h"
#include "wine/winuser16.h"
......@@ -152,7 +152,7 @@ INT WINAPI OffsetClipRgn( HDC hdc, INT x, INT y )
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return ERROR;
MF_MetaParam2(dc, META_OFFSETCLIPRGN, x, y);
MFDRV_MetaParam2(dc, META_OFFSETCLIPRGN, x, y);
GDI_HEAP_UNLOCK( hdc );
return NULLREGION; /* ?? */
}
......@@ -257,7 +257,7 @@ INT WINAPI ExcludeClipRect( HDC hdc, INT left, INT top,
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return ERROR;
MF_MetaParam4(dc, META_EXCLUDECLIPRECT, left, top, right, bottom);
MFDRV_MetaParam4(dc, META_EXCLUDECLIPRECT, left, top, right, bottom);
GDI_HEAP_UNLOCK( hdc );
return NULLREGION; /* ?? */
}
......@@ -297,7 +297,7 @@ INT WINAPI IntersectClipRect( HDC hdc, INT left, INT top,
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return ERROR;
MF_MetaParam4(dc, META_INTERSECTCLIPRECT, left, top, right, bottom);
MFDRV_MetaParam4(dc, META_INTERSECTCLIPRECT, left, top, right, bottom);
GDI_HEAP_UNLOCK( hdc );
return NULLREGION; /* ?? */
}
......
......@@ -15,7 +15,7 @@
#include "dc.h"
#include "gdi.h"
#include "heap.h"
#include "metafile.h"
#include "metafiledrv.h"
#include "debug.h"
#include "font.h"
#include "winerror.h"
......@@ -410,7 +410,7 @@ INT WINAPI SaveDC( HDC hdc )
{
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
if (!dc) return 0;
MF_MetaParam0(dc, META_SAVEDC);
MFDRV_MetaParam0(dc, META_SAVEDC);
GDI_HEAP_UNLOCK( hdc );
return 1; /* ?? */
}
......@@ -473,7 +473,7 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level )
GDI_HEAP_UNLOCK( hdc );
return FALSE;
}
MF_MetaParam1(dc, META_RESTOREDC, level);
MFDRV_MetaParam1(dc, META_RESTOREDC, level);
GDI_HEAP_UNLOCK( hdc );
return TRUE;
}
......@@ -841,7 +841,7 @@ UINT WINAPI SetTextAlign( HDC hdc, UINT textAlign )
if (!dc)
{
if (!(dc = (DC *)GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC ))) return 0;
MF_MetaParam1( dc, META_SETTEXTALIGN, textAlign );
MFDRV_MetaParam1( dc, META_SETTEXTALIGN, textAlign );
GDI_HEAP_UNLOCK( hdc );
return 1;
}
......
......@@ -6,7 +6,7 @@
*/
#include "gdi.h"
#include "metafile.h"
#include "metafiledrv.h"
#define DC_GET_VAL_16( func_type, func_name, dc_field ) \
......@@ -65,7 +65,7 @@ INT16 WINAPI func_name( HDC16 hdc, INT16 mode ) \
if (!dc) { \
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); \
if (!dc) return 0; \
MF_MetaParam1(dc, meta_func, mode); \
MFDRV_MetaParam1(dc, meta_func, mode); \
return 1; \
} \
prevMode = dc->dc_field; \
......@@ -82,7 +82,7 @@ INT WINAPI func_name( HDC hdc, INT mode ) \
if (!dc) { \
dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); \
if (!dc) return 0; \
MF_MetaParam1(dc, meta_func, mode); \
MFDRV_MetaParam1(dc, meta_func, mode); \
return 1; \
} \
prevMode = dc->dc_field; \
......
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