Commit e4118c18 authored by Evan Stade's avatar Evan Stade Committed by Alexandre Julliard

gdiplus: Added GdipAddPathLine2.

parent 5dc8dee7
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
@ stub GdipAddPathCurveI @ stub GdipAddPathCurveI
@ stub GdipAddPathEllipse @ stub GdipAddPathEllipse
@ stub GdipAddPathEllipseI @ stub GdipAddPathEllipseI
@ stub GdipAddPathLine2 @ stdcall GdipAddPathLine2(ptr ptr long)
@ stub GdipAddPathLine2I @ stub GdipAddPathLine2I
@ stub GdipAddPathLine @ stub GdipAddPathLine
@ stub GdipAddPathLineI @ stub GdipAddPathLineI
......
...@@ -52,9 +52,9 @@ struct GpSolidFill{ ...@@ -52,9 +52,9 @@ struct GpSolidFill{
struct GpPath{ struct GpPath{
GpFillMode fill; GpFillMode fill;
GpGraphics* graphics;
GpPathData pathdata; GpPathData pathdata;
BOOL newfigure; /* whether the next drawing action starts a new figure */ BOOL newfigure; /* whether the next drawing action starts a new figure */
INT datalen; /* size of the arrays in pathdata */
}; };
#endif #endif
...@@ -30,11 +30,68 @@ ...@@ -30,11 +30,68 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path) /* make sure path has enough space for len more points */
static BOOL lengthen_path(GpPath *path, INT len)
{ {
HDC hdc; /* initial allocation */
GpStatus ret; if(path->datalen == 0){
path->datalen = len * 2;
path->pathdata.Points = GdipAlloc(path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Types = GdipAlloc(path->datalen);
if(!path->pathdata.Types){
GdipFree(path->pathdata.Points);
return FALSE;
}
}
/* reallocation, double size of arrays */
else if(path->datalen - path->pathdata.Count < len){
while(path->datalen - path->pathdata.Count < len)
path->datalen *= 2;
path->pathdata.Points = HeapReAlloc(GetProcessHeap(), 0,
path->pathdata.Points, path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Types = HeapReAlloc(GetProcessHeap(), 0,
path->pathdata.Types, path->datalen);
if(!path->pathdata.Types) return FALSE;
}
return TRUE;
}
GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points,
INT count)
{
INT i, old_count = path->pathdata.Count;
if(!path || !points)
return InvalidParameter;
if(!lengthen_path(path, count + (path->newfigure ? 1 : 0)))
return OutOfMemory;
for(i = 0; i < count; i++){
path->pathdata.Points[old_count + i].X = points[i].X;
path->pathdata.Points[old_count + i].Y = points[i].Y;
path->pathdata.Types[old_count + i] = PathPointTypeLine;
}
if(path->newfigure){
path->pathdata.Types[old_count] = PathPointTypeStart;
path->newfigure = FALSE;
}
path->pathdata.Count += count;
return Ok;
}
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
{
if(!path) if(!path)
return InvalidParameter; return InvalidParameter;
...@@ -44,24 +101,14 @@ GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path) ...@@ -44,24 +101,14 @@ GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
(*path)->fill = fill; (*path)->fill = fill;
(*path)->newfigure = TRUE; (*path)->newfigure = TRUE;
hdc = GetDC(0); return Ok;
ret = GdipCreateFromHDC(hdc, &((*path)->graphics));
if(ret != Ok){
ReleaseDC(0, hdc);
GdipFree(*path);
}
return ret;
} }
GpStatus WINGDIPAPI GdipDeletePath(GpPath *path) GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
{ {
if(!path || !(path->graphics)) if(!path)
return InvalidParameter; return InvalidParameter;
ReleaseDC(0, path->graphics->hdc);
GdipDeleteGraphics(path->graphics);
GdipFree(path); GdipFree(path);
return Ok; return Ok;
......
...@@ -62,12 +62,24 @@ enum LineCap ...@@ -62,12 +62,24 @@ enum LineCap
LineCapAnchorMask = 0xf0 LineCapAnchorMask = 0xf0
}; };
enum PathPointType{
PathPointTypeStart = 0, /* start of a figure */
PathPointTypeLine = 1,
PathPointTypeBezier = 3,
PathPointTypePathTypeMask = 7,
PathPointTypePathDashMode = 16, /* not used */
PathPointTypePathMarker = 32,
PathPointTypeCloseSubpath = 128, /* end of a closed figure */
PathPointTypeBezier3 = 3
};
#ifndef __cplusplus #ifndef __cplusplus
typedef enum Unit Unit; typedef enum Unit Unit;
typedef enum BrushType BrushType; typedef enum BrushType BrushType;
typedef enum FillMode FillMode; typedef enum FillMode FillMode;
typedef enum LineCap LineCap; typedef enum LineCap LineCap;
typedef enum PathPointType PathPointType;
#endif /* end of c typedefs */ #endif /* end of c typedefs */
......
...@@ -48,6 +48,7 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB,GpSolidFill**); ...@@ -48,6 +48,7 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB,GpSolidFill**);
GpStatus WINGDIPAPI GdipGetBrushType(GpBrush*,GpBrushType*); GpStatus WINGDIPAPI GdipGetBrushType(GpBrush*,GpBrushType*);
GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush*); GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush*);
GpStatus WINGDIPAPI GdipAddPathLine2(GpPath*,GDIPCONST GpPointF*,INT);
GpStatus WINGDIPAPI GdipCreatePath(GpFillMode,GpPath**); GpStatus WINGDIPAPI GdipCreatePath(GpFillMode,GpPath**);
GpStatus WINGDIPAPI GdipDeletePath(GpPath*); GpStatus WINGDIPAPI GdipDeletePath(GpPath*);
......
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