gdiplus: Support GdipSetClipRegion in metafiles.
[wine.git] / dlls / gdi32 / path.c
blob51334b28b466d5a1c3baa7b5ea5b7fc8a13cfcf3
1 /*
2 * Graphics paths (BeginPath, EndPath etc.)
4 * Copyright 1997, 1998 Martin Boehme
5 * 1999 Huw D M Davies
6 * Copyright 2005 Dmitry Timoshkov
7 * Copyright 2011 Alexandre Julliard
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include <assert.h>
28 #include <math.h>
29 #include <stdarg.h>
30 #include <string.h>
31 #include <stdlib.h>
32 #if defined(HAVE_FLOAT_H)
33 #include <float.h>
34 #endif
36 #include "windef.h"
37 #include "winbase.h"
38 #include "wingdi.h"
39 #include "winerror.h"
41 #include "gdi_private.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
46 /* Notes on the implementation
48 * The implementation is based on dynamically resizable arrays of points and
49 * flags. I dithered for a bit before deciding on this implementation, and
50 * I had even done a bit of work on a linked list version before switching
51 * to arrays. It's a bit of a tradeoff. When you use linked lists, the
52 * implementation of FlattenPath is easier, because you can rip the
53 * PT_BEZIERTO entries out of the middle of the list and link the
54 * corresponding PT_LINETO entries in. However, when you use arrays,
55 * PathToRegion becomes easier, since you can essentially just pass your array
56 * of points to CreatePolyPolygonRgn. Also, if I'd used linked lists, I would
57 * have had the extra effort of creating a chunk-based allocation scheme
58 * in order to use memory effectively. That's why I finally decided to use
59 * arrays. Note by the way that the array based implementation has the same
60 * linear time complexity that linked lists would have since the arrays grow
61 * exponentially.
63 * The points are stored in the path in device coordinates. This is
64 * consistent with the way Windows does things (for instance, see the Win32
65 * SDK documentation for GetPath).
67 * The word "stroke" appears in several places (e.g. in the flag
68 * GdiPath.newStroke). A stroke consists of a PT_MOVETO followed by one or
69 * more PT_LINETOs or PT_BEZIERTOs, up to, but not including, the next
70 * PT_MOVETO. Note that this is not the same as the definition of a figure;
71 * a figure can contain several strokes.
73 * Martin Boehme
76 #define NUM_ENTRIES_INITIAL 16 /* Initial size of points / flags arrays */
78 /* A floating point version of the POINT structure */
79 typedef struct tagFLOAT_POINT
81 double x, y;
82 } FLOAT_POINT;
84 struct gdi_path
86 POINT *points;
87 BYTE *flags;
88 int count;
89 int allocated;
90 BOOL newStroke;
91 POINT pos; /* current cursor position */
92 POINT points_buf[NUM_ENTRIES_INITIAL];
93 BYTE flags_buf[NUM_ENTRIES_INITIAL];
96 struct path_physdev
98 struct gdi_physdev dev;
99 struct gdi_path *path;
102 static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
104 return CONTAINING_RECORD( dev, struct path_physdev, dev );
107 void free_gdi_path( struct gdi_path *path )
109 if (path->points != path->points_buf)
110 HeapFree( GetProcessHeap(), 0, path->points );
111 HeapFree( GetProcessHeap(), 0, path );
114 static struct gdi_path *alloc_gdi_path( int count )
116 struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) );
118 if (!path)
120 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
121 return NULL;
123 count = max( NUM_ENTRIES_INITIAL, count );
124 if (count > NUM_ENTRIES_INITIAL)
126 path->points = HeapAlloc( GetProcessHeap(), 0,
127 count * (sizeof(path->points[0]) + sizeof(path->flags[0])) );
128 if (!path->points)
130 HeapFree( GetProcessHeap(), 0, path );
131 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
132 return NULL;
134 path->flags = (BYTE *)(path->points + count);
136 else
138 path->points = path->points_buf;
139 path->flags = path->flags_buf;
141 path->count = 0;
142 path->allocated = count;
143 path->newStroke = TRUE;
144 path->pos.x = path->pos.y = 0;
145 return path;
148 static struct gdi_path *copy_gdi_path( const struct gdi_path *src_path )
150 struct gdi_path *path = alloc_gdi_path( src_path->count );
152 if (!path) return NULL;
154 path->count = src_path->count;
155 path->newStroke = src_path->newStroke;
156 path->pos = src_path->pos;
157 memcpy( path->points, src_path->points, path->count * sizeof(*path->points) );
158 memcpy( path->flags, src_path->flags, path->count * sizeof(*path->flags) );
159 return path;
162 /* Performs a world-to-viewport transformation on the specified point (which
163 * is in floating point format).
165 static inline void INTERNAL_LPTODP_FLOAT( DC *dc, FLOAT_POINT *point, int count )
167 double x, y;
169 while (count--)
171 x = point->x;
172 y = point->y;
173 point->x = x * dc->xformWorld2Vport.eM11 + y * dc->xformWorld2Vport.eM21 + dc->xformWorld2Vport.eDx;
174 point->y = x * dc->xformWorld2Vport.eM12 + y * dc->xformWorld2Vport.eM22 + dc->xformWorld2Vport.eDy;
175 point++;
179 static inline INT int_from_fixed(FIXED f)
181 return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
185 /* PATH_ReserveEntries
187 * Ensures that at least "numEntries" entries (for points and flags) have
188 * been allocated; allocates larger arrays and copies the existing entries
189 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
191 static BOOL PATH_ReserveEntries(struct gdi_path *path, INT count)
193 POINT *pts_new;
194 int size;
196 assert(count>=0);
198 /* Do we have to allocate more memory? */
199 if (count > path->allocated)
201 /* Find number of entries to allocate. We let the size of the array
202 * grow exponentially, since that will guarantee linear time
203 * complexity. */
204 count = max( path->allocated * 2, count );
205 size = count * (sizeof(path->points[0]) + sizeof(path->flags[0]));
207 if (path->points == path->points_buf)
209 pts_new = HeapAlloc( GetProcessHeap(), 0, size );
210 if (!pts_new) return FALSE;
211 memcpy( pts_new, path->points, path->count * sizeof(path->points[0]) );
212 memcpy( pts_new + count, path->flags, path->count * sizeof(path->flags[0]) );
214 else
216 pts_new = HeapReAlloc( GetProcessHeap(), 0, path->points, size );
217 if (!pts_new) return FALSE;
218 memmove( pts_new + count, pts_new + path->allocated, path->count * sizeof(path->flags[0]) );
221 path->points = pts_new;
222 path->flags = (BYTE *)(pts_new + count);
223 path->allocated = count;
225 return TRUE;
228 /* PATH_AddEntry
230 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
231 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
232 * successful, FALSE otherwise (e.g. if not enough memory was available).
234 static BOOL PATH_AddEntry(struct gdi_path *pPath, const POINT *pPoint, BYTE flags)
236 /* FIXME: If newStroke is true, perhaps we want to check that we're
237 * getting a PT_MOVETO
239 TRACE("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags);
241 /* Reserve enough memory for an extra path entry */
242 if(!PATH_ReserveEntries(pPath, pPath->count+1))
243 return FALSE;
245 /* Store information in path entry */
246 pPath->points[pPath->count]=*pPoint;
247 pPath->flags[pPath->count]=flags;
249 pPath->count++;
251 return TRUE;
254 /* add a number of points, converting them to device coords */
255 /* return a pointer to the first type byte so it can be fixed up if necessary */
256 static BYTE *add_log_points( DC *dc, struct gdi_path *path, const POINT *points,
257 DWORD count, BYTE type )
259 BYTE *ret;
261 if (!PATH_ReserveEntries( path, path->count + count )) return NULL;
263 ret = &path->flags[path->count];
264 memcpy( &path->points[path->count], points, count * sizeof(*points) );
265 lp_to_dp( dc, &path->points[path->count], count );
266 memset( ret, type, count );
267 path->count += count;
268 return ret;
271 /* add a number of points that are already in device coords */
272 /* return a pointer to the first type byte so it can be fixed up if necessary */
273 static BYTE *add_points( struct gdi_path *path, const POINT *points, DWORD count, BYTE type )
275 BYTE *ret;
277 if (!PATH_ReserveEntries( path, path->count + count )) return NULL;
279 ret = &path->flags[path->count];
280 memcpy( &path->points[path->count], points, count * sizeof(*points) );
281 memset( ret, type, count );
282 path->count += count;
283 return ret;
286 /* reverse the order of an array of points */
287 static void reverse_points( POINT *points, UINT count )
289 UINT i;
290 for (i = 0; i < count / 2; i++)
292 POINT pt = points[i];
293 points[i] = points[count - i - 1];
294 points[count - i - 1] = pt;
298 /* start a new path stroke if necessary */
299 static BOOL start_new_stroke( struct gdi_path *path )
301 if (!path->newStroke && path->count &&
302 !(path->flags[path->count - 1] & PT_CLOSEFIGURE) &&
303 path->points[path->count - 1].x == path->pos.x &&
304 path->points[path->count - 1].y == path->pos.y)
305 return TRUE;
307 path->newStroke = FALSE;
308 return add_points( path, &path->pos, 1, PT_MOVETO ) != NULL;
311 /* set current position to the last point that was added to the path */
312 static void update_current_pos( struct gdi_path *path )
314 assert( path->count );
315 path->pos = path->points[path->count - 1];
318 /* close the current figure */
319 static void close_figure( struct gdi_path *path )
321 assert( path->count );
322 path->flags[path->count - 1] |= PT_CLOSEFIGURE;
325 /* add a number of points, starting a new stroke if necessary */
326 static BOOL add_log_points_new_stroke( DC *dc, struct gdi_path *path, const POINT *points,
327 DWORD count, BYTE type )
329 if (!start_new_stroke( path )) return FALSE;
330 if (!add_log_points( dc, path, points, count, type )) return FALSE;
331 update_current_pos( path );
332 return TRUE;
335 /* convert a (flattened) path to a region */
336 static HRGN path_to_region( const struct gdi_path *path, int mode )
338 int i, pos, polygons, *counts;
339 HRGN hrgn;
341 if (!path->count) return 0;
343 if (!(counts = HeapAlloc( GetProcessHeap(), 0, (path->count / 2) * sizeof(*counts) ))) return 0;
345 pos = polygons = 0;
346 assert( path->flags[0] == PT_MOVETO );
347 for (i = 1; i < path->count; i++)
349 if (path->flags[i] != PT_MOVETO) continue;
350 counts[polygons++] = i - pos;
351 pos = i;
353 if (i > pos + 1) counts[polygons++] = i - pos;
355 assert( polygons <= path->count / 2 );
356 hrgn = CreatePolyPolygonRgn( path->points, counts, polygons, mode );
357 HeapFree( GetProcessHeap(), 0, counts );
358 return hrgn;
361 /* PATH_CheckCorners
363 * Helper function for RoundRect() and Rectangle()
365 static BOOL PATH_CheckCorners( DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2 )
367 INT temp;
369 /* Convert points to device coordinates */
370 corners[0].x=x1;
371 corners[0].y=y1;
372 corners[1].x=x2;
373 corners[1].y=y2;
374 lp_to_dp( dc, corners, 2 );
376 /* Make sure first corner is top left and second corner is bottom right */
377 if(corners[0].x>corners[1].x)
379 temp=corners[0].x;
380 corners[0].x=corners[1].x;
381 corners[1].x=temp;
383 if(corners[0].y>corners[1].y)
385 temp=corners[0].y;
386 corners[0].y=corners[1].y;
387 corners[1].y=temp;
390 /* In GM_COMPATIBLE, don't include bottom and right edges */
391 if (dc->GraphicsMode == GM_COMPATIBLE)
393 if (corners[0].x == corners[1].x) return FALSE;
394 if (corners[0].y == corners[1].y) return FALSE;
395 corners[1].x--;
396 corners[1].y--;
398 return TRUE;
401 /* PATH_AddFlatBezier
403 static BOOL PATH_AddFlatBezier(struct gdi_path *pPath, POINT *pt, BOOL closed)
405 POINT *pts;
406 BOOL ret;
407 INT no;
409 pts = GDI_Bezier( pt, 4, &no );
410 if(!pts) return FALSE;
412 ret = (add_points( pPath, pts + 1, no - 1, PT_LINETO ) != NULL);
413 if (ret && closed) close_figure( pPath );
414 HeapFree( GetProcessHeap(), 0, pts );
415 return ret;
418 /* PATH_FlattenPath
420 * Replaces Beziers with line segments
423 static struct gdi_path *PATH_FlattenPath(const struct gdi_path *pPath)
425 struct gdi_path *new_path;
426 INT srcpt;
428 if (!(new_path = alloc_gdi_path( pPath->count ))) return NULL;
430 for(srcpt = 0; srcpt < pPath->count; srcpt++) {
431 switch(pPath->flags[srcpt] & ~PT_CLOSEFIGURE) {
432 case PT_MOVETO:
433 case PT_LINETO:
434 if (!PATH_AddEntry(new_path, &pPath->points[srcpt], pPath->flags[srcpt]))
436 free_gdi_path( new_path );
437 return NULL;
439 break;
440 case PT_BEZIERTO:
441 if (!PATH_AddFlatBezier(new_path, &pPath->points[srcpt-1],
442 pPath->flags[srcpt+2] & PT_CLOSEFIGURE))
444 free_gdi_path( new_path );
445 return NULL;
447 srcpt += 2;
448 break;
451 return new_path;
454 /* PATH_ScaleNormalizedPoint
456 * Scales a normalized point (x, y) with respect to the box whose corners are
457 * passed in "corners". The point is stored in "*pPoint". The normalized
458 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
459 * (1.0, 1.0) correspond to corners[1].
461 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
462 double y, POINT *pPoint)
464 pPoint->x=GDI_ROUND( (double)corners[0].x + (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
465 pPoint->y=GDI_ROUND( (double)corners[0].y + (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
468 /* PATH_NormalizePoint
470 * Normalizes a point with respect to the box whose corners are passed in
471 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
473 static void PATH_NormalizePoint(FLOAT_POINT corners[],
474 const FLOAT_POINT *pPoint,
475 double *pX, double *pY)
477 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) * 2.0 - 1.0;
478 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) * 2.0 - 1.0;
481 /* PATH_DoArcPart
483 * Creates a Bezier spline that corresponds to part of an arc and appends the
484 * corresponding points to the path. The start and end angles are passed in
485 * "angleStart" and "angleEnd"; these angles should span a quarter circle
486 * at most. If "startEntryType" is non-zero, an entry of that type for the first
487 * control point is added to the path; otherwise, it is assumed that the current
488 * position is equal to the first control point.
490 static BOOL PATH_DoArcPart(struct gdi_path *pPath, FLOAT_POINT corners[],
491 double angleStart, double angleEnd, BYTE startEntryType)
493 double halfAngle, a;
494 double xNorm[4], yNorm[4];
495 POINT points[4];
496 BYTE *type;
497 int i, start;
499 assert(fabs(angleEnd-angleStart)<=M_PI_2);
501 /* FIXME: Is there an easier way of computing this? */
503 /* Compute control points */
504 halfAngle=(angleEnd-angleStart)/2.0;
505 if(fabs(halfAngle)>1e-8)
507 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
508 xNorm[0]=cos(angleStart);
509 yNorm[0]=sin(angleStart);
510 xNorm[1]=xNorm[0] - a*yNorm[0];
511 yNorm[1]=yNorm[0] + a*xNorm[0];
512 xNorm[3]=cos(angleEnd);
513 yNorm[3]=sin(angleEnd);
514 xNorm[2]=xNorm[3] + a*yNorm[3];
515 yNorm[2]=yNorm[3] - a*xNorm[3];
517 else
518 for(i=0; i<4; i++)
520 xNorm[i]=cos(angleStart);
521 yNorm[i]=sin(angleStart);
524 /* Add starting point to path if desired */
525 start = !startEntryType;
526 for (i = start; i < 4; i++) PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &points[i]);
527 if (!(type = add_points( pPath, points + start, 4 - start, PT_BEZIERTO ))) return FALSE;
528 if (!start) type[0] = startEntryType;
529 return TRUE;
532 /* retrieve a flattened path in device coordinates, and optionally its region */
533 /* the DC path is deleted; the returned data must be freed by caller using free_gdi_path() */
534 /* helper for stroke_and_fill_path in the DIB driver */
535 struct gdi_path *get_gdi_flat_path( DC *dc, HRGN *rgn )
537 struct gdi_path *ret = NULL;
539 if (dc->path)
541 ret = PATH_FlattenPath( dc->path );
543 free_gdi_path( dc->path );
544 dc->path = NULL;
545 if (ret && rgn) *rgn = path_to_region( ret, dc->polyFillMode );
547 else SetLastError( ERROR_CAN_NOT_COMPLETE );
549 return ret;
552 int get_gdi_path_data( struct gdi_path *path, POINT **pts, BYTE **flags )
554 *pts = path->points;
555 *flags = path->flags;
556 return path->count;
559 /***********************************************************************
560 * BeginPath (GDI32.@)
562 BOOL WINAPI BeginPath(HDC hdc)
564 BOOL ret = FALSE;
565 DC *dc = get_dc_ptr( hdc );
567 if (dc)
569 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pBeginPath );
570 ret = physdev->funcs->pBeginPath( physdev );
571 release_dc_ptr( dc );
573 return ret;
577 /***********************************************************************
578 * EndPath (GDI32.@)
580 BOOL WINAPI EndPath(HDC hdc)
582 BOOL ret = FALSE;
583 DC *dc = get_dc_ptr( hdc );
585 if (dc)
587 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEndPath );
588 ret = physdev->funcs->pEndPath( physdev );
589 release_dc_ptr( dc );
591 return ret;
595 /******************************************************************************
596 * AbortPath [GDI32.@]
597 * Closes and discards paths from device context
599 * NOTES
600 * Check that SetLastError is being called correctly
602 * PARAMS
603 * hdc [I] Handle to device context
605 * RETURNS
606 * Success: TRUE
607 * Failure: FALSE
609 BOOL WINAPI AbortPath( HDC hdc )
611 BOOL ret = FALSE;
612 DC *dc = get_dc_ptr( hdc );
614 if (dc)
616 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pAbortPath );
617 ret = physdev->funcs->pAbortPath( physdev );
618 release_dc_ptr( dc );
620 return ret;
624 /***********************************************************************
625 * CloseFigure (GDI32.@)
627 * FIXME: Check that SetLastError is being called correctly
629 BOOL WINAPI CloseFigure(HDC hdc)
631 BOOL ret = FALSE;
632 DC *dc = get_dc_ptr( hdc );
634 if (dc)
636 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pCloseFigure );
637 ret = physdev->funcs->pCloseFigure( physdev );
638 release_dc_ptr( dc );
640 return ret;
644 /***********************************************************************
645 * GetPath (GDI32.@)
647 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes, INT nSize)
649 INT ret = -1;
650 DC *dc = get_dc_ptr( hdc );
652 if(!dc) return -1;
654 if (!dc->path)
656 SetLastError(ERROR_CAN_NOT_COMPLETE);
657 goto done;
660 if(nSize==0)
661 ret = dc->path->count;
662 else if(nSize<dc->path->count)
664 SetLastError(ERROR_INVALID_PARAMETER);
665 goto done;
667 else
669 memcpy(pPoints, dc->path->points, sizeof(POINT)*dc->path->count);
670 memcpy(pTypes, dc->path->flags, sizeof(BYTE)*dc->path->count);
672 /* Convert the points to logical coordinates */
673 if(!dp_to_lp(dc, pPoints, dc->path->count))
675 /* FIXME: Is this the correct value? */
676 SetLastError(ERROR_CAN_NOT_COMPLETE);
677 goto done;
679 else ret = dc->path->count;
681 done:
682 release_dc_ptr( dc );
683 return ret;
687 /***********************************************************************
688 * PathToRegion (GDI32.@)
690 HRGN WINAPI PathToRegion(HDC hdc)
692 HRGN ret = 0;
693 DC *dc = get_dc_ptr( hdc );
695 if (!dc) return 0;
697 if (dc->path)
699 struct gdi_path *path = PATH_FlattenPath( dc->path );
701 free_gdi_path( dc->path );
702 dc->path = NULL;
703 if (path)
705 ret = path_to_region( path, dc->polyFillMode );
706 free_gdi_path( path );
709 else SetLastError( ERROR_CAN_NOT_COMPLETE );
711 release_dc_ptr( dc );
712 return ret;
716 /***********************************************************************
717 * FillPath (GDI32.@)
719 * FIXME
720 * Check that SetLastError is being called correctly
722 BOOL WINAPI FillPath(HDC hdc)
724 BOOL ret = FALSE;
725 DC *dc = get_dc_ptr( hdc );
727 if (dc)
729 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFillPath );
730 ret = physdev->funcs->pFillPath( physdev );
731 release_dc_ptr( dc );
733 return ret;
737 /***********************************************************************
738 * SelectClipPath (GDI32.@)
740 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
742 BOOL ret = FALSE;
743 DC *dc = get_dc_ptr( hdc );
745 if (dc)
747 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectClipPath );
748 ret = physdev->funcs->pSelectClipPath( physdev, iMode );
749 release_dc_ptr( dc );
751 return ret;
755 /***********************************************************************
756 * pathdrv_BeginPath
758 static BOOL pathdrv_BeginPath( PHYSDEV dev )
760 /* path already open, nothing to do */
761 return TRUE;
765 /***********************************************************************
766 * pathdrv_AbortPath
768 static BOOL pathdrv_AbortPath( PHYSDEV dev )
770 DC *dc = get_physdev_dc( dev );
772 path_driver.pDeleteDC( pop_dc_driver( dc, &path_driver ));
773 return TRUE;
777 /***********************************************************************
778 * pathdrv_EndPath
780 static BOOL pathdrv_EndPath( PHYSDEV dev )
782 struct path_physdev *physdev = get_path_physdev( dev );
783 DC *dc = get_physdev_dc( dev );
785 dc->path = physdev->path;
786 pop_dc_driver( dc, &path_driver );
787 HeapFree( GetProcessHeap(), 0, physdev );
788 return TRUE;
792 /***********************************************************************
793 * pathdrv_CreateDC
795 static BOOL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
796 LPCWSTR output, const DEVMODEW *devmode )
798 struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) );
800 if (!physdev) return FALSE;
801 push_dc_driver( dev, &physdev->dev, &path_driver );
802 return TRUE;
806 /*************************************************************
807 * pathdrv_DeleteDC
809 static BOOL pathdrv_DeleteDC( PHYSDEV dev )
811 struct path_physdev *physdev = get_path_physdev( dev );
813 free_gdi_path( physdev->path );
814 HeapFree( GetProcessHeap(), 0, physdev );
815 return TRUE;
819 BOOL PATH_SavePath( DC *dst, DC *src )
821 PHYSDEV dev;
823 if (src->path)
825 if (!(dst->path = copy_gdi_path( src->path ))) return FALSE;
827 else if ((dev = find_dc_driver( src, &path_driver )))
829 struct path_physdev *physdev = get_path_physdev( dev );
830 if (!(dst->path = copy_gdi_path( physdev->path ))) return FALSE;
831 dst->path_open = TRUE;
833 else dst->path = NULL;
834 return TRUE;
837 BOOL PATH_RestorePath( DC *dst, DC *src )
839 PHYSDEV dev;
840 struct path_physdev *physdev;
842 if ((dev = pop_dc_driver( dst, &path_driver )))
844 physdev = get_path_physdev( dev );
845 free_gdi_path( physdev->path );
846 HeapFree( GetProcessHeap(), 0, physdev );
849 if (src->path && src->path_open)
851 if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
852 physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
853 physdev->path = src->path;
854 src->path_open = FALSE;
855 src->path = NULL;
858 if (dst->path) free_gdi_path( dst->path );
859 dst->path = src->path;
860 src->path = NULL;
861 return TRUE;
865 /*************************************************************
866 * pathdrv_MoveTo
868 static BOOL pathdrv_MoveTo( PHYSDEV dev, INT x, INT y )
870 struct path_physdev *physdev = get_path_physdev( dev );
871 DC *dc = get_physdev_dc( dev );
873 physdev->path->newStroke = TRUE;
874 physdev->path->pos.x = x;
875 physdev->path->pos.y = y;
876 lp_to_dp( dc, &physdev->path->pos, 1 );
877 return TRUE;
881 /*************************************************************
882 * pathdrv_LineTo
884 static BOOL pathdrv_LineTo( PHYSDEV dev, INT x, INT y )
886 struct path_physdev *physdev = get_path_physdev( dev );
887 DC *dc = get_physdev_dc( dev );
888 POINT point;
890 point.x = x;
891 point.y = y;
892 return add_log_points_new_stroke( dc, physdev->path, &point, 1, PT_LINETO );
896 /*************************************************************
897 * pathdrv_Rectangle
899 static BOOL pathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
901 struct path_physdev *physdev = get_path_physdev( dev );
902 DC *dc = get_physdev_dc( dev );
903 POINT corners[2], points[4];
904 BYTE *type;
906 if (!PATH_CheckCorners( dc, corners, x1, y1, x2, y2 )) return TRUE;
908 points[0].x = corners[1].x;
909 points[0].y = corners[0].y;
910 points[1] = corners[0];
911 points[2].x = corners[0].x;
912 points[2].y = corners[1].y;
913 points[3] = corners[1];
914 if (dc->ArcDirection == AD_CLOCKWISE) reverse_points( points, 4 );
916 if (!(type = add_points( physdev->path, points, 4, PT_LINETO ))) return FALSE;
917 type[0] = PT_MOVETO;
918 close_figure( physdev->path );
919 return TRUE;
923 /*************************************************************
924 * pathdrv_RoundRect
926 static BOOL pathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height )
928 const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */
929 struct path_physdev *physdev = get_path_physdev( dev );
930 DC *dc = get_physdev_dc( dev );
931 POINT corners[2], ellipse[2], points[16];
932 BYTE *type;
933 double width, height;
935 if (!ell_width || !ell_height) return pathdrv_Rectangle( dev, x1, y1, x2, y2 );
937 if (!PATH_CheckCorners( dc, corners, x1, y1, x2, y2 )) return TRUE;
939 ellipse[0].x = ellipse[0].y = 0;
940 ellipse[1].x = ell_width;
941 ellipse[1].y = ell_height;
942 lp_to_dp( dc, (POINT *)&ellipse, 2 );
943 ell_width = min( abs( ellipse[1].x - ellipse[0].x ), corners[1].x - corners[0].x );
944 ell_height = min( abs( ellipse[1].y - ellipse[0].y ), corners[1].y - corners[0].y );
945 width = ell_width / 2.0;
946 height = ell_height / 2.0;
948 /* starting point */
949 points[0].x = corners[1].x;
950 points[0].y = corners[0].y + GDI_ROUND( height );
951 /* first curve */
952 points[1].x = corners[1].x;
953 points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
954 points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
955 points[2].y = corners[0].y;
956 points[3].x = corners[1].x - GDI_ROUND( width );
957 points[3].y = corners[0].y;
958 /* horizontal line */
959 points[4].x = corners[0].x + GDI_ROUND( width );
960 points[4].y = corners[0].y;
961 /* second curve */
962 points[5].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
963 points[5].y = corners[0].y;
964 points[6].x = corners[0].x;
965 points[6].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
966 points[7].x = corners[0].x;
967 points[7].y = corners[0].y + GDI_ROUND( height );
968 /* vertical line */
969 points[8].x = corners[0].x;
970 points[8].y = corners[1].y - GDI_ROUND( height );
971 /* third curve */
972 points[9].x = corners[0].x;
973 points[9].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
974 points[10].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
975 points[10].y = corners[1].y;
976 points[11].x = corners[0].x + GDI_ROUND( width );
977 points[11].y = corners[1].y;
978 /* horizontal line */
979 points[12].x = corners[1].x - GDI_ROUND( width );
980 points[12].y = corners[1].y;
981 /* fourth curve */
982 points[13].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
983 points[13].y = corners[1].y;
984 points[14].x = corners[1].x;
985 points[14].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
986 points[15].x = corners[1].x;
987 points[15].y = corners[1].y - GDI_ROUND( height );
989 if (dc->ArcDirection == AD_CLOCKWISE) reverse_points( points, 16 );
990 if (!(type = add_points( physdev->path, points, 16, PT_BEZIERTO ))) return FALSE;
991 type[0] = PT_MOVETO;
992 type[4] = type[8] = type[12] = PT_LINETO;
993 close_figure( physdev->path );
994 return TRUE;
998 /*************************************************************
999 * pathdrv_Ellipse
1001 static BOOL pathdrv_Ellipse( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
1003 const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */
1004 struct path_physdev *physdev = get_path_physdev( dev );
1005 DC *dc = get_physdev_dc( dev );
1006 POINT corners[2], points[13];
1007 BYTE *type;
1008 double width, height;
1010 if (!PATH_CheckCorners( dc, corners, x1, y1, x2, y2 )) return TRUE;
1012 width = (corners[1].x - corners[0].x) / 2.0;
1013 height = (corners[1].y - corners[0].y) / 2.0;
1015 /* starting point */
1016 points[0].x = corners[1].x;
1017 points[0].y = corners[0].y + GDI_ROUND( height );
1018 /* first curve */
1019 points[1].x = corners[1].x;
1020 points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
1021 points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
1022 points[2].y = corners[0].y;
1023 points[3].x = corners[0].x + GDI_ROUND( width );
1024 points[3].y = corners[0].y;
1025 /* second curve */
1026 points[4].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
1027 points[4].y = corners[0].y;
1028 points[5].x = corners[0].x;
1029 points[5].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
1030 points[6].x = corners[0].x;
1031 points[6].y = corners[0].y + GDI_ROUND( height );
1032 /* third curve */
1033 points[7].x = corners[0].x;
1034 points[7].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
1035 points[8].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
1036 points[8].y = corners[1].y;
1037 points[9].x = corners[0].x + GDI_ROUND( width );
1038 points[9].y = corners[1].y;
1039 /* fourth curve */
1040 points[10].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
1041 points[10].y = corners[1].y;
1042 points[11].x = corners[1].x;
1043 points[11].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
1044 points[12].x = corners[1].x;
1045 points[12].y = corners[1].y - GDI_ROUND( height );
1047 if (dc->ArcDirection == AD_CLOCKWISE) reverse_points( points, 13 );
1048 if (!(type = add_points( physdev->path, points, 13, PT_BEZIERTO ))) return FALSE;
1049 type[0] = PT_MOVETO;
1050 close_figure( physdev->path );
1051 return TRUE;
1055 /* PATH_Arc
1057 * Should be called when a call to Arc is performed on a DC that has
1058 * an open path. This adds up to five Bezier splines representing the arc
1059 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
1060 * when 'lines' is 2, we add 2 extra lines to get a pie, and when 'lines' is
1061 * -1 we add 1 extra line from the current DC position to the starting position
1062 * of the arc before drawing the arc itself (arcto). Returns TRUE if successful,
1063 * else FALSE.
1065 static BOOL PATH_Arc( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2,
1066 INT xStart, INT yStart, INT xEnd, INT yEnd, int direction, int lines )
1068 DC *dc = get_physdev_dc( dev );
1069 struct path_physdev *physdev = get_path_physdev( dev );
1070 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
1071 /* Initialize angleEndQuadrant to silence gcc's warning */
1072 double x, y;
1073 FLOAT_POINT corners[2], pointStart, pointEnd;
1074 POINT centre;
1075 BOOL start, end;
1076 INT temp;
1078 /* FIXME: Do we have to respect newStroke? */
1080 /* Check for zero height / width */
1081 /* FIXME: Only in GM_COMPATIBLE? */
1082 if(x1==x2 || y1==y2)
1083 return TRUE;
1085 /* Convert points to device coordinates */
1086 corners[0].x = x1;
1087 corners[0].y = y1;
1088 corners[1].x = x2;
1089 corners[1].y = y2;
1090 pointStart.x = xStart;
1091 pointStart.y = yStart;
1092 pointEnd.x = xEnd;
1093 pointEnd.y = yEnd;
1094 INTERNAL_LPTODP_FLOAT(dc, corners, 2);
1095 INTERNAL_LPTODP_FLOAT(dc, &pointStart, 1);
1096 INTERNAL_LPTODP_FLOAT(dc, &pointEnd, 1);
1098 /* Make sure first corner is top left and second corner is bottom right */
1099 if(corners[0].x>corners[1].x)
1101 temp=corners[0].x;
1102 corners[0].x=corners[1].x;
1103 corners[1].x=temp;
1105 if(corners[0].y>corners[1].y)
1107 temp=corners[0].y;
1108 corners[0].y=corners[1].y;
1109 corners[1].y=temp;
1112 /* Compute start and end angle */
1113 PATH_NormalizePoint(corners, &pointStart, &x, &y);
1114 angleStart=atan2(y, x);
1115 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
1116 angleEnd=atan2(y, x);
1118 /* Make sure the end angle is "on the right side" of the start angle */
1119 if (direction == AD_CLOCKWISE)
1121 if(angleEnd<=angleStart)
1123 angleEnd+=2*M_PI;
1124 assert(angleEnd>=angleStart);
1127 else
1129 if(angleEnd>=angleStart)
1131 angleEnd-=2*M_PI;
1132 assert(angleEnd<=angleStart);
1136 /* In GM_COMPATIBLE, don't include bottom and right edges */
1137 if (dc->GraphicsMode == GM_COMPATIBLE)
1139 corners[1].x--;
1140 corners[1].y--;
1143 /* arcto: Add a PT_MOVETO only if this is the first entry in a stroke */
1144 if (lines == -1 && !start_new_stroke( physdev->path )) return FALSE;
1146 /* Add the arc to the path with one Bezier spline per quadrant that the
1147 * arc spans */
1148 start=TRUE;
1149 end=FALSE;
1152 /* Determine the start and end angles for this quadrant */
1153 if(start)
1155 angleStartQuadrant=angleStart;
1156 if (direction == AD_CLOCKWISE)
1157 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
1158 else
1159 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
1161 else
1163 angleStartQuadrant=angleEndQuadrant;
1164 if (direction == AD_CLOCKWISE)
1165 angleEndQuadrant+=M_PI_2;
1166 else
1167 angleEndQuadrant-=M_PI_2;
1170 /* Have we reached the last part of the arc? */
1171 if((direction == AD_CLOCKWISE && angleEnd<angleEndQuadrant) ||
1172 (direction == AD_COUNTERCLOCKWISE && angleEnd>angleEndQuadrant))
1174 /* Adjust the end angle for this quadrant */
1175 angleEndQuadrant=angleEnd;
1176 end=TRUE;
1179 /* Add the Bezier spline to the path */
1180 PATH_DoArcPart(physdev->path, corners, angleStartQuadrant, angleEndQuadrant,
1181 start ? (lines==-1 ? PT_LINETO : PT_MOVETO) : 0);
1182 start=FALSE;
1183 } while(!end);
1185 /* chord: close figure. pie: add line and close figure */
1186 switch (lines)
1188 case -1:
1189 update_current_pos( physdev->path );
1190 break;
1191 case 1:
1192 close_figure( physdev->path );
1193 break;
1194 case 2:
1195 centre.x = (corners[0].x+corners[1].x)/2;
1196 centre.y = (corners[0].y+corners[1].y)/2;
1197 if(!PATH_AddEntry(physdev->path, &centre, PT_LINETO | PT_CLOSEFIGURE))
1198 return FALSE;
1199 break;
1201 return TRUE;
1205 /*************************************************************
1206 * pathdrv_AngleArc
1208 static BOOL pathdrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT eStartAngle, FLOAT eSweepAngle)
1210 int x1 = GDI_ROUND( x + cos(eStartAngle*M_PI/180) * radius );
1211 int y1 = GDI_ROUND( y - sin(eStartAngle*M_PI/180) * radius );
1212 int x2 = GDI_ROUND( x + cos((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1213 int y2 = GDI_ROUND( y - sin((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1214 return PATH_Arc( dev, x-radius, y-radius, x+radius, y+radius, x1, y1, x2, y2,
1215 eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE, -1 );
1219 /*************************************************************
1220 * pathdrv_Arc
1222 static BOOL pathdrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1223 INT xstart, INT ystart, INT xend, INT yend )
1225 DC *dc = get_physdev_dc( dev );
1226 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1227 dc->ArcDirection, 0 );
1231 /*************************************************************
1232 * pathdrv_ArcTo
1234 static BOOL pathdrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1235 INT xstart, INT ystart, INT xend, INT yend )
1237 DC *dc = get_physdev_dc( dev );
1238 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1239 dc->ArcDirection, -1 );
1243 /*************************************************************
1244 * pathdrv_Chord
1246 static BOOL pathdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1247 INT xstart, INT ystart, INT xend, INT yend )
1249 DC *dc = get_physdev_dc( dev );
1250 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1251 dc->ArcDirection, 1 );
1255 /*************************************************************
1256 * pathdrv_Pie
1258 static BOOL pathdrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1259 INT xstart, INT ystart, INT xend, INT yend )
1261 DC *dc = get_physdev_dc( dev );
1262 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1263 dc->ArcDirection, 2 );
1267 /*************************************************************
1268 * pathdrv_PolyBezierTo
1270 static BOOL pathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1272 struct path_physdev *physdev = get_path_physdev( dev );
1273 DC *dc = get_physdev_dc( dev );
1275 return add_log_points_new_stroke( dc, physdev->path, pts, cbPoints, PT_BEZIERTO );
1279 /*************************************************************
1280 * pathdrv_PolyBezier
1282 static BOOL pathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1284 struct path_physdev *physdev = get_path_physdev( dev );
1285 DC *dc = get_physdev_dc( dev );
1286 BYTE *type = add_log_points( dc, physdev->path, pts, cbPoints, PT_BEZIERTO );
1288 if (!type) return FALSE;
1289 type[0] = PT_MOVETO;
1290 return TRUE;
1294 /*************************************************************
1295 * pathdrv_PolyDraw
1297 static BOOL pathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD cbPoints )
1299 struct path_physdev *physdev = get_path_physdev( dev );
1300 struct gdi_path *path = physdev->path;
1301 DC *dc = get_physdev_dc( dev );
1302 POINT orig_pos;
1303 INT i, lastmove = 0;
1305 for (i = 0; i < path->count; i++) if (path->flags[i] == PT_MOVETO) lastmove = i;
1306 orig_pos = path->pos;
1308 for(i = 0; i < cbPoints; i++)
1310 switch (types[i])
1312 case PT_MOVETO:
1313 path->newStroke = TRUE;
1314 path->pos = pts[i];
1315 lp_to_dp( dc, &path->pos, 1 );
1316 lastmove = path->count;
1317 break;
1318 case PT_LINETO:
1319 case PT_LINETO | PT_CLOSEFIGURE:
1320 if (!add_log_points_new_stroke( dc, path, &pts[i], 1, PT_LINETO )) return FALSE;
1321 break;
1322 case PT_BEZIERTO:
1323 if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
1324 (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
1326 if (!add_log_points_new_stroke( dc, path, &pts[i], 3, PT_BEZIERTO )) return FALSE;
1327 i += 2;
1328 break;
1330 /* fall through */
1331 default:
1332 /* restore original position */
1333 path->pos = orig_pos;
1334 return FALSE;
1337 if (types[i] & PT_CLOSEFIGURE)
1339 close_figure( path );
1340 path->pos = path->points[lastmove];
1343 return TRUE;
1347 /*************************************************************
1348 * pathdrv_Polyline
1350 static BOOL pathdrv_Polyline( PHYSDEV dev, const POINT *pts, INT count )
1352 struct path_physdev *physdev = get_path_physdev( dev );
1353 DC *dc = get_physdev_dc( dev );
1354 BYTE *type;
1356 if (count < 2) return FALSE;
1357 if (!(type = add_log_points( dc, physdev->path, pts, count, PT_LINETO ))) return FALSE;
1358 type[0] = PT_MOVETO;
1359 return TRUE;
1363 /*************************************************************
1364 * pathdrv_PolylineTo
1366 static BOOL pathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT count )
1368 struct path_physdev *physdev = get_path_physdev( dev );
1369 DC *dc = get_physdev_dc( dev );
1371 if (count < 1) return FALSE;
1372 return add_log_points_new_stroke( dc, physdev->path, pts, count, PT_LINETO );
1376 /*************************************************************
1377 * pathdrv_Polygon
1379 static BOOL pathdrv_Polygon( PHYSDEV dev, const POINT *pts, INT count )
1381 struct path_physdev *physdev = get_path_physdev( dev );
1382 DC *dc = get_physdev_dc( dev );
1383 BYTE *type;
1385 if (count < 2) return FALSE;
1386 if (!(type = add_log_points( dc, physdev->path, pts, count, PT_LINETO ))) return FALSE;
1387 type[0] = PT_MOVETO;
1388 type[count - 1] = PT_LINETO | PT_CLOSEFIGURE;
1389 return TRUE;
1393 /*************************************************************
1394 * pathdrv_PolyPolygon
1396 static BOOL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
1398 struct path_physdev *physdev = get_path_physdev( dev );
1399 DC *dc = get_physdev_dc( dev );
1400 UINT poly, count;
1401 BYTE *type;
1403 if (!polygons) return FALSE;
1404 for (poly = count = 0; poly < polygons; poly++)
1406 if (counts[poly] < 2) return FALSE;
1407 count += counts[poly];
1410 type = add_log_points( dc, physdev->path, pts, count, PT_LINETO );
1411 if (!type) return FALSE;
1413 /* make the first point of each polyline a PT_MOVETO, and close the last one */
1414 for (poly = 0; poly < polygons; type += counts[poly++])
1416 type[0] = PT_MOVETO;
1417 type[counts[poly] - 1] = PT_LINETO | PT_CLOSEFIGURE;
1419 return TRUE;
1423 /*************************************************************
1424 * pathdrv_PolyPolyline
1426 static BOOL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
1428 struct path_physdev *physdev = get_path_physdev( dev );
1429 DC *dc = get_physdev_dc( dev );
1430 UINT poly, count;
1431 BYTE *type;
1433 if (!polylines) return FALSE;
1434 for (poly = count = 0; poly < polylines; poly++)
1436 if (counts[poly] < 2) return FALSE;
1437 count += counts[poly];
1440 type = add_log_points( dc, physdev->path, pts, count, PT_LINETO );
1441 if (!type) return FALSE;
1443 /* make the first point of each polyline a PT_MOVETO */
1444 for (poly = 0; poly < polylines; type += counts[poly++]) *type = PT_MOVETO;
1445 return TRUE;
1449 /**********************************************************************
1450 * PATH_BezierTo
1452 * internally used by PATH_add_outline
1454 static void PATH_BezierTo(struct gdi_path *pPath, POINT *lppt, INT n)
1456 if (n < 2) return;
1458 if (n == 2)
1460 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1462 else if (n == 3)
1464 add_points( pPath, lppt, 3, PT_BEZIERTO );
1466 else
1468 POINT pt[3];
1469 INT i = 0;
1471 pt[2] = lppt[0];
1472 n--;
1474 while (n > 2)
1476 pt[0] = pt[2];
1477 pt[1] = lppt[i+1];
1478 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1479 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1480 add_points( pPath, pt, 3, PT_BEZIERTO );
1481 n--;
1482 i++;
1485 pt[0] = pt[2];
1486 pt[1] = lppt[i+1];
1487 pt[2] = lppt[i+2];
1488 add_points( pPath, pt, 3, PT_BEZIERTO );
1492 static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y,
1493 TTPOLYGONHEADER *header, DWORD size)
1495 TTPOLYGONHEADER *start;
1496 POINT pt;
1498 start = header;
1500 while ((char *)header < (char *)start + size)
1502 TTPOLYCURVE *curve;
1504 if (header->dwType != TT_POLYGON_TYPE)
1506 FIXME("Unknown header type %d\n", header->dwType);
1507 return FALSE;
1510 pt.x = x + int_from_fixed(header->pfxStart.x);
1511 pt.y = y - int_from_fixed(header->pfxStart.y);
1512 PATH_AddEntry(physdev->path, &pt, PT_MOVETO);
1514 curve = (TTPOLYCURVE *)(header + 1);
1516 while ((char *)curve < (char *)header + header->cb)
1518 /*TRACE("curve->wType %d\n", curve->wType);*/
1520 switch(curve->wType)
1522 case TT_PRIM_LINE:
1524 WORD i;
1526 for (i = 0; i < curve->cpfx; i++)
1528 pt.x = x + int_from_fixed(curve->apfx[i].x);
1529 pt.y = y - int_from_fixed(curve->apfx[i].y);
1530 PATH_AddEntry(physdev->path, &pt, PT_LINETO);
1532 break;
1535 case TT_PRIM_QSPLINE:
1536 case TT_PRIM_CSPLINE:
1538 WORD i;
1539 POINTFX ptfx;
1540 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1542 if (!pts) return FALSE;
1544 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1546 pts[0].x = x + int_from_fixed(ptfx.x);
1547 pts[0].y = y - int_from_fixed(ptfx.y);
1549 for(i = 0; i < curve->cpfx; i++)
1551 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1552 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1555 PATH_BezierTo(physdev->path, pts, curve->cpfx + 1);
1557 HeapFree(GetProcessHeap(), 0, pts);
1558 break;
1561 default:
1562 FIXME("Unknown curve type %04x\n", curve->wType);
1563 return FALSE;
1566 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1569 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1572 close_figure( physdev->path );
1573 return TRUE;
1576 /*************************************************************
1577 * pathdrv_ExtTextOut
1579 static BOOL pathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprc,
1580 LPCWSTR str, UINT count, const INT *dx )
1582 struct path_physdev *physdev = get_path_physdev( dev );
1583 unsigned int idx, ggo_flags = GGO_NATIVE;
1584 POINT offset = {0, 0};
1586 if (!count) return TRUE;
1587 if (flags & ETO_GLYPH_INDEX) ggo_flags |= GGO_GLYPH_INDEX;
1589 for (idx = 0; idx < count; idx++)
1591 static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
1592 GLYPHMETRICS gm;
1593 DWORD dwSize;
1594 void *outline;
1596 dwSize = GetGlyphOutlineW(dev->hdc, str[idx], ggo_flags, &gm, 0, NULL, &identity);
1597 if (dwSize == GDI_ERROR) return FALSE;
1599 /* add outline only if char is printable */
1600 if(dwSize)
1602 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1603 if (!outline) return FALSE;
1605 GetGlyphOutlineW(dev->hdc, str[idx], ggo_flags, &gm, dwSize, outline, &identity);
1606 PATH_add_outline(physdev, x + offset.x, y + offset.y, outline, dwSize);
1608 HeapFree(GetProcessHeap(), 0, outline);
1611 if (dx)
1613 if(flags & ETO_PDY)
1615 offset.x += dx[idx * 2];
1616 offset.y += dx[idx * 2 + 1];
1618 else
1619 offset.x += dx[idx];
1621 else
1623 offset.x += gm.gmCellIncX;
1624 offset.y += gm.gmCellIncY;
1627 return TRUE;
1631 /*************************************************************
1632 * pathdrv_CloseFigure
1634 static BOOL pathdrv_CloseFigure( PHYSDEV dev )
1636 struct path_physdev *physdev = get_path_physdev( dev );
1638 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
1639 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
1640 if (physdev->path->count) close_figure( physdev->path );
1641 return TRUE;
1645 /*******************************************************************
1646 * FlattenPath [GDI32.@]
1650 BOOL WINAPI FlattenPath(HDC hdc)
1652 BOOL ret = FALSE;
1653 DC *dc = get_dc_ptr( hdc );
1655 if (dc)
1657 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath );
1658 ret = physdev->funcs->pFlattenPath( physdev );
1659 release_dc_ptr( dc );
1661 return ret;
1665 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1667 static struct gdi_path *PATH_WidenPath(DC *dc)
1669 INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
1670 struct gdi_path *flat_path, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
1671 EXTLOGPEN *elp;
1672 BYTE *type;
1673 DWORD obj_type, joint, endcap, penType;
1675 size = GetObjectW( dc->hPen, 0, NULL );
1676 if (!size) {
1677 SetLastError(ERROR_CAN_NOT_COMPLETE);
1678 return NULL;
1681 elp = HeapAlloc( GetProcessHeap(), 0, size );
1682 GetObjectW( dc->hPen, size, elp );
1684 obj_type = GetObjectType(dc->hPen);
1685 if(obj_type == OBJ_PEN) {
1686 penStyle = ((LOGPEN*)elp)->lopnStyle;
1688 else if(obj_type == OBJ_EXTPEN) {
1689 penStyle = elp->elpPenStyle;
1691 else {
1692 SetLastError(ERROR_CAN_NOT_COMPLETE);
1693 HeapFree( GetProcessHeap(), 0, elp );
1694 return NULL;
1697 penWidth = elp->elpWidth;
1698 HeapFree( GetProcessHeap(), 0, elp );
1700 endcap = (PS_ENDCAP_MASK & penStyle);
1701 joint = (PS_JOIN_MASK & penStyle);
1702 penType = (PS_TYPE_MASK & penStyle);
1704 /* The function cannot apply to cosmetic pens */
1705 if(obj_type == OBJ_EXTPEN && penType == PS_COSMETIC) {
1706 SetLastError(ERROR_CAN_NOT_COMPLETE);
1707 return NULL;
1710 if (!(flat_path = PATH_FlattenPath( dc->path ))) return NULL;
1712 penWidthIn = penWidth / 2;
1713 penWidthOut = penWidth / 2;
1714 if(penWidthIn + penWidthOut < penWidth)
1715 penWidthOut++;
1717 numStrokes = 0;
1719 for(i = 0, j = 0; i < flat_path->count; i++, j++) {
1720 POINT point;
1721 if((i == 0 || (flat_path->flags[i-1] & PT_CLOSEFIGURE)) &&
1722 (flat_path->flags[i] != PT_MOVETO)) {
1723 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1724 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1725 flat_path->flags[i]);
1726 free_gdi_path( flat_path );
1727 return NULL;
1729 switch(flat_path->flags[i]) {
1730 case PT_MOVETO:
1731 numStrokes++;
1732 j = 0;
1733 if(numStrokes == 1)
1734 pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(*pStrokes));
1735 else
1736 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes));
1737 if(!pStrokes) return NULL;
1738 pStrokes[numStrokes - 1] = alloc_gdi_path(0);
1739 /* fall through */
1740 case PT_LINETO:
1741 case (PT_LINETO | PT_CLOSEFIGURE):
1742 point.x = flat_path->points[i].x;
1743 point.y = flat_path->points[i].y;
1744 PATH_AddEntry(pStrokes[numStrokes - 1], &point, flat_path->flags[i]);
1745 break;
1746 case PT_BEZIERTO:
1747 /* should never happen because of the FlattenPath call */
1748 ERR("Should never happen\n");
1749 break;
1750 default:
1751 ERR("Got path flag %c\n", flat_path->flags[i]);
1752 return NULL;
1756 pNewPath = alloc_gdi_path( flat_path->count );
1758 for(i = 0; i < numStrokes; i++) {
1759 pUpPath = alloc_gdi_path( pStrokes[i]->count );
1760 pDownPath = alloc_gdi_path( pStrokes[i]->count );
1762 for(j = 0; j < pStrokes[i]->count; j++) {
1763 /* Beginning or end of the path if not closed */
1764 if((!(pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->count - 1) ) {
1765 /* Compute segment angle */
1766 double xo, yo, xa, ya, theta;
1767 POINT pt;
1768 FLOAT_POINT corners[2];
1769 if(j == 0) {
1770 xo = pStrokes[i]->points[j].x;
1771 yo = pStrokes[i]->points[j].y;
1772 xa = pStrokes[i]->points[1].x;
1773 ya = pStrokes[i]->points[1].y;
1775 else {
1776 xa = pStrokes[i]->points[j - 1].x;
1777 ya = pStrokes[i]->points[j - 1].y;
1778 xo = pStrokes[i]->points[j].x;
1779 yo = pStrokes[i]->points[j].y;
1781 theta = atan2( ya - yo, xa - xo );
1782 switch(endcap) {
1783 case PS_ENDCAP_SQUARE :
1784 pt.x = xo + round(sqrt(2) * penWidthOut * cos(M_PI_4 + theta));
1785 pt.y = yo + round(sqrt(2) * penWidthOut * sin(M_PI_4 + theta));
1786 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO) );
1787 pt.x = xo + round(sqrt(2) * penWidthIn * cos(- M_PI_4 + theta));
1788 pt.y = yo + round(sqrt(2) * penWidthIn * sin(- M_PI_4 + theta));
1789 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1790 break;
1791 case PS_ENDCAP_FLAT :
1792 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1793 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1794 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
1795 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1796 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1797 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1798 break;
1799 case PS_ENDCAP_ROUND :
1800 default :
1801 corners[0].x = xo - penWidthIn;
1802 corners[0].y = yo - penWidthIn;
1803 corners[1].x = xo + penWidthOut;
1804 corners[1].y = yo + penWidthOut;
1805 PATH_DoArcPart(pUpPath ,corners, theta + M_PI_2 , theta + 3 * M_PI_4, (j == 0 ? PT_MOVETO : 0));
1806 PATH_DoArcPart(pUpPath ,corners, theta + 3 * M_PI_4 , theta + M_PI, 0);
1807 PATH_DoArcPart(pUpPath ,corners, theta + M_PI, theta + 5 * M_PI_4, 0);
1808 PATH_DoArcPart(pUpPath ,corners, theta + 5 * M_PI_4 , theta + 3 * M_PI_2, 0);
1809 break;
1812 /* Corpse of the path */
1813 else {
1814 /* Compute angle */
1815 INT previous, next;
1816 double xa, ya, xb, yb, xo, yo;
1817 double alpha, theta, miterWidth;
1818 DWORD _joint = joint;
1819 POINT pt;
1820 struct gdi_path *pInsidePath, *pOutsidePath;
1821 if(j > 0 && j < pStrokes[i]->count - 1) {
1822 previous = j - 1;
1823 next = j + 1;
1825 else if (j == 0) {
1826 previous = pStrokes[i]->count - 1;
1827 next = j + 1;
1829 else {
1830 previous = j - 1;
1831 next = 0;
1833 xo = pStrokes[i]->points[j].x;
1834 yo = pStrokes[i]->points[j].y;
1835 xa = pStrokes[i]->points[previous].x;
1836 ya = pStrokes[i]->points[previous].y;
1837 xb = pStrokes[i]->points[next].x;
1838 yb = pStrokes[i]->points[next].y;
1839 theta = atan2( yo - ya, xo - xa );
1840 alpha = atan2( yb - yo, xb - xo ) - theta;
1841 if (alpha > 0) alpha -= M_PI;
1842 else alpha += M_PI;
1843 if(_joint == PS_JOIN_MITER && dc->miterLimit < fabs(1 / sin(alpha/2))) {
1844 _joint = PS_JOIN_BEVEL;
1846 if(alpha > 0) {
1847 pInsidePath = pUpPath;
1848 pOutsidePath = pDownPath;
1850 else if(alpha < 0) {
1851 pInsidePath = pDownPath;
1852 pOutsidePath = pUpPath;
1854 else {
1855 continue;
1857 /* Inside angle points */
1858 if(alpha > 0) {
1859 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1860 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1862 else {
1863 pt.x = xo + round( penWidthIn * cos(theta + M_PI_2) );
1864 pt.y = yo + round( penWidthIn * sin(theta + M_PI_2) );
1866 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1867 if(alpha > 0) {
1868 pt.x = xo + round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1869 pt.y = yo + round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1871 else {
1872 pt.x = xo - round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1873 pt.y = yo - round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1875 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1876 /* Outside angle point */
1877 switch(_joint) {
1878 case PS_JOIN_MITER :
1879 miterWidth = fabs(penWidthOut / cos(M_PI_2 - fabs(alpha) / 2));
1880 pt.x = xo + round( miterWidth * cos(theta + alpha / 2) );
1881 pt.y = yo + round( miterWidth * sin(theta + alpha / 2) );
1882 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1883 break;
1884 case PS_JOIN_BEVEL :
1885 if(alpha > 0) {
1886 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1887 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1889 else {
1890 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1891 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1893 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1894 if(alpha > 0) {
1895 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1896 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1898 else {
1899 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1900 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1902 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1903 break;
1904 case PS_JOIN_ROUND :
1905 default :
1906 if(alpha > 0) {
1907 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1908 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1910 else {
1911 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1912 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1914 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1915 pt.x = xo + round( penWidthOut * cos(theta + alpha / 2) );
1916 pt.y = yo + round( penWidthOut * sin(theta + alpha / 2) );
1917 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1918 if(alpha > 0) {
1919 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1920 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1922 else {
1923 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1924 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1926 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1927 break;
1931 type = add_points( pNewPath, pUpPath->points, pUpPath->count, PT_LINETO );
1932 type[0] = PT_MOVETO;
1933 reverse_points( pDownPath->points, pDownPath->count );
1934 type = add_points( pNewPath, pDownPath->points, pDownPath->count, PT_LINETO );
1935 if (pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE) type[0] = PT_MOVETO;
1937 free_gdi_path( pStrokes[i] );
1938 free_gdi_path( pUpPath );
1939 free_gdi_path( pDownPath );
1941 HeapFree(GetProcessHeap(), 0, pStrokes);
1942 free_gdi_path( flat_path );
1943 return pNewPath;
1947 /*******************************************************************
1948 * StrokeAndFillPath [GDI32.@]
1952 BOOL WINAPI StrokeAndFillPath(HDC hdc)
1954 BOOL ret = FALSE;
1955 DC *dc = get_dc_ptr( hdc );
1957 if (dc)
1959 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath );
1960 ret = physdev->funcs->pStrokeAndFillPath( physdev );
1961 release_dc_ptr( dc );
1963 return ret;
1967 /*******************************************************************
1968 * StrokePath [GDI32.@]
1972 BOOL WINAPI StrokePath(HDC hdc)
1974 BOOL ret = FALSE;
1975 DC *dc = get_dc_ptr( hdc );
1977 if (dc)
1979 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath );
1980 ret = physdev->funcs->pStrokePath( physdev );
1981 release_dc_ptr( dc );
1983 return ret;
1987 /*******************************************************************
1988 * WidenPath [GDI32.@]
1992 BOOL WINAPI WidenPath(HDC hdc)
1994 BOOL ret = FALSE;
1995 DC *dc = get_dc_ptr( hdc );
1997 if (dc)
1999 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath );
2000 ret = physdev->funcs->pWidenPath( physdev );
2001 release_dc_ptr( dc );
2003 return ret;
2007 /***********************************************************************
2008 * null driver fallback implementations
2011 BOOL nulldrv_BeginPath( PHYSDEV dev )
2013 DC *dc = get_nulldrv_dc( dev );
2014 struct path_physdev *physdev;
2015 struct gdi_path *path = alloc_gdi_path(0);
2017 if (!path) return FALSE;
2018 if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
2020 free_gdi_path( path );
2021 return FALSE;
2023 physdev = get_path_physdev( find_dc_driver( dc, &path_driver ));
2024 physdev->path = path;
2025 path->pos = dc->cur_pos;
2026 lp_to_dp( dc, &path->pos, 1 );
2027 if (dc->path) free_gdi_path( dc->path );
2028 dc->path = NULL;
2029 return TRUE;
2032 BOOL nulldrv_EndPath( PHYSDEV dev )
2034 SetLastError( ERROR_CAN_NOT_COMPLETE );
2035 return FALSE;
2038 BOOL nulldrv_AbortPath( PHYSDEV dev )
2040 DC *dc = get_nulldrv_dc( dev );
2042 if (dc->path) free_gdi_path( dc->path );
2043 dc->path = NULL;
2044 return TRUE;
2047 BOOL nulldrv_CloseFigure( PHYSDEV dev )
2049 SetLastError( ERROR_CAN_NOT_COMPLETE );
2050 return FALSE;
2053 BOOL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
2055 BOOL ret = FALSE;
2056 HRGN hrgn = PathToRegion( dev->hdc );
2058 if (hrgn)
2060 ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR;
2061 DeleteObject( hrgn );
2063 return ret;
2066 BOOL nulldrv_FillPath( PHYSDEV dev )
2068 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2069 AbortPath( dev->hdc );
2070 return TRUE;
2073 BOOL nulldrv_StrokeAndFillPath( PHYSDEV dev )
2075 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2076 AbortPath( dev->hdc );
2077 return TRUE;
2080 BOOL nulldrv_StrokePath( PHYSDEV dev )
2082 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2083 AbortPath( dev->hdc );
2084 return TRUE;
2087 BOOL nulldrv_FlattenPath( PHYSDEV dev )
2089 DC *dc = get_nulldrv_dc( dev );
2090 struct gdi_path *path;
2092 if (!dc->path)
2094 SetLastError( ERROR_CAN_NOT_COMPLETE );
2095 return FALSE;
2097 if (!(path = PATH_FlattenPath( dc->path ))) return FALSE;
2098 free_gdi_path( dc->path );
2099 dc->path = path;
2100 return TRUE;
2103 BOOL nulldrv_WidenPath( PHYSDEV dev )
2105 DC *dc = get_nulldrv_dc( dev );
2106 struct gdi_path *path;
2108 if (!dc->path)
2110 SetLastError( ERROR_CAN_NOT_COMPLETE );
2111 return FALSE;
2113 if (!(path = PATH_WidenPath( dc ))) return FALSE;
2114 free_gdi_path( dc->path );
2115 dc->path = path;
2116 return TRUE;
2119 const struct gdi_dc_funcs path_driver =
2121 NULL, /* pAbortDoc */
2122 pathdrv_AbortPath, /* pAbortPath */
2123 NULL, /* pAlphaBlend */
2124 pathdrv_AngleArc, /* pAngleArc */
2125 pathdrv_Arc, /* pArc */
2126 pathdrv_ArcTo, /* pArcTo */
2127 pathdrv_BeginPath, /* pBeginPath */
2128 NULL, /* pBlendImage */
2129 pathdrv_Chord, /* pChord */
2130 pathdrv_CloseFigure, /* pCloseFigure */
2131 NULL, /* pCreateCompatibleDC */
2132 pathdrv_CreateDC, /* pCreateDC */
2133 pathdrv_DeleteDC, /* pDeleteDC */
2134 NULL, /* pDeleteObject */
2135 NULL, /* pDeviceCapabilities */
2136 pathdrv_Ellipse, /* pEllipse */
2137 NULL, /* pEndDoc */
2138 NULL, /* pEndPage */
2139 pathdrv_EndPath, /* pEndPath */
2140 NULL, /* pEnumFonts */
2141 NULL, /* pEnumICMProfiles */
2142 NULL, /* pExcludeClipRect */
2143 NULL, /* pExtDeviceMode */
2144 NULL, /* pExtEscape */
2145 NULL, /* pExtFloodFill */
2146 NULL, /* pExtSelectClipRgn */
2147 pathdrv_ExtTextOut, /* pExtTextOut */
2148 NULL, /* pFillPath */
2149 NULL, /* pFillRgn */
2150 NULL, /* pFlattenPath */
2151 NULL, /* pFontIsLinked */
2152 NULL, /* pFrameRgn */
2153 NULL, /* pGdiComment */
2154 NULL, /* pGetBoundsRect */
2155 NULL, /* pGetCharABCWidths */
2156 NULL, /* pGetCharABCWidthsI */
2157 NULL, /* pGetCharWidth */
2158 NULL, /* pGetDeviceCaps */
2159 NULL, /* pGetDeviceGammaRamp */
2160 NULL, /* pGetFontData */
2161 NULL, /* pGetFontRealizationInfo */
2162 NULL, /* pGetFontUnicodeRanges */
2163 NULL, /* pGetGlyphIndices */
2164 NULL, /* pGetGlyphOutline */
2165 NULL, /* pGetICMProfile */
2166 NULL, /* pGetImage */
2167 NULL, /* pGetKerningPairs */
2168 NULL, /* pGetNearestColor */
2169 NULL, /* pGetOutlineTextMetrics */
2170 NULL, /* pGetPixel */
2171 NULL, /* pGetSystemPaletteEntries */
2172 NULL, /* pGetTextCharsetInfo */
2173 NULL, /* pGetTextExtentExPoint */
2174 NULL, /* pGetTextExtentExPointI */
2175 NULL, /* pGetTextFace */
2176 NULL, /* pGetTextMetrics */
2177 NULL, /* pGradientFill */
2178 NULL, /* pIntersectClipRect */
2179 NULL, /* pInvertRgn */
2180 pathdrv_LineTo, /* pLineTo */
2181 NULL, /* pModifyWorldTransform */
2182 pathdrv_MoveTo, /* pMoveTo */
2183 NULL, /* pOffsetClipRgn */
2184 NULL, /* pOffsetViewportOrg */
2185 NULL, /* pOffsetWindowOrg */
2186 NULL, /* pPaintRgn */
2187 NULL, /* pPatBlt */
2188 pathdrv_Pie, /* pPie */
2189 pathdrv_PolyBezier, /* pPolyBezier */
2190 pathdrv_PolyBezierTo, /* pPolyBezierTo */
2191 pathdrv_PolyDraw, /* pPolyDraw */
2192 pathdrv_PolyPolygon, /* pPolyPolygon */
2193 pathdrv_PolyPolyline, /* pPolyPolyline */
2194 pathdrv_Polygon, /* pPolygon */
2195 pathdrv_Polyline, /* pPolyline */
2196 pathdrv_PolylineTo, /* pPolylineTo */
2197 NULL, /* pPutImage */
2198 NULL, /* pRealizeDefaultPalette */
2199 NULL, /* pRealizePalette */
2200 pathdrv_Rectangle, /* pRectangle */
2201 NULL, /* pResetDC */
2202 NULL, /* pRestoreDC */
2203 pathdrv_RoundRect, /* pRoundRect */
2204 NULL, /* pSaveDC */
2205 NULL, /* pScaleViewportExt */
2206 NULL, /* pScaleWindowExt */
2207 NULL, /* pSelectBitmap */
2208 NULL, /* pSelectBrush */
2209 NULL, /* pSelectClipPath */
2210 NULL, /* pSelectFont */
2211 NULL, /* pSelectPalette */
2212 NULL, /* pSelectPen */
2213 NULL, /* pSetArcDirection */
2214 NULL, /* pSetBkColor */
2215 NULL, /* pSetBkMode */
2216 NULL, /* pSetDCBrushColor */
2217 NULL, /* pSetDCPenColor */
2218 NULL, /* pSetDIBColorTable */
2219 NULL, /* pSetDIBitsToDevice */
2220 NULL, /* pSetDeviceClipping */
2221 NULL, /* pSetDeviceGammaRamp */
2222 NULL, /* pSetLayout */
2223 NULL, /* pSetMapMode */
2224 NULL, /* pSetMapperFlags */
2225 NULL, /* pSetPixel */
2226 NULL, /* pSetPolyFillMode */
2227 NULL, /* pSetROP2 */
2228 NULL, /* pSetRelAbs */
2229 NULL, /* pSetStretchBltMode */
2230 NULL, /* pSetTextAlign */
2231 NULL, /* pSetTextCharacterExtra */
2232 NULL, /* pSetTextColor */
2233 NULL, /* pSetTextJustification */
2234 NULL, /* pSetViewportExt */
2235 NULL, /* pSetViewportOrg */
2236 NULL, /* pSetWindowExt */
2237 NULL, /* pSetWindowOrg */
2238 NULL, /* pSetWorldTransform */
2239 NULL, /* pStartDoc */
2240 NULL, /* pStartPage */
2241 NULL, /* pStretchBlt */
2242 NULL, /* pStretchDIBits */
2243 NULL, /* pStrokeAndFillPath */
2244 NULL, /* pStrokePath */
2245 NULL, /* pUnrealizePalette */
2246 NULL, /* pWidenPath */
2247 NULL, /* wine_get_wgl_driver */
2248 GDI_PRIORITY_PATH_DRV /* priority */