mirror of
git://source.winehq.org/git/wine.git
synced 2024-08-31 08:44:07 +00:00
gdiplus: Added GdipAddPathRectangle with tests.
This commit is contained in:
parent
22c6e57637
commit
b5046c28ca
|
@ -25,8 +25,8 @@
|
|||
@ stub GdipAddPathPieI
|
||||
@ stub GdipAddPathPolygon
|
||||
@ stub GdipAddPathPolygonI
|
||||
@ stub GdipAddPathRectangle
|
||||
@ stub GdipAddPathRectangleI
|
||||
@ stdcall GdipAddPathRectangle(ptr long long long long)
|
||||
@ stdcall GdipAddPathRectangleI(ptr long long long long)
|
||||
@ stub GdipAddPathRectangles
|
||||
@ stub GdipAddPathRectanglesI
|
||||
@ stub GdipAddPathString
|
||||
|
|
|
@ -708,3 +708,53 @@ GpStatus WINGDIPAPI GdipTransformPath(GpPath *path, GpMatrix *matrix)
|
|||
return GdipTransformMatrixPoints(matrix, path->pathdata.Points,
|
||||
path->pathdata.Count);
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y,
|
||||
REAL width, REAL height)
|
||||
{
|
||||
GpPath *backup;
|
||||
GpPointF ptf[2];
|
||||
GpStatus retstat;
|
||||
BOOL old_new;
|
||||
|
||||
if(!path || width < 0.0 || height < 0.0)
|
||||
return InvalidParameter;
|
||||
|
||||
/* make a backup copy of path data */
|
||||
if((retstat = GdipClonePath(path, &backup)) != Ok)
|
||||
return retstat;
|
||||
|
||||
/* rectangle should start as new path */
|
||||
old_new = path->newfigure;
|
||||
path->newfigure = TRUE;
|
||||
if((retstat = GdipAddPathLine(path,x,y,x+width,y)) != Ok){
|
||||
path->newfigure = old_new;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ptf[0].X = x+width;
|
||||
ptf[0].Y = y+height;
|
||||
ptf[1].X = x;
|
||||
ptf[1].Y = y+height;
|
||||
|
||||
if((retstat = GdipAddPathLine2(path,(GDIPCONST GpPointF*)&ptf,2)) != Ok) goto fail;
|
||||
path->pathdata.Types[path->pathdata.Count-1] |= PathPointTypeCloseSubpath;
|
||||
|
||||
/* free backup */
|
||||
GdipDeletePath(backup);
|
||||
return Ok;
|
||||
|
||||
fail:
|
||||
/* reverting */
|
||||
GdipDeletePath(path);
|
||||
GdipClonePath(backup, &path);
|
||||
GdipDeletePath(backup);
|
||||
|
||||
return retstat;
|
||||
}
|
||||
|
||||
GpStatus WINGDIPAPI GdipAddPathRectangleI(GpPath *path, INT x, INT y,
|
||||
INT width, INT height)
|
||||
{
|
||||
return GdipAddPathRectangle(path,(REAL)x,(REAL)y,(REAL)width,(REAL)height);
|
||||
}
|
||||
|
|
|
@ -545,6 +545,34 @@ static void test_linei(void)
|
|||
GdipDeletePath(path);
|
||||
}
|
||||
|
||||
static path_test_t rect_path[] = {
|
||||
{5.0, 5.0, PathPointTypeStart, 0, 0}, /*0*/
|
||||
{105.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/
|
||||
{105.0, 55.0, PathPointTypeLine, 0, 0}, /*2*/
|
||||
{5.0, 55.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*3*/
|
||||
|
||||
{100.0, 50.0, PathPointTypeStart, 0, 0}, /*4*/
|
||||
{220.0, 50.0, PathPointTypeLine, 0, 0}, /*5*/
|
||||
{220.0, 80.0, PathPointTypeLine, 0, 0}, /*6*/
|
||||
{100.0, 80.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0} /*7*/
|
||||
};
|
||||
|
||||
static void test_rect(void)
|
||||
{
|
||||
GpStatus status;
|
||||
GpPath *path;
|
||||
|
||||
GdipCreatePath(FillModeAlternate, &path);
|
||||
status = GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
|
||||
expect(Ok, status);
|
||||
status = GdipAddPathRectangle(path, 100.0, 50.0, 120.0, 30.0);
|
||||
expect(Ok, status);
|
||||
|
||||
ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE);
|
||||
|
||||
GdipDeletePath(path);
|
||||
}
|
||||
|
||||
START_TEST(graphicspath)
|
||||
{
|
||||
struct GdiplusStartupInput gdiplusStartupInput;
|
||||
|
@ -564,6 +592,7 @@ START_TEST(graphicspath)
|
|||
test_pathpath();
|
||||
test_ellipse();
|
||||
test_linei();
|
||||
test_rect();
|
||||
|
||||
GdiplusShutdown(gdiplusToken);
|
||||
}
|
||||
|
|
|
@ -213,6 +213,8 @@ GpStatus WINGDIPAPI GdipAddPathLine2(GpPath*,GDIPCONST GpPointF*,INT);
|
|||
GpStatus WINGDIPAPI GdipAddPathLine2I(GpPath*,GDIPCONST GpPoint*,INT);
|
||||
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 GdipClonePath(GpPath*,GpPath**);
|
||||
GpStatus WINGDIPAPI GdipClosePathFigure(GpPath*);
|
||||
GpStatus WINGDIPAPI GdipClosePathFigures(GpPath*);
|
||||
|
|
Loading…
Reference in a new issue