Commit a3d3ff8d authored by Huw D M Davies's avatar Huw D M Davies Committed by Alexandre Julliard

Implement StrokeAndFillPath.

Call DeleteObject when finished with hrgn in PATH_FillPath.
parent 008c388a
......@@ -244,8 +244,6 @@ BOOL WINAPI CloseFigure(HDC hdc)
return FALSE;
}
/* FIXME: Shouldn't we draw a line to the beginning of the figure? */
/* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
if(pPath->numEntriesUsed)
{
......@@ -360,39 +358,13 @@ HRGN WINAPI PathToRegion(HDC hdc)
return hrgnRval;
}
/***********************************************************************
* FillPath16 (GDI.515)
*/
BOOL16 WINAPI FillPath16(HDC16 hdc)
{
return (BOOL16) FillPath((HDC) hdc);
}
/***********************************************************************
* FillPath (GDI32.100)
*
* FIXME
* Check that SetLastError is being called correctly
*/
BOOL WINAPI FillPath(HDC hdc)
static BOOL PATH_FillPath(HDC hdc, GdiPath *pPath)
{
GdiPath *pPath;
INT mapMode, graphicsMode;
SIZE ptViewportExt, ptWindowExt;
POINT ptViewportOrg, ptWindowOrg;
XFORM xform;
XFORM xform;
HRGN hrgn;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) {
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if(dc->funcs->pFillPath)
return dc->funcs->pFillPath(dc);
pPath = &dc->w.path;
/* Check that path is closed */
if(pPath->state!=PATH_Closed)
......@@ -434,7 +406,7 @@ BOOL WINAPI FillPath(HDC hdc)
/* Paint the region */
PaintRgn(hdc, hrgn);
DeleteObject(hrgn);
/* Restore the old mapping mode */
SetMapMode(hdc, mapMode);
SetViewportExtEx(hdc, ptViewportExt.cx, ptViewportExt.cy, NULL);
......@@ -447,17 +419,43 @@ BOOL WINAPI FillPath(HDC hdc)
SetGraphicsMode(hdc, GM_ADVANCED);
SetWorldTransform(hdc, &xform);
SetGraphicsMode(hdc, graphicsMode);
/* Empty the path */
PATH_EmptyPath(pPath);
return TRUE;
}
else
{
/* FIXME: Should the path be emptied even if conversion failed? */
/* PATH_EmptyPath(pPath); */
return FALSE;
return FALSE;
}
/***********************************************************************
* FillPath16 (GDI.515)
*/
BOOL16 WINAPI FillPath16(HDC16 hdc)
{
return (BOOL16) FillPath((HDC) hdc);
}
/***********************************************************************
* FillPath (GDI32.100)
*
* FIXME
* Check that SetLastError is being called correctly
*/
BOOL WINAPI FillPath(HDC hdc)
{
DC *dc = DC_GetDCPtr( hdc );
if(!dc) {
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if(dc->funcs->pFillPath)
return dc->funcs->pFillPath(dc);
if(!PATH_FillPath(hdc, &dc->w.path))
return FALSE;
/* FIXME: Should the path be emptied even if conversion failed? */
PATH_EmptyPath(&dc->w.path);
return TRUE;
}
/***********************************************************************
......@@ -1454,6 +1452,55 @@ BOOL WINAPI FlattenPath(HDC hdc)
return PATH_FlattenPath(pPath);
}
static BOOL PATH_StrokePath(HDC hdc, GdiPath *pPath)
{
INT i;
POINT ptLastMove = {0,0};
if(pPath->state != PATH_Closed)
return FALSE;
SaveDC(hdc);
SetMapMode(hdc, MM_TEXT);
SetViewportOrgEx(hdc, 0, 0, NULL);
SetWindowOrgEx(hdc, 0, 0, NULL);
for(i = 0; i < pPath->numEntriesUsed; i++) {
switch(pPath->pFlags[i]) {
case PT_MOVETO:
TRACE("Got PT_MOVETO (%ld, %ld)\n",
pPath->pPoints[i].x, pPath->pPoints[i].y);
MoveToEx(hdc, pPath->pPoints[i].x, pPath->pPoints[i].y, NULL);
ptLastMove = pPath->pPoints[i];
break;
case PT_LINETO:
case (PT_LINETO | PT_CLOSEFIGURE):
TRACE("Got PT_LINETO (%ld, %ld)\n",
pPath->pPoints[i].x, pPath->pPoints[i].y);
LineTo(hdc, pPath->pPoints[i].x, pPath->pPoints[i].y);
break;
case PT_BEZIERTO:
TRACE("Got PT_BEZIERTO\n");
if(pPath->pFlags[i+1] != PT_BEZIERTO ||
(pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
return FALSE;
}
PolyBezierTo(hdc, &pPath->pPoints[i], 3);
i += 2;
break;
default:
ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
return FALSE;
}
if(pPath->pFlags[i] & PT_CLOSEFIGURE)
LineTo(hdc, ptLastMove.x, ptLastMove.y);
}
RestoreDC(hdc, -1);
return TRUE;
}
/*******************************************************************
* StrokeAndFillPath16 [GDI.520]
*
......@@ -1472,7 +1519,8 @@ BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
BOOL WINAPI StrokeAndFillPath(HDC hdc)
{
DC *dc = DC_GetDCPtr( hdc );
BOOL bRet;
if(!dc) {
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
......@@ -1481,8 +1529,10 @@ BOOL WINAPI StrokeAndFillPath(HDC hdc)
if(dc->funcs->pStrokeAndFillPath)
return dc->funcs->pStrokeAndFillPath(dc);
FIXME("stub\n");
return StrokePath(hdc);
bRet = PATH_FillPath(hdc, &dc->w.path);
if(bRet) bRet = PATH_StrokePath(hdc, &dc->w.path);
if(bRet) PATH_EmptyPath(&dc->w.path);
return bRet;
}
/*******************************************************************
......@@ -1504,8 +1554,6 @@ BOOL WINAPI StrokePath(HDC hdc)
{
DC *dc = DC_GetDCPtr( hdc );
GdiPath *pPath;
INT i;
POINT ptLastMove = {0,0};
TRACE("(%08x)\n", hdc);
if(!dc) {
......@@ -1517,45 +1565,7 @@ BOOL WINAPI StrokePath(HDC hdc)
return dc->funcs->pStrokePath(dc);
pPath = &dc->w.path;
if(pPath->state != PATH_Closed)
return FALSE;
SaveDC(hdc);
SetMapMode(hdc, MM_TEXT);
SetViewportOrgEx(hdc, 0, 0, NULL);
SetWindowOrgEx(hdc, 0, 0, NULL);
for(i = 0; i < pPath->numEntriesUsed; i++) {
switch(pPath->pFlags[i]) {
case PT_MOVETO:
TRACE("Got PT_MOVETO (%ld, %ld)\n",
pPath->pPoints[i].x, pPath->pPoints[i].y);
MoveToEx(hdc, pPath->pPoints[i].x, pPath->pPoints[i].y, NULL);
ptLastMove = pPath->pPoints[i];
break;
case PT_LINETO:
case (PT_LINETO | PT_CLOSEFIGURE):
TRACE("Got PT_LINETO (%ld, %ld)\n",
pPath->pPoints[i].x, pPath->pPoints[i].y);
LineTo(hdc, pPath->pPoints[i].x, pPath->pPoints[i].y);
break;
case PT_BEZIERTO:
TRACE("Got PT_BEZIERTO\n");
if(pPath->pFlags[i+1] != PT_BEZIERTO ||
(pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
return FALSE;
}
PolyBezierTo(hdc, &pPath->pPoints[i], 3);
i += 2;
break;
default:
ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
return FALSE;
}
if(pPath->pFlags[i] & PT_CLOSEFIGURE)
LineTo(hdc, ptLastMove.x, ptLastMove.y);
}
RestoreDC(hdc, -1);
PATH_StrokePath(hdc, pPath);
PATH_EmptyPath(pPath);
return TRUE;
}
......
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