fix generation of PolyPolygon in mfdrv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





ChangeLog:

     Fix the Metafile driver PolyPolygon function so it really
     generates a polypolygon and not multiple sets of polygons.

Warren Baird : Warren_Baird@cimmetry.com
Xavier Servettaz

diff -ur clean/wine/dlls/gdi/mfdrv/graphics.c   wine/dlls/gdi/mfdrv/graphics.c
--- clean/wine/dlls/gdi/mfdrv/graphics.c      Wed Jan 29 15:30:25 2003
+++ wine/dlls/gdi/mfdrv/graphics.c Fri Jan 31 13:28:55 2003
@@ -190,23 +190,53 @@
 BOOL
 MFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT
polygons)
 {
-    int       i,j;
-    LPPOINT16 pt16;
-    const POINT* curpt=pt;
-    BOOL ret;
-
-    for (i=0;i<polygons;i++) {
-         pt16=(LPPOINT16)HeapAlloc( GetProcessHeap(), 0,
-                      sizeof(POINT16) * counts[i] );
-    if(!pt16) return FALSE;
-    for (j=counts[i];j--;) CONV_POINT32TO16(&(curpt[j]),&(pt16[j]));
-    ret = MFDRV_MetaPoly(dev, META_POLYGON, pt16, counts[i]);
+    BOOL ret;
+    DWORD len;
+    METARECORD *mr;
+    int       i,j;
+    LPPOINT16 pt16;
+    INT16 totalpoint16 = 0;
+    INT16 * pointcounts;
+
+    for (i=0;i<polygons;i++) {
+         totalpoint16 += counts[i];
+    }
+
+    /* allocate space for all points */
+    pt16=(LPPOINT16)HeapAlloc( GetProcessHeap(), 0,
+                                     sizeof(POINT16) * totalpoint16 );
+    pointcounts = (INT16*)HeapAlloc( GetProcessHeap(), 0,
+                                     sizeof(INT16) * totalpoint16 );
+
+    /* copy point counts */
+    for (i=0;i<polygons;i++) {
+          pointcounts[i] = counts[i];
+    }
+
+    /* convert all points */
+    for (j = totalpoint16; j--;){
+         CONV_POINT32TO16(&(pt[j]),&(pt16[j]));
+    }
+
+    len = sizeof(METARECORD) + sizeof(WORD) + polygons*sizeof(INT16) +
totalpoint16*sizeof(POINT16);
+
+    if (!(mr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len ))) {
+         HeapFree( GetProcessHeap(), 0, pt16 );
+         HeapFree( GetProcessHeap(), 0, pointcounts );
+         return FALSE;
+    }
+
+    mr->rdSize = len /2;
+    mr->rdFunction = META_POLYPOLYGON;
+    *(mr->rdParm) = polygons;
+    memcpy(mr->rdParm + 1, pointcounts, polygons*sizeof(INT16));
+    memcpy(mr->rdParm + 1+polygons, pt16 , totalpoint16*sizeof(POINT16));
+    ret = MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
+
     HeapFree( GetProcessHeap(), 0, pt16 );
-    if (!ret)
-        return FALSE;
-    curpt+=counts[i];
-    }
-    return TRUE;
+    HeapFree( GetProcessHeap(), 0, pointcounts );
+    HeapFree( GetProcessHeap(), 0, mr);
+    return ret;
 }






[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux