[6/6] gdiplus: implemented GdipAddPathRectangles with tests
Nikolay Sivov
bunglehead at gmail.com
Mon May 19 11:34:53 CDT 2008
Changelog:
- implemented GdipAddPathRectangles with tests
---
dlls/gdiplus/gdiplus.spec | 4 +-
dlls/gdiplus/graphicspath.c | 63 +++++++++++++++++++++++++++++++++++++
dlls/gdiplus/tests/graphicspath.c | 19 +++++++++++
include/gdiplusflat.h | 2 +
4 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index f2eb2b3..70864ba 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -27,8 +27,8 @@
@ stub GdipAddPathPolygonI
@ stdcall GdipAddPathRectangle(ptr long long long long)
@ stdcall GdipAddPathRectangleI(ptr long long long long)
-@ stub GdipAddPathRectangles
-@ stub GdipAddPathRectanglesI
+@ stdcall GdipAddPathRectangles(ptr ptr long)
+@ stdcall GdipAddPathRectanglesI(ptr ptr long)
@ stub GdipAddPathString
@ stub GdipAddPathStringI
@ stdcall GdipAlloc(long)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 3b09e04..4cbd33a 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -758,3 +758,66 @@ GpStatus WINGDIPAPI GdipAddPathRectangleI(GpPath *path, INT x, INT y,
{
return GdipAddPathRectangle(path,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
}
+
+GpStatus WINGDIPAPI GdipAddPathRectangles(GpPath *path, GDIPCONST GpRectF *rects, INT count)
+{
+ GpPath *backup;
+ GpStatus retstat;
+ INT i;
+
+ /* count == 0 - verified condition */
+ if(!path || !rects || count == 0)
+ return InvalidParameter;
+
+ if(count < 0)
+ return OutOfMemory;
+
+ /* make a backup copy */
+ if((retstat = GdipClonePath(path, &backup)) != Ok)
+ return retstat;
+
+ for(i = 0; i < count; i++){
+ if((retstat = GdipAddPathRectangle(path,rects[i].X,rects[i].Y,rects[i].Width,rects[i].Height)) != Ok)
+ goto fail;
+ }
+
+ /* free backup */
+ GdipDeletePath(backup);
+ return Ok;
+
+fail:
+ /* reverting */
+ GdipDeletePath(path);
+ GdipClonePath(backup, &path);
+ GdipDeletePath(backup);
+
+ return retstat;
+}
+
+GpStatus WINGDIPAPI GdipAddPathRectanglesI(GpPath *path, GDIPCONST GpRect *rects, INT count)
+{
+ GpRectF *rectsF;
+ GpStatus retstat;
+ INT i;
+
+ if(!rects || count == 0)
+ return InvalidParameter;
+
+ if(count < 0)
+ return OutOfMemory;
+
+ rectsF = GdipAlloc(sizeof(GpRectF)*count);
+
+ for(i = 0;i < count;i++){
+ rectsF[i].X = (REAL)rects[i].X;
+ rectsF[i].Y = (REAL)rects[i].Y;
+ rectsF[i].Width = (REAL)rects[i].Width;
+ rectsF[i].Height = (REAL)rects[i].Height;
+ }
+
+ retstat = GdipAddPathRectangles(path, rectsF, count);
+ GdipFree(rectsF);
+
+ return retstat;
+}
+
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index e797b44..6436b1a 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -561,6 +561,7 @@ static void test_rect(void)
{
GpStatus status;
GpPath *path;
+ GpRectF rects[2];
GdipCreatePath(FillModeAlternate, &path);
status = GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
@@ -571,6 +572,24 @@ static void test_rect(void)
ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE);
GdipDeletePath(path);
+
+ GdipCreatePath(FillModeAlternate, &path);
+
+ rects[0].X = 5.0;
+ rects[0].Y = 5.0;
+ rects[0].Width = 100.0;
+ rects[0].Height = 50.0;
+ rects[1].X = 100.0;
+ rects[1].Y = 50.0;
+ rects[1].Width = 120.0;
+ rects[1].Height = 30.0;
+
+ status = GdipAddPathRectangles(path, (GDIPCONST GpRectF*)&rects, 2);
+ expect(Ok, status);
+
+ ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE);
+
+ GdipDeletePath(path);
}
START_TEST(graphicspath)
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index 0d21c82..5ce32b2 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -215,6 +215,8 @@ GpStatus WINGDIPAPI GdipAddPathLineI(GpPath*,INT,INT,INT,INT);
GpStatus WINGDIPAPI GdipAddPathPath(GpPath*,GDIPCONST GpPath*,BOOL);
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath*,REAL,REAL,REAL,REAL);
GpStatus WINGDIPAPI GdipAddPathRectangleI(GpPath*,INT,INT,INT,INT);
+GpStatus WINGDIPAPI GdipAddPathRectangles(GpPath*,GDIPCONST GpRectF*,INT);
+GpStatus WINGDIPAPI GdipAddPathRectanglesI(GpPath*,GDIPCONST GpRect*,INT);
GpStatus WINGDIPAPI GdipClonePath(GpPath*,GpPath**);
GpStatus WINGDIPAPI GdipClosePathFigure(GpPath*);
GpStatus WINGDIPAPI GdipClosePathFigures(GpPath*);
--
1.4.4.4
More information about the wine-patches
mailing list