[Gdi32]
[reactos.git] / reactos / win32ss / gdi / gdi32 / wine / enhmfdrv / init.c
index 682f412..ce9d9fb 100644 (file)
@@ -34,14 +34,14 @@ 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 */
     NULL,                            /* pAlphaBlend */
-    NULL,                            /* pAngleArc */
+    EMFDRV_AngleArc,                 /* pAngleArc */
     EMFDRV_Arc,                      /* pArc */
-    NULL,                            /* pArcTo */
+    EMFDRV_ArcTo,                    /* pArcTo */
     EMFDRV_BeginPath,                /* pBeginPath */
     NULL,                            /* pBlendImage */
     EMFDRV_Chord,                    /* pChord */
@@ -69,7 +69,6 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
     NULL,                            /* pFontIsLinked */
     EMFDRV_FrameRgn,                 /* pFrameRgn */
     EMFDRV_GdiComment,               /* pGdiComment */
-    NULL,                            /* pGdiRealizationInfo */
     NULL,                            /* pGetBoundsRect */
     NULL,                            /* pGetCharABCWidths */
     NULL,                            /* pGetCharABCWidthsI */
@@ -77,6 +76,7 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
     EMFDRV_GetDeviceCaps,            /* pGetDeviceCaps */
     NULL,                            /* pGetDeviceGammaRamp */
     NULL,                            /* pGetFontData */
+    NULL,                            /* pGetFontRealizationInfo */
     NULL,                            /* pGetFontUnicodeRanges */
     NULL,                            /* pGetGlyphIndices */
     NULL,                            /* pGetGlyphOutline */
@@ -92,7 +92,7 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
     NULL,                            /* pGetTextExtentExPointI */
     NULL,                            /* pGetTextFace */
     NULL,                            /* pGetTextMetrics */
-    NULL,                            /* pGradientFill */
+    EMFDRV_GradientFill,             /* pGradientFill */
     EMFDRV_IntersectClipRect,        /* pIntersectClipRect */
     EMFDRV_InvertRgn,                /* pInvertRgn */
     EMFDRV_LineTo,                   /* pLineTo */
@@ -106,12 +106,12 @@ static const struct gdi_dc_funcs EMFDRV_Funcs =
     EMFDRV_Pie,                      /* pPie */
     EMFDRV_PolyBezier,               /* pPolyBezier */
     EMFDRV_PolyBezierTo,             /* pPolyBezierTo */
-    NULL,                            /* pPolyDraw */
+    EMFDRV_PolyDraw,                 /* pPolyDraw */
     EMFDRV_PolyPolygon,              /* pPolyPolygon */
     EMFDRV_PolyPolyline,             /* pPolyPolyline */
     EMFDRV_Polygon,                  /* pPolygon */
     EMFDRV_Polyline,                 /* pPolyline */
-    NULL,                            /* pPolylineTo */
+    EMFDRV_PolylineTo,               /* pPolylineTo */
     NULL,                            /* pPutImage */
     NULL,                            /* pRealizeDefaultPalette */
     NULL,                            /* pRealizePalette */
@@ -172,10 +172,10 @@ 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 );
+    HeapFree( GetProcessHeap(), 0, physDev->emh );
     for(index = 0; index < physDev->handles_size; index++)
         if(physDev->handles[index])
            GDI_hdc_not_using_object(physDev->handles[index], dev->hdc);
@@ -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;
 
@@ -319,11 +319,11 @@ HDC WINAPI CreateEnhMetaFileW(
     DWORD size = 0, length = 0;
     DWORD bytes_written;
 
-    TRACE("%s\n", debugstr_w(filename) );
+    TRACE("(%p %s %s %s)\n", hdc, debugstr_w(filename), wine_dbgstr_rect(rect), debugstr_w(description) );
 
     if (!(dc = alloc_dc_ptr( OBJ_ENHMETADC ))) return 0;
 
-    physDev = HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
+    physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev));
     if (!physDev) {
         free_dc_ptr( dc );
         return 0;
@@ -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;
@@ -352,6 +352,7 @@ HDC WINAPI CreateEnhMetaFileW(
     physDev->dc_pen = 0;
     physDev->screen_dc = 0;
     physDev->restoring = 0;
+    physDev->path = FALSE;
     if (hdc)  /* if no ref, use current display */
         physDev->ref_dc = hdc;
     else
@@ -449,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);
@@ -463,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) {