mshtml: Added DIID_DispHTMLDocument to QueryInterface.
[wine/testsucceed.git] / dlls / gdi32 / path.c
blobaf756b3d7074a85b1cf83cacaaa80ade577b8d0b
1 /*
2 * Graphics paths (BeginPath, EndPath etc.)
4 * Copyright 1997, 1998 Martin Boehme
5 * 1999 Huw D M Davies
6 * Copyright 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <assert.h>
27 #include <math.h>
28 #include <stdarg.h>
29 #include <string.h>
30 #include <stdlib.h>
31 #if defined(HAVE_FLOAT_H)
32 #include <float.h>
33 #endif
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wingdi.h"
38 #include "winerror.h"
40 #include "gdi_private.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
45 /* Notes on the implementation
47 * The implementation is based on dynamically resizable arrays of points and
48 * flags. I dithered for a bit before deciding on this implementation, and
49 * I had even done a bit of work on a linked list version before switching
50 * to arrays. It's a bit of a tradeoff. When you use linked lists, the
51 * implementation of FlattenPath is easier, because you can rip the
52 * PT_BEZIERTO entries out of the middle of the list and link the
53 * corresponding PT_LINETO entries in. However, when you use arrays,
54 * PathToRegion becomes easier, since you can essentially just pass your array
55 * of points to CreatePolyPolygonRgn. Also, if I'd used linked lists, I would
56 * have had the extra effort of creating a chunk-based allocation scheme
57 * in order to use memory effectively. That's why I finally decided to use
58 * arrays. Note by the way that the array based implementation has the same
59 * linear time complexity that linked lists would have since the arrays grow
60 * exponentially.
62 * The points are stored in the path in device coordinates. This is
63 * consistent with the way Windows does things (for instance, see the Win32
64 * SDK documentation for GetPath).
66 * The word "stroke" appears in several places (e.g. in the flag
67 * GdiPath.newStroke). A stroke consists of a PT_MOVETO followed by one or
68 * more PT_LINETOs or PT_BEZIERTOs, up to, but not including, the next
69 * PT_MOVETO. Note that this is not the same as the definition of a figure;
70 * a figure can contain several strokes.
72 * I modified the drawing functions (MoveTo, LineTo etc.) to test whether
73 * the path is open and to call the corresponding function in path.c if this
74 * is the case. A more elegant approach would be to modify the function
75 * pointers in the DC_FUNCTIONS structure; however, this would be a lot more
76 * complex. Also, the performance degradation caused by my approach in the
77 * case where no path is open is so small that it cannot be measured.
79 * Martin Boehme
82 /* FIXME: A lot of stuff isn't implemented yet. There is much more to come. */
84 #define NUM_ENTRIES_INITIAL 16 /* Initial size of points / flags arrays */
85 #define GROW_FACTOR_NUMER 2 /* Numerator of grow factor for the array */
86 #define GROW_FACTOR_DENOM 1 /* Denominator of grow factor */
88 /* A floating point version of the POINT structure */
89 typedef struct tagFLOAT_POINT
91 FLOAT x, y;
92 } FLOAT_POINT;
95 static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
96 HRGN *pHrgn);
97 static void PATH_EmptyPath(GdiPath *pPath);
98 static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries);
99 static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
100 double angleStart, double angleEnd, BOOL addMoveTo);
101 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
102 double y, POINT *pPoint);
103 static void PATH_NormalizePoint(FLOAT_POINT corners[], const FLOAT_POINT
104 *pPoint, double *pX, double *pY);
105 static BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2);
107 /* Performs a world-to-viewport transformation on the specified point (which
108 * is in floating point format).
110 static inline void INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
112 FLOAT x, y;
114 /* Perform the transformation */
115 x = point->x;
116 y = point->y;
117 point->x = x * dc->xformWorld2Vport.eM11 +
118 y * dc->xformWorld2Vport.eM21 +
119 dc->xformWorld2Vport.eDx;
120 point->y = x * dc->xformWorld2Vport.eM12 +
121 y * dc->xformWorld2Vport.eM22 +
122 dc->xformWorld2Vport.eDy;
126 /***********************************************************************
127 * BeginPath (GDI32.@)
129 BOOL WINAPI BeginPath(HDC hdc)
131 BOOL ret = TRUE;
132 DC *dc = DC_GetDCPtr( hdc );
134 if(!dc) return FALSE;
136 if(dc->funcs->pBeginPath)
137 ret = dc->funcs->pBeginPath(dc->physDev);
138 else
140 /* If path is already open, do nothing */
141 if(dc->path.state != PATH_Open)
143 /* Make sure that path is empty */
144 PATH_EmptyPath(&dc->path);
146 /* Initialize variables for new path */
147 dc->path.newStroke=TRUE;
148 dc->path.state=PATH_Open;
151 GDI_ReleaseObj( hdc );
152 return ret;
156 /***********************************************************************
157 * EndPath (GDI32.@)
159 BOOL WINAPI EndPath(HDC hdc)
161 BOOL ret = TRUE;
162 DC *dc = DC_GetDCPtr( hdc );
164 if(!dc) return FALSE;
166 if(dc->funcs->pEndPath)
167 ret = dc->funcs->pEndPath(dc->physDev);
168 else
170 /* Check that path is currently being constructed */
171 if(dc->path.state!=PATH_Open)
173 SetLastError(ERROR_CAN_NOT_COMPLETE);
174 ret = FALSE;
176 /* Set flag to indicate that path is finished */
177 else dc->path.state=PATH_Closed;
179 GDI_ReleaseObj( hdc );
180 return ret;
184 /******************************************************************************
185 * AbortPath [GDI32.@]
186 * Closes and discards paths from device context
188 * NOTES
189 * Check that SetLastError is being called correctly
191 * PARAMS
192 * hdc [I] Handle to device context
194 * RETURNS
195 * Success: TRUE
196 * Failure: FALSE
198 BOOL WINAPI AbortPath( HDC hdc )
200 BOOL ret = TRUE;
201 DC *dc = DC_GetDCPtr( hdc );
203 if(!dc) return FALSE;
205 if(dc->funcs->pAbortPath)
206 ret = dc->funcs->pAbortPath(dc->physDev);
207 else /* Remove all entries from the path */
208 PATH_EmptyPath( &dc->path );
209 GDI_ReleaseObj( hdc );
210 return ret;
214 /***********************************************************************
215 * CloseFigure (GDI32.@)
217 * FIXME: Check that SetLastError is being called correctly
219 BOOL WINAPI CloseFigure(HDC hdc)
221 BOOL ret = TRUE;
222 DC *dc = DC_GetDCPtr( hdc );
224 if(!dc) return FALSE;
226 if(dc->funcs->pCloseFigure)
227 ret = dc->funcs->pCloseFigure(dc->physDev);
228 else
230 /* Check that path is open */
231 if(dc->path.state!=PATH_Open)
233 SetLastError(ERROR_CAN_NOT_COMPLETE);
234 ret = FALSE;
236 else
238 /* FIXME: Shouldn't we draw a line to the beginning of the
239 figure? */
240 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
241 if(dc->path.numEntriesUsed)
243 dc->path.pFlags[dc->path.numEntriesUsed-1]|=PT_CLOSEFIGURE;
244 dc->path.newStroke=TRUE;
248 GDI_ReleaseObj( hdc );
249 return ret;
253 /***********************************************************************
254 * GetPath (GDI32.@)
256 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes,
257 INT nSize)
259 INT ret = -1;
260 GdiPath *pPath;
261 DC *dc = DC_GetDCPtr( hdc );
263 if(!dc) return -1;
265 pPath = &dc->path;
267 /* Check that path is closed */
268 if(pPath->state!=PATH_Closed)
270 SetLastError(ERROR_CAN_NOT_COMPLETE);
271 goto done;
274 if(nSize==0)
275 ret = pPath->numEntriesUsed;
276 else if(nSize<pPath->numEntriesUsed)
278 SetLastError(ERROR_INVALID_PARAMETER);
279 goto done;
281 else
283 memcpy(pPoints, pPath->pPoints, sizeof(POINT)*pPath->numEntriesUsed);
284 memcpy(pTypes, pPath->pFlags, sizeof(BYTE)*pPath->numEntriesUsed);
286 /* Convert the points to logical coordinates */
287 if(!DPtoLP(hdc, pPoints, pPath->numEntriesUsed))
289 /* FIXME: Is this the correct value? */
290 SetLastError(ERROR_CAN_NOT_COMPLETE);
291 goto done;
293 else ret = pPath->numEntriesUsed;
295 done:
296 GDI_ReleaseObj( hdc );
297 return ret;
301 /***********************************************************************
302 * PathToRegion (GDI32.@)
304 * FIXME
305 * Check that SetLastError is being called correctly
307 * The documentation does not state this explicitly, but a test under Windows
308 * shows that the region which is returned should be in device coordinates.
310 HRGN WINAPI PathToRegion(HDC hdc)
312 GdiPath *pPath;
313 HRGN hrgnRval = 0;
314 DC *dc = DC_GetDCPtr( hdc );
316 /* Get pointer to path */
317 if(!dc) return 0;
319 pPath = &dc->path;
321 /* Check that path is closed */
322 if(pPath->state!=PATH_Closed) SetLastError(ERROR_CAN_NOT_COMPLETE);
323 else
325 /* FIXME: Should we empty the path even if conversion failed? */
326 if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnRval))
327 PATH_EmptyPath(pPath);
328 else
329 hrgnRval=0;
331 GDI_ReleaseObj( hdc );
332 return hrgnRval;
335 static BOOL PATH_FillPath(DC *dc, GdiPath *pPath)
337 INT mapMode, graphicsMode;
338 SIZE ptViewportExt, ptWindowExt;
339 POINT ptViewportOrg, ptWindowOrg;
340 XFORM xform;
341 HRGN hrgn;
343 if(dc->funcs->pFillPath)
344 return dc->funcs->pFillPath(dc->physDev);
346 /* Check that path is closed */
347 if(pPath->state!=PATH_Closed)
349 SetLastError(ERROR_CAN_NOT_COMPLETE);
350 return FALSE;
353 /* Construct a region from the path and fill it */
354 if(PATH_PathToRegion(pPath, dc->polyFillMode, &hrgn))
356 /* Since PaintRgn interprets the region as being in logical coordinates
357 * but the points we store for the path are already in device
358 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
359 * Using SaveDC to save information about the mapping mode / world
360 * transform would be easier but would require more overhead, especially
361 * now that SaveDC saves the current path.
364 /* Save the information about the old mapping mode */
365 mapMode=GetMapMode(dc->hSelf);
366 GetViewportExtEx(dc->hSelf, &ptViewportExt);
367 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
368 GetWindowExtEx(dc->hSelf, &ptWindowExt);
369 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
371 /* Save world transform
372 * NB: The Windows documentation on world transforms would lead one to
373 * believe that this has to be done only in GM_ADVANCED; however, my
374 * tests show that resetting the graphics mode to GM_COMPATIBLE does
375 * not reset the world transform.
377 GetWorldTransform(dc->hSelf, &xform);
379 /* Set MM_TEXT */
380 SetMapMode(dc->hSelf, MM_TEXT);
381 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
382 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
383 graphicsMode=GetGraphicsMode(dc->hSelf);
384 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
385 ModifyWorldTransform(dc->hSelf, &xform, MWT_IDENTITY);
386 SetGraphicsMode(dc->hSelf, graphicsMode);
388 /* Paint the region */
389 PaintRgn(dc->hSelf, hrgn);
390 DeleteObject(hrgn);
391 /* Restore the old mapping mode */
392 SetMapMode(dc->hSelf, mapMode);
393 SetViewportExtEx(dc->hSelf, ptViewportExt.cx, ptViewportExt.cy, NULL);
394 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
395 SetWindowExtEx(dc->hSelf, ptWindowExt.cx, ptWindowExt.cy, NULL);
396 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
398 /* Go to GM_ADVANCED temporarily to restore the world transform */
399 graphicsMode=GetGraphicsMode(dc->hSelf);
400 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
401 SetWorldTransform(dc->hSelf, &xform);
402 SetGraphicsMode(dc->hSelf, graphicsMode);
403 return TRUE;
405 return FALSE;
409 /***********************************************************************
410 * FillPath (GDI32.@)
412 * FIXME
413 * Check that SetLastError is being called correctly
415 BOOL WINAPI FillPath(HDC hdc)
417 DC *dc = DC_GetDCPtr( hdc );
418 BOOL bRet = FALSE;
420 if(!dc) return FALSE;
422 if(dc->funcs->pFillPath)
423 bRet = dc->funcs->pFillPath(dc->physDev);
424 else
426 bRet = PATH_FillPath(dc, &dc->path);
427 if(bRet)
429 /* FIXME: Should the path be emptied even if conversion
430 failed? */
431 PATH_EmptyPath(&dc->path);
434 GDI_ReleaseObj( hdc );
435 return bRet;
439 /***********************************************************************
440 * SelectClipPath (GDI32.@)
441 * FIXME
442 * Check that SetLastError is being called correctly
444 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
446 GdiPath *pPath;
447 HRGN hrgnPath;
448 BOOL success = FALSE;
449 DC *dc = DC_GetDCPtr( hdc );
451 if(!dc) return FALSE;
453 if(dc->funcs->pSelectClipPath)
454 success = dc->funcs->pSelectClipPath(dc->physDev, iMode);
455 else
457 pPath = &dc->path;
459 /* Check that path is closed */
460 if(pPath->state!=PATH_Closed)
461 SetLastError(ERROR_CAN_NOT_COMPLETE);
462 /* Construct a region from the path */
463 else if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnPath))
465 success = ExtSelectClipRgn( hdc, hrgnPath, iMode ) != ERROR;
466 DeleteObject(hrgnPath);
468 /* Empty the path */
469 if(success)
470 PATH_EmptyPath(pPath);
471 /* FIXME: Should this function delete the path even if it failed? */
474 GDI_ReleaseObj( hdc );
475 return success;
479 /***********************************************************************
480 * Exported functions
483 /* PATH_InitGdiPath
485 * Initializes the GdiPath structure.
487 void PATH_InitGdiPath(GdiPath *pPath)
489 assert(pPath!=NULL);
491 pPath->state=PATH_Null;
492 pPath->pPoints=NULL;
493 pPath->pFlags=NULL;
494 pPath->numEntriesUsed=0;
495 pPath->numEntriesAllocated=0;
498 /* PATH_DestroyGdiPath
500 * Destroys a GdiPath structure (frees the memory in the arrays).
502 void PATH_DestroyGdiPath(GdiPath *pPath)
504 assert(pPath!=NULL);
506 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
507 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
510 /* PATH_AssignGdiPath
512 * Copies the GdiPath structure "pPathSrc" to "pPathDest". A deep copy is
513 * performed, i.e. the contents of the pPoints and pFlags arrays are copied,
514 * not just the pointers. Since this means that the arrays in pPathDest may
515 * need to be resized, pPathDest should have been initialized using
516 * PATH_InitGdiPath (in C++, this function would be an assignment operator,
517 * not a copy constructor).
518 * Returns TRUE if successful, else FALSE.
520 BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc)
522 assert(pPathDest!=NULL && pPathSrc!=NULL);
524 /* Make sure destination arrays are big enough */
525 if(!PATH_ReserveEntries(pPathDest, pPathSrc->numEntriesUsed))
526 return FALSE;
528 /* Perform the copy operation */
529 memcpy(pPathDest->pPoints, pPathSrc->pPoints,
530 sizeof(POINT)*pPathSrc->numEntriesUsed);
531 memcpy(pPathDest->pFlags, pPathSrc->pFlags,
532 sizeof(BYTE)*pPathSrc->numEntriesUsed);
534 pPathDest->state=pPathSrc->state;
535 pPathDest->numEntriesUsed=pPathSrc->numEntriesUsed;
536 pPathDest->newStroke=pPathSrc->newStroke;
538 return TRUE;
541 /* PATH_MoveTo
543 * Should be called when a MoveTo is performed on a DC that has an
544 * open path. This starts a new stroke. Returns TRUE if successful, else
545 * FALSE.
547 BOOL PATH_MoveTo(DC *dc)
549 GdiPath *pPath = &dc->path;
551 /* Check that path is open */
552 if(pPath->state!=PATH_Open)
553 /* FIXME: Do we have to call SetLastError? */
554 return FALSE;
556 /* Start a new stroke */
557 pPath->newStroke=TRUE;
559 return TRUE;
562 /* PATH_LineTo
564 * Should be called when a LineTo is performed on a DC that has an
565 * open path. This adds a PT_LINETO entry to the path (and possibly
566 * a PT_MOVETO entry, if this is the first LineTo in a stroke).
567 * Returns TRUE if successful, else FALSE.
569 BOOL PATH_LineTo(DC *dc, INT x, INT y)
571 GdiPath *pPath = &dc->path;
572 POINT point, pointCurPos;
574 /* Check that path is open */
575 if(pPath->state!=PATH_Open)
576 return FALSE;
578 /* Convert point to device coordinates */
579 point.x=x;
580 point.y=y;
581 if(!LPtoDP(dc->hSelf, &point, 1))
582 return FALSE;
584 /* Add a PT_MOVETO if necessary */
585 if(pPath->newStroke)
587 pPath->newStroke=FALSE;
588 pointCurPos.x = dc->CursPosX;
589 pointCurPos.y = dc->CursPosY;
590 if(!LPtoDP(dc->hSelf, &pointCurPos, 1))
591 return FALSE;
592 if(!PATH_AddEntry(pPath, &pointCurPos, PT_MOVETO))
593 return FALSE;
596 /* Add a PT_LINETO entry */
597 return PATH_AddEntry(pPath, &point, PT_LINETO);
600 /* PATH_RoundRect
602 * Should be called when a call to RoundRect is performed on a DC that has
603 * an open path. Returns TRUE if successful, else FALSE.
605 * FIXME: it adds the same entries to the path as windows does, but there
606 * is an error in the bezier drawing code so that there are small pixel-size
607 * gaps when the resulting path is drawn by StrokePath()
609 BOOL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height)
611 GdiPath *pPath = &dc->path;
612 POINT corners[2], pointTemp;
613 FLOAT_POINT ellCorners[2];
615 /* Check that path is open */
616 if(pPath->state!=PATH_Open)
617 return FALSE;
619 if(!PATH_CheckCorners(dc,corners,x1,y1,x2,y2))
620 return FALSE;
622 /* Add points to the roundrect path */
623 ellCorners[0].x = corners[1].x-ell_width;
624 ellCorners[0].y = corners[0].y;
625 ellCorners[1].x = corners[1].x;
626 ellCorners[1].y = corners[0].y+ell_height;
627 if(!PATH_DoArcPart(pPath, ellCorners, 0, -M_PI_2, TRUE))
628 return FALSE;
629 pointTemp.x = corners[0].x+ell_width/2;
630 pointTemp.y = corners[0].y;
631 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
632 return FALSE;
633 ellCorners[0].x = corners[0].x;
634 ellCorners[1].x = corners[0].x+ell_width;
635 if(!PATH_DoArcPart(pPath, ellCorners, -M_PI_2, -M_PI, FALSE))
636 return FALSE;
637 pointTemp.x = corners[0].x;
638 pointTemp.y = corners[1].y-ell_height/2;
639 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
640 return FALSE;
641 ellCorners[0].y = corners[1].y-ell_height;
642 ellCorners[1].y = corners[1].y;
643 if(!PATH_DoArcPart(pPath, ellCorners, M_PI, M_PI_2, FALSE))
644 return FALSE;
645 pointTemp.x = corners[1].x-ell_width/2;
646 pointTemp.y = corners[1].y;
647 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
648 return FALSE;
649 ellCorners[0].x = corners[1].x-ell_width;
650 ellCorners[1].x = corners[1].x;
651 if(!PATH_DoArcPart(pPath, ellCorners, M_PI_2, 0, FALSE))
652 return FALSE;
654 /* Close the roundrect figure */
655 if(!CloseFigure(dc->hSelf))
656 return FALSE;
658 return TRUE;
661 /* PATH_Rectangle
663 * Should be called when a call to Rectangle is performed on a DC that has
664 * an open path. Returns TRUE if successful, else FALSE.
666 BOOL PATH_Rectangle(DC *dc, INT x1, INT y1, INT x2, INT y2)
668 GdiPath *pPath = &dc->path;
669 POINT corners[2], pointTemp;
671 /* Check that path is open */
672 if(pPath->state!=PATH_Open)
673 return FALSE;
675 if(!PATH_CheckCorners(dc,corners,x1,y1,x2,y2))
676 return FALSE;
678 /* Close any previous figure */
679 if(!CloseFigure(dc->hSelf))
681 /* The CloseFigure call shouldn't have failed */
682 assert(FALSE);
683 return FALSE;
686 /* Add four points to the path */
687 pointTemp.x=corners[1].x;
688 pointTemp.y=corners[0].y;
689 if(!PATH_AddEntry(pPath, &pointTemp, PT_MOVETO))
690 return FALSE;
691 if(!PATH_AddEntry(pPath, corners, PT_LINETO))
692 return FALSE;
693 pointTemp.x=corners[0].x;
694 pointTemp.y=corners[1].y;
695 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
696 return FALSE;
697 if(!PATH_AddEntry(pPath, corners+1, PT_LINETO))
698 return FALSE;
700 /* Close the rectangle figure */
701 if(!CloseFigure(dc->hSelf))
703 /* The CloseFigure call shouldn't have failed */
704 assert(FALSE);
705 return FALSE;
708 return TRUE;
711 /* PATH_Ellipse
713 * Should be called when a call to Ellipse is performed on a DC that has
714 * an open path. This adds four Bezier splines representing the ellipse
715 * to the path. Returns TRUE if successful, else FALSE.
717 BOOL PATH_Ellipse(DC *dc, INT x1, INT y1, INT x2, INT y2)
719 return( PATH_Arc(dc, x1, y1, x2, y2, x1, (y1+y2)/2, x1, (y1+y2)/2,0) &&
720 CloseFigure(dc->hSelf) );
723 /* PATH_Arc
725 * Should be called when a call to Arc is performed on a DC that has
726 * an open path. This adds up to five Bezier splines representing the arc
727 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
728 * and when 'lines' is 2, we add 2 extra lines to get a pie.
729 * Returns TRUE if successful, else FALSE.
731 BOOL PATH_Arc(DC *dc, INT x1, INT y1, INT x2, INT y2,
732 INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines)
734 GdiPath *pPath = &dc->path;
735 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
736 /* Initialize angleEndQuadrant to silence gcc's warning */
737 double x, y;
738 FLOAT_POINT corners[2], pointStart, pointEnd;
739 POINT centre;
740 BOOL start, end;
741 INT temp;
743 /* FIXME: This function should check for all possible error returns */
744 /* FIXME: Do we have to respect newStroke? */
746 /* Check that path is open */
747 if(pPath->state!=PATH_Open)
748 return FALSE;
750 /* Check for zero height / width */
751 /* FIXME: Only in GM_COMPATIBLE? */
752 if(x1==x2 || y1==y2)
753 return TRUE;
755 /* Convert points to device coordinates */
756 corners[0].x=(FLOAT)x1;
757 corners[0].y=(FLOAT)y1;
758 corners[1].x=(FLOAT)x2;
759 corners[1].y=(FLOAT)y2;
760 pointStart.x=(FLOAT)xStart;
761 pointStart.y=(FLOAT)yStart;
762 pointEnd.x=(FLOAT)xEnd;
763 pointEnd.y=(FLOAT)yEnd;
764 INTERNAL_LPTODP_FLOAT(dc, corners);
765 INTERNAL_LPTODP_FLOAT(dc, corners+1);
766 INTERNAL_LPTODP_FLOAT(dc, &pointStart);
767 INTERNAL_LPTODP_FLOAT(dc, &pointEnd);
769 /* Make sure first corner is top left and second corner is bottom right */
770 if(corners[0].x>corners[1].x)
772 temp=corners[0].x;
773 corners[0].x=corners[1].x;
774 corners[1].x=temp;
776 if(corners[0].y>corners[1].y)
778 temp=corners[0].y;
779 corners[0].y=corners[1].y;
780 corners[1].y=temp;
783 /* Compute start and end angle */
784 PATH_NormalizePoint(corners, &pointStart, &x, &y);
785 angleStart=atan2(y, x);
786 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
787 angleEnd=atan2(y, x);
789 /* Make sure the end angle is "on the right side" of the start angle */
790 if(dc->ArcDirection==AD_CLOCKWISE)
792 if(angleEnd<=angleStart)
794 angleEnd+=2*M_PI;
795 assert(angleEnd>=angleStart);
798 else
800 if(angleEnd>=angleStart)
802 angleEnd-=2*M_PI;
803 assert(angleEnd<=angleStart);
807 /* In GM_COMPATIBLE, don't include bottom and right edges */
808 if(dc->GraphicsMode==GM_COMPATIBLE)
810 corners[1].x--;
811 corners[1].y--;
814 /* Add the arc to the path with one Bezier spline per quadrant that the
815 * arc spans */
816 start=TRUE;
817 end=FALSE;
820 /* Determine the start and end angles for this quadrant */
821 if(start)
823 angleStartQuadrant=angleStart;
824 if(dc->ArcDirection==AD_CLOCKWISE)
825 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
826 else
827 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
829 else
831 angleStartQuadrant=angleEndQuadrant;
832 if(dc->ArcDirection==AD_CLOCKWISE)
833 angleEndQuadrant+=M_PI_2;
834 else
835 angleEndQuadrant-=M_PI_2;
838 /* Have we reached the last part of the arc? */
839 if((dc->ArcDirection==AD_CLOCKWISE &&
840 angleEnd<angleEndQuadrant) ||
841 (dc->ArcDirection==AD_COUNTERCLOCKWISE &&
842 angleEnd>angleEndQuadrant))
844 /* Adjust the end angle for this quadrant */
845 angleEndQuadrant=angleEnd;
846 end=TRUE;
849 /* Add the Bezier spline to the path */
850 PATH_DoArcPart(pPath, corners, angleStartQuadrant, angleEndQuadrant,
851 start);
852 start=FALSE;
853 } while(!end);
855 /* chord: close figure. pie: add line and close figure */
856 if(lines==1)
858 if(!CloseFigure(dc->hSelf))
859 return FALSE;
861 else if(lines==2)
863 centre.x = (corners[0].x+corners[1].x)/2;
864 centre.y = (corners[0].y+corners[1].y)/2;
865 if(!PATH_AddEntry(pPath, &centre, PT_LINETO | PT_CLOSEFIGURE))
866 return FALSE;
869 return TRUE;
872 BOOL PATH_PolyBezierTo(DC *dc, const POINT *pts, DWORD cbPoints)
874 GdiPath *pPath = &dc->path;
875 POINT pt;
876 UINT i;
878 /* Check that path is open */
879 if(pPath->state!=PATH_Open)
880 return FALSE;
882 /* Add a PT_MOVETO if necessary */
883 if(pPath->newStroke)
885 pPath->newStroke=FALSE;
886 pt.x = dc->CursPosX;
887 pt.y = dc->CursPosY;
888 if(!LPtoDP(dc->hSelf, &pt, 1))
889 return FALSE;
890 if(!PATH_AddEntry(pPath, &pt, PT_MOVETO))
891 return FALSE;
894 for(i = 0; i < cbPoints; i++) {
895 pt = pts[i];
896 if(!LPtoDP(dc->hSelf, &pt, 1))
897 return FALSE;
898 PATH_AddEntry(pPath, &pt, PT_BEZIERTO);
900 return TRUE;
903 BOOL PATH_PolyBezier(DC *dc, const POINT *pts, DWORD cbPoints)
905 GdiPath *pPath = &dc->path;
906 POINT pt;
907 UINT i;
909 /* Check that path is open */
910 if(pPath->state!=PATH_Open)
911 return FALSE;
913 for(i = 0; i < cbPoints; i++) {
914 pt = pts[i];
915 if(!LPtoDP(dc->hSelf, &pt, 1))
916 return FALSE;
917 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO : PT_BEZIERTO);
919 return TRUE;
922 BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints)
924 GdiPath *pPath = &dc->path;
925 POINT pt;
926 UINT i;
928 /* Check that path is open */
929 if(pPath->state!=PATH_Open)
930 return FALSE;
932 for(i = 0; i < cbPoints; i++) {
933 pt = pts[i];
934 if(!LPtoDP(dc->hSelf, &pt, 1))
935 return FALSE;
936 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO : PT_LINETO);
938 return TRUE;
941 BOOL PATH_PolylineTo(DC *dc, const POINT *pts, DWORD cbPoints)
943 GdiPath *pPath = &dc->path;
944 POINT pt;
945 UINT i;
947 /* Check that path is open */
948 if(pPath->state!=PATH_Open)
949 return FALSE;
951 /* Add a PT_MOVETO if necessary */
952 if(pPath->newStroke)
954 pPath->newStroke=FALSE;
955 pt.x = dc->CursPosX;
956 pt.y = dc->CursPosY;
957 if(!LPtoDP(dc->hSelf, &pt, 1))
958 return FALSE;
959 if(!PATH_AddEntry(pPath, &pt, PT_MOVETO))
960 return FALSE;
963 for(i = 0; i < cbPoints; i++) {
964 pt = pts[i];
965 if(!LPtoDP(dc->hSelf, &pt, 1))
966 return FALSE;
967 PATH_AddEntry(pPath, &pt, PT_LINETO);
970 return TRUE;
974 BOOL PATH_Polygon(DC *dc, const POINT *pts, DWORD cbPoints)
976 GdiPath *pPath = &dc->path;
977 POINT pt;
978 UINT i;
980 /* Check that path is open */
981 if(pPath->state!=PATH_Open)
982 return FALSE;
984 for(i = 0; i < cbPoints; i++) {
985 pt = pts[i];
986 if(!LPtoDP(dc->hSelf, &pt, 1))
987 return FALSE;
988 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO :
989 ((i == cbPoints-1) ? PT_LINETO | PT_CLOSEFIGURE :
990 PT_LINETO));
992 return TRUE;
995 BOOL PATH_PolyPolygon( DC *dc, const POINT* pts, const INT* counts,
996 UINT polygons )
998 GdiPath *pPath = &dc->path;
999 POINT pt, startpt;
1000 UINT poly, i;
1001 INT point;
1003 /* Check that path is open */
1004 if(pPath->state!=PATH_Open)
1005 return FALSE;
1007 for(i = 0, poly = 0; poly < polygons; poly++) {
1008 for(point = 0; point < counts[poly]; point++, i++) {
1009 pt = pts[i];
1010 if(!LPtoDP(dc->hSelf, &pt, 1))
1011 return FALSE;
1012 if(point == 0) startpt = pt;
1013 PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1015 /* win98 adds an extra line to close the figure for some reason */
1016 PATH_AddEntry(pPath, &startpt, PT_LINETO | PT_CLOSEFIGURE);
1018 return TRUE;
1021 BOOL PATH_PolyPolyline( DC *dc, const POINT* pts, const DWORD* counts,
1022 DWORD polylines )
1024 GdiPath *pPath = &dc->path;
1025 POINT pt;
1026 UINT poly, point, i;
1028 /* Check that path is open */
1029 if(pPath->state!=PATH_Open)
1030 return FALSE;
1032 for(i = 0, poly = 0; poly < polylines; poly++) {
1033 for(point = 0; point < counts[poly]; point++, i++) {
1034 pt = pts[i];
1035 if(!LPtoDP(dc->hSelf, &pt, 1))
1036 return FALSE;
1037 PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1040 return TRUE;
1043 /***********************************************************************
1044 * Internal functions
1047 /* PATH_CheckCorners
1049 * Helper function for PATH_RoundRect() and PATH_Rectangle()
1051 static BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2)
1053 INT temp;
1055 /* Convert points to device coordinates */
1056 corners[0].x=x1;
1057 corners[0].y=y1;
1058 corners[1].x=x2;
1059 corners[1].y=y2;
1060 if(!LPtoDP(dc->hSelf, corners, 2))
1061 return FALSE;
1063 /* Make sure first corner is top left and second corner is bottom right */
1064 if(corners[0].x>corners[1].x)
1066 temp=corners[0].x;
1067 corners[0].x=corners[1].x;
1068 corners[1].x=temp;
1070 if(corners[0].y>corners[1].y)
1072 temp=corners[0].y;
1073 corners[0].y=corners[1].y;
1074 corners[1].y=temp;
1077 /* In GM_COMPATIBLE, don't include bottom and right edges */
1078 if(dc->GraphicsMode==GM_COMPATIBLE)
1080 corners[1].x--;
1081 corners[1].y--;
1084 return TRUE;
1087 /* PATH_AddFlatBezier
1089 static BOOL PATH_AddFlatBezier(GdiPath *pPath, POINT *pt, BOOL closed)
1091 POINT *pts;
1092 INT no, i;
1094 pts = GDI_Bezier( pt, 4, &no );
1095 if(!pts) return FALSE;
1097 for(i = 1; i < no; i++)
1098 PATH_AddEntry(pPath, &pts[i],
1099 (i == no-1 && closed) ? PT_LINETO | PT_CLOSEFIGURE : PT_LINETO);
1100 HeapFree( GetProcessHeap(), 0, pts );
1101 return TRUE;
1104 /* PATH_FlattenPath
1106 * Replaces Beziers with line segments
1109 static BOOL PATH_FlattenPath(GdiPath *pPath)
1111 GdiPath newPath;
1112 INT srcpt;
1114 memset(&newPath, 0, sizeof(newPath));
1115 newPath.state = PATH_Open;
1116 for(srcpt = 0; srcpt < pPath->numEntriesUsed; srcpt++) {
1117 switch(pPath->pFlags[srcpt] & ~PT_CLOSEFIGURE) {
1118 case PT_MOVETO:
1119 case PT_LINETO:
1120 PATH_AddEntry(&newPath, &pPath->pPoints[srcpt],
1121 pPath->pFlags[srcpt]);
1122 break;
1123 case PT_BEZIERTO:
1124 PATH_AddFlatBezier(&newPath, &pPath->pPoints[srcpt-1],
1125 pPath->pFlags[srcpt+2] & PT_CLOSEFIGURE);
1126 srcpt += 2;
1127 break;
1130 newPath.state = PATH_Closed;
1131 PATH_AssignGdiPath(pPath, &newPath);
1132 PATH_DestroyGdiPath(&newPath);
1133 return TRUE;
1136 /* PATH_PathToRegion
1138 * Creates a region from the specified path using the specified polygon
1139 * filling mode. The path is left unchanged. A handle to the region that
1140 * was created is stored in *pHrgn. If successful, TRUE is returned; if an
1141 * error occurs, SetLastError is called with the appropriate value and
1142 * FALSE is returned.
1144 static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
1145 HRGN *pHrgn)
1147 int numStrokes, iStroke, i;
1148 INT *pNumPointsInStroke;
1149 HRGN hrgn;
1151 assert(pPath!=NULL);
1152 assert(pHrgn!=NULL);
1154 PATH_FlattenPath(pPath);
1156 /* FIXME: What happens when number of points is zero? */
1158 /* First pass: Find out how many strokes there are in the path */
1159 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
1160 numStrokes=0;
1161 for(i=0; i<pPath->numEntriesUsed; i++)
1162 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
1163 numStrokes++;
1165 /* Allocate memory for number-of-points-in-stroke array */
1166 pNumPointsInStroke=HeapAlloc( GetProcessHeap(), 0, sizeof(int) * numStrokes );
1167 if(!pNumPointsInStroke)
1169 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1170 return FALSE;
1173 /* Second pass: remember number of points in each polygon */
1174 iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
1175 for(i=0; i<pPath->numEntriesUsed; i++)
1177 /* Is this the beginning of a new stroke? */
1178 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
1180 iStroke++;
1181 pNumPointsInStroke[iStroke]=0;
1184 pNumPointsInStroke[iStroke]++;
1187 /* Create a region from the strokes */
1188 hrgn=CreatePolyPolygonRgn(pPath->pPoints, pNumPointsInStroke,
1189 numStrokes, nPolyFillMode);
1191 /* Free memory for number-of-points-in-stroke array */
1192 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
1194 if(hrgn==NULL)
1196 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1197 return FALSE;
1200 /* Success! */
1201 *pHrgn=hrgn;
1202 return TRUE;
1205 static inline INT int_from_fixed(FIXED f)
1207 return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
1210 /**********************************************************************
1211 * PATH_BezierTo
1213 * internally used by PATH_add_outline
1215 static void PATH_BezierTo(GdiPath *pPath, POINT *lppt, INT n)
1217 if (n < 2) return;
1219 if (n == 2)
1221 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1223 else if (n == 3)
1225 PATH_AddEntry(pPath, &lppt[0], PT_BEZIERTO);
1226 PATH_AddEntry(pPath, &lppt[1], PT_BEZIERTO);
1227 PATH_AddEntry(pPath, &lppt[2], PT_BEZIERTO);
1229 else
1231 POINT pt[3];
1232 INT i = 0;
1234 pt[2] = lppt[0];
1235 n--;
1237 while (n > 2)
1239 pt[0] = pt[2];
1240 pt[1] = lppt[i+1];
1241 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1242 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1243 PATH_BezierTo(pPath, pt, 3);
1244 n--;
1245 i++;
1248 pt[0] = pt[2];
1249 pt[1] = lppt[i+1];
1250 pt[2] = lppt[i+2];
1251 PATH_BezierTo(pPath, pt, 3);
1255 static BOOL PATH_add_outline(DC *dc, INT x, INT y, TTPOLYGONHEADER *header, DWORD size)
1257 GdiPath *pPath = &dc->path;
1258 TTPOLYGONHEADER *start;
1259 POINT pt;
1261 start = header;
1263 while ((char *)header < (char *)start + size)
1265 TTPOLYCURVE *curve;
1267 if (header->dwType != TT_POLYGON_TYPE)
1269 FIXME("Unknown header type %d\n", header->dwType);
1270 return FALSE;
1273 pt.x = x + int_from_fixed(header->pfxStart.x);
1274 pt.y = y - int_from_fixed(header->pfxStart.y);
1275 LPtoDP(dc->hSelf, &pt, 1);
1276 PATH_AddEntry(pPath, &pt, PT_MOVETO);
1278 curve = (TTPOLYCURVE *)(header + 1);
1280 while ((char *)curve < (char *)header + header->cb)
1282 /*TRACE("curve->wType %d\n", curve->wType);*/
1284 switch(curve->wType)
1286 case TT_PRIM_LINE:
1288 WORD i;
1290 for (i = 0; i < curve->cpfx; i++)
1292 pt.x = x + int_from_fixed(curve->apfx[i].x);
1293 pt.y = y - int_from_fixed(curve->apfx[i].y);
1294 LPtoDP(dc->hSelf, &pt, 1);
1295 PATH_AddEntry(pPath, &pt, PT_LINETO);
1297 break;
1300 case TT_PRIM_QSPLINE:
1301 case TT_PRIM_CSPLINE:
1303 WORD i;
1304 POINTFX ptfx;
1305 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1307 if (!pts) return FALSE;
1309 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1311 pts[0].x = x + int_from_fixed(ptfx.x);
1312 pts[0].y = y - int_from_fixed(ptfx.y);
1313 LPtoDP(dc->hSelf, &pts[0], 1);
1315 for(i = 0; i < curve->cpfx; i++)
1317 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1318 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1319 LPtoDP(dc->hSelf, &pts[i + 1], 1);
1322 PATH_BezierTo(pPath, pts, curve->cpfx + 1);
1324 HeapFree(GetProcessHeap(), 0, pts);
1325 break;
1328 default:
1329 FIXME("Unknown curve type %04x\n", curve->wType);
1330 return FALSE;
1333 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1336 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1339 return CloseFigure(dc->hSelf);
1342 /**********************************************************************
1343 * PATH_ExtTextOut
1345 BOOL PATH_ExtTextOut(DC *dc, INT x, INT y, UINT flags, const RECT *lprc,
1346 LPCWSTR str, UINT count, const INT *dx)
1348 unsigned int idx;
1349 double cosEsc, sinEsc;
1350 LOGFONTW lf;
1351 POINT org;
1352 HDC hdc = dc->hSelf;
1353 INT offset = 0, xoff = 0, yoff = 0;
1355 TRACE("%p, %d, %d, %08x, %s, %s, %d, %p)\n", hdc, x, y, flags,
1356 wine_dbgstr_rect(lprc), debugstr_wn(str, count), count, dx);
1358 if (!count) return TRUE;
1360 GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
1362 if (lf.lfEscapement != 0)
1364 cosEsc = cos(lf.lfEscapement * M_PI / 1800);
1365 sinEsc = sin(lf.lfEscapement * M_PI / 1800);
1366 } else
1368 cosEsc = 1;
1369 sinEsc = 0;
1372 GetDCOrgEx(hdc, &org);
1374 for (idx = 0; idx < count; idx++)
1376 GLYPHMETRICS gm;
1377 DWORD dwSize;
1378 void *outline;
1380 dwSize = GetGlyphOutlineW(hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE, &gm, 0, NULL, NULL);
1381 if (!dwSize) return FALSE;
1383 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1384 if (!outline) return FALSE;
1386 GetGlyphOutlineW(hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE, &gm, dwSize, outline, NULL);
1388 PATH_add_outline(dc, org.x + x + xoff, org.x + y + yoff, outline, dwSize);
1390 HeapFree(GetProcessHeap(), 0, outline);
1392 if (dx)
1394 offset += dx[idx];
1395 xoff = offset * cosEsc;
1396 yoff = offset * -sinEsc;
1398 else
1400 xoff += gm.gmCellIncX;
1401 yoff += gm.gmCellIncY;
1404 return TRUE;
1407 /* PATH_EmptyPath
1409 * Removes all entries from the path and sets the path state to PATH_Null.
1411 static void PATH_EmptyPath(GdiPath *pPath)
1413 assert(pPath!=NULL);
1415 pPath->state=PATH_Null;
1416 pPath->numEntriesUsed=0;
1419 /* PATH_AddEntry
1421 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
1422 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
1423 * successful, FALSE otherwise (e.g. if not enough memory was available).
1425 BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint, BYTE flags)
1427 assert(pPath!=NULL);
1429 /* FIXME: If newStroke is true, perhaps we want to check that we're
1430 * getting a PT_MOVETO
1432 TRACE("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags);
1434 /* Check that path is open */
1435 if(pPath->state!=PATH_Open)
1436 return FALSE;
1438 /* Reserve enough memory for an extra path entry */
1439 if(!PATH_ReserveEntries(pPath, pPath->numEntriesUsed+1))
1440 return FALSE;
1442 /* Store information in path entry */
1443 pPath->pPoints[pPath->numEntriesUsed]=*pPoint;
1444 pPath->pFlags[pPath->numEntriesUsed]=flags;
1446 /* If this is PT_CLOSEFIGURE, we have to start a new stroke next time */
1447 if((flags & PT_CLOSEFIGURE) == PT_CLOSEFIGURE)
1448 pPath->newStroke=TRUE;
1450 /* Increment entry count */
1451 pPath->numEntriesUsed++;
1453 return TRUE;
1456 /* PATH_ReserveEntries
1458 * Ensures that at least "numEntries" entries (for points and flags) have
1459 * been allocated; allocates larger arrays and copies the existing entries
1460 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
1462 static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries)
1464 INT numEntriesToAllocate;
1465 POINT *pPointsNew;
1466 BYTE *pFlagsNew;
1468 assert(pPath!=NULL);
1469 assert(numEntries>=0);
1471 /* Do we have to allocate more memory? */
1472 if(numEntries > pPath->numEntriesAllocated)
1474 /* Find number of entries to allocate. We let the size of the array
1475 * grow exponentially, since that will guarantee linear time
1476 * complexity. */
1477 if(pPath->numEntriesAllocated)
1479 numEntriesToAllocate=pPath->numEntriesAllocated;
1480 while(numEntriesToAllocate<numEntries)
1481 numEntriesToAllocate=numEntriesToAllocate*GROW_FACTOR_NUMER/
1482 GROW_FACTOR_DENOM;
1484 else
1485 numEntriesToAllocate=numEntries;
1487 /* Allocate new arrays */
1488 pPointsNew=HeapAlloc( GetProcessHeap(), 0, numEntriesToAllocate * sizeof(POINT) );
1489 if(!pPointsNew)
1490 return FALSE;
1491 pFlagsNew=HeapAlloc( GetProcessHeap(), 0, numEntriesToAllocate * sizeof(BYTE) );
1492 if(!pFlagsNew)
1494 HeapFree( GetProcessHeap(), 0, pPointsNew );
1495 return FALSE;
1498 /* Copy old arrays to new arrays and discard old arrays */
1499 if(pPath->pPoints)
1501 assert(pPath->pFlags);
1503 memcpy(pPointsNew, pPath->pPoints,
1504 sizeof(POINT)*pPath->numEntriesUsed);
1505 memcpy(pFlagsNew, pPath->pFlags,
1506 sizeof(BYTE)*pPath->numEntriesUsed);
1508 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
1509 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
1511 pPath->pPoints=pPointsNew;
1512 pPath->pFlags=pFlagsNew;
1513 pPath->numEntriesAllocated=numEntriesToAllocate;
1516 return TRUE;
1519 /* PATH_DoArcPart
1521 * Creates a Bezier spline that corresponds to part of an arc and appends the
1522 * corresponding points to the path. The start and end angles are passed in
1523 * "angleStart" and "angleEnd"; these angles should span a quarter circle
1524 * at most. If "addMoveTo" is true, a PT_MOVETO entry for the first control
1525 * point is added to the path; otherwise, it is assumed that the current
1526 * position is equal to the first control point.
1528 static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
1529 double angleStart, double angleEnd, BOOL addMoveTo)
1531 double halfAngle, a;
1532 double xNorm[4], yNorm[4];
1533 POINT point;
1534 int i;
1536 assert(fabs(angleEnd-angleStart)<=M_PI_2);
1538 /* FIXME: Is there an easier way of computing this? */
1540 /* Compute control points */
1541 halfAngle=(angleEnd-angleStart)/2.0;
1542 if(fabs(halfAngle)>1e-8)
1544 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
1545 xNorm[0]=cos(angleStart);
1546 yNorm[0]=sin(angleStart);
1547 xNorm[1]=xNorm[0] - a*yNorm[0];
1548 yNorm[1]=yNorm[0] + a*xNorm[0];
1549 xNorm[3]=cos(angleEnd);
1550 yNorm[3]=sin(angleEnd);
1551 xNorm[2]=xNorm[3] + a*yNorm[3];
1552 yNorm[2]=yNorm[3] - a*xNorm[3];
1554 else
1555 for(i=0; i<4; i++)
1557 xNorm[i]=cos(angleStart);
1558 yNorm[i]=sin(angleStart);
1561 /* Add starting point to path if desired */
1562 if(addMoveTo)
1564 PATH_ScaleNormalizedPoint(corners, xNorm[0], yNorm[0], &point);
1565 if(!PATH_AddEntry(pPath, &point, PT_MOVETO))
1566 return FALSE;
1569 /* Add remaining control points */
1570 for(i=1; i<4; i++)
1572 PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &point);
1573 if(!PATH_AddEntry(pPath, &point, PT_BEZIERTO))
1574 return FALSE;
1577 return TRUE;
1580 /* PATH_ScaleNormalizedPoint
1582 * Scales a normalized point (x, y) with respect to the box whose corners are
1583 * passed in "corners". The point is stored in "*pPoint". The normalized
1584 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
1585 * (1.0, 1.0) correspond to corners[1].
1587 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
1588 double y, POINT *pPoint)
1590 pPoint->x=GDI_ROUND( (double)corners[0].x +
1591 (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
1592 pPoint->y=GDI_ROUND( (double)corners[0].y +
1593 (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
1596 /* PATH_NormalizePoint
1598 * Normalizes a point with respect to the box whose corners are passed in
1599 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
1601 static void PATH_NormalizePoint(FLOAT_POINT corners[],
1602 const FLOAT_POINT *pPoint,
1603 double *pX, double *pY)
1605 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) *
1606 2.0 - 1.0;
1607 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) *
1608 2.0 - 1.0;
1612 /*******************************************************************
1613 * FlattenPath [GDI32.@]
1617 BOOL WINAPI FlattenPath(HDC hdc)
1619 BOOL ret = FALSE;
1620 DC *dc = DC_GetDCPtr( hdc );
1622 if(!dc) return FALSE;
1624 if(dc->funcs->pFlattenPath) ret = dc->funcs->pFlattenPath(dc->physDev);
1625 else
1627 GdiPath *pPath = &dc->path;
1628 if(pPath->state != PATH_Closed)
1629 ret = PATH_FlattenPath(pPath);
1631 GDI_ReleaseObj( hdc );
1632 return ret;
1636 static BOOL PATH_StrokePath(DC *dc, GdiPath *pPath)
1638 INT i, nLinePts, nAlloc;
1639 POINT *pLinePts;
1640 POINT ptViewportOrg, ptWindowOrg;
1641 SIZE szViewportExt, szWindowExt;
1642 DWORD mapMode, graphicsMode;
1643 XFORM xform;
1644 BOOL ret = TRUE;
1646 if(dc->funcs->pStrokePath)
1647 return dc->funcs->pStrokePath(dc->physDev);
1649 if(pPath->state != PATH_Closed)
1650 return FALSE;
1652 /* Save the mapping mode info */
1653 mapMode=GetMapMode(dc->hSelf);
1654 GetViewportExtEx(dc->hSelf, &szViewportExt);
1655 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
1656 GetWindowExtEx(dc->hSelf, &szWindowExt);
1657 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
1658 GetWorldTransform(dc->hSelf, &xform);
1660 /* Set MM_TEXT */
1661 SetMapMode(dc->hSelf, MM_TEXT);
1662 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
1663 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
1664 graphicsMode=GetGraphicsMode(dc->hSelf);
1665 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
1666 ModifyWorldTransform(dc->hSelf, &xform, MWT_IDENTITY);
1667 SetGraphicsMode(dc->hSelf, graphicsMode);
1669 /* Allocate enough memory for the worst case without beziers (one PT_MOVETO
1670 * and the rest PT_LINETO with PT_CLOSEFIGURE at the end) plus some buffer
1671 * space in case we get one to keep the number of reallocations small. */
1672 nAlloc = pPath->numEntriesUsed + 1 + 300;
1673 pLinePts = HeapAlloc(GetProcessHeap(), 0, nAlloc * sizeof(POINT));
1674 nLinePts = 0;
1676 for(i = 0; i < pPath->numEntriesUsed; i++) {
1677 if((i == 0 || (pPath->pFlags[i-1] & PT_CLOSEFIGURE)) &&
1678 (pPath->pFlags[i] != PT_MOVETO)) {
1679 ERR("Expected PT_MOVETO %s, got path flag %d\n",
1680 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1681 (INT)pPath->pFlags[i]);
1682 ret = FALSE;
1683 goto end;
1685 switch(pPath->pFlags[i]) {
1686 case PT_MOVETO:
1687 TRACE("Got PT_MOVETO (%d, %d)\n",
1688 pPath->pPoints[i].x, pPath->pPoints[i].y);
1689 if(nLinePts >= 2)
1690 Polyline(dc->hSelf, pLinePts, nLinePts);
1691 nLinePts = 0;
1692 pLinePts[nLinePts++] = pPath->pPoints[i];
1693 break;
1694 case PT_LINETO:
1695 case (PT_LINETO | PT_CLOSEFIGURE):
1696 TRACE("Got PT_LINETO (%d, %d)\n",
1697 pPath->pPoints[i].x, pPath->pPoints[i].y);
1698 pLinePts[nLinePts++] = pPath->pPoints[i];
1699 break;
1700 case PT_BEZIERTO:
1701 TRACE("Got PT_BEZIERTO\n");
1702 if(pPath->pFlags[i+1] != PT_BEZIERTO ||
1703 (pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
1704 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
1705 ret = FALSE;
1706 goto end;
1707 } else {
1708 INT nBzrPts, nMinAlloc;
1709 POINT *pBzrPts = GDI_Bezier(&pPath->pPoints[i-1], 4, &nBzrPts);
1710 /* Make sure we have allocated enough memory for the lines of
1711 * this bezier and the rest of the path, assuming we won't get
1712 * another one (since we won't reallocate again then). */
1713 nMinAlloc = nLinePts + (pPath->numEntriesUsed - i) + nBzrPts;
1714 if(nAlloc < nMinAlloc)
1716 nAlloc = nMinAlloc * 2;
1717 pLinePts = HeapReAlloc(GetProcessHeap(), 0, pLinePts,
1718 nAlloc * sizeof(POINT));
1720 memcpy(&pLinePts[nLinePts], &pBzrPts[1],
1721 (nBzrPts - 1) * sizeof(POINT));
1722 nLinePts += nBzrPts - 1;
1723 HeapFree(GetProcessHeap(), 0, pBzrPts);
1724 i += 2;
1726 break;
1727 default:
1728 ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
1729 ret = FALSE;
1730 goto end;
1732 if(pPath->pFlags[i] & PT_CLOSEFIGURE)
1733 pLinePts[nLinePts++] = pLinePts[0];
1735 if(nLinePts >= 2)
1736 Polyline(dc->hSelf, pLinePts, nLinePts);
1738 end:
1739 HeapFree(GetProcessHeap(), 0, pLinePts);
1741 /* Restore the old mapping mode */
1742 SetMapMode(dc->hSelf, mapMode);
1743 SetWindowExtEx(dc->hSelf, szWindowExt.cx, szWindowExt.cy, NULL);
1744 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
1745 SetViewportExtEx(dc->hSelf, szViewportExt.cx, szViewportExt.cy, NULL);
1746 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
1748 /* Go to GM_ADVANCED temporarily to restore the world transform */
1749 graphicsMode=GetGraphicsMode(dc->hSelf);
1750 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
1751 SetWorldTransform(dc->hSelf, &xform);
1752 SetGraphicsMode(dc->hSelf, graphicsMode);
1754 /* If we've moved the current point then get its new position
1755 which will be in device (MM_TEXT) co-ords, convert it to
1756 logical co-ords and re-set it. This basically updates
1757 dc->CurPosX|Y so that their values are in the correct mapping
1758 mode.
1760 if(i > 0) {
1761 POINT pt;
1762 GetCurrentPositionEx(dc->hSelf, &pt);
1763 DPtoLP(dc->hSelf, &pt, 1);
1764 MoveToEx(dc->hSelf, pt.x, pt.y, NULL);
1767 return ret;
1771 static BOOL PATH_WidenPath(DC *dc)
1773 INT i, j, numStrokes, nLinePts, penWidth, penWidthIn, penWidthOut, size;
1774 BOOL ret = FALSE;
1775 GdiPath *pPath, *pNewPath, **pStrokes, *pUpPath, *pDownPath;
1776 EXTLOGPEN *elp;
1777 FLOAT fCos, fSin, nPente;
1779 pPath = &dc->path;
1781 PATH_FlattenPath(pPath);
1783 if(pPath->state != PATH_Closed) {
1784 ERR("Path Closed\n");
1785 return FALSE;
1788 size = GetObjectW( dc->hPen, 0, NULL );
1789 if (!size) return FALSE;
1791 elp = HeapAlloc( GetProcessHeap(), 0, size );
1793 GetObjectW( dc->hPen, size, elp );
1794 /* FIXME: add support for user style pens */
1795 penWidth = elp->elpWidth;
1796 HeapFree( GetProcessHeap(), 0, elp );
1798 /* FIXME : If extPen, use the shape on corners */
1799 penWidthIn = penWidth / 2;
1800 penWidthOut = penWidth / 2;
1801 if(penWidthIn + penWidthOut < penWidth)
1802 penWidthOut++;
1804 numStrokes = 0;
1805 nLinePts = 0;
1807 pStrokes = HeapAlloc(GetProcessHeap(), 0, numStrokes * sizeof(GdiPath*));
1808 pStrokes[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1809 PATH_InitGdiPath(pStrokes[0]);
1810 pStrokes[0]->pFlags = HeapAlloc(GetProcessHeap(), 0, pPath->numEntriesUsed * sizeof(INT));
1811 pStrokes[0]->pPoints = HeapAlloc(GetProcessHeap(), 0, pPath->numEntriesUsed * sizeof(POINT));
1812 pStrokes[0]->numEntriesUsed = 0;
1814 for(i = 0, j = 0; i < pPath->numEntriesUsed; i++, j++) {
1815 if((i == 0 || (pPath->pFlags[i-1] & PT_CLOSEFIGURE)) &&
1816 (pPath->pFlags[i] != PT_MOVETO)) {
1817 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1818 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1819 pPath->pFlags[i]);
1820 return FALSE;
1822 switch(pPath->pFlags[i]) {
1823 case PT_MOVETO:
1824 numStrokes++;
1825 j = 0;
1826 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(GdiPath*));
1827 pStrokes[numStrokes - 1] = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1828 PATH_InitGdiPath(pStrokes[numStrokes - 1]);
1829 pStrokes[numStrokes - 1]->pFlags = HeapAlloc(GetProcessHeap(), 0, pPath->numEntriesUsed * sizeof(INT));
1830 pStrokes[numStrokes - 1]->pPoints = HeapAlloc(GetProcessHeap(), 0, pPath->numEntriesUsed * sizeof(POINT));
1831 pStrokes[numStrokes - 1]->numEntriesUsed = 0;
1833 pStrokes[numStrokes - 1]->pFlags[j] = pPath->pFlags[i];
1834 pStrokes[numStrokes - 1]->pPoints[j].x = pPath->pPoints[i].x;
1835 pStrokes[numStrokes - 1]->pPoints[j].y = pPath->pPoints[i].y;
1836 pStrokes[numStrokes - 1]->numEntriesUsed++;
1838 break;
1839 case PT_LINETO:
1840 case (PT_LINETO | PT_CLOSEFIGURE):
1841 pStrokes[numStrokes - 1]->pFlags[j] = pPath->pFlags[i];
1842 pStrokes[numStrokes - 1]->pPoints[j].x = pPath->pPoints[i].x;
1843 pStrokes[numStrokes - 1]->pPoints[j].y = pPath->pPoints[i].y;
1844 pStrokes[numStrokes - 1]->numEntriesUsed++;
1845 break;
1846 case PT_BEZIERTO:
1847 /* should never happen because of the FlattenPath call */
1848 ERR("Should never happen\n");
1849 break;
1850 default:
1851 ERR("Got path flag %c\n", pPath->pFlags[i]);
1852 return FALSE;
1856 pNewPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1857 PATH_InitGdiPath(pNewPath);
1858 pNewPath->pFlags = HeapAlloc(GetProcessHeap(), 0, 4 * pPath->numEntriesUsed * sizeof(INT));
1859 pNewPath->pPoints = HeapAlloc(GetProcessHeap(), 0, 4 * pPath->numEntriesUsed * sizeof(POINT));
1860 pNewPath->numEntriesUsed = 0;
1861 pNewPath->numEntriesAllocated = 4 * pPath->numEntriesUsed;
1863 for(i = 0; i < numStrokes; i++) {
1864 pUpPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1865 PATH_InitGdiPath(pUpPath);
1866 pUpPath->pFlags = HeapAlloc(GetProcessHeap(), 0, 2 * pStrokes[i]->numEntriesUsed * sizeof(INT));
1867 pUpPath->pPoints = HeapAlloc(GetProcessHeap(), 0, 2 * pStrokes[i]->numEntriesUsed * sizeof(POINT));
1868 pUpPath->numEntriesUsed = 0;
1869 pDownPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1870 PATH_InitGdiPath(pDownPath);
1871 pDownPath->pFlags = HeapAlloc(GetProcessHeap(), 0, 2 * pStrokes[i]->numEntriesUsed * sizeof(INT));
1872 pDownPath->pPoints = HeapAlloc(GetProcessHeap(), 0, 2 * pStrokes[i]->numEntriesUsed * sizeof(POINT));
1873 pDownPath->numEntriesUsed = 0;
1874 for(j = 0; j < pStrokes[i]->numEntriesUsed - 1; j++) {
1875 if(pStrokes[i]->pPoints[j+1].x != pStrokes[i]->pPoints[j].x) {
1876 nPente = (pStrokes[i]->pPoints[j+1].y - pStrokes[i]->pPoints[j].y) / (pStrokes[i]->pPoints[j+1].x - pStrokes[i]->pPoints[j].x);
1877 fCos = cos(atan(nPente));
1878 fSin = sin(atan(nPente));
1880 else if(pStrokes[i]->pPoints[j+1].y > pStrokes[i]->pPoints[j].y) {
1881 fCos = 0;
1882 fSin = -1;
1884 else {
1885 fCos = 0;
1886 fSin = 1;
1889 /* FIXME : Improve corners */
1890 pUpPath->pPoints[2 * j].x = pStrokes[i]->pPoints[j].x + penWidthOut * fSin;
1891 pUpPath->pPoints[2 * j].y = pStrokes[i]->pPoints[j].y + penWidthOut * fCos;
1892 pUpPath->pFlags[2 * j] = pStrokes[i]->pFlags[j];
1893 pUpPath->pPoints[2 * j + 1] .x = pStrokes[i]->pPoints[j+1].x + penWidthOut * fSin;
1894 pUpPath->pPoints[2 * j + 1] .y = pStrokes[i]->pPoints[j+1].y + penWidthOut * fCos;
1895 pUpPath->pFlags[2 * j + 1] = PT_LINETO;
1896 pUpPath->numEntriesUsed = pUpPath->numEntriesUsed + 2;
1898 pDownPath->pPoints[2 * j].x = pStrokes[i]->pPoints[j].x - penWidthIn * fSin;
1899 pDownPath->pPoints[2 * j].y = pStrokes[i]->pPoints[j].y - penWidthIn * fCos;
1900 pDownPath->pFlags[2 * j] = PT_LINETO;
1901 pDownPath->pPoints[2 * j + 1] .x = pStrokes[i]->pPoints[j+1].x - penWidthIn * fSin;
1902 pDownPath->pPoints[2 * j + 1] .y = pStrokes[i]->pPoints[j+1].y - penWidthIn * fCos;
1903 pDownPath->pFlags[2 * j + 1] = PT_LINETO;
1904 pDownPath->numEntriesUsed = pUpPath->numEntriesUsed;
1907 for(j = 0; j < pUpPath->numEntriesUsed; j++) {
1908 pNewPath->pPoints[pNewPath->numEntriesUsed + j].x = pUpPath->pPoints[j].x;
1909 pNewPath->pPoints[pNewPath->numEntriesUsed + j].y = pUpPath->pPoints[j].y;
1910 pNewPath->pFlags[pNewPath->numEntriesUsed + j] = pUpPath->pFlags[j];
1911 pNewPath->pPoints[pNewPath->numEntriesUsed + pUpPath->numEntriesUsed + j].x = pDownPath->pPoints[pUpPath->numEntriesUsed - j - 1].x;
1912 pNewPath->pPoints[pNewPath->numEntriesUsed + pUpPath->numEntriesUsed + j].y = pDownPath->pPoints[pUpPath->numEntriesUsed - j - 1].y;
1913 pNewPath->pFlags[pNewPath->numEntriesUsed + pUpPath->numEntriesUsed + j] = pDownPath->pFlags[pUpPath->numEntriesUsed - j - 1];
1915 pNewPath->numEntriesUsed += 2 * pUpPath->numEntriesUsed;
1916 pNewPath->pFlags[pNewPath->numEntriesUsed - 1] = PT_CLOSEFIGURE | PT_LINETO;
1918 PATH_DestroyGdiPath(pStrokes[i]);
1919 HeapFree(GetProcessHeap(), 0, pStrokes[i]);
1920 PATH_DestroyGdiPath(pUpPath);
1921 HeapFree(GetProcessHeap(), 0, pUpPath);
1922 PATH_DestroyGdiPath(pDownPath);
1923 HeapFree(GetProcessHeap(), 0, pDownPath);
1925 HeapFree(GetProcessHeap(), 0, pStrokes);
1927 pNewPath->state = PATH_Closed;
1928 if (!(ret = PATH_AssignGdiPath(pPath, pNewPath)))
1929 ERR("Assign path failed\n");
1930 PATH_DestroyGdiPath(pNewPath);
1931 HeapFree(GetProcessHeap(), 0, pNewPath);
1932 return ret;
1936 /*******************************************************************
1937 * StrokeAndFillPath [GDI32.@]
1941 BOOL WINAPI StrokeAndFillPath(HDC hdc)
1943 DC *dc = DC_GetDCPtr( hdc );
1944 BOOL bRet = FALSE;
1946 if(!dc) return FALSE;
1948 if(dc->funcs->pStrokeAndFillPath)
1949 bRet = dc->funcs->pStrokeAndFillPath(dc->physDev);
1950 else
1952 bRet = PATH_FillPath(dc, &dc->path);
1953 if(bRet) bRet = PATH_StrokePath(dc, &dc->path);
1954 if(bRet) PATH_EmptyPath(&dc->path);
1956 GDI_ReleaseObj( hdc );
1957 return bRet;
1961 /*******************************************************************
1962 * StrokePath [GDI32.@]
1966 BOOL WINAPI StrokePath(HDC hdc)
1968 DC *dc = DC_GetDCPtr( hdc );
1969 GdiPath *pPath;
1970 BOOL bRet = FALSE;
1972 TRACE("(%p)\n", hdc);
1973 if(!dc) return FALSE;
1975 if(dc->funcs->pStrokePath)
1976 bRet = dc->funcs->pStrokePath(dc->physDev);
1977 else
1979 pPath = &dc->path;
1980 bRet = PATH_StrokePath(dc, pPath);
1981 PATH_EmptyPath(pPath);
1983 GDI_ReleaseObj( hdc );
1984 return bRet;
1988 /*******************************************************************
1989 * WidenPath [GDI32.@]
1993 BOOL WINAPI WidenPath(HDC hdc)
1995 DC *dc = DC_GetDCPtr( hdc );
1996 BOOL ret = FALSE;
1998 if(!dc) return FALSE;
2000 if(dc->funcs->pWidenPath)
2001 ret = dc->funcs->pWidenPath(dc->physDev);
2002 else
2003 ret = PATH_WidenPath(dc);
2004 GDI_ReleaseObj( hdc );
2005 FIXME("partially implemented\n");
2006 return ret;