Commit 991e785f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Fix GdipGetPathData implementation and test.

Previous version (commit 3bacdaf6) was totally incorrect. Thanks to Paul Vriens for pointing this out.
parent c42d9374
...@@ -484,17 +484,8 @@ GpStatus WINGDIPAPI GdipGetPathData(GpPath *path, GpPathData* pathData) ...@@ -484,17 +484,8 @@ GpStatus WINGDIPAPI GdipGetPathData(GpPath *path, GpPathData* pathData)
if(!path || !pathData) if(!path || !pathData)
return InvalidParameter; return InvalidParameter;
pathData->Count = path->pathdata.Count; /* Only copy data. pathData allocation/freeing controlled by wrapper class.
Assumed that pathData is enough wide to get all data - controlled by wrapper too. */
pathData->Points = GdipAlloc(sizeof(PointF) * pathData->Count);
if(!pathData->Points)
return OutOfMemory;
pathData->Types = GdipAlloc(pathData->Count);
if(!pathData->Points)
return OutOfMemory;
/* copy data */
memcpy(pathData->Points, path->pathdata.Points, sizeof(PointF) * pathData->Count); memcpy(pathData->Points, path->pathdata.Points, sizeof(PointF) * pathData->Count);
memcpy(pathData->Types , path->pathdata.Types , pathData->Count); memcpy(pathData->Types , path->pathdata.Types , pathData->Count);
......
...@@ -154,14 +154,22 @@ static void test_getpathdata(void) ...@@ -154,14 +154,22 @@ static void test_getpathdata(void)
GpPath *path; GpPath *path;
GpPathData data; GpPathData data;
GpStatus status; GpStatus status;
INT count;
GdipCreatePath(FillModeAlternate, &path); GdipCreatePath(FillModeAlternate, &path);
status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0); status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
expect(Ok, status); expect(Ok, status);
/* Prepare storage. Made by wrapper class. */
status = GdipGetPointCount(path, &count);
expect(Ok, status);
data.Count = 2;
data.Types = GdipAlloc(sizeof(BYTE) * count);
data.Points = GdipAlloc(sizeof(PointF) * count);
status = GdipGetPathData(path, &data); status = GdipGetPathData(path, &data);
expect(Ok, status); expect(Ok, status);
expect((data.Count == 2), TRUE);
expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) && expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) &&
(data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE); (data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE);
expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE); expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE);
......
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