- Sync with Wine HEAD
authorDmitry Chapyshev <dmitry@reactos.org>
Sun, 1 Jun 2008 13:14:02 +0000 (13:14 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Sun, 1 Jun 2008 13:14:02 +0000 (13:14 +0000)
svn path=/trunk/; revision=33804

reactos/dll/win32/gdiplus/font.c
reactos/dll/win32/gdiplus/gdiplus.spec
reactos/dll/win32/gdiplus/gdiplus_private.h
reactos/dll/win32/gdiplus/graphics.c
reactos/dll/win32/gdiplus/graphicspath.c
reactos/dll/win32/gdiplus/image.c
reactos/dll/win32/gdiplus/matrix.c
reactos/dll/win32/gdiplus/pen.c
reactos/dll/win32/gdiplus/region.c

index a05ef75..82523ce 100644 (file)
@@ -68,7 +68,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontA(HDC hdc,
     if(!lfa || !font)
         return InvalidParameter;
 
-    memcpy(&lfw, lfa, sizeof(LOGFONTA));
+    memcpy(&lfw, lfa, FIELD_OFFSET(LOGFONTA,lfFaceName) );
 
     if(!MultiByteToWideChar(CP_ACP, 0, lfa->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE))
         return GenericError;
index ec3897a..f2eb2b3 100644 (file)
@@ -25,8 +25,8 @@
 @ stub GdipAddPathPieI
 @ stub GdipAddPathPolygon
 @ stub GdipAddPathPolygonI
-@ stub GdipAddPathRectangle
-@ stub GdipAddPathRectangleI
+@ stdcall GdipAddPathRectangle(ptr long long long long)
+@ stdcall GdipAddPathRectangleI(ptr long long long long)
 @ stub GdipAddPathRectangles
 @ stub GdipAddPathRectanglesI
 @ stub GdipAddPathString
@@ -92,7 +92,7 @@
 @ stdcall GdipCreateFromHDC2(long long ptr)
 @ stdcall GdipCreateFromHDC(long ptr)
 @ stdcall GdipCreateFromHWND(long ptr)
-@ stub GdipCreateFromHWNDICM
+@ stdcall GdipCreateFromHWNDICM(long ptr)
 @ stdcall GdipCreateHBITMAPFromBitmap(ptr ptr long)
 @ stub GdipCreateHICONFromBitmap
 @ stub GdipCreateHalftonePalette
 @ stdcall GdipCreatePathIter(ptr ptr)
 @ stdcall GdipCreatePen1(long long long ptr)
 @ stdcall GdipCreatePen2(ptr long long ptr)
-@ stub GdipCreateRegion
+@ stdcall GdipCreateRegion(ptr)
 @ stub GdipCreateRegionHrgn
-@ stub GdipCreateRegionPath
+@ stdcall GdipCreateRegionPath(ptr ptr)
 @ stub GdipCreateRegionRect
 @ stub GdipCreateRegionRectI
 @ stub GdipCreateRegionRgnData
 @ stdcall GdipDeletePathIter(ptr)
 @ stdcall GdipDeletePen(ptr)
 @ stub GdipDeletePrivateFontCollection
-@ stub GdipDeleteRegion
+@ stdcall GdipDeleteRegion(ptr)
 @ stdcall GdipDeleteStringFormat(ptr)
 @ stdcall GdipDisposeImage(ptr)
 @ stdcall GdipDisposeImageAttributes(ptr)
 @ stdcall GdipGetBrushType(ptr ptr)
 @ stub GdipGetCellAscent
 @ stub GdipGetCellDescent
-@ stub GdipGetClip
+@ stdcall GdipGetClip(ptr ptr)
 @ stub GdipGetClipBounds
 @ stub GdipGetClipBoundsI
 @ stdcall GdipGetCompositingMode(ptr ptr)
 @ stub GdipGetCustomLineCapStrokeJoin
 @ stub GdipGetCustomLineCapType
 @ stub GdipGetCustomLineCapWidthScale
-@ stub GdipGetDC
+@ stdcall GdipGetDC(ptr ptr)
 @ stdcall GdipGetDpiX(ptr ptr)
 @ stdcall GdipGetDpiY(ptr ptr)
 @ stub GdipGetEffectParameterSize
 @ stdcall GdipGetImageDimension(ptr ptr ptr)
 @ stdcall GdipGetImageEncoders(long long ptr)
 @ stdcall GdipGetImageEncodersSize(ptr ptr)
-@ stub GdipGetImageFlags
+@ stdcall GdipGetImageFlags(ptr ptr)
 @ stdcall GdipGetImageGraphicsContext(ptr ptr)
 @ stdcall GdipGetImageHeight(ptr ptr)
 @ stdcall GdipGetImageHorizontalResolution(ptr ptr)
 @ stub GdipGetRegionBoundsI
 @ stub GdipGetRegionData
 @ stub GdipGetRegionDataSize
-@ stub GdipGetRegionHRgn
+@ stdcall GdipGetRegionHRgn(ptr ptr ptr)
 @ stub GdipGetRegionScans
 @ stub GdipGetRegionScansCount
 @ stub GdipGetRegionScansI
 @ stub GdipIsVisibleRegionRect
 @ stub GdipIsVisibleRegionRectI
 @ stdcall GdipLoadImageFromFile(wstr ptr)
-@ stub GdipLoadImageFromFileICM
+@ stdcall GdipLoadImageFromFileICM(wstr ptr)
 @ stdcall GdipLoadImageFromStream(ptr ptr)
 @ stdcall GdipLoadImageFromStreamICM(ptr ptr)
 @ stub GdipMeasureCharacterRanges
 @ stub GdipRecordMetafileI
 @ stub GdipRecordMetafileStream
 @ stub GdipRecordMetafileStreamI
-@ stub GdipReleaseDC
+@ stdcall GdipReleaseDC(ptr ptr)
 @ stdcall GdipRemovePropertyItem(ptr long)
 @ stub GdipResetClip
 @ stub GdipResetImageAttributes
index 149d540..d2d0373 100644 (file)
@@ -149,6 +149,7 @@ struct GpCustomLineCap{
 struct GpImage{
     IPicture* picture;
     ImageType type;
+    UINT flags;
 };
 
 struct GpMetafile{
index 37280f8..347543f 100644 (file)
@@ -797,6 +797,12 @@ GpStatus WINGDIPAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics)
     return Ok;
 }
 
+/* FIXME: no icm handling */
+GpStatus WINGDIPAPI GdipCreateFromHWNDICM(HWND hwnd, GpGraphics **graphics)
+{
+    return GdipCreateFromHWND(hwnd, graphics);
+}
+
 GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete,
     GpMetafile **metafile)
 {
@@ -932,22 +938,7 @@ GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x,
 GpStatus WINGDIPAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x,
     INT y, INT width, INT height, REAL startAngle, REAL sweepAngle)
 {
-    INT save_state, num_pts;
-    GpPointF points[MAX_ARC_PTS];
-    GpStatus retval;
-
-    if(!graphics || !pen || width <= 0 || height <= 0)
-        return InvalidParameter;
-
-    num_pts = arc2polybezier(points, x, y, width, height, startAngle, sweepAngle);
-
-    save_state = prepare_dc(graphics, pen);
-
-    retval = draw_polybezier(graphics, pen, points, num_pts, TRUE);
-
-    restore_dc(graphics, save_state);
-
-    return retval;
+    return GdipDrawArc(graphics,pen,(REAL)x,(REAL)y,(REAL)width,(REAL)height,startAngle,sweepAngle);
 }
 
 GpStatus WINGDIPAPI GdipDrawBezier(GpGraphics *graphics, GpPen *pen, REAL x1,
@@ -2436,3 +2427,25 @@ GpStatus WINGDIPAPI GdipMultiplyWorldTransform(GpGraphics *graphics, GDIPCONST G
 
     return ret;
 }
+
+GpStatus WINGDIPAPI GdipGetDC(GpGraphics *graphics, HDC *hdc)
+{
+    FIXME("(%p, %p): stub\n", graphics, hdc);
+
+    *hdc = NULL;
+    return NotImplemented;
+}
+
+GpStatus WINGDIPAPI GdipReleaseDC(GpGraphics *graphics, HDC hdc)
+{
+    FIXME("(%p, %p): stub\n", graphics, hdc);
+
+    return NotImplemented;
+}
+
+GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
+{
+   FIXME("(%p, %p): stub\n", graphics, region);
+
+   return NotImplemented;
+}
index 84446aa..3b09e04 100644 (file)
@@ -708,3 +708,53 @@ GpStatus WINGDIPAPI GdipTransformPath(GpPath *path, GpMatrix *matrix)
     return GdipTransformMatrixPoints(matrix, path->pathdata.Points,
                                      path->pathdata.Count);
 }
+
+GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y,
+    REAL width, REAL height)
+{
+    GpPath *backup;
+    GpPointF ptf[2];
+    GpStatus retstat;
+    BOOL old_new;
+
+    if(!path || width < 0.0 || height < 0.0)
+        return InvalidParameter;
+
+    /* make a backup copy of path data */
+    if((retstat = GdipClonePath(path, &backup)) != Ok)
+        return retstat;
+
+    /* rectangle should start as new path */
+    old_new = path->newfigure;
+    path->newfigure = TRUE;
+    if((retstat = GdipAddPathLine(path,x,y,x+width,y)) != Ok){
+        path->newfigure = old_new;
+        goto fail;
+    }
+
+    ptf[0].X = x+width;
+    ptf[0].Y = y+height;
+    ptf[1].X = x;
+    ptf[1].Y = y+height;
+
+    if((retstat = GdipAddPathLine2(path,(GDIPCONST GpPointF*)&ptf,2)) != Ok)  goto fail;
+    path->pathdata.Types[path->pathdata.Count-1] |= PathPointTypeCloseSubpath;
+
+    /* free backup */
+    GdipDeletePath(backup);
+    return Ok;
+
+fail:
+    /* reverting */
+    GdipDeletePath(path);
+    GdipClonePath(backup, &path);
+    GdipDeletePath(backup);
+
+    return retstat;
+}
+
+GpStatus WINGDIPAPI GdipAddPathRectangleI(GpPath *path, INT x, INT y,
+    INT width, INT height)
+{
+    return GdipAddPathRectangle(path,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
+}
index a89b6ea..72bf7f5 100644 (file)
@@ -384,6 +384,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
     }
 
     (*bitmap)->image.type = ImageTypeBitmap;
+    (*bitmap)->image.flags = ImageFlagsNone;
     (*bitmap)->width = width;
     (*bitmap)->height = height;
     (*bitmap)->format = format;
@@ -726,6 +727,12 @@ GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR* filename,
     return stat;
 }
 
+/* FIXME: no icm handling */
+GpStatus WINGDIPAPI GdipLoadImageFromFileICM(GDIPCONST WCHAR* filename,GpImage **image)
+{
+    return GdipLoadImageFromFile(filename, image);
+}
+
 GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
 {
     IPicture *pic;
@@ -789,6 +796,7 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
     }
 
     (*image)->picture = pic;
+    (*image)->flags   = ImageFlagsNone;
 
     return Ok;
 }
@@ -1108,3 +1116,13 @@ GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect,
 
     return NotImplemented;
 }
+
+GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags)
+{
+    if(!image || !flags)
+        return InvalidParameter;
+
+    *flags = image->flags;
+
+    return Ok;
+}
index a8617db..eb83884 100644 (file)
@@ -244,7 +244,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts,
     REAL x, y;
     INT i;
 
-    if(!matrix || !pts)
+    if(!matrix || !pts || count <= 0)
         return InvalidParameter;
 
     for(i = 0; i < count; i++)
@@ -265,6 +265,9 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I
     GpStatus ret;
     INT i;
 
+    if(count <= 0)
+        return InvalidParameter;
+
     ptsF = GdipAlloc(sizeof(GpPointF) * count);
     if(!ptsF)
         return OutOfMemory;
@@ -314,7 +317,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPoints(GpMatrix *matrix, GpPointF *
     REAL x, y;
     INT i;
 
-    if(!matrix || !pts)
+    if(!matrix || !pts || count <= 0)
         return InvalidParameter;
 
     for(i = 0; i < count; i++)
@@ -335,6 +338,9 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
     GpStatus ret;
     INT i;
 
+    if(count <= 0)
+        return InvalidParameter;
+
     ptsF = GdipAlloc(sizeof(GpPointF) * count);
     if(!ptsF)
         return OutOfMemory;
index 7a692e3..9ef1482 100644 (file)
@@ -251,6 +251,9 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
     if(!pen || !dash)
         return InvalidParameter;
 
+    if(count <= 0)
+        return OutOfMemory;
+
     for(i = 0; i < count; i++){
         sum += dash[i];
         if(dash[i] < 0.0)
index 92da580..46e9919 100644 (file)
 
 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
 
+/**********************************************************
+ *
+ * Data returned by GdipGetRegionData (for rectangle based regions)
+ * looks something like this:
+ *
+ * struct region_data_header
+ * {
+ *   DWORD size;     size in bytes of the data - 8.
+ *   DWORD magic1;   probably a checksum.
+ *   DWORD magic2;   always seems to be 0xdbc01001 - version?
+ *   DWORD num_ops;  number of combining ops * 2
+ * };
+ *
+ * Then follows a sequence of combining ops and RECTFs.
+ *
+ * Combining ops are just stored as their CombineMode value.
+ *
+ * Each RECTF is preceded by the DWORD 0x10000000.  An empty rect is
+ * stored as 0x10000002 (with no following RECTF) and an infinite rect
+ * is stored as 0x10000003 (again with no following RECTF).
+ *
+ * The combining ops are stored in the reverse order to the RECTFs and in the
+ * reverse order to which the region was constructed.
+ *
+ * When two or more complex regions (ie those with more than one rect)
+ * are combined, the combining op for the two regions comes first,
+ * then the combining ops for the rects in region 1, followed by the
+ * rects for region 1, then follows the combining ops for region 2 and
+ * finally region 2's rects.  Presumably you're supposed to use the
+ * 0x10000000 rect header to find the end of the op list (the count of
+ * the rects in each region is not stored).
+ *
+ * When a simple region (1 rect) is combined, it's treated as if a single rect
+ * is being combined.
+ *
+ */
+
+GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
+{
+    FIXME("(%p): stub\n", region);
+
+    *region = NULL;
+    return NotImplemented;
+}
+
+GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
+{
+    FIXME("(%p, %p): stub\n", path, region);
+
+    *region = NULL;
+    return NotImplemented;
+}
+
+GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
+{
+    FIXME("(%p): stub\n", region);
+    return NotImplemented;
+}
+
+GpStatus WINGDIPAPI GdipGetRegionHRgn(GpRegion *region, GpGraphics *graphics, HRGN *hrgn)
+{
+    FIXME("(%p, %p, %p): stub\n", region, graphics, hrgn);
+
+    *hrgn = NULL;
+    return NotImplemented;
+}
+
 GpStatus WINGDIPAPI GdipSetEmpty(GpRegion *region)
 {
     static int calls;