From 0a9937c534823df161f0b911dd410a508ea4a148 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 5 Jul 2008 13:02:36 +0400 Subject: [PATCH] gdiplus: GdipPathIterNextMarker implementation with tests. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/pathiterator.c | 25 ++++++++++++++ dlls/gdiplus/tests/pathiterator.c | 57 +++++++++++++++++++++++++++++++ include/gdiplusflat.h | 1 + 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 9492065fc8e..df288637f4b 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -456,7 +456,7 @@ @ stub GdipPathIterGetSubpathCount @ stdcall GdipPathIterHasCurve(ptr ptr) @ stub GdipPathIterIsValid -@ stub GdipPathIterNextMarker +@ stdcall GdipPathIterNextMarker(ptr ptr ptr ptr) @ stub GdipPathIterNextMarkerPath @ stub GdipPathIterNextPathType @ stdcall GdipPathIterNextSubpath(ptr ptr ptr ptr ptr) diff --git a/dlls/gdiplus/pathiterator.c b/dlls/gdiplus/pathiterator.c index abb5dbb30f9..e9ba03e301c 100644 --- a/dlls/gdiplus/pathiterator.c +++ b/dlls/gdiplus/pathiterator.c @@ -105,6 +105,31 @@ GpStatus WINGDIPAPI GdipPathIterHasCurve(GpPathIterator* iterator, BOOL* hasCurv return Ok; } +GpStatus WINGDIPAPI GdipPathIterNextMarker(GpPathIterator* iterator, INT *resultCount, + INT* startIndex, INT* endIndex) +{ + INT i; + + if(!iterator || !startIndex || !endIndex) + return InvalidParameter; + + *resultCount = 0; + + /* first call could start with second point as all subsequent, cause + path couldn't contain only one */ + for(i = iterator->marker_pos + 1; i < iterator->pathdata.Count; i++){ + if(iterator->pathdata.Types[i] & PathPointTypePathMarker){ + *startIndex = iterator->marker_pos; + if(iterator->marker_pos > 0) (*startIndex)++; + *endIndex = iterator->marker_pos = i; + *resultCount= *endIndex - *startIndex + 1; + break; + } + } + + return Ok; +} + GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator, INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed) { diff --git a/dlls/gdiplus/tests/pathiterator.c b/dlls/gdiplus/tests/pathiterator.c index baeb22ba6f2..3406ce6dfaa 100644 --- a/dlls/gdiplus/tests/pathiterator.c +++ b/dlls/gdiplus/tests/pathiterator.c @@ -90,6 +90,62 @@ static void test_hascurve(void) GdipDeletePath(path); } +static void test_nextmarker(void) +{ + GpPath *path; + GpPathIterator *iter; + GpStatus stat; + INT start, end, result; + + /* NULL args + BOOL out argument is local in wrapper class method, + so it always has not-NULL address */ + stat = GdipPathIterNextMarker(NULL, &result, NULL, NULL); + expect(InvalidParameter, stat); + stat = GdipPathIterNextMarker(NULL, &result, &start, NULL); + expect(InvalidParameter, stat); + stat = GdipPathIterNextMarker(NULL, &result, NULL, &end); + expect(InvalidParameter, stat); + + GdipCreatePath(FillModeAlternate, &path); + GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0); + + /* no markers */ + GdipCreatePathIter(&iter, path); + stat = GdipPathIterNextMarker(iter, &result, &start, &end); + expect(Ok, stat); + expect(0, result); + GdipDeletePathIter(iter); + + /* one marker */ + GdipSetPathMarker(path); + GdipCreatePathIter(&iter, path); + stat = GdipPathIterNextMarker(iter, &result, &start, &end); + expect(Ok, stat); + expect(TRUE, (start == 0) && (end == 3) && (result == 4)); + stat = GdipPathIterNextMarker(iter, &result, &start, &end); + expect(Ok, stat); + expect(0, result); + GdipDeletePathIter(iter); + + /* two markers */ + GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0); + GdipSetPathMarker(path); + GdipCreatePathIter(&iter, path); + stat = GdipPathIterNextMarker(iter, &result, &start, &end); + expect(Ok, stat); + expect(TRUE, (start == 0) && (end == 3) && (result == 4)); + stat = GdipPathIterNextMarker(iter, &result, &start, &end); + expect(Ok, stat); + expect(TRUE, (start == 4) && (end == 5) && (result == 2)); + stat = GdipPathIterNextMarker(iter, &result, &start, &end); + expect(Ok, stat); + expect(0, result); + GdipDeletePathIter(iter); + + GdipDeletePath(path); +} + START_TEST(pathiterator) { struct GdiplusStartupInput gdiplusStartupInput; @@ -104,6 +160,7 @@ START_TEST(pathiterator) test_constructor_destructor(); test_hascurve(); + test_nextmarker(); GdiplusShutdown(gdiplusToken); } diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index 9ef7ad75b5f..c33645a56cd 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -281,6 +281,7 @@ GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator**,GpPath*); GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator*); GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator*,INT*,GpPointF*,BYTE*, INT,INT); +GpStatus WINGDIPAPI GdipPathIterNextMarker(GpPathIterator*,INT*,INT*,INT*); GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator*,INT*,INT*,INT*,BOOL*); GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator*); GpStatus WINGDIPAPI GdipPathIterGetCount(GpPathIterator*,INT*);