gdiplus: Implemented GdipAddPathRectangles with tests.
This commit is contained in:
parent
250a9d7412
commit
d4ae6fa1ea
|
@ -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)
|
||||
|
|
|
@ -758,3 +758,65 @@ 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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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*);
|
||||
|
|
Loading…
Reference in New Issue