diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index df288637f4b..04e0eb56340 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -453,7 +453,7 @@ @ stdcall GdipPathIterCopyData(ptr ptr ptr ptr long long) @ stdcall GdipPathIterEnumerate(ptr ptr ptr ptr long) @ stdcall GdipPathIterGetCount(ptr ptr) -@ stub GdipPathIterGetSubpathCount +@ stdcall GdipPathIterGetSubpathCount(ptr ptr) @ stdcall GdipPathIterHasCurve(ptr ptr) @ stub GdipPathIterIsValid @ stdcall GdipPathIterNextMarker(ptr ptr ptr ptr) diff --git a/dlls/gdiplus/pathiterator.c b/dlls/gdiplus/pathiterator.c index e9ba03e301c..bca9df0cab6 100644 --- a/dlls/gdiplus/pathiterator.c +++ b/dlls/gdiplus/pathiterator.c @@ -105,6 +105,22 @@ GpStatus WINGDIPAPI GdipPathIterHasCurve(GpPathIterator* iterator, BOOL* hasCurv return Ok; } +GpStatus WINGDIPAPI GdipPathIterGetSubpathCount(GpPathIterator* iterator, INT* count) +{ + INT i; + + if(!iterator || !count) + return InvalidParameter; + + *count = 0; + for(i = 0; i < iterator->pathdata.Count; i++){ + if(iterator->pathdata.Types[i] == PathPointTypeStart) + (*count)++; + } + + return Ok; +} + GpStatus WINGDIPAPI GdipPathIterNextMarker(GpPathIterator* iterator, INT *resultCount, INT* startIndex, INT* endIndex) { diff --git a/dlls/gdiplus/tests/pathiterator.c b/dlls/gdiplus/tests/pathiterator.c index 3406ce6dfaa..385be8818ea 100644 --- a/dlls/gdiplus/tests/pathiterator.c +++ b/dlls/gdiplus/tests/pathiterator.c @@ -146,6 +146,49 @@ static void test_nextmarker(void) GdipDeletePath(path); } +static void test_getsubpathcount(void) +{ + GpPath *path; + GpPathIterator *iter; + GpStatus stat; + INT count; + + /* NULL args */ + stat = GdipPathIterGetSubpathCount(NULL, NULL); + expect(InvalidParameter, stat); + stat = GdipPathIterGetSubpathCount(NULL, &count); + expect(InvalidParameter, stat); + + GdipCreatePath(FillModeAlternate, &path); + + /* empty path */ + GdipCreatePathIter(&iter, path); + stat = GdipPathIterGetSubpathCount(iter, &count); + expect(Ok, stat); + expect(0, count); + GdipDeletePathIter(iter); + + GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0); + + /* open figure */ + GdipCreatePathIter(&iter, path); + stat = GdipPathIterGetSubpathCount(iter, &count); + expect(Ok, stat); + expect(1, count); + GdipDeletePathIter(iter); + + /* manually start new figure */ + GdipStartPathFigure(path); + GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0); + GdipCreatePathIter(&iter, path); + stat = GdipPathIterGetSubpathCount(iter, &count); + expect(Ok, stat); + expect(2, count); + GdipDeletePathIter(iter); + + GdipDeletePath(path); +} + START_TEST(pathiterator) { struct GdiplusStartupInput gdiplusStartupInput; @@ -161,6 +204,7 @@ START_TEST(pathiterator) test_constructor_destructor(); test_hascurve(); test_nextmarker(); + test_getsubpathcount(); GdiplusShutdown(gdiplusToken); } diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index c33645a56cd..0859ad7295f 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -285,6 +285,7 @@ GpStatus WINGDIPAPI GdipPathIterNextMarker(GpPathIterator*,INT*,INT*,INT*); GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator*,INT*,INT*,INT*,BOOL*); GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator*); GpStatus WINGDIPAPI GdipPathIterGetCount(GpPathIterator*,INT*); +GpStatus WINGDIPAPI GdipPathIterGetSubpathCount(GpPathIterator*,INT*); GpStatus WINGDIPAPI GdipPathIterEnumerate(GpPathIterator*,INT*,GpPointF*,BYTE*,INT); GpStatus WINGDIPAPI GdipPathIterHasCurve(GpPathIterator*,BOOL*);