Commit 96937e04 authored by Evan Stade's avatar Evan Stade Committed by Alexandre Julliard

gdi32: Added PATH_PolyDraw.

parent 578ff168
......@@ -481,6 +481,7 @@ extern BOOL PATH_Arc(DC *dc, INT x1, INT y1, INT x2, INT y2,
INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines);
extern BOOL PATH_PolyBezierTo(DC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolyBezier(DC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types, DWORD cbCount);
extern BOOL PATH_PolylineTo(DC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_Polyline(DC *dc, const POINT *pt, DWORD cbCount);
extern BOOL PATH_Polygon(DC *dc, const POINT *pt, DWORD cbCount);
......
......@@ -830,12 +830,11 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
dc = DC_GetDCUpdate( hdc );
if(!dc) return FALSE;
if(dc->funcs->pPolyDraw)
{
if( PATH_IsPathOpen( dc->path ) )
result = PATH_PolyDraw(dc, lppt, lpbTypes, cCount);
else if(dc->funcs->pPolyDraw)
result = dc->funcs->pPolyDraw( dc->physDev, lppt, lpbTypes, cCount );
goto end;
}
else {
/* check for each bezierto if there are two more points */
for( i = 0; i < cCount; i++ )
if( lpbTypes[i] != PT_MOVETO &&
......@@ -872,14 +871,13 @@ BOOL WINAPI PolyDraw(HDC hdc, const POINT *lppt, const BYTE *lpbTypes,
if( lpbTypes[i] & PT_CLOSEFIGURE )
{
if( PATH_IsPathOpen( dc->path ) )
CloseFigure( hdc );
else
LineTo( hdc, lastmove.x, lastmove.y );
}
}
result = TRUE;
}
end:
GDI_ReleaseObj( hdc );
return result;
......
......@@ -933,6 +933,73 @@ BOOL PATH_PolyBezier(DC *dc, const POINT *pts, DWORD cbPoints)
return TRUE;
}
/* PATH_PolyDraw
*
* Should be called when a call to PolyDraw is performed on a DC that has
* an open path. Returns TRUE if successful, else FALSE.
*/
BOOL PATH_PolyDraw(DC *dc, const POINT *pts, const BYTE *types,
DWORD cbPoints)
{
GdiPath *pPath = &dc->path;
POINT lastmove, orig_pos;
INT i;
lastmove.x = orig_pos.x = dc->CursPosX;
lastmove.y = orig_pos.y = dc->CursPosY;
for(i = pPath->numEntriesUsed - 1; i >= 0; i--){
if(pPath->pFlags[i] == PT_MOVETO){
lastmove.x = pPath->pPoints[i].x;
lastmove.y = pPath->pPoints[i].y;
if(!DPtoLP(dc->hSelf, &lastmove, 1))
return FALSE;
break;
}
}
for(i = 0; i < cbPoints; i++){
if(types[i] == PT_MOVETO){
pPath->newStroke = TRUE;
lastmove.x = pts[i].x;
lastmove.y = pts[i].y;
}
else if((types[i] & ~PT_CLOSEFIGURE) == PT_LINETO){
PATH_LineTo(dc, pts[i].x, pts[i].y);
}
else if(types[i] == PT_BEZIERTO){
if(!((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO)
&& ((types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)))
goto err;
PATH_PolyBezierTo(dc, &(pts[i]), 3);
i += 2;
}
else
goto err;
dc->CursPosX = pts[i].x;
dc->CursPosY = pts[i].y;
if(types[i] & PT_CLOSEFIGURE){
pPath->pFlags[pPath->numEntriesUsed-1] |= PT_CLOSEFIGURE;
pPath->newStroke = TRUE;
dc->CursPosX = lastmove.x;
dc->CursPosY = lastmove.y;
}
}
return TRUE;
err:
if((dc->CursPosX != orig_pos.x) || (dc->CursPosY != orig_pos.y)){
pPath->newStroke = TRUE;
dc->CursPosX = orig_pos.x;
dc->CursPosY = orig_pos.y;
}
return FALSE;
}
BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints)
{
GdiPath *pPath = &dc->path;
......
......@@ -301,25 +301,25 @@ static const path_test_t polydraw_path[] = {
{95, 95, PT_LINETO, 0, 0}, /*4*/
{10, 10, PT_LINETO, 0, 0}, /*5*/
{10, 15, PT_LINETO | PT_CLOSEFIGURE, 0, 0}, /*6*/
{100, 100, PT_MOVETO, 0, 1}, /*7*/
{100, 100, PT_MOVETO, 0, 0}, /*7*/
{15, 15, PT_LINETO, 0, 0}, /*8*/
{25, 25, PT_MOVETO, 0, 1}, /*9*/
{25, 30, PT_LINETO, 0, 1}, /*10*/
{100, 100, PT_MOVETO, 0, 1}, /*11*/
{25, 25, PT_MOVETO, 0, 0}, /*9*/
{25, 30, PT_LINETO, 0, 0}, /*10*/
{100, 100, PT_MOVETO, 0, 0}, /*11*/
{30, 30, PT_BEZIERTO, 0, 0}, /*12*/
{30, 35, PT_BEZIERTO, 0, 0}, /*13*/
{35, 35, PT_BEZIERTO, 0, 0}, /*14*/
{35, 40, PT_LINETO, 0, 0}, /*15*/
{40, 40, PT_MOVETO, 0, 0}, /*16*/
{40, 45, PT_LINETO, 0, 0}, /*17*/
{35, 40, PT_MOVETO, 0, 1}, /*18*/
{45, 50, PT_LINETO, 0, 1}, /*19*/
{35, 40, PT_MOVETO, 0, 1}, /*20*/
{35, 40, PT_MOVETO, 0, 0}, /*18*/
{45, 50, PT_LINETO, 0, 0}, /*19*/
{35, 40, PT_MOVETO, 0, 0}, /*20*/
{50, 55, PT_LINETO, 0, 0}, /*21*/
{45, 50, PT_LINETO, 0, 0}, /*22*/
{35, 40, PT_MOVETO, 0, 1}, /*23*/
{60, 60, PT_LINETO, 0, 1}, /*24*/
{60, 65, PT_MOVETO, 0, 1}, /*25*/
{35, 40, PT_MOVETO, 0, 0}, /*23*/
{60, 60, PT_LINETO, 0, 0}, /*24*/
{60, 65, PT_MOVETO, 0, 0}, /*25*/
{65, 65, PT_LINETO, 0, 0} /*26*/
};
......@@ -366,8 +366,7 @@ static void test_polydraw(void)
expect(TRUE, retb);
/* bad bezier points */
retb = PolyDraw(hdc, &(polydraw_pts[2]), &(polydraw_tps[2]), 4);
todo_wine
expect(FALSE, retb);
expect(FALSE, retb);
retb = PolyDraw(hdc, &(polydraw_pts[6]), &(polydraw_tps[6]), 4);
expect(FALSE, retb);
/* good bezier points */
......@@ -378,8 +377,7 @@ static void test_polydraw(void)
expect(FALSE, retb);
/* bad point type, has already moved cursor position */
retb = PolyDraw(hdc, &(polydraw_pts[15]), &(polydraw_tps[15]), 4);
todo_wine
expect(FALSE, retb);
expect(FALSE, retb);
/* bad point type, cursor position is moved, but back to its original spot */
retb = PolyDraw(hdc, &(polydraw_pts[17]), &(polydraw_tps[17]), 4);
expect(FALSE, retb);
......@@ -388,7 +386,7 @@ static void test_polydraw(void)
expect(TRUE, retb);
EndPath(hdc);
ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t), 1);
ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t), 0);
done:
ReleaseDC(0, hdc);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment