IErrorInfo is now derived from IUnknown.
[wine/multimedia.git] / graphics / path.c
blobe82925d31a43ec4671c7c3604f302c214ba8bed9
1 /*
2 * Graphics paths (BeginPath, EndPath etc.)
4 * Copyright 1997, 1998 Martin Boehme
5 * 1999 Huw D M Davies
6 */
8 #include <assert.h>
9 #include <math.h>
10 #include <string.h>
11 #include "config.h"
12 #if defined(HAVE_FLOAT_H)
13 #include <float.h>
14 #endif
16 #include "winbase.h"
17 #include "wingdi.h"
18 #include "winerror.h"
20 #include "dc.h"
21 #include "debugtools.h"
22 #include "path.h"
24 DEFAULT_DEBUG_CHANNEL(gdi)
26 /* Notes on the implementation
28 * The implementation is based on dynamically resizable arrays of points and
29 * flags. I dithered for a bit before deciding on this implementation, and
30 * I had even done a bit of work on a linked list version before switching
31 * to arrays. It's a bit of a tradeoff. When you use linked lists, the
32 * implementation of FlattenPath is easier, because you can rip the
33 * PT_BEZIERTO entries out of the middle of the list and link the
34 * corresponding PT_LINETO entries in. However, when you use arrays,
35 * PathToRegion becomes easier, since you can essentially just pass your array
36 * of points to CreatePolyPolygonRgn. Also, if I'd used linked lists, I would
37 * have had the extra effort of creating a chunk-based allocation scheme
38 * in order to use memory effectively. That's why I finally decided to use
39 * arrays. Note by the way that the array based implementation has the same
40 * linear time complexity that linked lists would have since the arrays grow
41 * exponentially.
43 * The points are stored in the path in device coordinates. This is
44 * consistent with the way Windows does things (for instance, see the Win32
45 * SDK documentation for GetPath).
47 * The word "stroke" appears in several places (e.g. in the flag
48 * GdiPath.newStroke). A stroke consists of a PT_MOVETO followed by one or
49 * more PT_LINETOs or PT_BEZIERTOs, up to, but not including, the next
50 * PT_MOVETO. Note that this is not the same as the definition of a figure;
51 * a figure can contain several strokes.
53 * I modified the drawing functions (MoveTo, LineTo etc.) to test whether
54 * the path is open and to call the corresponding function in path.c if this
55 * is the case. A more elegant approach would be to modify the function
56 * pointers in the DC_FUNCTIONS structure; however, this would be a lot more
57 * complex. Also, the performance degradation caused by my approach in the
58 * case where no path is open is so small that it cannot be measured.
60 * Martin Boehme
63 /* FIXME: A lot of stuff isn't implemented yet. There is much more to come. */
65 #define NUM_ENTRIES_INITIAL 16 /* Initial size of points / flags arrays */
66 #define GROW_FACTOR_NUMER 2 /* Numerator of grow factor for the array */
67 #define GROW_FACTOR_DENOM 1 /* Denominator of grow factor */
70 static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
71 HRGN *pHrgn);
72 static void PATH_EmptyPath(GdiPath *pPath);
73 static BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint,
74 BYTE flags);
75 static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries);
76 static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
77 double angleStart, double angleEnd, BOOL addMoveTo);
78 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
79 double y, POINT *pPoint);
80 static void PATH_NormalizePoint(FLOAT_POINT corners[], const FLOAT_POINT
81 *pPoint, double *pX, double *pY);
84 /***********************************************************************
85 * BeginPath16 (GDI.512)
87 BOOL16 WINAPI BeginPath16(HDC16 hdc)
89 return (BOOL16)BeginPath((HDC)hdc);
93 /***********************************************************************
94 * BeginPath (GDI32.9)
96 BOOL WINAPI BeginPath(HDC hdc)
98 BOOL ret = TRUE;
99 DC *dc = DC_GetDCPtr( hdc );
101 if(!dc) return FALSE;
103 if(dc->funcs->pBeginPath)
104 ret = dc->funcs->pBeginPath(dc);
105 else
107 /* If path is already open, do nothing */
108 if(dc->w.path.state != PATH_Open)
110 /* Make sure that path is empty */
111 PATH_EmptyPath(&dc->w.path);
113 /* Initialize variables for new path */
114 dc->w.path.newStroke=TRUE;
115 dc->w.path.state=PATH_Open;
118 GDI_ReleaseObj( hdc );
119 return ret;
123 /***********************************************************************
124 * EndPath16 (GDI.514)
126 BOOL16 WINAPI EndPath16(HDC16 hdc)
128 return (BOOL16)EndPath((HDC)hdc);
132 /***********************************************************************
133 * EndPath (GDI32.78)
135 BOOL WINAPI EndPath(HDC hdc)
137 BOOL ret = TRUE;
138 DC *dc = DC_GetDCPtr( hdc );
140 if(!dc) return FALSE;
142 if(dc->funcs->pEndPath)
143 ret = dc->funcs->pEndPath(dc);
144 else
146 /* Check that path is currently being constructed */
147 if(dc->w.path.state!=PATH_Open)
149 SetLastError(ERROR_CAN_NOT_COMPLETE);
150 ret = FALSE;
152 /* Set flag to indicate that path is finished */
153 else dc->w.path.state=PATH_Closed;
155 GDI_ReleaseObj( hdc );
156 return ret;
160 /***********************************************************************
161 * AbortPath16 (GDI.511)
163 BOOL16 WINAPI AbortPath16(HDC16 hdc)
165 return (BOOL16)AbortPath((HDC)hdc);
169 /******************************************************************************
170 * AbortPath [GDI32.1]
171 * Closes and discards paths from device context
173 * NOTES
174 * Check that SetLastError is being called correctly
176 * PARAMS
177 * hdc [I] Handle to device context
179 * RETURNS STD
181 BOOL WINAPI AbortPath( HDC hdc )
183 BOOL ret = TRUE;
184 DC *dc = DC_GetDCPtr( hdc );
186 if(!dc) return FALSE;
188 if(dc->funcs->pAbortPath)
189 ret = dc->funcs->pAbortPath(dc);
190 else /* Remove all entries from the path */
191 PATH_EmptyPath( &dc->w.path );
192 GDI_ReleaseObj( hdc );
193 return ret;
197 /***********************************************************************
198 * CloseFigure16 (GDI.513)
200 BOOL16 WINAPI CloseFigure16(HDC16 hdc)
202 return (BOOL16)CloseFigure((HDC)hdc);
206 /***********************************************************************
207 * CloseFigure (GDI32.16)
209 * FIXME: Check that SetLastError is being called correctly
211 BOOL WINAPI CloseFigure(HDC hdc)
213 BOOL ret = TRUE;
214 DC *dc = DC_GetDCPtr( hdc );
216 if(!dc) return FALSE;
218 if(dc->funcs->pCloseFigure)
219 ret = dc->funcs->pCloseFigure(dc);
220 else
222 /* Check that path is open */
223 if(dc->w.path.state!=PATH_Open)
225 SetLastError(ERROR_CAN_NOT_COMPLETE);
226 ret = FALSE;
228 else
230 /* FIXME: Shouldn't we draw a line to the beginning of the
231 figure? */
232 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
233 if(dc->w.path.numEntriesUsed)
235 dc->w.path.pFlags[dc->w.path.numEntriesUsed-1]|=PT_CLOSEFIGURE;
236 dc->w.path.newStroke=TRUE;
240 GDI_ReleaseObj( hdc );
241 return ret;
245 /***********************************************************************
246 * GetPath16 (GDI.517)
248 INT16 WINAPI GetPath16(HDC16 hdc, LPPOINT16 pPoints, LPBYTE pTypes,
249 INT16 nSize)
251 FIXME("(%d,%p,%p): stub\n",hdc,pPoints,pTypes);
253 return 0;
257 /***********************************************************************
258 * GetPath (GDI32.210)
260 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes,
261 INT nSize)
263 INT ret = -1;
264 GdiPath *pPath;
265 DC *dc = DC_GetDCPtr( hdc );
267 if(!dc) return -1;
269 pPath = &dc->w.path;
271 /* Check that path is closed */
272 if(pPath->state!=PATH_Closed)
274 SetLastError(ERROR_CAN_NOT_COMPLETE);
275 goto done;
278 if(nSize==0)
279 ret = pPath->numEntriesUsed;
280 else if(nSize<pPath->numEntriesUsed)
282 SetLastError(ERROR_INVALID_PARAMETER);
283 goto done;
285 else
287 memcpy(pPoints, pPath->pPoints, sizeof(POINT)*pPath->numEntriesUsed);
288 memcpy(pTypes, pPath->pFlags, sizeof(BYTE)*pPath->numEntriesUsed);
290 /* Convert the points to logical coordinates */
291 if(!DPtoLP(hdc, pPoints, pPath->numEntriesUsed))
293 /* FIXME: Is this the correct value? */
294 SetLastError(ERROR_CAN_NOT_COMPLETE);
295 goto done;
297 else ret = pPath->numEntriesUsed;
299 done:
300 GDI_ReleaseObj( hdc );
301 return ret;
304 /***********************************************************************
305 * PathToRegion16 (GDI.518)
307 HRGN16 WINAPI PathToRegion16(HDC16 hdc)
309 return (HRGN16) PathToRegion((HDC) hdc);
312 /***********************************************************************
313 * PathToRegion (GDI32.261)
315 * FIXME
316 * Check that SetLastError is being called correctly
318 * The documentation does not state this explicitly, but a test under Windows
319 * shows that the region which is returned should be in device coordinates.
321 HRGN WINAPI PathToRegion(HDC hdc)
323 GdiPath *pPath;
324 HRGN hrgnRval = 0;
325 DC *dc = DC_GetDCPtr( hdc );
327 /* Get pointer to path */
328 if(!dc) return -1;
330 pPath = &dc->w.path;
332 /* Check that path is closed */
333 if(pPath->state!=PATH_Closed) SetLastError(ERROR_CAN_NOT_COMPLETE);
334 else
336 /* FIXME: Should we empty the path even if conversion failed? */
337 if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnRval))
338 PATH_EmptyPath(pPath);
339 else
340 hrgnRval=0;
342 GDI_ReleaseObj( hdc );
343 return hrgnRval;
346 static BOOL PATH_FillPath(DC *dc, GdiPath *pPath)
348 INT mapMode, graphicsMode;
349 SIZE ptViewportExt, ptWindowExt;
350 POINT ptViewportOrg, ptWindowOrg;
351 XFORM xform;
352 HRGN hrgn;
354 if(dc->funcs->pFillPath)
355 return dc->funcs->pFillPath(dc);
357 /* Check that path is closed */
358 if(pPath->state!=PATH_Closed)
360 SetLastError(ERROR_CAN_NOT_COMPLETE);
361 return FALSE;
364 /* Construct a region from the path and fill it */
365 if(PATH_PathToRegion(pPath, dc->w.polyFillMode, &hrgn))
367 /* Since PaintRgn interprets the region as being in logical coordinates
368 * but the points we store for the path are already in device
369 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
370 * Using SaveDC to save information about the mapping mode / world
371 * transform would be easier but would require more overhead, especially
372 * now that SaveDC saves the current path.
375 /* Save the information about the old mapping mode */
376 mapMode=GetMapMode(dc->hSelf);
377 GetViewportExtEx(dc->hSelf, &ptViewportExt);
378 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
379 GetWindowExtEx(dc->hSelf, &ptWindowExt);
380 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
382 /* Save world transform
383 * NB: The Windows documentation on world transforms would lead one to
384 * believe that this has to be done only in GM_ADVANCED; however, my
385 * tests show that resetting the graphics mode to GM_COMPATIBLE does
386 * not reset the world transform.
388 GetWorldTransform(dc->hSelf, &xform);
390 /* Set MM_TEXT */
391 SetMapMode(dc->hSelf, MM_TEXT);
392 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
393 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
395 /* Paint the region */
396 PaintRgn(dc->hSelf, hrgn);
397 DeleteObject(hrgn);
398 /* Restore the old mapping mode */
399 SetMapMode(dc->hSelf, mapMode);
400 SetViewportExtEx(dc->hSelf, ptViewportExt.cx, ptViewportExt.cy, NULL);
401 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
402 SetWindowExtEx(dc->hSelf, ptWindowExt.cx, ptWindowExt.cy, NULL);
403 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
405 /* Go to GM_ADVANCED temporarily to restore the world transform */
406 graphicsMode=GetGraphicsMode(dc->hSelf);
407 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
408 SetWorldTransform(dc->hSelf, &xform);
409 SetGraphicsMode(dc->hSelf, graphicsMode);
410 return TRUE;
412 return FALSE;
415 /***********************************************************************
416 * FillPath16 (GDI.515)
418 BOOL16 WINAPI FillPath16(HDC16 hdc)
420 return (BOOL16) FillPath((HDC) hdc);
423 /***********************************************************************
424 * FillPath (GDI32.100)
426 * FIXME
427 * Check that SetLastError is being called correctly
429 BOOL WINAPI FillPath(HDC hdc)
431 DC *dc = DC_GetDCPtr( hdc );
432 BOOL bRet = FALSE;
434 if(!dc) return FALSE;
436 if(dc->funcs->pFillPath)
437 bRet = dc->funcs->pFillPath(dc);
438 else
440 bRet = PATH_FillPath(dc, &dc->w.path);
441 if(bRet)
443 /* FIXME: Should the path be emptied even if conversion
444 failed? */
445 PATH_EmptyPath(&dc->w.path);
448 GDI_ReleaseObj( hdc );
449 return bRet;
452 /***********************************************************************
453 * SelectClipPath16 (GDI.519)
455 BOOL16 WINAPI SelectClipPath16(HDC16 hdc, INT16 iMode)
457 return (BOOL16) SelectClipPath((HDC) hdc, iMode);
460 /***********************************************************************
461 * SelectClipPath (GDI32.296)
462 * FIXME
463 * Check that SetLastError is being called correctly
465 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
467 GdiPath *pPath;
468 HRGN hrgnPath;
469 BOOL success = FALSE;
470 DC *dc = DC_GetDCPtr( hdc );
472 if(!dc) return FALSE;
474 if(dc->funcs->pSelectClipPath)
475 success = dc->funcs->pSelectClipPath(dc, iMode);
476 else
478 pPath = &dc->w.path;
480 /* Check that path is closed */
481 if(pPath->state!=PATH_Closed)
482 SetLastError(ERROR_CAN_NOT_COMPLETE);
483 /* Construct a region from the path */
484 else if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnPath))
486 success = ExtSelectClipRgn( hdc, hrgnPath, iMode ) != ERROR;
487 DeleteObject(hrgnPath);
489 /* Empty the path */
490 if(success)
491 PATH_EmptyPath(pPath);
492 /* FIXME: Should this function delete the path even if it failed? */
495 GDI_ReleaseObj( hdc );
496 return success;
500 /***********************************************************************
501 * Exported functions
504 /* PATH_InitGdiPath
506 * Initializes the GdiPath structure.
508 void PATH_InitGdiPath(GdiPath *pPath)
510 assert(pPath!=NULL);
512 pPath->state=PATH_Null;
513 pPath->pPoints=NULL;
514 pPath->pFlags=NULL;
515 pPath->numEntriesUsed=0;
516 pPath->numEntriesAllocated=0;
519 /* PATH_DestroyGdiPath
521 * Destroys a GdiPath structure (frees the memory in the arrays).
523 void PATH_DestroyGdiPath(GdiPath *pPath)
525 assert(pPath!=NULL);
527 if (pPath->pPoints) HeapFree( GetProcessHeap(), 0, pPath->pPoints );
528 if (pPath->pFlags) HeapFree( GetProcessHeap(), 0, pPath->pFlags );
531 /* PATH_AssignGdiPath
533 * Copies the GdiPath structure "pPathSrc" to "pPathDest". A deep copy is
534 * performed, i.e. the contents of the pPoints and pFlags arrays are copied,
535 * not just the pointers. Since this means that the arrays in pPathDest may
536 * need to be resized, pPathDest should have been initialized using
537 * PATH_InitGdiPath (in C++, this function would be an assignment operator,
538 * not a copy constructor).
539 * Returns TRUE if successful, else FALSE.
541 BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc)
543 assert(pPathDest!=NULL && pPathSrc!=NULL);
545 /* Make sure destination arrays are big enough */
546 if(!PATH_ReserveEntries(pPathDest, pPathSrc->numEntriesUsed))
547 return FALSE;
549 /* Perform the copy operation */
550 memcpy(pPathDest->pPoints, pPathSrc->pPoints,
551 sizeof(POINT)*pPathSrc->numEntriesUsed);
552 memcpy(pPathDest->pFlags, pPathSrc->pFlags,
553 sizeof(BYTE)*pPathSrc->numEntriesUsed);
555 pPathDest->state=pPathSrc->state;
556 pPathDest->numEntriesUsed=pPathSrc->numEntriesUsed;
557 pPathDest->newStroke=pPathSrc->newStroke;
559 return TRUE;
562 /* PATH_MoveTo
564 * Should be called when a MoveTo is performed on a DC that has an
565 * open path. This starts a new stroke. Returns TRUE if successful, else
566 * FALSE.
568 BOOL PATH_MoveTo(DC *dc)
570 GdiPath *pPath = &dc->w.path;
572 /* Check that path is open */
573 if(pPath->state!=PATH_Open)
574 /* FIXME: Do we have to call SetLastError? */
575 return FALSE;
577 /* Start a new stroke */
578 pPath->newStroke=TRUE;
580 return TRUE;
583 /* PATH_LineTo
585 * Should be called when a LineTo is performed on a DC that has an
586 * open path. This adds a PT_LINETO entry to the path (and possibly
587 * a PT_MOVETO entry, if this is the first LineTo in a stroke).
588 * Returns TRUE if successful, else FALSE.
590 BOOL PATH_LineTo(DC *dc, INT x, INT y)
592 GdiPath *pPath = &dc->w.path;
593 POINT point, pointCurPos;
595 /* Check that path is open */
596 if(pPath->state!=PATH_Open)
597 return FALSE;
599 /* Convert point to device coordinates */
600 point.x=x;
601 point.y=y;
602 if(!LPtoDP(dc->hSelf, &point, 1))
603 return FALSE;
605 /* Add a PT_MOVETO if necessary */
606 if(pPath->newStroke)
608 pPath->newStroke=FALSE;
609 pointCurPos.x = dc->w.CursPosX;
610 pointCurPos.y = dc->w.CursPosY;
611 if(!LPtoDP(dc->hSelf, &pointCurPos, 1))
612 return FALSE;
613 if(!PATH_AddEntry(pPath, &pointCurPos, PT_MOVETO))
614 return FALSE;
617 /* Add a PT_LINETO entry */
618 return PATH_AddEntry(pPath, &point, PT_LINETO);
621 /* PATH_Rectangle
623 * Should be called when a call to Rectangle is performed on a DC that has
624 * an open path. Returns TRUE if successful, else FALSE.
626 BOOL PATH_Rectangle(DC *dc, INT x1, INT y1, INT x2, INT y2)
628 GdiPath *pPath = &dc->w.path;
629 POINT corners[2], pointTemp;
630 INT temp;
632 /* Check that path is open */
633 if(pPath->state!=PATH_Open)
634 return FALSE;
636 /* Convert points to device coordinates */
637 corners[0].x=x1;
638 corners[0].y=y1;
639 corners[1].x=x2;
640 corners[1].y=y2;
641 if(!LPtoDP(dc->hSelf, corners, 2))
642 return FALSE;
644 /* Make sure first corner is top left and second corner is bottom right */
645 if(corners[0].x>corners[1].x)
647 temp=corners[0].x;
648 corners[0].x=corners[1].x;
649 corners[1].x=temp;
651 if(corners[0].y>corners[1].y)
653 temp=corners[0].y;
654 corners[0].y=corners[1].y;
655 corners[1].y=temp;
658 /* In GM_COMPATIBLE, don't include bottom and right edges */
659 if(dc->w.GraphicsMode==GM_COMPATIBLE)
661 corners[1].x--;
662 corners[1].y--;
665 /* Close any previous figure */
666 if(!CloseFigure(dc->hSelf))
668 /* The CloseFigure call shouldn't have failed */
669 assert(FALSE);
670 return FALSE;
673 /* Add four points to the path */
674 pointTemp.x=corners[1].x;
675 pointTemp.y=corners[0].y;
676 if(!PATH_AddEntry(pPath, &pointTemp, PT_MOVETO))
677 return FALSE;
678 if(!PATH_AddEntry(pPath, corners, PT_LINETO))
679 return FALSE;
680 pointTemp.x=corners[0].x;
681 pointTemp.y=corners[1].y;
682 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
683 return FALSE;
684 if(!PATH_AddEntry(pPath, corners+1, PT_LINETO))
685 return FALSE;
687 /* Close the rectangle figure */
688 if(!CloseFigure(dc->hSelf))
690 /* The CloseFigure call shouldn't have failed */
691 assert(FALSE);
692 return FALSE;
695 return TRUE;
698 /* PATH_Ellipse
700 * Should be called when a call to Ellipse is performed on a DC that has
701 * an open path. This adds four Bezier splines representing the ellipse
702 * to the path. Returns TRUE if successful, else FALSE.
704 BOOL PATH_Ellipse(DC *dc, INT x1, INT y1, INT x2, INT y2)
706 /* TODO: This should probably be revised to call PATH_AngleArc */
707 /* (once it exists) */
708 return PATH_Arc(dc, x1, y1, x2, y2, x1, (y1+y2)/2, x1, (y1+y2)/2);
711 /* PATH_Arc
713 * Should be called when a call to Arc is performed on a DC that has
714 * an open path. This adds up to five Bezier splines representing the arc
715 * to the path. Returns TRUE if successful, else FALSE.
717 BOOL PATH_Arc(DC *dc, INT x1, INT y1, INT x2, INT y2,
718 INT xStart, INT yStart, INT xEnd, INT yEnd)
720 GdiPath *pPath = &dc->w.path;
721 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
722 /* Initialize angleEndQuadrant to silence gcc's warning */
723 double x, y;
724 FLOAT_POINT corners[2], pointStart, pointEnd;
725 BOOL start, end;
726 INT temp;
728 /* FIXME: This function should check for all possible error returns */
729 /* FIXME: Do we have to respect newStroke? */
731 /* Check that path is open */
732 if(pPath->state!=PATH_Open)
733 return FALSE;
735 /* FIXME: Do we have to close the current figure? */
737 /* Check for zero height / width */
738 /* FIXME: Only in GM_COMPATIBLE? */
739 if(x1==x2 || y1==y2)
740 return TRUE;
742 /* Convert points to device coordinates */
743 corners[0].x=(FLOAT)x1;
744 corners[0].y=(FLOAT)y1;
745 corners[1].x=(FLOAT)x2;
746 corners[1].y=(FLOAT)y2;
747 pointStart.x=(FLOAT)xStart;
748 pointStart.y=(FLOAT)yStart;
749 pointEnd.x=(FLOAT)xEnd;
750 pointEnd.y=(FLOAT)yEnd;
751 INTERNAL_LPTODP_FLOAT(dc, corners);
752 INTERNAL_LPTODP_FLOAT(dc, corners+1);
753 INTERNAL_LPTODP_FLOAT(dc, &pointStart);
754 INTERNAL_LPTODP_FLOAT(dc, &pointEnd);
756 /* Make sure first corner is top left and second corner is bottom right */
757 if(corners[0].x>corners[1].x)
759 temp=corners[0].x;
760 corners[0].x=corners[1].x;
761 corners[1].x=temp;
763 if(corners[0].y>corners[1].y)
765 temp=corners[0].y;
766 corners[0].y=corners[1].y;
767 corners[1].y=temp;
770 /* Compute start and end angle */
771 PATH_NormalizePoint(corners, &pointStart, &x, &y);
772 angleStart=atan2(y, x);
773 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
774 angleEnd=atan2(y, x);
776 /* Make sure the end angle is "on the right side" of the start angle */
777 if(dc->w.ArcDirection==AD_CLOCKWISE)
779 if(angleEnd<=angleStart)
781 angleEnd+=2*M_PI;
782 assert(angleEnd>=angleStart);
785 else
787 if(angleEnd>=angleStart)
789 angleEnd-=2*M_PI;
790 assert(angleEnd<=angleStart);
794 /* In GM_COMPATIBLE, don't include bottom and right edges */
795 if(dc->w.GraphicsMode==GM_COMPATIBLE)
797 corners[1].x--;
798 corners[1].y--;
801 /* Add the arc to the path with one Bezier spline per quadrant that the
802 * arc spans */
803 start=TRUE;
804 end=FALSE;
807 /* Determine the start and end angles for this quadrant */
808 if(start)
810 angleStartQuadrant=angleStart;
811 if(dc->w.ArcDirection==AD_CLOCKWISE)
812 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
813 else
814 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
816 else
818 angleStartQuadrant=angleEndQuadrant;
819 if(dc->w.ArcDirection==AD_CLOCKWISE)
820 angleEndQuadrant+=M_PI_2;
821 else
822 angleEndQuadrant-=M_PI_2;
825 /* Have we reached the last part of the arc? */
826 if((dc->w.ArcDirection==AD_CLOCKWISE &&
827 angleEnd<angleEndQuadrant) ||
828 (dc->w.ArcDirection==AD_COUNTERCLOCKWISE &&
829 angleEnd>angleEndQuadrant))
831 /* Adjust the end angle for this quadrant */
832 angleEndQuadrant=angleEnd;
833 end=TRUE;
836 /* Add the Bezier spline to the path */
837 PATH_DoArcPart(pPath, corners, angleStartQuadrant, angleEndQuadrant,
838 start);
839 start=FALSE;
840 } while(!end);
842 return TRUE;
845 BOOL PATH_PolyBezierTo(DC *dc, const POINT *pts, DWORD cbPoints)
847 GdiPath *pPath = &dc->w.path;
848 POINT pt;
849 INT i;
851 /* Check that path is open */
852 if(pPath->state!=PATH_Open)
853 return FALSE;
855 /* Add a PT_MOVETO if necessary */
856 if(pPath->newStroke)
858 pPath->newStroke=FALSE;
859 pt.x = dc->w.CursPosX;
860 pt.y = dc->w.CursPosY;
861 if(!LPtoDP(dc->hSelf, &pt, 1))
862 return FALSE;
863 if(!PATH_AddEntry(pPath, &pt, PT_MOVETO))
864 return FALSE;
867 for(i = 0; i < cbPoints; i++) {
868 pt = pts[i];
869 if(!LPtoDP(dc->hSelf, &pt, 1))
870 return FALSE;
871 PATH_AddEntry(pPath, &pt, PT_BEZIERTO);
873 return TRUE;
876 BOOL PATH_PolyBezier(DC *dc, const POINT *pts, DWORD cbPoints)
878 GdiPath *pPath = &dc->w.path;
879 POINT pt;
880 INT i;
882 /* Check that path is open */
883 if(pPath->state!=PATH_Open)
884 return FALSE;
886 for(i = 0; i < cbPoints; i++) {
887 pt = pts[i];
888 if(!LPtoDP(dc->hSelf, &pt, 1))
889 return FALSE;
890 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO : PT_BEZIERTO);
892 return TRUE;
895 BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints)
897 GdiPath *pPath = &dc->w.path;
898 POINT pt;
899 INT i;
901 /* Check that path is open */
902 if(pPath->state!=PATH_Open)
903 return FALSE;
905 for(i = 0; i < cbPoints; i++) {
906 pt = pts[i];
907 if(!LPtoDP(dc->hSelf, &pt, 1))
908 return FALSE;
909 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO : PT_LINETO);
911 return TRUE;
914 BOOL PATH_PolylineTo(DC *dc, const POINT *pts, DWORD cbPoints)
916 GdiPath *pPath = &dc->w.path;
917 POINT pt;
918 INT i;
920 /* Check that path is open */
921 if(pPath->state!=PATH_Open)
922 return FALSE;
924 /* Add a PT_MOVETO if necessary */
925 if(pPath->newStroke)
927 pPath->newStroke=FALSE;
928 pt.x = dc->w.CursPosX;
929 pt.y = dc->w.CursPosY;
930 if(!LPtoDP(dc->hSelf, &pt, 1))
931 return FALSE;
932 if(!PATH_AddEntry(pPath, &pt, PT_MOVETO))
933 return FALSE;
936 for(i = 0; i < cbPoints; i++) {
937 pt = pts[i];
938 if(!LPtoDP(dc->hSelf, &pt, 1))
939 return FALSE;
940 PATH_AddEntry(pPath, &pt, PT_LINETO);
943 return TRUE;
947 BOOL PATH_Polygon(DC *dc, const POINT *pts, DWORD cbPoints)
949 GdiPath *pPath = &dc->w.path;
950 POINT pt;
951 INT i;
953 /* Check that path is open */
954 if(pPath->state!=PATH_Open)
955 return FALSE;
957 for(i = 0; i < cbPoints; i++) {
958 pt = pts[i];
959 if(!LPtoDP(dc->hSelf, &pt, 1))
960 return FALSE;
961 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO :
962 ((i == cbPoints-1) ? PT_LINETO | PT_CLOSEFIGURE :
963 PT_LINETO));
965 return TRUE;
968 BOOL PATH_PolyPolygon( DC *dc, const POINT* pts, const INT* counts,
969 UINT polygons )
971 GdiPath *pPath = &dc->w.path;
972 POINT pt, startpt;
973 INT poly, point, i;
975 /* Check that path is open */
976 if(pPath->state!=PATH_Open)
977 return FALSE;
979 for(i = 0, poly = 0; poly < polygons; poly++) {
980 for(point = 0; point < counts[poly]; point++, i++) {
981 pt = pts[i];
982 if(!LPtoDP(dc->hSelf, &pt, 1))
983 return FALSE;
984 if(point == 0) startpt = pt;
985 PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
987 /* win98 adds an extra line to close the figure for some reason */
988 PATH_AddEntry(pPath, &startpt, PT_LINETO | PT_CLOSEFIGURE);
990 return TRUE;
993 BOOL PATH_PolyPolyline( DC *dc, const POINT* pts, const DWORD* counts,
994 DWORD polylines )
996 GdiPath *pPath = &dc->w.path;
997 POINT pt;
998 INT poly, point, i;
1000 /* Check that path is open */
1001 if(pPath->state!=PATH_Open)
1002 return FALSE;
1004 for(i = 0, poly = 0; poly < polylines; poly++) {
1005 for(point = 0; point < counts[poly]; point++, i++) {
1006 pt = pts[i];
1007 if(!LPtoDP(dc->hSelf, &pt, 1))
1008 return FALSE;
1009 PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1012 return TRUE;
1015 /***********************************************************************
1016 * Internal functions
1020 /* PATH_AddFlatBezier
1023 static BOOL PATH_AddFlatBezier(GdiPath *pPath, POINT *pt, BOOL closed)
1025 POINT *pts;
1026 INT no, i;
1028 pts = GDI_Bezier( pt, 4, &no );
1029 if(!pts) return FALSE;
1031 for(i = 1; i < no; i++)
1032 PATH_AddEntry(pPath, &pts[i],
1033 (i == no-1 && closed) ? PT_LINETO | PT_CLOSEFIGURE : PT_LINETO);
1034 HeapFree( GetProcessHeap(), 0, pts );
1035 return TRUE;
1038 /* PATH_FlattenPath
1040 * Replaces Beziers with line segments
1043 static BOOL PATH_FlattenPath(GdiPath *pPath)
1045 GdiPath newPath;
1046 INT srcpt;
1048 memset(&newPath, 0, sizeof(newPath));
1049 newPath.state = PATH_Open;
1050 for(srcpt = 0; srcpt < pPath->numEntriesUsed; srcpt++) {
1051 switch(pPath->pFlags[srcpt] & ~PT_CLOSEFIGURE) {
1052 case PT_MOVETO:
1053 case PT_LINETO:
1054 PATH_AddEntry(&newPath, &pPath->pPoints[srcpt],
1055 pPath->pFlags[srcpt]);
1056 break;
1057 case PT_BEZIERTO:
1058 PATH_AddFlatBezier(&newPath, &pPath->pPoints[srcpt-1],
1059 pPath->pFlags[srcpt+2] & PT_CLOSEFIGURE);
1060 srcpt += 2;
1061 break;
1064 newPath.state = PATH_Closed;
1065 PATH_AssignGdiPath(pPath, &newPath);
1066 PATH_EmptyPath(&newPath);
1067 return TRUE;
1070 /* PATH_PathToRegion
1072 * Creates a region from the specified path using the specified polygon
1073 * filling mode. The path is left unchanged. A handle to the region that
1074 * was created is stored in *pHrgn. If successful, TRUE is returned; if an
1075 * error occurs, SetLastError is called with the appropriate value and
1076 * FALSE is returned.
1078 static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
1079 HRGN *pHrgn)
1081 int numStrokes, iStroke, i;
1082 INT *pNumPointsInStroke;
1083 HRGN hrgn;
1085 assert(pPath!=NULL);
1086 assert(pHrgn!=NULL);
1088 PATH_FlattenPath(pPath);
1090 /* FIXME: What happens when number of points is zero? */
1092 /* First pass: Find out how many strokes there are in the path */
1093 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
1094 numStrokes=0;
1095 for(i=0; i<pPath->numEntriesUsed; i++)
1096 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
1097 numStrokes++;
1099 /* Allocate memory for number-of-points-in-stroke array */
1100 pNumPointsInStroke=(int *)HeapAlloc( GetProcessHeap(), 0,
1101 sizeof(int) * numStrokes );
1102 if(!pNumPointsInStroke)
1104 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1105 return FALSE;
1108 /* Second pass: remember number of points in each polygon */
1109 iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
1110 for(i=0; i<pPath->numEntriesUsed; i++)
1112 /* Is this the beginning of a new stroke? */
1113 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
1115 iStroke++;
1116 pNumPointsInStroke[iStroke]=0;
1119 pNumPointsInStroke[iStroke]++;
1122 /* Create a region from the strokes */
1123 hrgn=CreatePolyPolygonRgn(pPath->pPoints, pNumPointsInStroke,
1124 numStrokes, nPolyFillMode);
1125 if(hrgn==(HRGN)0)
1127 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1128 return FALSE;
1131 /* Free memory for number-of-points-in-stroke array */
1132 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
1134 /* Success! */
1135 *pHrgn=hrgn;
1136 return TRUE;
1139 /* PATH_EmptyPath
1141 * Removes all entries from the path and sets the path state to PATH_Null.
1143 static void PATH_EmptyPath(GdiPath *pPath)
1145 assert(pPath!=NULL);
1147 pPath->state=PATH_Null;
1148 pPath->numEntriesUsed=0;
1151 /* PATH_AddEntry
1153 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
1154 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
1155 * successful, FALSE otherwise (e.g. if not enough memory was available).
1157 BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint, BYTE flags)
1159 assert(pPath!=NULL);
1161 /* FIXME: If newStroke is true, perhaps we want to check that we're
1162 * getting a PT_MOVETO
1164 TRACE("(%ld,%ld) - %d\n", pPoint->x, pPoint->y, flags);
1166 /* Check that path is open */
1167 if(pPath->state!=PATH_Open)
1168 return FALSE;
1170 /* Reserve enough memory for an extra path entry */
1171 if(!PATH_ReserveEntries(pPath, pPath->numEntriesUsed+1))
1172 return FALSE;
1174 /* Store information in path entry */
1175 pPath->pPoints[pPath->numEntriesUsed]=*pPoint;
1176 pPath->pFlags[pPath->numEntriesUsed]=flags;
1178 /* If this is PT_CLOSEFIGURE, we have to start a new stroke next time */
1179 if((flags & PT_CLOSEFIGURE) == PT_CLOSEFIGURE)
1180 pPath->newStroke=TRUE;
1182 /* Increment entry count */
1183 pPath->numEntriesUsed++;
1185 return TRUE;
1188 /* PATH_ReserveEntries
1190 * Ensures that at least "numEntries" entries (for points and flags) have
1191 * been allocated; allocates larger arrays and copies the existing entries
1192 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
1194 static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries)
1196 INT numEntriesToAllocate;
1197 POINT *pPointsNew;
1198 BYTE *pFlagsNew;
1200 assert(pPath!=NULL);
1201 assert(numEntries>=0);
1203 /* Do we have to allocate more memory? */
1204 if(numEntries > pPath->numEntriesAllocated)
1206 /* Find number of entries to allocate. We let the size of the array
1207 * grow exponentially, since that will guarantee linear time
1208 * complexity. */
1209 if(pPath->numEntriesAllocated)
1211 numEntriesToAllocate=pPath->numEntriesAllocated;
1212 while(numEntriesToAllocate<numEntries)
1213 numEntriesToAllocate=numEntriesToAllocate*GROW_FACTOR_NUMER/
1214 GROW_FACTOR_DENOM;
1216 else
1217 numEntriesToAllocate=numEntries;
1219 /* Allocate new arrays */
1220 pPointsNew=(POINT *)HeapAlloc( GetProcessHeap(), 0,
1221 numEntriesToAllocate * sizeof(POINT) );
1222 if(!pPointsNew)
1223 return FALSE;
1224 pFlagsNew=(BYTE *)HeapAlloc( GetProcessHeap(), 0,
1225 numEntriesToAllocate * sizeof(BYTE) );
1226 if(!pFlagsNew)
1228 HeapFree( GetProcessHeap(), 0, pPointsNew );
1229 return FALSE;
1232 /* Copy old arrays to new arrays and discard old arrays */
1233 if(pPath->pPoints)
1235 assert(pPath->pFlags);
1237 memcpy(pPointsNew, pPath->pPoints,
1238 sizeof(POINT)*pPath->numEntriesUsed);
1239 memcpy(pFlagsNew, pPath->pFlags,
1240 sizeof(BYTE)*pPath->numEntriesUsed);
1242 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
1243 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
1245 pPath->pPoints=pPointsNew;
1246 pPath->pFlags=pFlagsNew;
1247 pPath->numEntriesAllocated=numEntriesToAllocate;
1250 return TRUE;
1253 /* PATH_DoArcPart
1255 * Creates a Bezier spline that corresponds to part of an arc and appends the
1256 * corresponding points to the path. The start and end angles are passed in
1257 * "angleStart" and "angleEnd"; these angles should span a quarter circle
1258 * at most. If "addMoveTo" is true, a PT_MOVETO entry for the first control
1259 * point is added to the path; otherwise, it is assumed that the current
1260 * position is equal to the first control point.
1262 static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
1263 double angleStart, double angleEnd, BOOL addMoveTo)
1265 double halfAngle, a;
1266 double xNorm[4], yNorm[4];
1267 POINT point;
1268 int i;
1270 assert(fabs(angleEnd-angleStart)<=M_PI_2);
1272 /* FIXME: Is there an easier way of computing this? */
1274 /* Compute control points */
1275 halfAngle=(angleEnd-angleStart)/2.0;
1276 if(fabs(halfAngle)>1e-8)
1278 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
1279 xNorm[0]=cos(angleStart);
1280 yNorm[0]=sin(angleStart);
1281 xNorm[1]=xNorm[0] - a*yNorm[0];
1282 yNorm[1]=yNorm[0] + a*xNorm[0];
1283 xNorm[3]=cos(angleEnd);
1284 yNorm[3]=sin(angleEnd);
1285 xNorm[2]=xNorm[3] + a*yNorm[3];
1286 yNorm[2]=yNorm[3] - a*xNorm[3];
1288 else
1289 for(i=0; i<4; i++)
1291 xNorm[i]=cos(angleStart);
1292 yNorm[i]=sin(angleStart);
1295 /* Add starting point to path if desired */
1296 if(addMoveTo)
1298 PATH_ScaleNormalizedPoint(corners, xNorm[0], yNorm[0], &point);
1299 if(!PATH_AddEntry(pPath, &point, PT_MOVETO))
1300 return FALSE;
1303 /* Add remaining control points */
1304 for(i=1; i<4; i++)
1306 PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &point);
1307 if(!PATH_AddEntry(pPath, &point, PT_BEZIERTO))
1308 return FALSE;
1311 return TRUE;
1314 /* PATH_ScaleNormalizedPoint
1316 * Scales a normalized point (x, y) with respect to the box whose corners are
1317 * passed in "corners". The point is stored in "*pPoint". The normalized
1318 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
1319 * (1.0, 1.0) correspond to corners[1].
1321 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
1322 double y, POINT *pPoint)
1324 pPoint->x=GDI_ROUND( (double)corners[0].x +
1325 (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
1326 pPoint->y=GDI_ROUND( (double)corners[0].y +
1327 (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
1330 /* PATH_NormalizePoint
1332 * Normalizes a point with respect to the box whose corners are passed in
1333 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
1335 static void PATH_NormalizePoint(FLOAT_POINT corners[],
1336 const FLOAT_POINT *pPoint,
1337 double *pX, double *pY)
1339 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) *
1340 2.0 - 1.0;
1341 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) *
1342 2.0 - 1.0;
1345 /*******************************************************************
1346 * FlattenPath16 [GDI.516]
1350 BOOL16 WINAPI FlattenPath16(HDC16 hdc)
1352 return (BOOL16) FlattenPath((HDC) hdc);
1355 /*******************************************************************
1356 * FlattenPath [GDI32.103]
1360 BOOL WINAPI FlattenPath(HDC hdc)
1362 BOOL ret = FALSE;
1363 DC *dc = DC_GetDCPtr( hdc );
1365 if(!dc) return FALSE;
1367 if(dc->funcs->pFlattenPath) ret = dc->funcs->pFlattenPath(dc);
1368 else
1370 GdiPath *pPath = &dc->w.path;
1371 if(pPath->state != PATH_Closed)
1372 ret = PATH_FlattenPath(pPath);
1374 GDI_ReleaseObj( hdc );
1375 return ret;
1379 static BOOL PATH_StrokePath(DC *dc, GdiPath *pPath)
1381 INT i;
1382 POINT ptLastMove = {0,0};
1384 if(dc->funcs->pStrokePath)
1385 return dc->funcs->pStrokePath(dc);
1387 if(pPath->state != PATH_Closed)
1388 return FALSE;
1390 SaveDC(dc->hSelf);
1391 SetMapMode(dc->hSelf, MM_TEXT);
1392 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
1393 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
1394 for(i = 0; i < pPath->numEntriesUsed; i++) {
1395 switch(pPath->pFlags[i]) {
1396 case PT_MOVETO:
1397 TRACE("Got PT_MOVETO (%ld, %ld)\n",
1398 pPath->pPoints[i].x, pPath->pPoints[i].y);
1399 MoveToEx(dc->hSelf, pPath->pPoints[i].x, pPath->pPoints[i].y, NULL);
1400 ptLastMove = pPath->pPoints[i];
1401 break;
1402 case PT_LINETO:
1403 case (PT_LINETO | PT_CLOSEFIGURE):
1404 TRACE("Got PT_LINETO (%ld, %ld)\n",
1405 pPath->pPoints[i].x, pPath->pPoints[i].y);
1406 LineTo(dc->hSelf, pPath->pPoints[i].x, pPath->pPoints[i].y);
1407 break;
1408 case PT_BEZIERTO:
1409 TRACE("Got PT_BEZIERTO\n");
1410 if(pPath->pFlags[i+1] != PT_BEZIERTO ||
1411 (pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
1412 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
1413 return FALSE;
1415 PolyBezierTo(dc->hSelf, &pPath->pPoints[i], 3);
1416 i += 2;
1417 break;
1418 default:
1419 ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
1420 return FALSE;
1422 if(pPath->pFlags[i] & PT_CLOSEFIGURE)
1423 LineTo(dc->hSelf, ptLastMove.x, ptLastMove.y);
1425 RestoreDC(dc->hSelf , -1);
1426 return TRUE;
1430 /*******************************************************************
1431 * StrokeAndFillPath16 [GDI.520]
1435 BOOL16 WINAPI StrokeAndFillPath16(HDC16 hdc)
1437 return (BOOL16) StrokeAndFillPath((HDC) hdc);
1440 /*******************************************************************
1441 * StrokeAndFillPath [GDI32.352]
1445 BOOL WINAPI StrokeAndFillPath(HDC hdc)
1447 DC *dc = DC_GetDCPtr( hdc );
1448 BOOL bRet = FALSE;
1450 if(!dc) return FALSE;
1452 if(dc->funcs->pStrokeAndFillPath)
1453 bRet = dc->funcs->pStrokeAndFillPath(dc);
1454 else
1456 bRet = PATH_FillPath(dc, &dc->w.path);
1457 if(bRet) bRet = PATH_StrokePath(dc, &dc->w.path);
1458 if(bRet) PATH_EmptyPath(&dc->w.path);
1460 GDI_ReleaseObj( hdc );
1461 return bRet;
1464 /*******************************************************************
1465 * StrokePath16 [GDI.521]
1469 BOOL16 WINAPI StrokePath16(HDC16 hdc)
1471 return (BOOL16) StrokePath((HDC) hdc);
1474 /*******************************************************************
1475 * StrokePath [GDI32.353]
1479 BOOL WINAPI StrokePath(HDC hdc)
1481 DC *dc = DC_GetDCPtr( hdc );
1482 GdiPath *pPath;
1483 BOOL bRet = FALSE;
1485 TRACE("(%08x)\n", hdc);
1486 if(!dc) return FALSE;
1488 if(dc->funcs->pStrokePath)
1489 bRet = dc->funcs->pStrokePath(dc);
1490 else
1492 pPath = &dc->w.path;
1493 bRet = PATH_StrokePath(dc, pPath);
1494 PATH_EmptyPath(pPath);
1496 GDI_ReleaseObj( hdc );
1497 return bRet;
1500 /*******************************************************************
1501 * WidenPath16 [GDI.522]
1505 BOOL16 WINAPI WidenPath16(HDC16 hdc)
1507 return (BOOL16) WidenPath((HDC) hdc);
1510 /*******************************************************************
1511 * WidenPath [GDI32.360]
1515 BOOL WINAPI WidenPath(HDC hdc)
1517 DC *dc = DC_GetDCPtr( hdc );
1518 BOOL ret = FALSE;
1520 if(!dc) return FALSE;
1522 if(dc->funcs->pWidenPath)
1523 ret = dc->funcs->pWidenPath(dc);
1525 FIXME("stub\n");
1526 GDI_ReleaseObj( hdc );
1527 return ret;