blob: 8460bcbc007e711721254ccd8d51e48389f6c937 [file] [log] [blame]
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001/*
2 * Graphics paths (BeginPath, EndPath etc.)
3 *
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00004 * Copyright 1997, 1998 Martin Boehme
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00005 * 1999 Huw D M Davies
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00006 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000020 */
21
Francois Gougete5ddd262001-10-14 16:18:52 +000022#include "config.h"
Patrik Stridvall9aab47e2002-08-28 23:42:34 +000023#include "wine/port.h"
Francois Gougete5ddd262001-10-14 16:18:52 +000024
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000025#include <assert.h>
Alexandre Julliard60ce85c1998-02-01 18:33:27 +000026#include <math.h>
Jeff Garzikc3e1f721999-02-19 15:42:11 +000027#include <string.h>
Robert Pouliot0a997521999-04-16 06:55:26 +000028#if defined(HAVE_FLOAT_H)
29#include <float.h>
30#endif
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000031
Marcus Meissner04c3e1d1999-02-19 10:37:02 +000032#include "winbase.h"
33#include "wingdi.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000034#include "winerror.h"
35
Alexandre Julliard2239abb2000-11-05 02:05:07 +000036#include "gdi.h"
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000037#include "wine/debug.h"
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000038
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000039WINE_DEFAULT_DEBUG_CHANNEL(gdi);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000040
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000041/* Notes on the implementation
42 *
43 * The implementation is based on dynamically resizable arrays of points and
44 * flags. I dithered for a bit before deciding on this implementation, and
45 * I had even done a bit of work on a linked list version before switching
46 * to arrays. It's a bit of a tradeoff. When you use linked lists, the
47 * implementation of FlattenPath is easier, because you can rip the
48 * PT_BEZIERTO entries out of the middle of the list and link the
49 * corresponding PT_LINETO entries in. However, when you use arrays,
50 * PathToRegion becomes easier, since you can essentially just pass your array
51 * of points to CreatePolyPolygonRgn. Also, if I'd used linked lists, I would
52 * have had the extra effort of creating a chunk-based allocation scheme
53 * in order to use memory effectively. That's why I finally decided to use
54 * arrays. Note by the way that the array based implementation has the same
55 * linear time complexity that linked lists would have since the arrays grow
56 * exponentially.
57 *
58 * The points are stored in the path in device coordinates. This is
59 * consistent with the way Windows does things (for instance, see the Win32
60 * SDK documentation for GetPath).
61 *
62 * The word "stroke" appears in several places (e.g. in the flag
63 * GdiPath.newStroke). A stroke consists of a PT_MOVETO followed by one or
64 * more PT_LINETOs or PT_BEZIERTOs, up to, but not including, the next
65 * PT_MOVETO. Note that this is not the same as the definition of a figure;
66 * a figure can contain several strokes.
67 *
68 * I modified the drawing functions (MoveTo, LineTo etc.) to test whether
69 * the path is open and to call the corresponding function in path.c if this
70 * is the case. A more elegant approach would be to modify the function
71 * pointers in the DC_FUNCTIONS structure; however, this would be a lot more
72 * complex. Also, the performance degradation caused by my approach in the
73 * case where no path is open is so small that it cannot be measured.
74 *
75 * Martin Boehme
76 */
77
78/* FIXME: A lot of stuff isn't implemented yet. There is much more to come. */
79
80#define NUM_ENTRIES_INITIAL 16 /* Initial size of points / flags arrays */
81#define GROW_FACTOR_NUMER 2 /* Numerator of grow factor for the array */
82#define GROW_FACTOR_DENOM 1 /* Denominator of grow factor */
83
Alexandre Julliard5ee15992002-06-25 23:29:51 +000084/* A floating point version of the POINT structure */
85typedef struct tagFLOAT_POINT
86{
87 FLOAT x, y;
88} FLOAT_POINT;
89
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000090
Niels Kristian Bech Jensenc9742b32000-03-28 20:44:59 +000091static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
Alexandre Julliarda3960291999-02-26 11:11:13 +000092 HRGN *pHrgn);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +000093static void PATH_EmptyPath(GdiPath *pPath);
Alexandre Julliarda3960291999-02-26 11:11:13 +000094static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries);
Alexandre Julliarda3960291999-02-26 11:11:13 +000095static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
96 double angleStart, double angleEnd, BOOL addMoveTo);
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000097static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
Alexandre Julliarda3960291999-02-26 11:11:13 +000098 double y, POINT *pPoint);
Alexandre Julliarddadf78f1998-05-17 17:13:43 +000099static void PATH_NormalizePoint(FLOAT_POINT corners[], const FLOAT_POINT
100 *pPoint, double *pX, double *pY);
Mark Dufour704c6752000-11-01 02:12:52 +0000101static BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000102
Alexandre Julliard5ee15992002-06-25 23:29:51 +0000103/* Performs a world-to-viewport transformation on the specified point (which
104 * is in floating point format).
105 */
106static inline void WINE_UNUSED INTERNAL_LPTODP_FLOAT(DC *dc, FLOAT_POINT *point)
107{
108 FLOAT x, y;
109
110 /* Perform the transformation */
111 x = point->x;
112 y = point->y;
113 point->x = x * dc->xformWorld2Vport.eM11 +
114 y * dc->xformWorld2Vport.eM21 +
115 dc->xformWorld2Vport.eDx;
116 point->y = x * dc->xformWorld2Vport.eM12 +
117 y * dc->xformWorld2Vport.eM22 +
118 dc->xformWorld2Vport.eDy;
119}
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000120
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000121
122/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000123 * BeginPath (GDI32.@)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000124 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000125BOOL WINAPI BeginPath(HDC hdc)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000126{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000127 BOOL ret = TRUE;
128 DC *dc = DC_GetDCPtr( hdc );
Vincent Béron9a624912002-05-31 23:06:46 +0000129
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000130 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000131
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000132 if(dc->funcs->pBeginPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000133 ret = dc->funcs->pBeginPath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000134 else
135 {
136 /* If path is already open, do nothing */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000137 if(dc->path.state != PATH_Open)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000138 {
139 /* Make sure that path is empty */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000140 PATH_EmptyPath(&dc->path);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000141
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000142 /* Initialize variables for new path */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000143 dc->path.newStroke=TRUE;
144 dc->path.state=PATH_Open;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000145 }
146 }
147 GDI_ReleaseObj( hdc );
148 return ret;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000149}
150
151
152/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000153 * EndPath (GDI32.@)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000154 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000155BOOL WINAPI EndPath(HDC hdc)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000156{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000157 BOOL ret = TRUE;
158 DC *dc = DC_GetDCPtr( hdc );
Vincent Béron9a624912002-05-31 23:06:46 +0000159
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000160 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000161
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000162 if(dc->funcs->pEndPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000163 ret = dc->funcs->pEndPath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000164 else
165 {
166 /* Check that path is currently being constructed */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000167 if(dc->path.state!=PATH_Open)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000168 {
169 SetLastError(ERROR_CAN_NOT_COMPLETE);
170 ret = FALSE;
171 }
172 /* Set flag to indicate that path is finished */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000173 else dc->path.state=PATH_Closed;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000174 }
175 GDI_ReleaseObj( hdc );
176 return ret;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000177}
178
179
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000180/******************************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000181 * AbortPath [GDI32.@]
Alexandre Julliard46ea8b31998-05-03 19:01:20 +0000182 * Closes and discards paths from device context
183 *
184 * NOTES
185 * Check that SetLastError is being called correctly
186 *
187 * PARAMS
188 * hdc [I] Handle to device context
189 *
190 * RETURNS STD
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000191 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000192BOOL WINAPI AbortPath( HDC hdc )
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000193{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000194 BOOL ret = TRUE;
195 DC *dc = DC_GetDCPtr( hdc );
Vincent Béron9a624912002-05-31 23:06:46 +0000196
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000197 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000198
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000199 if(dc->funcs->pAbortPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000200 ret = dc->funcs->pAbortPath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000201 else /* Remove all entries from the path */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000202 PATH_EmptyPath( &dc->path );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000203 GDI_ReleaseObj( hdc );
204 return ret;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000205}
206
207
208/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000209 * CloseFigure (GDI32.@)
Alexandre Julliard829fe321998-07-26 14:27:39 +0000210 *
Vincent Béron9a624912002-05-31 23:06:46 +0000211 * FIXME: Check that SetLastError is being called correctly
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000212 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000213BOOL WINAPI CloseFigure(HDC hdc)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000214{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000215 BOOL ret = TRUE;
216 DC *dc = DC_GetDCPtr( hdc );
Vincent Béron9a624912002-05-31 23:06:46 +0000217
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000218 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000219
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000220 if(dc->funcs->pCloseFigure)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000221 ret = dc->funcs->pCloseFigure(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000222 else
223 {
224 /* Check that path is open */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000225 if(dc->path.state!=PATH_Open)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000226 {
227 SetLastError(ERROR_CAN_NOT_COMPLETE);
228 ret = FALSE;
229 }
230 else
231 {
232 /* FIXME: Shouldn't we draw a line to the beginning of the
233 figure? */
234 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000235 if(dc->path.numEntriesUsed)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000236 {
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000237 dc->path.pFlags[dc->path.numEntriesUsed-1]|=PT_CLOSEFIGURE;
238 dc->path.newStroke=TRUE;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000239 }
240 }
241 }
242 GDI_ReleaseObj( hdc );
243 return ret;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000244}
245
246
247/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000248 * GetPath (GDI32.@)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000249 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000250INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes,
251 INT nSize)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000252{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000253 INT ret = -1;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000254 GdiPath *pPath;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000255 DC *dc = DC_GetDCPtr( hdc );
Vincent Béron9a624912002-05-31 23:06:46 +0000256
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000257 if(!dc) return -1;
Vincent Béron9a624912002-05-31 23:06:46 +0000258
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000259 pPath = &dc->path;
Vincent Béron9a624912002-05-31 23:06:46 +0000260
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000261 /* Check that path is closed */
262 if(pPath->state!=PATH_Closed)
263 {
264 SetLastError(ERROR_CAN_NOT_COMPLETE);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000265 goto done;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000266 }
Vincent Béron9a624912002-05-31 23:06:46 +0000267
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000268 if(nSize==0)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000269 ret = pPath->numEntriesUsed;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000270 else if(nSize<pPath->numEntriesUsed)
271 {
272 SetLastError(ERROR_INVALID_PARAMETER);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000273 goto done;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000274 }
275 else
276 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000277 memcpy(pPoints, pPath->pPoints, sizeof(POINT)*pPath->numEntriesUsed);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000278 memcpy(pTypes, pPath->pFlags, sizeof(BYTE)*pPath->numEntriesUsed);
279
280 /* Convert the points to logical coordinates */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000281 if(!DPtoLP(hdc, pPoints, pPath->numEntriesUsed))
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000282 {
283 /* FIXME: Is this the correct value? */
284 SetLastError(ERROR_CAN_NOT_COMPLETE);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000285 goto done;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000286 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000287 else ret = pPath->numEntriesUsed;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000288 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000289 done:
290 GDI_ReleaseObj( hdc );
291 return ret;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000292}
293
294
295/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000296 * PathToRegion (GDI32.@)
Alexandre Julliard829fe321998-07-26 14:27:39 +0000297 *
Vincent Béron9a624912002-05-31 23:06:46 +0000298 * FIXME
299 * Check that SetLastError is being called correctly
Alexandre Julliard829fe321998-07-26 14:27:39 +0000300 *
301 * The documentation does not state this explicitly, but a test under Windows
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000302 * shows that the region which is returned should be in device coordinates.
303 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000304HRGN WINAPI PathToRegion(HDC hdc)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000305{
306 GdiPath *pPath;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000307 HRGN hrgnRval = 0;
308 DC *dc = DC_GetDCPtr( hdc );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000309
310 /* Get pointer to path */
Alexandre Julliard1c4b5c42002-08-16 00:42:06 +0000311 if(!dc) return 0;
Vincent Béron9a624912002-05-31 23:06:46 +0000312
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000313 pPath = &dc->path;
Vincent Béron9a624912002-05-31 23:06:46 +0000314
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000315 /* Check that path is closed */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000316 if(pPath->state!=PATH_Closed) SetLastError(ERROR_CAN_NOT_COMPLETE);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000317 else
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000318 {
319 /* FIXME: Should we empty the path even if conversion failed? */
320 if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnRval))
321 PATH_EmptyPath(pPath);
322 else
323 hrgnRval=0;
324 }
325 GDI_ReleaseObj( hdc );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000326 return hrgnRval;
327}
328
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000329static BOOL PATH_FillPath(DC *dc, GdiPath *pPath)
Patrik Stridvall900290a1999-10-24 21:32:43 +0000330{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000331 INT mapMode, graphicsMode;
332 SIZE ptViewportExt, ptWindowExt;
333 POINT ptViewportOrg, ptWindowOrg;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000334 XFORM xform;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000335 HRGN hrgn;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000336
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000337 if(dc->funcs->pFillPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000338 return dc->funcs->pFillPath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000339
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000340 /* Check that path is closed */
341 if(pPath->state!=PATH_Closed)
342 {
343 SetLastError(ERROR_CAN_NOT_COMPLETE);
344 return FALSE;
345 }
Vincent Béron9a624912002-05-31 23:06:46 +0000346
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000347 /* Construct a region from the path and fill it */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000348 if(PATH_PathToRegion(pPath, dc->polyFillMode, &hrgn))
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000349 {
350 /* Since PaintRgn interprets the region as being in logical coordinates
351 * but the points we store for the path are already in device
352 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000353 * Using SaveDC to save information about the mapping mode / world
354 * transform would be easier but would require more overhead, especially
355 * now that SaveDC saves the current path.
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000356 */
Vincent Béron9a624912002-05-31 23:06:46 +0000357
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000358 /* Save the information about the old mapping mode */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000359 mapMode=GetMapMode(dc->hSelf);
360 GetViewportExtEx(dc->hSelf, &ptViewportExt);
361 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
362 GetWindowExtEx(dc->hSelf, &ptWindowExt);
363 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
Vincent Béron9a624912002-05-31 23:06:46 +0000364
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000365 /* Save world transform
366 * NB: The Windows documentation on world transforms would lead one to
367 * believe that this has to be done only in GM_ADVANCED; however, my
368 * tests show that resetting the graphics mode to GM_COMPATIBLE does
369 * not reset the world transform.
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000370 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000371 GetWorldTransform(dc->hSelf, &xform);
Vincent Béron9a624912002-05-31 23:06:46 +0000372
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000373 /* Set MM_TEXT */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000374 SetMapMode(dc->hSelf, MM_TEXT);
375 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
376 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000377
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000378 /* Paint the region */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000379 PaintRgn(dc->hSelf, hrgn);
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000380 DeleteObject(hrgn);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000381 /* Restore the old mapping mode */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000382 SetMapMode(dc->hSelf, mapMode);
383 SetViewportExtEx(dc->hSelf, ptViewportExt.cx, ptViewportExt.cy, NULL);
384 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
385 SetWindowExtEx(dc->hSelf, ptWindowExt.cx, ptWindowExt.cy, NULL);
386 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000387
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000388 /* Go to GM_ADVANCED temporarily to restore the world transform */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000389 graphicsMode=GetGraphicsMode(dc->hSelf);
390 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
391 SetWorldTransform(dc->hSelf, &xform);
392 SetGraphicsMode(dc->hSelf, graphicsMode);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000393 return TRUE;
394 }
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000395 return FALSE;
396}
397
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000398
399/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000400 * FillPath (GDI32.@)
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000401 *
402 * FIXME
Vincent Béron9a624912002-05-31 23:06:46 +0000403 * Check that SetLastError is being called correctly
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000404 */
405BOOL WINAPI FillPath(HDC hdc)
406{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000407 DC *dc = DC_GetDCPtr( hdc );
408 BOOL bRet = FALSE;
Vincent Béron9a624912002-05-31 23:06:46 +0000409
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000410 if(!dc) return FALSE;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +0000411
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000412 if(dc->funcs->pFillPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000413 bRet = dc->funcs->pFillPath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000414 else
415 {
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000416 bRet = PATH_FillPath(dc, &dc->path);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000417 if(bRet)
418 {
419 /* FIXME: Should the path be emptied even if conversion
420 failed? */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000421 PATH_EmptyPath(&dc->path);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000422 }
423 }
424 GDI_ReleaseObj( hdc );
425 return bRet;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000426}
427
428
429/***********************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +0000430 * SelectClipPath (GDI32.@)
Vincent Béron9a624912002-05-31 23:06:46 +0000431 * FIXME
432 * Check that SetLastError is being called correctly
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000433 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000434BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000435{
436 GdiPath *pPath;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000437 HRGN hrgnPath;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000438 BOOL success = FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000439 DC *dc = DC_GetDCPtr( hdc );
Vincent Béron9a624912002-05-31 23:06:46 +0000440
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000441 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000442
443 if(dc->funcs->pSelectClipPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +0000444 success = dc->funcs->pSelectClipPath(dc->physDev, iMode);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000445 else
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000446 {
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000447 pPath = &dc->path;
Vincent Béron9a624912002-05-31 23:06:46 +0000448
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000449 /* Check that path is closed */
450 if(pPath->state!=PATH_Closed)
451 SetLastError(ERROR_CAN_NOT_COMPLETE);
452 /* Construct a region from the path */
453 else if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnPath))
454 {
455 success = ExtSelectClipRgn( hdc, hrgnPath, iMode ) != ERROR;
456 DeleteObject(hrgnPath);
457
458 /* Empty the path */
459 if(success)
460 PATH_EmptyPath(pPath);
461 /* FIXME: Should this function delete the path even if it failed? */
462 }
463 }
464 GDI_ReleaseObj( hdc );
465 return success;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000466}
467
468
469/***********************************************************************
470 * Exported functions
471 */
472
473/* PATH_InitGdiPath
474 *
475 * Initializes the GdiPath structure.
476 */
477void PATH_InitGdiPath(GdiPath *pPath)
478{
479 assert(pPath!=NULL);
480
481 pPath->state=PATH_Null;
482 pPath->pPoints=NULL;
483 pPath->pFlags=NULL;
484 pPath->numEntriesUsed=0;
485 pPath->numEntriesAllocated=0;
486}
487
488/* PATH_DestroyGdiPath
489 *
490 * Destroys a GdiPath structure (frees the memory in the arrays).
491 */
492void PATH_DestroyGdiPath(GdiPath *pPath)
493{
494 assert(pPath!=NULL);
495
Rob Farnumebe78312000-05-05 18:25:29 +0000496 if (pPath->pPoints) HeapFree( GetProcessHeap(), 0, pPath->pPoints );
497 if (pPath->pFlags) HeapFree( GetProcessHeap(), 0, pPath->pFlags );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000498}
499
500/* PATH_AssignGdiPath
501 *
502 * Copies the GdiPath structure "pPathSrc" to "pPathDest". A deep copy is
503 * performed, i.e. the contents of the pPoints and pFlags arrays are copied,
504 * not just the pointers. Since this means that the arrays in pPathDest may
505 * need to be resized, pPathDest should have been initialized using
506 * PATH_InitGdiPath (in C++, this function would be an assignment operator,
507 * not a copy constructor).
508 * Returns TRUE if successful, else FALSE.
509 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000510BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000511{
512 assert(pPathDest!=NULL && pPathSrc!=NULL);
513
514 /* Make sure destination arrays are big enough */
515 if(!PATH_ReserveEntries(pPathDest, pPathSrc->numEntriesUsed))
516 return FALSE;
517
518 /* Perform the copy operation */
519 memcpy(pPathDest->pPoints, pPathSrc->pPoints,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000520 sizeof(POINT)*pPathSrc->numEntriesUsed);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000521 memcpy(pPathDest->pFlags, pPathSrc->pFlags,
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000522 sizeof(BYTE)*pPathSrc->numEntriesUsed);
523
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000524 pPathDest->state=pPathSrc->state;
525 pPathDest->numEntriesUsed=pPathSrc->numEntriesUsed;
526 pPathDest->newStroke=pPathSrc->newStroke;
527
528 return TRUE;
529}
530
531/* PATH_MoveTo
532 *
533 * Should be called when a MoveTo is performed on a DC that has an
534 * open path. This starts a new stroke. Returns TRUE if successful, else
535 * FALSE.
536 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000537BOOL PATH_MoveTo(DC *dc)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000538{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000539 GdiPath *pPath = &dc->path;
Vincent Béron9a624912002-05-31 23:06:46 +0000540
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000541 /* Check that path is open */
542 if(pPath->state!=PATH_Open)
543 /* FIXME: Do we have to call SetLastError? */
544 return FALSE;
545
546 /* Start a new stroke */
547 pPath->newStroke=TRUE;
548
549 return TRUE;
550}
551
552/* PATH_LineTo
553 *
554 * Should be called when a LineTo is performed on a DC that has an
555 * open path. This adds a PT_LINETO entry to the path (and possibly
556 * a PT_MOVETO entry, if this is the first LineTo in a stroke).
557 * Returns TRUE if successful, else FALSE.
558 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000559BOOL PATH_LineTo(DC *dc, INT x, INT y)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000560{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000561 GdiPath *pPath = &dc->path;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000562 POINT point, pointCurPos;
Vincent Béron9a624912002-05-31 23:06:46 +0000563
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000564 /* Check that path is open */
565 if(pPath->state!=PATH_Open)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000566 return FALSE;
567
568 /* Convert point to device coordinates */
569 point.x=x;
570 point.y=y;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000571 if(!LPtoDP(dc->hSelf, &point, 1))
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000572 return FALSE;
Vincent Béron9a624912002-05-31 23:06:46 +0000573
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000574 /* Add a PT_MOVETO if necessary */
575 if(pPath->newStroke)
576 {
577 pPath->newStroke=FALSE;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000578 pointCurPos.x = dc->CursPosX;
579 pointCurPos.y = dc->CursPosY;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000580 if(!LPtoDP(dc->hSelf, &pointCurPos, 1))
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000581 return FALSE;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000582 if(!PATH_AddEntry(pPath, &pointCurPos, PT_MOVETO))
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000583 return FALSE;
584 }
Vincent Béron9a624912002-05-31 23:06:46 +0000585
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000586 /* Add a PT_LINETO entry */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000587 return PATH_AddEntry(pPath, &point, PT_LINETO);
588}
589
Mark Dufour704c6752000-11-01 02:12:52 +0000590/* PATH_RoundRect
591 *
592 * Should be called when a call to RoundRect is performed on a DC that has
593 * an open path. Returns TRUE if successful, else FALSE.
594 *
Vincent Béron9a624912002-05-31 23:06:46 +0000595 * FIXME: it adds the same entries to the path as windows does, but there
Mark Dufour704c6752000-11-01 02:12:52 +0000596 * is an error in the bezier drawing code so that there are small pixel-size
597 * gaps when the resulting path is drawn by StrokePath()
598 */
599BOOL PATH_RoundRect(DC *dc, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height)
600{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000601 GdiPath *pPath = &dc->path;
Mark Dufour704c6752000-11-01 02:12:52 +0000602 POINT corners[2], pointTemp;
603 FLOAT_POINT ellCorners[2];
Vincent Béron9a624912002-05-31 23:06:46 +0000604
Mark Dufour704c6752000-11-01 02:12:52 +0000605 /* Check that path is open */
606 if(pPath->state!=PATH_Open)
607 return FALSE;
608
609 if(!PATH_CheckCorners(dc,corners,x1,y1,x2,y2))
610 return FALSE;
611
Vincent Béron9a624912002-05-31 23:06:46 +0000612 /* Add points to the roundrect path */
Mark Dufour704c6752000-11-01 02:12:52 +0000613 ellCorners[0].x = corners[1].x-ell_width;
Vincent Béron9a624912002-05-31 23:06:46 +0000614 ellCorners[0].y = corners[0].y;
615 ellCorners[1].x = corners[1].x;
616 ellCorners[1].y = corners[0].y+ell_height;
Mark Dufour704c6752000-11-01 02:12:52 +0000617 if(!PATH_DoArcPart(pPath, ellCorners, 0, -M_PI_2, TRUE))
618 return FALSE;
619 pointTemp.x = corners[0].x+ell_width/2;
620 pointTemp.y = corners[0].y;
621 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
622 return FALSE;
623 ellCorners[0].x = corners[0].x;
624 ellCorners[1].x = corners[0].x+ell_width;
625 if(!PATH_DoArcPart(pPath, ellCorners, -M_PI_2, -M_PI, FALSE))
626 return FALSE;
627 pointTemp.x = corners[0].x;
628 pointTemp.y = corners[1].y-ell_height/2;
629 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
630 return FALSE;
631 ellCorners[0].y = corners[1].y-ell_height;
632 ellCorners[1].y = corners[1].y;
633 if(!PATH_DoArcPart(pPath, ellCorners, M_PI, M_PI_2, FALSE))
634 return FALSE;
635 pointTemp.x = corners[1].x-ell_width/2;
636 pointTemp.y = corners[1].y;
637 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
638 return FALSE;
639 ellCorners[0].x = corners[1].x-ell_width;
640 ellCorners[1].x = corners[1].x;
641 if(!PATH_DoArcPart(pPath, ellCorners, M_PI_2, 0, FALSE))
Vincent Béron9a624912002-05-31 23:06:46 +0000642 return FALSE;
643
Mark Dufour704c6752000-11-01 02:12:52 +0000644 /* Close the roundrect figure */
645 if(!CloseFigure(dc->hSelf))
646 return FALSE;
647
648 return TRUE;
649}
650
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000651/* PATH_Rectangle
652 *
653 * Should be called when a call to Rectangle is performed on a DC that has
654 * an open path. Returns TRUE if successful, else FALSE.
655 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000656BOOL PATH_Rectangle(DC *dc, INT x1, INT y1, INT x2, INT y2)
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000657{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000658 GdiPath *pPath = &dc->path;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000659 POINT corners[2], pointTemp;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000660
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000661 /* Check that path is open */
662 if(pPath->state!=PATH_Open)
663 return FALSE;
664
Mark Dufour704c6752000-11-01 02:12:52 +0000665 if(!PATH_CheckCorners(dc,corners,x1,y1,x2,y2))
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000666 return FALSE;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000667
668 /* Close any previous figure */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000669 if(!CloseFigure(dc->hSelf))
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000670 {
671 /* The CloseFigure call shouldn't have failed */
672 assert(FALSE);
673 return FALSE;
674 }
675
676 /* Add four points to the path */
677 pointTemp.x=corners[1].x;
678 pointTemp.y=corners[0].y;
679 if(!PATH_AddEntry(pPath, &pointTemp, PT_MOVETO))
680 return FALSE;
681 if(!PATH_AddEntry(pPath, corners, PT_LINETO))
682 return FALSE;
683 pointTemp.x=corners[0].x;
684 pointTemp.y=corners[1].y;
685 if(!PATH_AddEntry(pPath, &pointTemp, PT_LINETO))
686 return FALSE;
687 if(!PATH_AddEntry(pPath, corners+1, PT_LINETO))
688 return FALSE;
689
690 /* Close the rectangle figure */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000691 if(!CloseFigure(dc->hSelf))
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000692 {
693 /* The CloseFigure call shouldn't have failed */
694 assert(FALSE);
695 return FALSE;
696 }
697
698 return TRUE;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000699}
700
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000701/* PATH_Ellipse
Vincent Béron9a624912002-05-31 23:06:46 +0000702 *
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000703 * Should be called when a call to Ellipse is performed on a DC that has
704 * an open path. This adds four Bezier splines representing the ellipse
705 * to the path. Returns TRUE if successful, else FALSE.
706 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000707BOOL PATH_Ellipse(DC *dc, INT x1, INT y1, INT x2, INT y2)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000708{
Vincent Béron9a624912002-05-31 23:06:46 +0000709 return( PATH_Arc(dc, x1, y1, x2, y2, x1, (y1+y2)/2, x1, (y1+y2)/2,0) &&
Mark Dufour704c6752000-11-01 02:12:52 +0000710 CloseFigure(dc->hSelf) );
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000711}
712
713/* PATH_Arc
714 *
715 * Should be called when a call to Arc is performed on a DC that has
716 * an open path. This adds up to five Bezier splines representing the arc
Mark Dufour704c6752000-11-01 02:12:52 +0000717 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
718 * and when 'lines' is 2, we add 2 extra lines to get a pie.
719 * Returns TRUE if successful, else FALSE.
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000720 */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000721BOOL PATH_Arc(DC *dc, INT x1, INT y1, INT x2, INT y2,
Mark Dufour704c6752000-11-01 02:12:52 +0000722 INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000723{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000724 GdiPath *pPath = &dc->path;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000725 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
726 /* Initialize angleEndQuadrant to silence gcc's warning */
727 double x, y;
728 FLOAT_POINT corners[2], pointStart, pointEnd;
Mark Dufour704c6752000-11-01 02:12:52 +0000729 POINT centre;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000730 BOOL start, end;
731 INT temp;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000732
733 /* FIXME: This function should check for all possible error returns */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000734 /* FIXME: Do we have to respect newStroke? */
Vincent Béron9a624912002-05-31 23:06:46 +0000735
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000736 /* Check that path is open */
737 if(pPath->state!=PATH_Open)
738 return FALSE;
739
740 /* Check for zero height / width */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000741 /* FIXME: Only in GM_COMPATIBLE? */
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000742 if(x1==x2 || y1==y2)
743 return TRUE;
Vincent Béron9a624912002-05-31 23:06:46 +0000744
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000745 /* Convert points to device coordinates */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000746 corners[0].x=(FLOAT)x1;
747 corners[0].y=(FLOAT)y1;
748 corners[1].x=(FLOAT)x2;
749 corners[1].y=(FLOAT)y2;
750 pointStart.x=(FLOAT)xStart;
751 pointStart.y=(FLOAT)yStart;
752 pointEnd.x=(FLOAT)xEnd;
753 pointEnd.y=(FLOAT)yEnd;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000754 INTERNAL_LPTODP_FLOAT(dc, corners);
755 INTERNAL_LPTODP_FLOAT(dc, corners+1);
756 INTERNAL_LPTODP_FLOAT(dc, &pointStart);
757 INTERNAL_LPTODP_FLOAT(dc, &pointEnd);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000758
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000759 /* Make sure first corner is top left and second corner is bottom right */
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000760 if(corners[0].x>corners[1].x)
761 {
762 temp=corners[0].x;
763 corners[0].x=corners[1].x;
764 corners[1].x=temp;
765 }
766 if(corners[0].y>corners[1].y)
767 {
768 temp=corners[0].y;
769 corners[0].y=corners[1].y;
770 corners[1].y=temp;
771 }
772
773 /* Compute start and end angle */
774 PATH_NormalizePoint(corners, &pointStart, &x, &y);
775 angleStart=atan2(y, x);
776 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
777 angleEnd=atan2(y, x);
778
779 /* Make sure the end angle is "on the right side" of the start angle */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000780 if(dc->ArcDirection==AD_CLOCKWISE)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000781 {
782 if(angleEnd<=angleStart)
783 {
784 angleEnd+=2*M_PI;
785 assert(angleEnd>=angleStart);
786 }
787 }
788 else
789 {
790 if(angleEnd>=angleStart)
791 {
792 angleEnd-=2*M_PI;
793 assert(angleEnd<=angleStart);
794 }
795 }
796
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000797 /* In GM_COMPATIBLE, don't include bottom and right edges */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000798 if(dc->GraphicsMode==GM_COMPATIBLE)
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000799 {
800 corners[1].x--;
801 corners[1].y--;
802 }
Vincent Béron9a624912002-05-31 23:06:46 +0000803
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000804 /* Add the arc to the path with one Bezier spline per quadrant that the
805 * arc spans */
806 start=TRUE;
807 end=FALSE;
808 do
809 {
810 /* Determine the start and end angles for this quadrant */
811 if(start)
812 {
813 angleStartQuadrant=angleStart;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000814 if(dc->ArcDirection==AD_CLOCKWISE)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000815 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
816 else
817 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
818 }
819 else
820 {
821 angleStartQuadrant=angleEndQuadrant;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000822 if(dc->ArcDirection==AD_CLOCKWISE)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000823 angleEndQuadrant+=M_PI_2;
824 else
825 angleEndQuadrant-=M_PI_2;
826 }
827
828 /* Have we reached the last part of the arc? */
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000829 if((dc->ArcDirection==AD_CLOCKWISE &&
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000830 angleEnd<angleEndQuadrant) ||
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000831 (dc->ArcDirection==AD_COUNTERCLOCKWISE &&
Alexandre Julliarddadf78f1998-05-17 17:13:43 +0000832 angleEnd>angleEndQuadrant))
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000833 {
834 /* Adjust the end angle for this quadrant */
835 angleEndQuadrant=angleEnd;
836 end=TRUE;
837 }
838
839 /* Add the Bezier spline to the path */
840 PATH_DoArcPart(pPath, corners, angleStartQuadrant, angleEndQuadrant,
841 start);
842 start=FALSE;
843 } while(!end);
844
Mark Dufour704c6752000-11-01 02:12:52 +0000845 /* chord: close figure. pie: add line and close figure */
846 if(lines==1)
847 {
848 if(!CloseFigure(dc->hSelf))
849 return FALSE;
850 }
851 else if(lines==2)
852 {
Vincent Béron9a624912002-05-31 23:06:46 +0000853 centre.x = (corners[0].x+corners[1].x)/2;
Mark Dufour704c6752000-11-01 02:12:52 +0000854 centre.y = (corners[0].y+corners[1].y)/2;
855 if(!PATH_AddEntry(pPath, &centre, PT_LINETO | PT_CLOSEFIGURE))
856 return FALSE;
857 }
Vincent Béron9a624912002-05-31 23:06:46 +0000858
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000859 return TRUE;
860}
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000861
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000862BOOL PATH_PolyBezierTo(DC *dc, const POINT *pts, DWORD cbPoints)
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000863{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000864 GdiPath *pPath = &dc->path;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000865 POINT pt;
866 INT i;
867
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000868 /* Check that path is open */
869 if(pPath->state!=PATH_Open)
870 return FALSE;
871
872 /* Add a PT_MOVETO if necessary */
873 if(pPath->newStroke)
874 {
875 pPath->newStroke=FALSE;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000876 pt.x = dc->CursPosX;
877 pt.y = dc->CursPosY;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000878 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000879 return FALSE;
880 if(!PATH_AddEntry(pPath, &pt, PT_MOVETO))
881 return FALSE;
882 }
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000883
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000884 for(i = 0; i < cbPoints; i++) {
885 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000886 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000887 return FALSE;
888 PATH_AddEntry(pPath, &pt, PT_BEZIERTO);
889 }
890 return TRUE;
891}
Vincent Béron9a624912002-05-31 23:06:46 +0000892
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000893BOOL PATH_PolyBezier(DC *dc, const POINT *pts, DWORD cbPoints)
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000894{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000895 GdiPath *pPath = &dc->path;
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000896 POINT pt;
897 INT i;
898
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000899 /* Check that path is open */
900 if(pPath->state!=PATH_Open)
901 return FALSE;
902
903 for(i = 0; i < cbPoints; i++) {
904 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000905 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000906 return FALSE;
907 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO : PT_BEZIERTO);
908 }
909 return TRUE;
910}
911
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000912BOOL PATH_Polyline(DC *dc, const POINT *pts, DWORD cbPoints)
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000913{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000914 GdiPath *pPath = &dc->path;
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000915 POINT pt;
916 INT i;
917
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000918 /* Check that path is open */
919 if(pPath->state!=PATH_Open)
920 return FALSE;
921
922 for(i = 0; i < cbPoints; i++) {
923 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000924 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000925 return FALSE;
926 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO : PT_LINETO);
927 }
928 return TRUE;
929}
Vincent Béron9a624912002-05-31 23:06:46 +0000930
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000931BOOL PATH_PolylineTo(DC *dc, const POINT *pts, DWORD cbPoints)
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000932{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000933 GdiPath *pPath = &dc->path;
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000934 POINT pt;
935 INT i;
936
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000937 /* Check that path is open */
938 if(pPath->state!=PATH_Open)
939 return FALSE;
940
941 /* Add a PT_MOVETO if necessary */
942 if(pPath->newStroke)
943 {
944 pPath->newStroke=FALSE;
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000945 pt.x = dc->CursPosX;
946 pt.y = dc->CursPosY;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000947 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000948 return FALSE;
949 if(!PATH_AddEntry(pPath, &pt, PT_MOVETO))
950 return FALSE;
951 }
952
953 for(i = 0; i < cbPoints; i++) {
954 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000955 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000956 return FALSE;
957 PATH_AddEntry(pPath, &pt, PT_LINETO);
958 }
959
960 return TRUE;
961}
962
963
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000964BOOL PATH_Polygon(DC *dc, const POINT *pts, DWORD cbPoints)
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000965{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000966 GdiPath *pPath = &dc->path;
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000967 POINT pt;
968 INT i;
969
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000970 /* Check that path is open */
971 if(pPath->state!=PATH_Open)
972 return FALSE;
973
974 for(i = 0; i < cbPoints; i++) {
975 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000976 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000977 return FALSE;
978 PATH_AddEntry(pPath, &pt, (i == 0) ? PT_MOVETO :
979 ((i == cbPoints-1) ? PT_LINETO | PT_CLOSEFIGURE :
980 PT_LINETO));
981 }
982 return TRUE;
983}
984
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000985BOOL PATH_PolyPolygon( DC *dc, const POINT* pts, const INT* counts,
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000986 UINT polygons )
987{
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000988 GdiPath *pPath = &dc->path;
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000989 POINT pt, startpt;
990 INT poly, point, i;
991
Huw D M Daviesb8e94b61999-12-20 04:14:48 +0000992 /* Check that path is open */
993 if(pPath->state!=PATH_Open)
994 return FALSE;
995
996 for(i = 0, poly = 0; poly < polygons; poly++) {
997 for(point = 0; point < counts[poly]; point++, i++) {
998 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +0000999 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001000 return FALSE;
1001 if(point == 0) startpt = pt;
1002 PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1003 }
1004 /* win98 adds an extra line to close the figure for some reason */
1005 PATH_AddEntry(pPath, &startpt, PT_LINETO | PT_CLOSEFIGURE);
1006 }
1007 return TRUE;
1008}
1009
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001010BOOL PATH_PolyPolyline( DC *dc, const POINT* pts, const DWORD* counts,
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001011 DWORD polylines )
1012{
Alexandre Julliard2239abb2000-11-05 02:05:07 +00001013 GdiPath *pPath = &dc->path;
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001014 POINT pt;
1015 INT poly, point, i;
1016
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001017 /* Check that path is open */
1018 if(pPath->state!=PATH_Open)
1019 return FALSE;
1020
1021 for(i = 0, poly = 0; poly < polylines; poly++) {
1022 for(point = 0; point < counts[poly]; point++, i++) {
1023 pt = pts[i];
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001024 if(!LPtoDP(dc->hSelf, &pt, 1))
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001025 return FALSE;
1026 PATH_AddEntry(pPath, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1027 }
1028 }
1029 return TRUE;
1030}
Vincent Béron9a624912002-05-31 23:06:46 +00001031
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001032/***********************************************************************
1033 * Internal functions
1034 */
1035
Mark Dufour704c6752000-11-01 02:12:52 +00001036/* PATH_CheckCorners
1037 *
Vincent Béron9a624912002-05-31 23:06:46 +00001038 * Helper function for PATH_RoundRect() and PATH_Rectangle()
Mark Dufour704c6752000-11-01 02:12:52 +00001039 */
1040static BOOL PATH_CheckCorners(DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2)
1041{
1042 INT temp;
1043
1044 /* Convert points to device coordinates */
1045 corners[0].x=x1;
1046 corners[0].y=y1;
1047 corners[1].x=x2;
1048 corners[1].y=y2;
1049 if(!LPtoDP(dc->hSelf, corners, 2))
1050 return FALSE;
Vincent Béron9a624912002-05-31 23:06:46 +00001051
Mark Dufour704c6752000-11-01 02:12:52 +00001052 /* Make sure first corner is top left and second corner is bottom right */
1053 if(corners[0].x>corners[1].x)
1054 {
1055 temp=corners[0].x;
1056 corners[0].x=corners[1].x;
1057 corners[1].x=temp;
1058 }
1059 if(corners[0].y>corners[1].y)
1060 {
1061 temp=corners[0].y;
1062 corners[0].y=corners[1].y;
1063 corners[1].y=temp;
1064 }
Vincent Béron9a624912002-05-31 23:06:46 +00001065
Mark Dufour704c6752000-11-01 02:12:52 +00001066 /* In GM_COMPATIBLE, don't include bottom and right edges */
Alexandre Julliard2239abb2000-11-05 02:05:07 +00001067 if(dc->GraphicsMode==GM_COMPATIBLE)
Mark Dufour704c6752000-11-01 02:12:52 +00001068 {
1069 corners[1].x--;
1070 corners[1].y--;
1071 }
1072
1073 return TRUE;
1074}
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001075
1076/* PATH_AddFlatBezier
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001077 */
1078static BOOL PATH_AddFlatBezier(GdiPath *pPath, POINT *pt, BOOL closed)
1079{
1080 POINT *pts;
1081 INT no, i;
1082
1083 pts = GDI_Bezier( pt, 4, &no );
1084 if(!pts) return FALSE;
1085
1086 for(i = 1; i < no; i++)
Vincent Béron9a624912002-05-31 23:06:46 +00001087 PATH_AddEntry(pPath, &pts[i],
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001088 (i == no-1 && closed) ? PT_LINETO | PT_CLOSEFIGURE : PT_LINETO);
1089 HeapFree( GetProcessHeap(), 0, pts );
1090 return TRUE;
1091}
1092
1093/* PATH_FlattenPath
1094 *
1095 * Replaces Beziers with line segments
1096 *
1097 */
1098static BOOL PATH_FlattenPath(GdiPath *pPath)
1099{
1100 GdiPath newPath;
1101 INT srcpt;
1102
1103 memset(&newPath, 0, sizeof(newPath));
1104 newPath.state = PATH_Open;
1105 for(srcpt = 0; srcpt < pPath->numEntriesUsed; srcpt++) {
1106 switch(pPath->pFlags[srcpt] & ~PT_CLOSEFIGURE) {
1107 case PT_MOVETO:
1108 case PT_LINETO:
1109 PATH_AddEntry(&newPath, &pPath->pPoints[srcpt],
1110 pPath->pFlags[srcpt]);
1111 break;
1112 case PT_BEZIERTO:
1113 PATH_AddFlatBezier(&newPath, &pPath->pPoints[srcpt-1],
1114 pPath->pFlags[srcpt+2] & PT_CLOSEFIGURE);
1115 srcpt += 2;
1116 break;
1117 }
1118 }
1119 newPath.state = PATH_Closed;
1120 PATH_AssignGdiPath(pPath, &newPath);
1121 PATH_EmptyPath(&newPath);
1122 return TRUE;
1123}
Vincent Béron9a624912002-05-31 23:06:46 +00001124
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001125/* PATH_PathToRegion
1126 *
1127 * Creates a region from the specified path using the specified polygon
1128 * filling mode. The path is left unchanged. A handle to the region that
1129 * was created is stored in *pHrgn. If successful, TRUE is returned; if an
1130 * error occurs, SetLastError is called with the appropriate value and
1131 * FALSE is returned.
1132 */
Niels Kristian Bech Jensenc9742b32000-03-28 20:44:59 +00001133static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001134 HRGN *pHrgn)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001135{
1136 int numStrokes, iStroke, i;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001137 INT *pNumPointsInStroke;
1138 HRGN hrgn;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001139
1140 assert(pPath!=NULL);
1141 assert(pHrgn!=NULL);
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001142
Niels Kristian Bech Jensenc9742b32000-03-28 20:44:59 +00001143 PATH_FlattenPath(pPath);
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001144
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001145 /* FIXME: What happens when number of points is zero? */
Vincent Béron9a624912002-05-31 23:06:46 +00001146
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001147 /* First pass: Find out how many strokes there are in the path */
1148 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
1149 numStrokes=0;
1150 for(i=0; i<pPath->numEntriesUsed; i++)
1151 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
1152 numStrokes++;
1153
1154 /* Allocate memory for number-of-points-in-stroke array */
Vincent Béron9a624912002-05-31 23:06:46 +00001155 pNumPointsInStroke=(int *)HeapAlloc( GetProcessHeap(), 0,
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001156 sizeof(int) * numStrokes );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001157 if(!pNumPointsInStroke)
1158 {
1159 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1160 return FALSE;
1161 }
Vincent Béron9a624912002-05-31 23:06:46 +00001162
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001163 /* Second pass: remember number of points in each polygon */
1164 iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
1165 for(i=0; i<pPath->numEntriesUsed; i++)
1166 {
1167 /* Is this the beginning of a new stroke? */
1168 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
1169 {
1170 iStroke++;
1171 pNumPointsInStroke[iStroke]=0;
1172 }
1173
1174 pNumPointsInStroke[iStroke]++;
1175 }
1176
1177 /* Create a region from the strokes */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001178 hrgn=CreatePolyPolygonRgn(pPath->pPoints, pNumPointsInStroke,
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001179 numStrokes, nPolyFillMode);
Alexandre Julliarda5755b12002-06-13 23:54:55 +00001180
1181 /* Free memory for number-of-points-in-stroke array */
1182 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
1183
Francois Gougetd2667a42002-12-02 18:10:57 +00001184 if(hrgn==NULL)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001185 {
1186 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1187 return FALSE;
1188 }
1189
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001190 /* Success! */
1191 *pHrgn=hrgn;
1192 return TRUE;
1193}
1194
1195/* PATH_EmptyPath
1196 *
1197 * Removes all entries from the path and sets the path state to PATH_Null.
1198 */
1199static void PATH_EmptyPath(GdiPath *pPath)
1200{
1201 assert(pPath!=NULL);
1202
1203 pPath->state=PATH_Null;
1204 pPath->numEntriesUsed=0;
1205}
1206
1207/* PATH_AddEntry
1208 *
1209 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
1210 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
1211 * successful, FALSE otherwise (e.g. if not enough memory was available).
1212 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001213BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint, BYTE flags)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001214{
1215 assert(pPath!=NULL);
Vincent Béron9a624912002-05-31 23:06:46 +00001216
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001217 /* FIXME: If newStroke is true, perhaps we want to check that we're
1218 * getting a PT_MOVETO
1219 */
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001220 TRACE("(%ld,%ld) - %d\n", pPoint->x, pPoint->y, flags);
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001221
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001222 /* Check that path is open */
1223 if(pPath->state!=PATH_Open)
1224 return FALSE;
Vincent Béron9a624912002-05-31 23:06:46 +00001225
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001226 /* Reserve enough memory for an extra path entry */
1227 if(!PATH_ReserveEntries(pPath, pPath->numEntriesUsed+1))
1228 return FALSE;
1229
1230 /* Store information in path entry */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001231 pPath->pPoints[pPath->numEntriesUsed]=*pPoint;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001232 pPath->pFlags[pPath->numEntriesUsed]=flags;
1233
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001234 /* If this is PT_CLOSEFIGURE, we have to start a new stroke next time */
1235 if((flags & PT_CLOSEFIGURE) == PT_CLOSEFIGURE)
1236 pPath->newStroke=TRUE;
1237
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001238 /* Increment entry count */
1239 pPath->numEntriesUsed++;
1240
1241 return TRUE;
1242}
1243
1244/* PATH_ReserveEntries
1245 *
1246 * Ensures that at least "numEntries" entries (for points and flags) have
1247 * been allocated; allocates larger arrays and copies the existing entries
1248 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
1249 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001250static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001251{
Alexandre Julliarda3960291999-02-26 11:11:13 +00001252 INT numEntriesToAllocate;
1253 POINT *pPointsNew;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001254 BYTE *pFlagsNew;
Vincent Béron9a624912002-05-31 23:06:46 +00001255
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001256 assert(pPath!=NULL);
1257 assert(numEntries>=0);
1258
1259 /* Do we have to allocate more memory? */
1260 if(numEntries > pPath->numEntriesAllocated)
1261 {
1262 /* Find number of entries to allocate. We let the size of the array
1263 * grow exponentially, since that will guarantee linear time
1264 * complexity. */
1265 if(pPath->numEntriesAllocated)
1266 {
1267 numEntriesToAllocate=pPath->numEntriesAllocated;
1268 while(numEntriesToAllocate<numEntries)
1269 numEntriesToAllocate=numEntriesToAllocate*GROW_FACTOR_NUMER/
1270 GROW_FACTOR_DENOM;
1271 }
1272 else
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001273 numEntriesToAllocate=numEntries;
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001274
1275 /* Allocate new arrays */
Vincent Béron9a624912002-05-31 23:06:46 +00001276 pPointsNew=(POINT *)HeapAlloc( GetProcessHeap(), 0,
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001277 numEntriesToAllocate * sizeof(POINT) );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001278 if(!pPointsNew)
1279 return FALSE;
Vincent Béron9a624912002-05-31 23:06:46 +00001280 pFlagsNew=(BYTE *)HeapAlloc( GetProcessHeap(), 0,
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001281 numEntriesToAllocate * sizeof(BYTE) );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001282 if(!pFlagsNew)
1283 {
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001284 HeapFree( GetProcessHeap(), 0, pPointsNew );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001285 return FALSE;
1286 }
1287
1288 /* Copy old arrays to new arrays and discard old arrays */
1289 if(pPath->pPoints)
1290 {
1291 assert(pPath->pFlags);
1292
1293 memcpy(pPointsNew, pPath->pPoints,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001294 sizeof(POINT)*pPath->numEntriesUsed);
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001295 memcpy(pFlagsNew, pPath->pFlags,
1296 sizeof(BYTE)*pPath->numEntriesUsed);
1297
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001298 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
1299 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00001300 }
1301 pPath->pPoints=pPointsNew;
1302 pPath->pFlags=pFlagsNew;
1303 pPath->numEntriesAllocated=numEntriesToAllocate;
1304 }
1305
1306 return TRUE;
1307}
1308
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001309/* PATH_DoArcPart
1310 *
1311 * Creates a Bezier spline that corresponds to part of an arc and appends the
1312 * corresponding points to the path. The start and end angles are passed in
1313 * "angleStart" and "angleEnd"; these angles should span a quarter circle
1314 * at most. If "addMoveTo" is true, a PT_MOVETO entry for the first control
1315 * point is added to the path; otherwise, it is assumed that the current
1316 * position is equal to the first control point.
1317 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001318static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
1319 double angleStart, double angleEnd, BOOL addMoveTo)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001320{
1321 double halfAngle, a;
1322 double xNorm[4], yNorm[4];
Alexandre Julliarda3960291999-02-26 11:11:13 +00001323 POINT point;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001324 int i;
1325
1326 assert(fabs(angleEnd-angleStart)<=M_PI_2);
1327
1328 /* FIXME: Is there an easier way of computing this? */
1329
1330 /* Compute control points */
1331 halfAngle=(angleEnd-angleStart)/2.0;
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001332 if(fabs(halfAngle)>1e-8)
1333 {
1334 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
1335 xNorm[0]=cos(angleStart);
1336 yNorm[0]=sin(angleStart);
1337 xNorm[1]=xNorm[0] - a*yNorm[0];
1338 yNorm[1]=yNorm[0] + a*xNorm[0];
1339 xNorm[3]=cos(angleEnd);
1340 yNorm[3]=sin(angleEnd);
1341 xNorm[2]=xNorm[3] + a*yNorm[3];
1342 yNorm[2]=yNorm[3] - a*xNorm[3];
1343 }
1344 else
1345 for(i=0; i<4; i++)
1346 {
1347 xNorm[i]=cos(angleStart);
1348 yNorm[i]=sin(angleStart);
1349 }
Vincent Béron9a624912002-05-31 23:06:46 +00001350
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001351 /* Add starting point to path if desired */
1352 if(addMoveTo)
1353 {
1354 PATH_ScaleNormalizedPoint(corners, xNorm[0], yNorm[0], &point);
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001355 if(!PATH_AddEntry(pPath, &point, PT_MOVETO))
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001356 return FALSE;
1357 }
1358
1359 /* Add remaining control points */
1360 for(i=1; i<4; i++)
1361 {
1362 PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &point);
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001363 if(!PATH_AddEntry(pPath, &point, PT_BEZIERTO))
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001364 return FALSE;
1365 }
1366
1367 return TRUE;
1368}
1369
1370/* PATH_ScaleNormalizedPoint
1371 *
1372 * Scales a normalized point (x, y) with respect to the box whose corners are
1373 * passed in "corners". The point is stored in "*pPoint". The normalized
1374 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
1375 * (1.0, 1.0) correspond to corners[1].
1376 */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001377static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001378 double y, POINT *pPoint)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001379{
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001380 pPoint->x=GDI_ROUND( (double)corners[0].x +
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001381 (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001382 pPoint->y=GDI_ROUND( (double)corners[0].y +
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001383 (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
1384}
1385
1386/* PATH_NormalizePoint
1387 *
1388 * Normalizes a point with respect to the box whose corners are passed in
1389 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
1390 */
Alexandre Julliarddadf78f1998-05-17 17:13:43 +00001391static void PATH_NormalizePoint(FLOAT_POINT corners[],
1392 const FLOAT_POINT *pPoint,
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001393 double *pX, double *pY)
1394{
1395 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) *
1396 2.0 - 1.0;
1397 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) *
1398 2.0 - 1.0;
1399}
Paul Quinn1beaae51998-12-15 15:38:36 +00001400
Patrik Stridvall900290a1999-10-24 21:32:43 +00001401
1402/*******************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +00001403 * FlattenPath [GDI32.@]
Paul Quinn1beaae51998-12-15 15:38:36 +00001404 *
1405 *
1406 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001407BOOL WINAPI FlattenPath(HDC hdc)
Paul Quinn1beaae51998-12-15 15:38:36 +00001408{
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001409 BOOL ret = FALSE;
1410 DC *dc = DC_GetDCPtr( hdc );
Huw D M Daviesb8e94b61999-12-20 04:14:48 +00001411
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001412 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001413
Alexandre Julliarde21c15e2002-03-28 22:22:05 +00001414 if(dc->funcs->pFlattenPath) ret = dc->funcs->pFlattenPath(dc->physDev);
Vincent Béron9a624912002-05-31 23:06:46 +00001415 else
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001416 {
Alexandre Julliard2239abb2000-11-05 02:05:07 +00001417 GdiPath *pPath = &dc->path;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001418 if(pPath->state != PATH_Closed)
1419 ret = PATH_FlattenPath(pPath);
1420 }
1421 GDI_ReleaseObj( hdc );
1422 return ret;
Paul Quinn1beaae51998-12-15 15:38:36 +00001423}
1424
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001425
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001426static BOOL PATH_StrokePath(DC *dc, GdiPath *pPath)
Patrik Stridvall900290a1999-10-24 21:32:43 +00001427{
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001428 INT i;
1429 POINT ptLastMove = {0,0};
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001430 POINT ptViewportOrg, ptWindowOrg;
1431 SIZE szViewportExt, szWindowExt;
1432 DWORD mapMode, graphicsMode;
1433 XFORM xform;
1434 BOOL ret = TRUE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001435
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001436 if(dc->funcs->pStrokePath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +00001437 return dc->funcs->pStrokePath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001438
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001439 if(pPath->state != PATH_Closed)
1440 return FALSE;
1441
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001442 /* Save the mapping mode info */
1443 mapMode=GetMapMode(dc->hSelf);
1444 GetViewportExtEx(dc->hSelf, &szViewportExt);
1445 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
1446 GetWindowExtEx(dc->hSelf, &szWindowExt);
1447 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
1448 GetWorldTransform(dc->hSelf, &xform);
Vincent Béron9a624912002-05-31 23:06:46 +00001449
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001450 /* Set MM_TEXT */
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001451 SetMapMode(dc->hSelf, MM_TEXT);
1452 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
1453 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001454
1455
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001456 for(i = 0; i < pPath->numEntriesUsed; i++) {
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001457 switch(pPath->pFlags[i]) {
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001458 case PT_MOVETO:
1459 TRACE("Got PT_MOVETO (%ld, %ld)\n",
1460 pPath->pPoints[i].x, pPath->pPoints[i].y);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001461 MoveToEx(dc->hSelf, pPath->pPoints[i].x, pPath->pPoints[i].y, NULL);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001462 ptLastMove = pPath->pPoints[i];
1463 break;
1464 case PT_LINETO:
1465 case (PT_LINETO | PT_CLOSEFIGURE):
1466 TRACE("Got PT_LINETO (%ld, %ld)\n",
1467 pPath->pPoints[i].x, pPath->pPoints[i].y);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001468 LineTo(dc->hSelf, pPath->pPoints[i].x, pPath->pPoints[i].y);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001469 break;
1470 case PT_BEZIERTO:
1471 TRACE("Got PT_BEZIERTO\n");
Vincent Béron9a624912002-05-31 23:06:46 +00001472 if(pPath->pFlags[i+1] != PT_BEZIERTO ||
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001473 (pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
1474 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001475 ret = FALSE;
1476 goto end;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001477 }
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001478 PolyBezierTo(dc->hSelf, &pPath->pPoints[i], 3);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001479 i += 2;
1480 break;
1481 default:
1482 ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001483 ret = FALSE;
1484 goto end;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001485 }
1486 if(pPath->pFlags[i] & PT_CLOSEFIGURE)
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001487 LineTo(dc->hSelf, ptLastMove.x, ptLastMove.y);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001488 }
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001489
1490 end:
1491
1492 /* Restore the old mapping mode */
1493 SetMapMode(dc->hSelf, mapMode);
1494 SetViewportExtEx(dc->hSelf, szViewportExt.cx, szViewportExt.cy, NULL);
1495 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
1496 SetWindowExtEx(dc->hSelf, szWindowExt.cx, szWindowExt.cy, NULL);
1497 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
1498
1499 /* Go to GM_ADVANCED temporarily to restore the world transform */
1500 graphicsMode=GetGraphicsMode(dc->hSelf);
1501 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
1502 SetWorldTransform(dc->hSelf, &xform);
1503 SetGraphicsMode(dc->hSelf, graphicsMode);
Huw D M Daviesff6bda82002-08-13 18:12:52 +00001504
1505 /* If we've moved the current point then get its new position
1506 which will be in device (MM_TEXT) co-ords, convert it to
1507 logical co-ords and re-set it. This basically updates
1508 dc->CurPosX|Y so that their values are in the correct mapping
1509 mode.
1510 */
1511 if(i > 0) {
1512 POINT pt;
1513 GetCurrentPositionEx(dc->hSelf, &pt);
1514 DPtoLP(dc->hSelf, &pt, 1);
1515 MoveToEx(dc->hSelf, pt.x, pt.y, NULL);
1516 }
Huw D M Davies6e24a0a2001-09-14 21:28:36 +00001517 return ret;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001518}
1519
1520
1521/*******************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +00001522 * StrokeAndFillPath [GDI32.@]
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001523 *
1524 *
1525 */
1526BOOL WINAPI StrokeAndFillPath(HDC hdc)
1527{
1528 DC *dc = DC_GetDCPtr( hdc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001529 BOOL bRet = FALSE;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001530
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001531 if(!dc) return FALSE;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001532
1533 if(dc->funcs->pStrokeAndFillPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +00001534 bRet = dc->funcs->pStrokeAndFillPath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001535 else
1536 {
Alexandre Julliard2239abb2000-11-05 02:05:07 +00001537 bRet = PATH_FillPath(dc, &dc->path);
1538 if(bRet) bRet = PATH_StrokePath(dc, &dc->path);
1539 if(bRet) PATH_EmptyPath(&dc->path);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001540 }
1541 GDI_ReleaseObj( hdc );
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001542 return bRet;
1543}
1544
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001545
1546/*******************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +00001547 * StrokePath [GDI32.@]
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001548 *
1549 *
1550 */
1551BOOL WINAPI StrokePath(HDC hdc)
1552{
1553 DC *dc = DC_GetDCPtr( hdc );
1554 GdiPath *pPath;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001555 BOOL bRet = FALSE;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001556
Alexandre Julliard547cdc22002-11-22 22:16:53 +00001557 TRACE("(%p)\n", hdc);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001558 if(!dc) return FALSE;
Huw D M Daviesa3d3ff82000-04-18 11:54:12 +00001559
1560 if(dc->funcs->pStrokePath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +00001561 bRet = dc->funcs->pStrokePath(dc->physDev);
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001562 else
1563 {
Alexandre Julliard2239abb2000-11-05 02:05:07 +00001564 pPath = &dc->path;
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001565 bRet = PATH_StrokePath(dc, pPath);
1566 PATH_EmptyPath(pPath);
1567 }
1568 GDI_ReleaseObj( hdc );
1569 return bRet;
Paul Quinn1beaae51998-12-15 15:38:36 +00001570}
1571
Patrik Stridvall900290a1999-10-24 21:32:43 +00001572
1573/*******************************************************************
Patrik Stridvalld0a41772001-02-14 23:11:17 +00001574 * WidenPath [GDI32.@]
Paul Quinn1beaae51998-12-15 15:38:36 +00001575 *
1576 *
1577 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001578BOOL WINAPI WidenPath(HDC hdc)
Paul Quinn1beaae51998-12-15 15:38:36 +00001579{
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001580 DC *dc = DC_GetDCPtr( hdc );
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001581 BOOL ret = FALSE;
Vincent Béron9a624912002-05-31 23:06:46 +00001582
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001583 if(!dc) return FALSE;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001584
1585 if(dc->funcs->pWidenPath)
Alexandre Julliarde21c15e2002-03-28 22:22:05 +00001586 ret = dc->funcs->pWidenPath(dc->physDev);
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001587
1588 FIXME("stub\n");
Alexandre Julliard2a2321b2000-08-19 21:38:55 +00001589 GDI_ReleaseObj( hdc );
1590 return ret;
Huw D M Daviesf0f8da51999-12-05 23:54:02 +00001591}