Module: wine Branch: master Commit: 20501e4ca8225208dacb4d7415b7cc9a5845c0b0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=20501e4ca8225208dacb4d7415...
Author: Nikolay Sivov bunglehead@gmail.com Date: Sat Jul 5 13:02:51 2008 +0400
gdiplus: Implementation of GdipPathIterGetSubpathCount with tests.
---
dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/pathiterator.c | 16 +++++++++++++ dlls/gdiplus/tests/pathiterator.c | 44 +++++++++++++++++++++++++++++++++++++ include/gdiplusflat.h | 1 + 4 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index df28863..04e0eb5 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 e9ba03e..bca9df0 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 3406ce6..385be88 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 c33645a..0859ad7 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*);