gdi32: Remove no longer used clipping driver entry points.
[wine.git] / dlls / gdi32 / path.c
blobc8f21633e82909c2efb6e6b3856b14df4bcc9a06
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 <assert.h>
25 #include <math.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include <float.h>
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "winerror.h"
36 #include "ntgdi_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
41 /* Notes on the implementation
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.
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).
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.
68 * Martin Boehme
71 #define NUM_ENTRIES_INITIAL 16 /* Initial size of points / flags arrays */
73 /* A floating point version of the POINT structure */
74 typedef struct tagFLOAT_POINT
76 double x, y;
77 } FLOAT_POINT;
79 struct gdi_path
81 POINT *points;
82 BYTE *flags;
83 int count;
84 int allocated;
85 BOOL newStroke;
86 POINT pos; /* current cursor position */
87 POINT points_buf[NUM_ENTRIES_INITIAL];
88 BYTE flags_buf[NUM_ENTRIES_INITIAL];
91 struct path_physdev
93 struct gdi_physdev dev;
94 struct gdi_path *path;
97 static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
99 return CONTAINING_RECORD( dev, struct path_physdev, dev );
102 void free_gdi_path( struct gdi_path *path )
104 if (path->points != path->points_buf)
105 HeapFree( GetProcessHeap(), 0, path->points );
106 HeapFree( GetProcessHeap(), 0, path );
109 static struct gdi_path *alloc_gdi_path( int count )
111 struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) );
113 if (!path)
115 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
116 return NULL;
118 count = max( NUM_ENTRIES_INITIAL, count );
119 if (count > NUM_ENTRIES_INITIAL)
121 path->points = HeapAlloc( GetProcessHeap(), 0,
122 count * (sizeof(path->points[0]) + sizeof(path->flags[0])) );
123 if (!path->points)
125 HeapFree( GetProcessHeap(), 0, path );
126 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
127 return NULL;
129 path->flags = (BYTE *)(path->points + count);
131 else
133 path->points = path->points_buf;
134 path->flags = path->flags_buf;
136 path->count = 0;
137 path->allocated = count;
138 path->newStroke = TRUE;
139 path->pos.x = path->pos.y = 0;
140 return path;
143 static struct gdi_path *copy_gdi_path( const struct gdi_path *src_path )
145 struct gdi_path *path = alloc_gdi_path( src_path->count );
147 if (!path) return NULL;
149 path->count = src_path->count;
150 path->newStroke = src_path->newStroke;
151 path->pos = src_path->pos;
152 memcpy( path->points, src_path->points, path->count * sizeof(*path->points) );
153 memcpy( path->flags, src_path->flags, path->count * sizeof(*path->flags) );
154 return path;
157 /* Performs a world-to-viewport transformation on the specified point (which
158 * is in floating point format).
160 static inline void INTERNAL_LPTODP_FLOAT( DC *dc, FLOAT_POINT *point, int count )
162 double x, y;
164 while (count--)
166 x = point->x;
167 y = point->y;
168 point->x = x * dc->xformWorld2Vport.eM11 + y * dc->xformWorld2Vport.eM21 + dc->xformWorld2Vport.eDx;
169 point->y = x * dc->xformWorld2Vport.eM12 + y * dc->xformWorld2Vport.eM22 + dc->xformWorld2Vport.eDy;
170 point++;
174 static inline INT int_from_fixed(FIXED f)
176 return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
180 /* PATH_ReserveEntries
182 * Ensures that at least "numEntries" entries (for points and flags) have
183 * been allocated; allocates larger arrays and copies the existing entries
184 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
186 static BOOL PATH_ReserveEntries(struct gdi_path *path, INT count)
188 POINT *pts_new;
189 int size;
191 assert(count>=0);
193 /* Do we have to allocate more memory? */
194 if (count > path->allocated)
196 /* Find number of entries to allocate. We let the size of the array
197 * grow exponentially, since that will guarantee linear time
198 * complexity. */
199 count = max( path->allocated * 2, count );
200 size = count * (sizeof(path->points[0]) + sizeof(path->flags[0]));
202 if (path->points == path->points_buf)
204 pts_new = HeapAlloc( GetProcessHeap(), 0, size );
205 if (!pts_new) return FALSE;
206 memcpy( pts_new, path->points, path->count * sizeof(path->points[0]) );
207 memcpy( pts_new + count, path->flags, path->count * sizeof(path->flags[0]) );
209 else
211 pts_new = HeapReAlloc( GetProcessHeap(), 0, path->points, size );
212 if (!pts_new) return FALSE;
213 memmove( pts_new + count, pts_new + path->allocated, path->count * sizeof(path->flags[0]) );
216 path->points = pts_new;
217 path->flags = (BYTE *)(pts_new + count);
218 path->allocated = count;
220 return TRUE;
223 /* PATH_AddEntry
225 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
226 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
227 * successful, FALSE otherwise (e.g. if not enough memory was available).
229 static BOOL PATH_AddEntry(struct gdi_path *pPath, const POINT *pPoint, BYTE flags)
231 /* FIXME: If newStroke is true, perhaps we want to check that we're
232 * getting a PT_MOVETO
234 TRACE("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags);
236 /* Reserve enough memory for an extra path entry */
237 if(!PATH_ReserveEntries(pPath, pPath->count+1))
238 return FALSE;
240 /* Store information in path entry */
241 pPath->points[pPath->count]=*pPoint;
242 pPath->flags[pPath->count]=flags;
244 pPath->count++;
246 return TRUE;
249 /* add a number of points, converting them to device coords */
250 /* return a pointer to the first type byte so it can be fixed up if necessary */
251 static BYTE *add_log_points( DC *dc, struct gdi_path *path, const POINT *points,
252 DWORD count, BYTE type )
254 BYTE *ret;
256 if (!PATH_ReserveEntries( path, path->count + count )) return NULL;
258 ret = &path->flags[path->count];
259 memcpy( &path->points[path->count], points, count * sizeof(*points) );
260 lp_to_dp( dc, &path->points[path->count], count );
261 memset( ret, type, count );
262 path->count += count;
263 return ret;
266 /* add a number of points that are already in device coords */
267 /* return a pointer to the first type byte so it can be fixed up if necessary */
268 static BYTE *add_points( struct gdi_path *path, const POINT *points, DWORD count, BYTE type )
270 BYTE *ret;
272 if (!PATH_ReserveEntries( path, path->count + count )) return NULL;
274 ret = &path->flags[path->count];
275 memcpy( &path->points[path->count], points, count * sizeof(*points) );
276 memset( ret, type, count );
277 path->count += count;
278 return ret;
281 /* reverse the order of an array of points */
282 static void reverse_points( POINT *points, UINT count )
284 UINT i;
285 for (i = 0; i < count / 2; i++)
287 POINT pt = points[i];
288 points[i] = points[count - i - 1];
289 points[count - i - 1] = pt;
293 /* start a new path stroke if necessary */
294 static BOOL start_new_stroke( struct gdi_path *path )
296 if (!path->newStroke && path->count &&
297 !(path->flags[path->count - 1] & PT_CLOSEFIGURE) &&
298 path->points[path->count - 1].x == path->pos.x &&
299 path->points[path->count - 1].y == path->pos.y)
300 return TRUE;
302 path->newStroke = FALSE;
303 return add_points( path, &path->pos, 1, PT_MOVETO ) != NULL;
306 /* set current position to the last point that was added to the path */
307 static void update_current_pos( struct gdi_path *path )
309 assert( path->count );
310 path->pos = path->points[path->count - 1];
313 /* close the current figure */
314 static void close_figure( struct gdi_path *path )
316 assert( path->count );
317 path->flags[path->count - 1] |= PT_CLOSEFIGURE;
320 /* add a number of points, starting a new stroke if necessary */
321 static BOOL add_log_points_new_stroke( DC *dc, struct gdi_path *path, const POINT *points,
322 DWORD count, BYTE type )
324 if (!start_new_stroke( path )) return FALSE;
325 if (!add_log_points( dc, path, points, count, type )) return FALSE;
326 update_current_pos( path );
327 return TRUE;
330 /* convert a (flattened) path to a region */
331 static HRGN path_to_region( const struct gdi_path *path, int mode )
333 int i, pos, polygons, *counts;
334 HRGN hrgn;
336 if (!path->count) return 0;
338 if (!(counts = HeapAlloc( GetProcessHeap(), 0, (path->count / 2) * sizeof(*counts) ))) return 0;
340 pos = polygons = 0;
341 assert( path->flags[0] == PT_MOVETO );
342 for (i = 1; i < path->count; i++)
344 if (path->flags[i] != PT_MOVETO) continue;
345 counts[polygons++] = i - pos;
346 pos = i;
348 if (i > pos + 1) counts[polygons++] = i - pos;
350 assert( polygons <= path->count / 2 );
351 hrgn = CreatePolyPolygonRgn( path->points, counts, polygons, mode );
352 HeapFree( GetProcessHeap(), 0, counts );
353 return hrgn;
356 /* PATH_CheckCorners
358 * Helper function for RoundRect() and Rectangle()
360 static BOOL PATH_CheckCorners( DC *dc, POINT corners[], INT x1, INT y1, INT x2, INT y2 )
362 INT temp;
364 /* Convert points to device coordinates */
365 corners[0].x=x1;
366 corners[0].y=y1;
367 corners[1].x=x2;
368 corners[1].y=y2;
369 lp_to_dp( dc, corners, 2 );
371 /* Make sure first corner is top left and second corner is bottom right */
372 if(corners[0].x>corners[1].x)
374 temp=corners[0].x;
375 corners[0].x=corners[1].x;
376 corners[1].x=temp;
378 if(corners[0].y>corners[1].y)
380 temp=corners[0].y;
381 corners[0].y=corners[1].y;
382 corners[1].y=temp;
385 /* In GM_COMPATIBLE, don't include bottom and right edges */
386 if (dc->attr->graphics_mode == GM_COMPATIBLE)
388 if (corners[0].x == corners[1].x) return FALSE;
389 if (corners[0].y == corners[1].y) return FALSE;
390 corners[1].x--;
391 corners[1].y--;
393 return TRUE;
396 /* PATH_AddFlatBezier
398 static BOOL PATH_AddFlatBezier(struct gdi_path *pPath, POINT *pt, BOOL closed)
400 POINT *pts;
401 BOOL ret;
402 INT no;
404 pts = GDI_Bezier( pt, 4, &no );
405 if(!pts) return FALSE;
407 ret = (add_points( pPath, pts + 1, no - 1, PT_LINETO ) != NULL);
408 if (ret && closed) close_figure( pPath );
409 HeapFree( GetProcessHeap(), 0, pts );
410 return ret;
413 /* PATH_FlattenPath
415 * Replaces Beziers with line segments
418 static struct gdi_path *PATH_FlattenPath(const struct gdi_path *pPath)
420 struct gdi_path *new_path;
421 INT srcpt;
423 if (!(new_path = alloc_gdi_path( pPath->count ))) return NULL;
425 for(srcpt = 0; srcpt < pPath->count; srcpt++) {
426 switch(pPath->flags[srcpt] & ~PT_CLOSEFIGURE) {
427 case PT_MOVETO:
428 case PT_LINETO:
429 if (!PATH_AddEntry(new_path, &pPath->points[srcpt], pPath->flags[srcpt]))
431 free_gdi_path( new_path );
432 return NULL;
434 break;
435 case PT_BEZIERTO:
436 if (!PATH_AddFlatBezier(new_path, &pPath->points[srcpt-1],
437 pPath->flags[srcpt+2] & PT_CLOSEFIGURE))
439 free_gdi_path( new_path );
440 return NULL;
442 srcpt += 2;
443 break;
446 return new_path;
449 /* PATH_ScaleNormalizedPoint
451 * Scales a normalized point (x, y) with respect to the box whose corners are
452 * passed in "corners". The point is stored in "*pPoint". The normalized
453 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
454 * (1.0, 1.0) correspond to corners[1].
456 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
457 double y, POINT *pPoint)
459 pPoint->x = GDI_ROUND( corners[0].x + (corners[1].x-corners[0].x)*0.5*(x+1.0) );
460 pPoint->y = GDI_ROUND( corners[0].y + (corners[1].y-corners[0].y)*0.5*(y+1.0) );
463 /* PATH_NormalizePoint
465 * Normalizes a point with respect to the box whose corners are passed in
466 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
468 static void PATH_NormalizePoint(FLOAT_POINT corners[],
469 const FLOAT_POINT *pPoint,
470 double *pX, double *pY)
472 *pX = (pPoint->x-corners[0].x)/(corners[1].x-corners[0].x) * 2.0 - 1.0;
473 *pY = (pPoint->y-corners[0].y)/(corners[1].y-corners[0].y) * 2.0 - 1.0;
476 /* PATH_DoArcPart
478 * Creates a Bezier spline that corresponds to part of an arc and appends the
479 * corresponding points to the path. The start and end angles are passed in
480 * "angleStart" and "angleEnd"; these angles should span a quarter circle
481 * at most. If "startEntryType" is non-zero, an entry of that type for the first
482 * control point is added to the path; otherwise, it is assumed that the current
483 * position is equal to the first control point.
485 static BOOL PATH_DoArcPart(struct gdi_path *pPath, FLOAT_POINT corners[],
486 double angleStart, double angleEnd, BYTE startEntryType)
488 double halfAngle, a;
489 double xNorm[4], yNorm[4];
490 POINT points[4];
491 BYTE *type;
492 int i, start;
494 assert(fabs(angleEnd-angleStart)<=M_PI_2);
496 /* FIXME: Is there an easier way of computing this? */
498 /* Compute control points */
499 halfAngle=(angleEnd-angleStart)/2.0;
500 if(fabs(halfAngle)>1e-8)
502 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
503 xNorm[0]=cos(angleStart);
504 yNorm[0]=sin(angleStart);
505 xNorm[1]=xNorm[0] - a*yNorm[0];
506 yNorm[1]=yNorm[0] + a*xNorm[0];
507 xNorm[3]=cos(angleEnd);
508 yNorm[3]=sin(angleEnd);
509 xNorm[2]=xNorm[3] + a*yNorm[3];
510 yNorm[2]=yNorm[3] - a*xNorm[3];
512 else
513 for(i=0; i<4; i++)
515 xNorm[i]=cos(angleStart);
516 yNorm[i]=sin(angleStart);
519 /* Add starting point to path if desired */
520 start = !startEntryType;
521 for (i = start; i < 4; i++) PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &points[i]);
522 if (!(type = add_points( pPath, points + start, 4 - start, PT_BEZIERTO ))) return FALSE;
523 if (!start) type[0] = startEntryType;
524 return TRUE;
527 /* retrieve a flattened path in device coordinates, and optionally its region */
528 /* the DC path is deleted; the returned data must be freed by caller using free_gdi_path() */
529 /* helper for stroke_and_fill_path in the DIB driver */
530 struct gdi_path *get_gdi_flat_path( DC *dc, HRGN *rgn )
532 struct gdi_path *ret = NULL;
534 if (dc->path)
536 ret = PATH_FlattenPath( dc->path );
538 free_gdi_path( dc->path );
539 dc->path = NULL;
540 if (ret && rgn) *rgn = path_to_region( ret, dc->attr->poly_fill_mode );
542 else SetLastError( ERROR_CAN_NOT_COMPLETE );
544 return ret;
547 int get_gdi_path_data( struct gdi_path *path, POINT **pts, BYTE **flags )
549 *pts = path->points;
550 *flags = path->flags;
551 return path->count;
554 /***********************************************************************
555 * NtGdiBeginPath (win32u.@)
557 BOOL WINAPI NtGdiBeginPath( HDC hdc )
559 BOOL ret = FALSE;
560 DC *dc = get_dc_ptr( hdc );
562 if (dc)
564 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pBeginPath );
565 ret = physdev->funcs->pBeginPath( physdev );
566 release_dc_ptr( dc );
568 return ret;
572 /***********************************************************************
573 * NtGdiEndPath (win32u.@)
575 BOOL WINAPI NtGdiEndPath( HDC hdc )
577 BOOL ret = FALSE;
578 DC *dc = get_dc_ptr( hdc );
580 if (dc)
582 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEndPath );
583 ret = physdev->funcs->pEndPath( physdev );
584 release_dc_ptr( dc );
586 return ret;
590 /******************************************************************************
591 * NtGdiAbortPath (win32u.@)
593 BOOL WINAPI NtGdiAbortPath( HDC hdc )
595 BOOL ret = FALSE;
596 DC *dc = get_dc_ptr( hdc );
598 if (dc)
600 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pAbortPath );
601 ret = physdev->funcs->pAbortPath( physdev );
602 release_dc_ptr( dc );
604 return ret;
608 /***********************************************************************
609 * NtGdiCloseFigure (win32u.@)
611 BOOL WINAPI NtGdiCloseFigure( HDC hdc )
613 BOOL ret = FALSE;
614 DC *dc = get_dc_ptr( hdc );
616 if (dc)
618 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pCloseFigure );
619 ret = physdev->funcs->pCloseFigure( physdev );
620 release_dc_ptr( dc );
622 return ret;
626 /***********************************************************************
627 * GetPath (GDI32.@)
629 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes, INT nSize)
631 INT ret = -1;
632 DC *dc = get_dc_ptr( hdc );
634 if(!dc) return -1;
636 if (!dc->path)
638 SetLastError(ERROR_CAN_NOT_COMPLETE);
639 goto done;
642 if(nSize==0)
643 ret = dc->path->count;
644 else if(nSize<dc->path->count)
646 SetLastError(ERROR_INVALID_PARAMETER);
647 goto done;
649 else
651 memcpy(pPoints, dc->path->points, sizeof(POINT)*dc->path->count);
652 memcpy(pTypes, dc->path->flags, sizeof(BYTE)*dc->path->count);
654 /* Convert the points to logical coordinates */
655 if(!dp_to_lp(dc, pPoints, dc->path->count))
657 /* FIXME: Is this the correct value? */
658 SetLastError(ERROR_CAN_NOT_COMPLETE);
659 goto done;
661 else ret = dc->path->count;
663 done:
664 release_dc_ptr( dc );
665 return ret;
669 /***********************************************************************
670 * PathToRegion (GDI32.@)
672 HRGN WINAPI PathToRegion(HDC hdc)
674 HRGN ret = 0;
675 DC *dc = get_dc_ptr( hdc );
677 if (!dc) return 0;
679 if (dc->path)
681 struct gdi_path *path = PATH_FlattenPath( dc->path );
683 free_gdi_path( dc->path );
684 dc->path = NULL;
685 if (path)
687 ret = path_to_region( path, dc->attr->poly_fill_mode );
688 free_gdi_path( path );
691 else SetLastError( ERROR_CAN_NOT_COMPLETE );
693 release_dc_ptr( dc );
694 return ret;
698 /***********************************************************************
699 * FillPath (GDI32.@)
701 * FIXME
702 * Check that SetLastError is being called correctly
704 BOOL WINAPI FillPath(HDC hdc)
706 BOOL ret = FALSE;
707 DC *dc = get_dc_ptr( hdc );
709 if (dc)
711 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFillPath );
712 ret = physdev->funcs->pFillPath( physdev );
713 release_dc_ptr( dc );
715 return ret;
719 /***********************************************************************
720 * SelectClipPath (GDI32.@)
722 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
724 BOOL ret = FALSE;
725 DC *dc = get_dc_ptr( hdc );
727 if (dc)
729 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectClipPath );
730 ret = physdev->funcs->pSelectClipPath( physdev, iMode );
731 release_dc_ptr( dc );
733 return ret;
737 /***********************************************************************
738 * pathdrv_BeginPath
740 static BOOL CDECL pathdrv_BeginPath( PHYSDEV dev )
742 /* path already open, nothing to do */
743 return TRUE;
747 /***********************************************************************
748 * pathdrv_AbortPath
750 static BOOL CDECL pathdrv_AbortPath( PHYSDEV dev )
752 DC *dc = get_physdev_dc( dev );
754 path_driver.pDeleteDC( pop_dc_driver( dc, &path_driver ));
755 return TRUE;
759 /***********************************************************************
760 * pathdrv_EndPath
762 static BOOL CDECL pathdrv_EndPath( PHYSDEV dev )
764 struct path_physdev *physdev = get_path_physdev( dev );
765 DC *dc = get_physdev_dc( dev );
767 dc->path = physdev->path;
768 pop_dc_driver( dc, &path_driver );
769 HeapFree( GetProcessHeap(), 0, physdev );
770 return TRUE;
774 /***********************************************************************
775 * pathdrv_CreateDC
777 static BOOL CDECL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
778 LPCWSTR output, const DEVMODEW *devmode )
780 struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) );
782 if (!physdev) return FALSE;
783 push_dc_driver( dev, &physdev->dev, &path_driver );
784 return TRUE;
788 /*************************************************************
789 * pathdrv_DeleteDC
791 static BOOL CDECL pathdrv_DeleteDC( PHYSDEV dev )
793 struct path_physdev *physdev = get_path_physdev( dev );
795 free_gdi_path( physdev->path );
796 HeapFree( GetProcessHeap(), 0, physdev );
797 return TRUE;
801 BOOL PATH_SavePath( DC *dst, DC *src )
803 PHYSDEV dev;
805 if (src->path)
807 if (!(dst->path = copy_gdi_path( src->path ))) return FALSE;
809 else if ((dev = find_dc_driver( src, &path_driver )))
811 struct path_physdev *physdev = get_path_physdev( dev );
812 if (!(dst->path = copy_gdi_path( physdev->path ))) return FALSE;
813 dst->path_open = TRUE;
815 else dst->path = NULL;
816 return TRUE;
819 BOOL PATH_RestorePath( DC *dst, DC *src )
821 PHYSDEV dev;
822 struct path_physdev *physdev;
824 if ((dev = pop_dc_driver( dst, &path_driver )))
826 physdev = get_path_physdev( dev );
827 free_gdi_path( physdev->path );
828 HeapFree( GetProcessHeap(), 0, physdev );
831 if (src->path && src->path_open)
833 if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
834 physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
835 physdev->path = src->path;
836 src->path_open = FALSE;
837 src->path = NULL;
840 if (dst->path) free_gdi_path( dst->path );
841 dst->path = src->path;
842 src->path = NULL;
843 return TRUE;
847 /*************************************************************
848 * pathdrv_MoveTo
850 static BOOL CDECL pathdrv_MoveTo( PHYSDEV dev, INT x, INT y )
852 struct path_physdev *physdev = get_path_physdev( dev );
853 DC *dc = get_physdev_dc( dev );
855 physdev->path->newStroke = TRUE;
856 physdev->path->pos.x = x;
857 physdev->path->pos.y = y;
858 lp_to_dp( dc, &physdev->path->pos, 1 );
859 return TRUE;
863 /*************************************************************
864 * pathdrv_LineTo
866 static BOOL CDECL pathdrv_LineTo( PHYSDEV dev, INT x, INT y )
868 struct path_physdev *physdev = get_path_physdev( dev );
869 DC *dc = get_physdev_dc( dev );
870 POINT point;
872 point.x = x;
873 point.y = y;
874 return add_log_points_new_stroke( dc, physdev->path, &point, 1, PT_LINETO );
878 /*************************************************************
879 * pathdrv_Rectangle
881 static BOOL CDECL pathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
883 struct path_physdev *physdev = get_path_physdev( dev );
884 DC *dc = get_physdev_dc( dev );
885 POINT corners[2], points[4];
886 BYTE *type;
888 if (!PATH_CheckCorners( dc, corners, x1, y1, x2, y2 )) return TRUE;
890 points[0].x = corners[1].x;
891 points[0].y = corners[0].y;
892 points[1] = corners[0];
893 points[2].x = corners[0].x;
894 points[2].y = corners[1].y;
895 points[3] = corners[1];
896 if (dc->attr->arc_direction == AD_CLOCKWISE) reverse_points( points, 4 );
898 if (!(type = add_points( physdev->path, points, 4, PT_LINETO ))) return FALSE;
899 type[0] = PT_MOVETO;
900 close_figure( physdev->path );
901 return TRUE;
905 /*************************************************************
906 * pathdrv_RoundRect
908 static BOOL CDECL pathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height )
910 const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */
911 struct path_physdev *physdev = get_path_physdev( dev );
912 DC *dc = get_physdev_dc( dev );
913 POINT corners[2], ellipse[2], points[16];
914 BYTE *type;
915 double width, height;
917 if (!ell_width || !ell_height) return pathdrv_Rectangle( dev, x1, y1, x2, y2 );
919 if (!PATH_CheckCorners( dc, corners, x1, y1, x2, y2 )) return TRUE;
921 ellipse[0].x = ellipse[0].y = 0;
922 ellipse[1].x = ell_width;
923 ellipse[1].y = ell_height;
924 lp_to_dp( dc, (POINT *)&ellipse, 2 );
925 ell_width = min( abs( ellipse[1].x - ellipse[0].x ), corners[1].x - corners[0].x );
926 ell_height = min( abs( ellipse[1].y - ellipse[0].y ), corners[1].y - corners[0].y );
927 width = ell_width / 2.0;
928 height = ell_height / 2.0;
930 /* starting point */
931 points[0].x = corners[1].x;
932 points[0].y = corners[0].y + GDI_ROUND( height );
933 /* first curve */
934 points[1].x = corners[1].x;
935 points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
936 points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
937 points[2].y = corners[0].y;
938 points[3].x = corners[1].x - GDI_ROUND( width );
939 points[3].y = corners[0].y;
940 /* horizontal line */
941 points[4].x = corners[0].x + GDI_ROUND( width );
942 points[4].y = corners[0].y;
943 /* second curve */
944 points[5].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
945 points[5].y = corners[0].y;
946 points[6].x = corners[0].x;
947 points[6].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
948 points[7].x = corners[0].x;
949 points[7].y = corners[0].y + GDI_ROUND( height );
950 /* vertical line */
951 points[8].x = corners[0].x;
952 points[8].y = corners[1].y - GDI_ROUND( height );
953 /* third curve */
954 points[9].x = corners[0].x;
955 points[9].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
956 points[10].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
957 points[10].y = corners[1].y;
958 points[11].x = corners[0].x + GDI_ROUND( width );
959 points[11].y = corners[1].y;
960 /* horizontal line */
961 points[12].x = corners[1].x - GDI_ROUND( width );
962 points[12].y = corners[1].y;
963 /* fourth curve */
964 points[13].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
965 points[13].y = corners[1].y;
966 points[14].x = corners[1].x;
967 points[14].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
968 points[15].x = corners[1].x;
969 points[15].y = corners[1].y - GDI_ROUND( height );
971 if (dc->attr->arc_direction == AD_CLOCKWISE) reverse_points( points, 16 );
972 if (!(type = add_points( physdev->path, points, 16, PT_BEZIERTO ))) return FALSE;
973 type[0] = PT_MOVETO;
974 type[4] = type[8] = type[12] = PT_LINETO;
975 close_figure( physdev->path );
976 return TRUE;
980 /*************************************************************
981 * pathdrv_Ellipse
983 static BOOL CDECL pathdrv_Ellipse( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
985 const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */
986 struct path_physdev *physdev = get_path_physdev( dev );
987 DC *dc = get_physdev_dc( dev );
988 POINT corners[2], points[13];
989 BYTE *type;
990 double width, height;
992 if (!PATH_CheckCorners( dc, corners, x1, y1, x2, y2 )) return TRUE;
994 width = (corners[1].x - corners[0].x) / 2.0;
995 height = (corners[1].y - corners[0].y) / 2.0;
997 /* starting point */
998 points[0].x = corners[1].x;
999 points[0].y = corners[0].y + GDI_ROUND( height );
1000 /* first curve */
1001 points[1].x = corners[1].x;
1002 points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
1003 points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
1004 points[2].y = corners[0].y;
1005 points[3].x = corners[0].x + GDI_ROUND( width );
1006 points[3].y = corners[0].y;
1007 /* second curve */
1008 points[4].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
1009 points[4].y = corners[0].y;
1010 points[5].x = corners[0].x;
1011 points[5].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
1012 points[6].x = corners[0].x;
1013 points[6].y = corners[0].y + GDI_ROUND( height );
1014 /* third curve */
1015 points[7].x = corners[0].x;
1016 points[7].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
1017 points[8].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
1018 points[8].y = corners[1].y;
1019 points[9].x = corners[0].x + GDI_ROUND( width );
1020 points[9].y = corners[1].y;
1021 /* fourth curve */
1022 points[10].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
1023 points[10].y = corners[1].y;
1024 points[11].x = corners[1].x;
1025 points[11].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
1026 points[12].x = corners[1].x;
1027 points[12].y = corners[1].y - GDI_ROUND( height );
1029 if (dc->attr->arc_direction == AD_CLOCKWISE) reverse_points( points, 13 );
1030 if (!(type = add_points( physdev->path, points, 13, PT_BEZIERTO ))) return FALSE;
1031 type[0] = PT_MOVETO;
1032 close_figure( physdev->path );
1033 return TRUE;
1037 /* PATH_Arc
1039 * Should be called when a call to Arc is performed on a DC that has
1040 * an open path. This adds up to five Bezier splines representing the arc
1041 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
1042 * when 'lines' is 2, we add 2 extra lines to get a pie, and when 'lines' is
1043 * -1 we add 1 extra line from the current DC position to the starting position
1044 * of the arc before drawing the arc itself (arcto). Returns TRUE if successful,
1045 * else FALSE.
1047 static BOOL PATH_Arc( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2,
1048 INT xStart, INT yStart, INT xEnd, INT yEnd, int direction, int lines )
1050 DC *dc = get_physdev_dc( dev );
1051 struct path_physdev *physdev = get_path_physdev( dev );
1052 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
1053 /* Initialize angleEndQuadrant to silence gcc's warning */
1054 double x, y;
1055 FLOAT_POINT corners[2], pointStart, pointEnd;
1056 POINT centre;
1057 BOOL start, end;
1058 INT temp;
1060 /* FIXME: Do we have to respect newStroke? */
1062 /* Check for zero height / width */
1063 /* FIXME: Only in GM_COMPATIBLE? */
1064 if(x1==x2 || y1==y2)
1065 return TRUE;
1067 /* Convert points to device coordinates */
1068 corners[0].x = x1;
1069 corners[0].y = y1;
1070 corners[1].x = x2;
1071 corners[1].y = y2;
1072 pointStart.x = xStart;
1073 pointStart.y = yStart;
1074 pointEnd.x = xEnd;
1075 pointEnd.y = yEnd;
1076 INTERNAL_LPTODP_FLOAT(dc, corners, 2);
1077 INTERNAL_LPTODP_FLOAT(dc, &pointStart, 1);
1078 INTERNAL_LPTODP_FLOAT(dc, &pointEnd, 1);
1080 /* Make sure first corner is top left and second corner is bottom right */
1081 if(corners[0].x>corners[1].x)
1083 temp=corners[0].x;
1084 corners[0].x=corners[1].x;
1085 corners[1].x=temp;
1087 if(corners[0].y>corners[1].y)
1089 temp=corners[0].y;
1090 corners[0].y=corners[1].y;
1091 corners[1].y=temp;
1094 /* Compute start and end angle */
1095 PATH_NormalizePoint(corners, &pointStart, &x, &y);
1096 angleStart=atan2(y, x);
1097 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
1098 angleEnd=atan2(y, x);
1100 /* Make sure the end angle is "on the right side" of the start angle */
1101 if (direction == AD_CLOCKWISE)
1103 if(angleEnd<=angleStart)
1105 angleEnd+=2*M_PI;
1106 assert(angleEnd>=angleStart);
1109 else
1111 if(angleEnd>=angleStart)
1113 angleEnd-=2*M_PI;
1114 assert(angleEnd<=angleStart);
1118 /* In GM_COMPATIBLE, don't include bottom and right edges */
1119 if (dc->attr->graphics_mode == GM_COMPATIBLE)
1121 corners[1].x--;
1122 corners[1].y--;
1125 /* arcto: Add a PT_MOVETO only if this is the first entry in a stroke */
1126 if (lines == -1 && !start_new_stroke( physdev->path )) return FALSE;
1128 /* Add the arc to the path with one Bezier spline per quadrant that the
1129 * arc spans */
1130 start=TRUE;
1131 end=FALSE;
1134 /* Determine the start and end angles for this quadrant */
1135 if(start)
1137 angleStartQuadrant=angleStart;
1138 if (direction == AD_CLOCKWISE)
1139 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
1140 else
1141 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
1143 else
1145 angleStartQuadrant=angleEndQuadrant;
1146 if (direction == AD_CLOCKWISE)
1147 angleEndQuadrant+=M_PI_2;
1148 else
1149 angleEndQuadrant-=M_PI_2;
1152 /* Have we reached the last part of the arc? */
1153 if((direction == AD_CLOCKWISE && angleEnd<angleEndQuadrant) ||
1154 (direction == AD_COUNTERCLOCKWISE && angleEnd>angleEndQuadrant))
1156 /* Adjust the end angle for this quadrant */
1157 angleEndQuadrant=angleEnd;
1158 end=TRUE;
1161 /* Add the Bezier spline to the path */
1162 PATH_DoArcPart(physdev->path, corners, angleStartQuadrant, angleEndQuadrant,
1163 start ? (lines==-1 ? PT_LINETO : PT_MOVETO) : 0);
1164 start=FALSE;
1165 } while(!end);
1167 /* chord: close figure. pie: add line and close figure */
1168 switch (lines)
1170 case -1:
1171 update_current_pos( physdev->path );
1172 break;
1173 case 1:
1174 close_figure( physdev->path );
1175 break;
1176 case 2:
1177 centre.x = (corners[0].x+corners[1].x)/2;
1178 centre.y = (corners[0].y+corners[1].y)/2;
1179 if(!PATH_AddEntry(physdev->path, &centre, PT_LINETO | PT_CLOSEFIGURE))
1180 return FALSE;
1181 break;
1183 return TRUE;
1187 /*************************************************************
1188 * pathdrv_AngleArc
1190 static BOOL CDECL pathdrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT eStartAngle, FLOAT eSweepAngle)
1192 int x1 = GDI_ROUND( x + cos(eStartAngle*M_PI/180) * radius );
1193 int y1 = GDI_ROUND( y - sin(eStartAngle*M_PI/180) * radius );
1194 int x2 = GDI_ROUND( x + cos((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1195 int y2 = GDI_ROUND( y - sin((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1196 return PATH_Arc( dev, x-radius, y-radius, x+radius, y+radius, x1, y1, x2, y2,
1197 eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE, -1 );
1201 /*************************************************************
1202 * pathdrv_Arc
1204 static BOOL CDECL pathdrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1205 INT xstart, INT ystart, INT xend, INT yend )
1207 DC *dc = get_physdev_dc( dev );
1208 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1209 dc->attr->arc_direction, 0 );
1213 /*************************************************************
1214 * pathdrv_ArcTo
1216 static BOOL CDECL pathdrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1217 INT xstart, INT ystart, INT xend, INT yend )
1219 DC *dc = get_physdev_dc( dev );
1220 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1221 dc->attr->arc_direction, -1 );
1225 /*************************************************************
1226 * pathdrv_Chord
1228 static BOOL CDECL pathdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1229 INT xstart, INT ystart, INT xend, INT yend )
1231 DC *dc = get_physdev_dc( dev );
1232 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1233 dc->attr->arc_direction, 1 );
1237 /*************************************************************
1238 * pathdrv_Pie
1240 static BOOL CDECL pathdrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1241 INT xstart, INT ystart, INT xend, INT yend )
1243 DC *dc = get_physdev_dc( dev );
1244 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1245 dc->attr->arc_direction, 2 );
1249 /*************************************************************
1250 * pathdrv_PolyBezierTo
1252 static BOOL CDECL pathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1254 struct path_physdev *physdev = get_path_physdev( dev );
1255 DC *dc = get_physdev_dc( dev );
1257 return add_log_points_new_stroke( dc, physdev->path, pts, cbPoints, PT_BEZIERTO );
1261 /*************************************************************
1262 * pathdrv_PolyBezier
1264 static BOOL CDECL pathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1266 struct path_physdev *physdev = get_path_physdev( dev );
1267 DC *dc = get_physdev_dc( dev );
1268 BYTE *type = add_log_points( dc, physdev->path, pts, cbPoints, PT_BEZIERTO );
1270 if (!type) return FALSE;
1271 type[0] = PT_MOVETO;
1272 return TRUE;
1276 /*************************************************************
1277 * pathdrv_PolyDraw
1279 static BOOL CDECL pathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD cbPoints )
1281 struct path_physdev *physdev = get_path_physdev( dev );
1282 struct gdi_path *path = physdev->path;
1283 DC *dc = get_physdev_dc( dev );
1284 POINT orig_pos;
1285 INT i, lastmove = 0;
1287 for (i = 0; i < path->count; i++) if (path->flags[i] == PT_MOVETO) lastmove = i;
1288 orig_pos = path->pos;
1290 for(i = 0; i < cbPoints; i++)
1292 switch (types[i])
1294 case PT_MOVETO:
1295 path->newStroke = TRUE;
1296 path->pos = pts[i];
1297 lp_to_dp( dc, &path->pos, 1 );
1298 lastmove = path->count;
1299 break;
1300 case PT_LINETO:
1301 case PT_LINETO | PT_CLOSEFIGURE:
1302 if (!add_log_points_new_stroke( dc, path, &pts[i], 1, PT_LINETO )) return FALSE;
1303 break;
1304 case PT_BEZIERTO:
1305 if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
1306 (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
1308 if (!add_log_points_new_stroke( dc, path, &pts[i], 3, PT_BEZIERTO )) return FALSE;
1309 i += 2;
1310 break;
1312 /* fall through */
1313 default:
1314 /* restore original position */
1315 path->pos = orig_pos;
1316 return FALSE;
1319 if (types[i] & PT_CLOSEFIGURE)
1321 close_figure( path );
1322 path->pos = path->points[lastmove];
1325 return TRUE;
1329 /*************************************************************
1330 * pathdrv_PolylineTo
1332 static BOOL CDECL pathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT count )
1334 struct path_physdev *physdev = get_path_physdev( dev );
1335 DC *dc = get_physdev_dc( dev );
1337 if (count < 1) return FALSE;
1338 return add_log_points_new_stroke( dc, physdev->path, pts, count, PT_LINETO );
1342 /*************************************************************
1343 * pathdrv_PolyPolygon
1345 static BOOL CDECL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
1347 struct path_physdev *physdev = get_path_physdev( dev );
1348 DC *dc = get_physdev_dc( dev );
1349 UINT poly, count;
1350 BYTE *type;
1352 if (!polygons) return FALSE;
1353 for (poly = count = 0; poly < polygons; poly++)
1355 if (counts[poly] < 2) return FALSE;
1356 count += counts[poly];
1359 type = add_log_points( dc, physdev->path, pts, count, PT_LINETO );
1360 if (!type) return FALSE;
1362 /* make the first point of each polyline a PT_MOVETO, and close the last one */
1363 for (poly = 0; poly < polygons; type += counts[poly++])
1365 type[0] = PT_MOVETO;
1366 type[counts[poly] - 1] = PT_LINETO | PT_CLOSEFIGURE;
1368 return TRUE;
1372 /*************************************************************
1373 * pathdrv_PolyPolyline
1375 static BOOL CDECL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
1377 struct path_physdev *physdev = get_path_physdev( dev );
1378 DC *dc = get_physdev_dc( dev );
1379 UINT poly, count;
1380 BYTE *type;
1382 if (!polylines) return FALSE;
1383 for (poly = count = 0; poly < polylines; poly++)
1385 if (counts[poly] < 2) return FALSE;
1386 count += counts[poly];
1389 type = add_log_points( dc, physdev->path, pts, count, PT_LINETO );
1390 if (!type) return FALSE;
1392 /* make the first point of each polyline a PT_MOVETO */
1393 for (poly = 0; poly < polylines; type += counts[poly++]) *type = PT_MOVETO;
1394 return TRUE;
1398 /**********************************************************************
1399 * PATH_BezierTo
1401 * internally used by PATH_add_outline
1403 static void PATH_BezierTo(struct gdi_path *pPath, POINT *lppt, INT n)
1405 if (n < 2) return;
1407 if (n == 2)
1409 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1411 else if (n == 3)
1413 add_points( pPath, lppt, 3, PT_BEZIERTO );
1415 else
1417 POINT pt[3];
1418 INT i = 0;
1420 pt[2] = lppt[0];
1421 n--;
1423 while (n > 2)
1425 pt[0] = pt[2];
1426 pt[1] = lppt[i+1];
1427 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1428 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1429 add_points( pPath, pt, 3, PT_BEZIERTO );
1430 n--;
1431 i++;
1434 pt[0] = pt[2];
1435 pt[1] = lppt[i+1];
1436 pt[2] = lppt[i+2];
1437 add_points( pPath, pt, 3, PT_BEZIERTO );
1441 static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y,
1442 TTPOLYGONHEADER *header, DWORD size)
1444 TTPOLYGONHEADER *start;
1445 POINT pt;
1447 start = header;
1449 while ((char *)header < (char *)start + size)
1451 TTPOLYCURVE *curve;
1453 if (header->dwType != TT_POLYGON_TYPE)
1455 FIXME("Unknown header type %d\n", header->dwType);
1456 return FALSE;
1459 pt.x = x + int_from_fixed(header->pfxStart.x);
1460 pt.y = y - int_from_fixed(header->pfxStart.y);
1461 PATH_AddEntry(physdev->path, &pt, PT_MOVETO);
1463 curve = (TTPOLYCURVE *)(header + 1);
1465 while ((char *)curve < (char *)header + header->cb)
1467 /*TRACE("curve->wType %d\n", curve->wType);*/
1469 switch(curve->wType)
1471 case TT_PRIM_LINE:
1473 WORD i;
1475 for (i = 0; i < curve->cpfx; i++)
1477 pt.x = x + int_from_fixed(curve->apfx[i].x);
1478 pt.y = y - int_from_fixed(curve->apfx[i].y);
1479 PATH_AddEntry(physdev->path, &pt, PT_LINETO);
1481 break;
1484 case TT_PRIM_QSPLINE:
1485 case TT_PRIM_CSPLINE:
1487 WORD i;
1488 POINTFX ptfx;
1489 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1491 if (!pts) return FALSE;
1493 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1495 pts[0].x = x + int_from_fixed(ptfx.x);
1496 pts[0].y = y - int_from_fixed(ptfx.y);
1498 for(i = 0; i < curve->cpfx; i++)
1500 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1501 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1504 PATH_BezierTo(physdev->path, pts, curve->cpfx + 1);
1506 HeapFree(GetProcessHeap(), 0, pts);
1507 break;
1510 default:
1511 FIXME("Unknown curve type %04x\n", curve->wType);
1512 return FALSE;
1515 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1518 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1521 close_figure( physdev->path );
1522 return TRUE;
1525 /*************************************************************
1526 * pathdrv_ExtTextOut
1528 static BOOL CDECL pathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprc,
1529 LPCWSTR str, UINT count, const INT *dx )
1531 struct path_physdev *physdev = get_path_physdev( dev );
1532 unsigned int idx, ggo_flags = GGO_NATIVE;
1533 POINT offset = {0, 0};
1535 if (!count) return TRUE;
1536 if (flags & ETO_GLYPH_INDEX) ggo_flags |= GGO_GLYPH_INDEX;
1538 for (idx = 0; idx < count; idx++)
1540 static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
1541 GLYPHMETRICS gm;
1542 DWORD dwSize;
1543 void *outline;
1545 dwSize = GetGlyphOutlineW(dev->hdc, str[idx], ggo_flags, &gm, 0, NULL, &identity);
1546 if (dwSize == GDI_ERROR) continue;
1548 /* add outline only if char is printable */
1549 if(dwSize)
1551 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1552 if (!outline) return FALSE;
1554 GetGlyphOutlineW(dev->hdc, str[idx], ggo_flags, &gm, dwSize, outline, &identity);
1555 PATH_add_outline(physdev, x + offset.x, y + offset.y, outline, dwSize);
1557 HeapFree(GetProcessHeap(), 0, outline);
1560 if (dx)
1562 if(flags & ETO_PDY)
1564 offset.x += dx[idx * 2];
1565 offset.y += dx[idx * 2 + 1];
1567 else
1568 offset.x += dx[idx];
1570 else
1572 offset.x += gm.gmCellIncX;
1573 offset.y += gm.gmCellIncY;
1576 return TRUE;
1580 /*************************************************************
1581 * pathdrv_CloseFigure
1583 static BOOL CDECL pathdrv_CloseFigure( PHYSDEV dev )
1585 struct path_physdev *physdev = get_path_physdev( dev );
1587 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
1588 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
1589 if (physdev->path->count) close_figure( physdev->path );
1590 return TRUE;
1594 /*******************************************************************
1595 * FlattenPath [GDI32.@]
1599 BOOL WINAPI FlattenPath(HDC hdc)
1601 BOOL ret = FALSE;
1602 DC *dc = get_dc_ptr( hdc );
1604 if (dc)
1606 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath );
1607 ret = physdev->funcs->pFlattenPath( physdev );
1608 release_dc_ptr( dc );
1610 return ret;
1614 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1616 static struct gdi_path *PATH_WidenPath(DC *dc)
1618 INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
1619 struct gdi_path *flat_path, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
1620 EXTLOGPEN *elp;
1621 BYTE *type;
1622 DWORD obj_type, joint, endcap, penType;
1624 size = GetObjectW( dc->hPen, 0, NULL );
1625 if (!size) {
1626 SetLastError(ERROR_CAN_NOT_COMPLETE);
1627 return NULL;
1630 elp = HeapAlloc( GetProcessHeap(), 0, size );
1631 GetObjectW( dc->hPen, size, elp );
1633 obj_type = GetObjectType(dc->hPen);
1634 if(obj_type == OBJ_PEN) {
1635 penStyle = ((LOGPEN*)elp)->lopnStyle;
1637 else if(obj_type == OBJ_EXTPEN) {
1638 penStyle = elp->elpPenStyle;
1640 else {
1641 SetLastError(ERROR_CAN_NOT_COMPLETE);
1642 HeapFree( GetProcessHeap(), 0, elp );
1643 return NULL;
1646 penWidth = elp->elpWidth;
1647 HeapFree( GetProcessHeap(), 0, elp );
1649 endcap = (PS_ENDCAP_MASK & penStyle);
1650 joint = (PS_JOIN_MASK & penStyle);
1651 penType = (PS_TYPE_MASK & penStyle);
1653 /* The function cannot apply to cosmetic pens */
1654 if(obj_type == OBJ_EXTPEN && penType == PS_COSMETIC) {
1655 SetLastError(ERROR_CAN_NOT_COMPLETE);
1656 return NULL;
1659 if (!(flat_path = PATH_FlattenPath( dc->path ))) return NULL;
1661 penWidthIn = penWidth / 2;
1662 penWidthOut = penWidth / 2;
1663 if(penWidthIn + penWidthOut < penWidth)
1664 penWidthOut++;
1666 numStrokes = 0;
1668 for(i = 0, j = 0; i < flat_path->count; i++, j++) {
1669 POINT point;
1670 if((i == 0 || (flat_path->flags[i-1] & PT_CLOSEFIGURE)) &&
1671 (flat_path->flags[i] != PT_MOVETO)) {
1672 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1673 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1674 flat_path->flags[i]);
1675 free_gdi_path( flat_path );
1676 return NULL;
1678 switch(flat_path->flags[i]) {
1679 case PT_MOVETO:
1680 numStrokes++;
1681 j = 0;
1682 if(numStrokes == 1)
1683 pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(*pStrokes));
1684 else
1685 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes));
1686 if(!pStrokes)
1688 free_gdi_path(flat_path);
1689 return NULL;
1691 pStrokes[numStrokes - 1] = alloc_gdi_path(0);
1692 /* fall through */
1693 case PT_LINETO:
1694 case (PT_LINETO | PT_CLOSEFIGURE):
1695 point.x = flat_path->points[i].x;
1696 point.y = flat_path->points[i].y;
1697 PATH_AddEntry(pStrokes[numStrokes - 1], &point, flat_path->flags[i]);
1698 break;
1699 case PT_BEZIERTO:
1700 /* should never happen because of the FlattenPath call */
1701 ERR("Should never happen\n");
1702 break;
1703 default:
1704 ERR("Got path flag %c\n", flat_path->flags[i]);
1705 for(i = 0; i < numStrokes; i++) free_gdi_path(pStrokes[i]);
1706 HeapFree(GetProcessHeap(), 0, pStrokes);
1707 free_gdi_path(flat_path);
1708 return NULL;
1712 pNewPath = alloc_gdi_path( flat_path->count );
1714 for(i = 0; i < numStrokes; i++) {
1715 pUpPath = alloc_gdi_path( pStrokes[i]->count );
1716 pDownPath = alloc_gdi_path( pStrokes[i]->count );
1718 for(j = 0; j < pStrokes[i]->count; j++) {
1719 /* Beginning or end of the path if not closed */
1720 if((!(pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->count - 1) ) {
1721 /* Compute segment angle */
1722 double xo, yo, xa, ya, theta;
1723 POINT pt;
1724 FLOAT_POINT corners[2];
1725 if(j == 0) {
1726 xo = pStrokes[i]->points[j].x;
1727 yo = pStrokes[i]->points[j].y;
1728 xa = pStrokes[i]->points[1].x;
1729 ya = pStrokes[i]->points[1].y;
1731 else {
1732 xa = pStrokes[i]->points[j - 1].x;
1733 ya = pStrokes[i]->points[j - 1].y;
1734 xo = pStrokes[i]->points[j].x;
1735 yo = pStrokes[i]->points[j].y;
1737 theta = atan2( ya - yo, xa - xo );
1738 switch(endcap) {
1739 case PS_ENDCAP_SQUARE :
1740 pt.x = xo + round(sqrt(2) * penWidthOut * cos(M_PI_4 + theta));
1741 pt.y = yo + round(sqrt(2) * penWidthOut * sin(M_PI_4 + theta));
1742 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO) );
1743 pt.x = xo + round(sqrt(2) * penWidthIn * cos(- M_PI_4 + theta));
1744 pt.y = yo + round(sqrt(2) * penWidthIn * sin(- M_PI_4 + theta));
1745 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1746 break;
1747 case PS_ENDCAP_FLAT :
1748 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1749 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1750 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
1751 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1752 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1753 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1754 break;
1755 case PS_ENDCAP_ROUND :
1756 default :
1757 corners[0].x = xo - penWidthIn;
1758 corners[0].y = yo - penWidthIn;
1759 corners[1].x = xo + penWidthOut;
1760 corners[1].y = yo + penWidthOut;
1761 PATH_DoArcPart(pUpPath ,corners, theta + M_PI_2 , theta + 3 * M_PI_4, (j == 0 ? PT_MOVETO : 0));
1762 PATH_DoArcPart(pUpPath ,corners, theta + 3 * M_PI_4 , theta + M_PI, 0);
1763 PATH_DoArcPart(pUpPath ,corners, theta + M_PI, theta + 5 * M_PI_4, 0);
1764 PATH_DoArcPart(pUpPath ,corners, theta + 5 * M_PI_4 , theta + 3 * M_PI_2, 0);
1765 break;
1768 /* Corpse of the path */
1769 else {
1770 /* Compute angle */
1771 INT previous, next;
1772 double xa, ya, xb, yb, xo, yo;
1773 double alpha, theta, miterWidth;
1774 DWORD _joint = joint;
1775 POINT pt;
1776 struct gdi_path *pInsidePath, *pOutsidePath;
1777 if(j > 0 && j < pStrokes[i]->count - 1) {
1778 previous = j - 1;
1779 next = j + 1;
1781 else if (j == 0) {
1782 previous = pStrokes[i]->count - 1;
1783 next = j + 1;
1785 else {
1786 previous = j - 1;
1787 next = 0;
1789 xo = pStrokes[i]->points[j].x;
1790 yo = pStrokes[i]->points[j].y;
1791 xa = pStrokes[i]->points[previous].x;
1792 ya = pStrokes[i]->points[previous].y;
1793 xb = pStrokes[i]->points[next].x;
1794 yb = pStrokes[i]->points[next].y;
1795 theta = atan2( yo - ya, xo - xa );
1796 alpha = atan2( yb - yo, xb - xo ) - theta;
1797 if (alpha > 0) alpha -= M_PI;
1798 else alpha += M_PI;
1799 if(_joint == PS_JOIN_MITER && dc->attr->miter_limit < fabs(1 / sin(alpha/2))) {
1800 _joint = PS_JOIN_BEVEL;
1802 if(alpha > 0) {
1803 pInsidePath = pUpPath;
1804 pOutsidePath = pDownPath;
1806 else if(alpha < 0) {
1807 pInsidePath = pDownPath;
1808 pOutsidePath = pUpPath;
1810 else {
1811 continue;
1813 /* Inside angle points */
1814 if(alpha > 0) {
1815 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1816 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1818 else {
1819 pt.x = xo + round( penWidthIn * cos(theta + M_PI_2) );
1820 pt.y = yo + round( penWidthIn * sin(theta + M_PI_2) );
1822 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1823 if(alpha > 0) {
1824 pt.x = xo + round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1825 pt.y = yo + round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1827 else {
1828 pt.x = xo - round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1829 pt.y = yo - round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1831 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1832 /* Outside angle point */
1833 switch(_joint) {
1834 case PS_JOIN_MITER :
1835 miterWidth = fabs(penWidthOut / cos(M_PI_2 - fabs(alpha) / 2));
1836 pt.x = xo + round( miterWidth * cos(theta + alpha / 2) );
1837 pt.y = yo + round( miterWidth * sin(theta + alpha / 2) );
1838 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1839 break;
1840 case PS_JOIN_BEVEL :
1841 if(alpha > 0) {
1842 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1843 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1845 else {
1846 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1847 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1849 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1850 if(alpha > 0) {
1851 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1852 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1854 else {
1855 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1856 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1858 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1859 break;
1860 case PS_JOIN_ROUND :
1861 default :
1862 if(alpha > 0) {
1863 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1864 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1866 else {
1867 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1868 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1870 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1871 pt.x = xo + round( penWidthOut * cos(theta + alpha / 2) );
1872 pt.y = yo + round( penWidthOut * sin(theta + alpha / 2) );
1873 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1874 if(alpha > 0) {
1875 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1876 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1878 else {
1879 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1880 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1882 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1883 break;
1887 type = add_points( pNewPath, pUpPath->points, pUpPath->count, PT_LINETO );
1888 type[0] = PT_MOVETO;
1889 reverse_points( pDownPath->points, pDownPath->count );
1890 type = add_points( pNewPath, pDownPath->points, pDownPath->count, PT_LINETO );
1891 if (pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE) type[0] = PT_MOVETO;
1893 free_gdi_path( pStrokes[i] );
1894 free_gdi_path( pUpPath );
1895 free_gdi_path( pDownPath );
1897 HeapFree(GetProcessHeap(), 0, pStrokes);
1898 free_gdi_path( flat_path );
1899 return pNewPath;
1903 /*******************************************************************
1904 * StrokeAndFillPath [GDI32.@]
1908 BOOL WINAPI StrokeAndFillPath(HDC hdc)
1910 BOOL ret = FALSE;
1911 DC *dc = get_dc_ptr( hdc );
1913 if (dc)
1915 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath );
1916 ret = physdev->funcs->pStrokeAndFillPath( physdev );
1917 release_dc_ptr( dc );
1919 return ret;
1923 /*******************************************************************
1924 * StrokePath [GDI32.@]
1928 BOOL WINAPI StrokePath(HDC hdc)
1930 BOOL ret = FALSE;
1931 DC *dc = get_dc_ptr( hdc );
1933 if (dc)
1935 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath );
1936 ret = physdev->funcs->pStrokePath( physdev );
1937 release_dc_ptr( dc );
1939 return ret;
1943 /*******************************************************************
1944 * WidenPath [GDI32.@]
1948 BOOL WINAPI WidenPath(HDC hdc)
1950 BOOL ret = FALSE;
1951 DC *dc = get_dc_ptr( hdc );
1953 if (dc)
1955 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath );
1956 ret = physdev->funcs->pWidenPath( physdev );
1957 release_dc_ptr( dc );
1959 return ret;
1963 /***********************************************************************
1964 * null driver fallback implementations
1967 BOOL CDECL nulldrv_BeginPath( PHYSDEV dev )
1969 DC *dc = get_nulldrv_dc( dev );
1970 struct path_physdev *physdev;
1971 struct gdi_path *path = alloc_gdi_path(0);
1973 if (!path) return FALSE;
1974 if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
1976 free_gdi_path( path );
1977 return FALSE;
1979 physdev = get_path_physdev( find_dc_driver( dc, &path_driver ));
1980 physdev->path = path;
1981 path->pos = dc->attr->cur_pos;
1982 lp_to_dp( dc, &path->pos, 1 );
1983 if (dc->path) free_gdi_path( dc->path );
1984 dc->path = NULL;
1985 return TRUE;
1988 BOOL CDECL nulldrv_EndPath( PHYSDEV dev )
1990 SetLastError( ERROR_CAN_NOT_COMPLETE );
1991 return FALSE;
1994 BOOL CDECL nulldrv_AbortPath( PHYSDEV dev )
1996 DC *dc = get_nulldrv_dc( dev );
1998 if (dc->path) free_gdi_path( dc->path );
1999 dc->path = NULL;
2000 return TRUE;
2003 BOOL CDECL nulldrv_CloseFigure( PHYSDEV dev )
2005 SetLastError( ERROR_CAN_NOT_COMPLETE );
2006 return FALSE;
2009 BOOL CDECL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
2011 BOOL ret = FALSE;
2012 HRGN hrgn = PathToRegion( dev->hdc );
2014 if (hrgn)
2016 ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR;
2017 DeleteObject( hrgn );
2019 return ret;
2022 BOOL CDECL nulldrv_FillPath( PHYSDEV dev )
2024 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2025 NtGdiAbortPath( dev->hdc );
2026 return TRUE;
2029 BOOL CDECL nulldrv_StrokeAndFillPath( PHYSDEV dev )
2031 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2032 NtGdiAbortPath( dev->hdc );
2033 return TRUE;
2036 BOOL CDECL nulldrv_StrokePath( PHYSDEV dev )
2038 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2039 NtGdiAbortPath( dev->hdc );
2040 return TRUE;
2043 BOOL CDECL nulldrv_FlattenPath( PHYSDEV dev )
2045 DC *dc = get_nulldrv_dc( dev );
2046 struct gdi_path *path;
2048 if (!dc->path)
2050 SetLastError( ERROR_CAN_NOT_COMPLETE );
2051 return FALSE;
2053 if (!(path = PATH_FlattenPath( dc->path ))) return FALSE;
2054 free_gdi_path( dc->path );
2055 dc->path = path;
2056 return TRUE;
2059 BOOL CDECL nulldrv_WidenPath( PHYSDEV dev )
2061 DC *dc = get_nulldrv_dc( dev );
2062 struct gdi_path *path;
2064 if (!dc->path)
2066 SetLastError( ERROR_CAN_NOT_COMPLETE );
2067 return FALSE;
2069 if (!(path = PATH_WidenPath( dc ))) return FALSE;
2070 free_gdi_path( dc->path );
2071 dc->path = path;
2072 return TRUE;
2075 const struct gdi_dc_funcs path_driver =
2077 NULL, /* pAbortDoc */
2078 pathdrv_AbortPath, /* pAbortPath */
2079 NULL, /* pAlphaBlend */
2080 pathdrv_AngleArc, /* pAngleArc */
2081 pathdrv_Arc, /* pArc */
2082 pathdrv_ArcTo, /* pArcTo */
2083 pathdrv_BeginPath, /* pBeginPath */
2084 NULL, /* pBlendImage */
2085 pathdrv_Chord, /* pChord */
2086 pathdrv_CloseFigure, /* pCloseFigure */
2087 NULL, /* pCreateCompatibleDC */
2088 pathdrv_CreateDC, /* pCreateDC */
2089 pathdrv_DeleteDC, /* pDeleteDC */
2090 NULL, /* pDeleteObject */
2091 NULL, /* pDeviceCapabilities */
2092 pathdrv_Ellipse, /* pEllipse */
2093 NULL, /* pEndDoc */
2094 NULL, /* pEndPage */
2095 pathdrv_EndPath, /* pEndPath */
2096 NULL, /* pEnumFonts */
2097 NULL, /* pEnumICMProfiles */
2098 NULL, /* pExtDeviceMode */
2099 NULL, /* pExtEscape */
2100 NULL, /* pExtFloodFill */
2101 pathdrv_ExtTextOut, /* pExtTextOut */
2102 NULL, /* pFillPath */
2103 NULL, /* pFillRgn */
2104 NULL, /* pFlattenPath */
2105 NULL, /* pFontIsLinked */
2106 NULL, /* pFrameRgn */
2107 NULL, /* pGdiComment */
2108 NULL, /* pGetBoundsRect */
2109 NULL, /* pGetCharABCWidths */
2110 NULL, /* pGetCharABCWidthsI */
2111 NULL, /* pGetCharWidth */
2112 NULL, /* pGetCharWidthInfo */
2113 NULL, /* pGetDeviceCaps */
2114 NULL, /* pGetDeviceGammaRamp */
2115 NULL, /* pGetFontData */
2116 NULL, /* pGetFontRealizationInfo */
2117 NULL, /* pGetFontUnicodeRanges */
2118 NULL, /* pGetGlyphIndices */
2119 NULL, /* pGetGlyphOutline */
2120 NULL, /* pGetICMProfile */
2121 NULL, /* pGetImage */
2122 NULL, /* pGetKerningPairs */
2123 NULL, /* pGetNearestColor */
2124 NULL, /* pGetOutlineTextMetrics */
2125 NULL, /* pGetPixel */
2126 NULL, /* pGetSystemPaletteEntries */
2127 NULL, /* pGetTextCharsetInfo */
2128 NULL, /* pGetTextExtentExPoint */
2129 NULL, /* pGetTextExtentExPointI */
2130 NULL, /* pGetTextFace */
2131 NULL, /* pGetTextMetrics */
2132 NULL, /* pGradientFill */
2133 NULL, /* pInvertRgn */
2134 pathdrv_LineTo, /* pLineTo */
2135 NULL, /* pModifyWorldTransform */
2136 pathdrv_MoveTo, /* pMoveTo */
2137 NULL, /* pOffsetViewportOrg */
2138 NULL, /* pOffsetWindowOrg */
2139 NULL, /* pPaintRgn */
2140 NULL, /* pPatBlt */
2141 pathdrv_Pie, /* pPie */
2142 pathdrv_PolyBezier, /* pPolyBezier */
2143 pathdrv_PolyBezierTo, /* pPolyBezierTo */
2144 pathdrv_PolyDraw, /* pPolyDraw */
2145 pathdrv_PolyPolygon, /* pPolyPolygon */
2146 pathdrv_PolyPolyline, /* pPolyPolyline */
2147 pathdrv_PolylineTo, /* pPolylineTo */
2148 NULL, /* pPutImage */
2149 NULL, /* pRealizeDefaultPalette */
2150 NULL, /* pRealizePalette */
2151 pathdrv_Rectangle, /* pRectangle */
2152 NULL, /* pResetDC */
2153 NULL, /* pRestoreDC */
2154 pathdrv_RoundRect, /* pRoundRect */
2155 NULL, /* pScaleViewportExt */
2156 NULL, /* pScaleWindowExt */
2157 NULL, /* pSelectBitmap */
2158 NULL, /* pSelectBrush */
2159 NULL, /* pSelectClipPath */
2160 NULL, /* pSelectFont */
2161 NULL, /* pSelectPalette */
2162 NULL, /* pSelectPen */
2163 NULL, /* pSetBkColor */
2164 NULL, /* pSetBoundsRect */
2165 NULL, /* pSetDCBrushColor */
2166 NULL, /* pSetDCPenColor */
2167 NULL, /* pSetDIBitsToDevice */
2168 NULL, /* pSetDeviceClipping */
2169 NULL, /* pSetDeviceGammaRamp */
2170 NULL, /* pSetLayout */
2171 NULL, /* pSetMapMode */
2172 NULL, /* pSetMapperFlags */
2173 NULL, /* pSetPixel */
2174 NULL, /* pSetTextCharacterExtra */
2175 NULL, /* pSetTextColor */
2176 NULL, /* pSetTextJustification */
2177 NULL, /* pSetViewportExt */
2178 NULL, /* pSetViewportOrg */
2179 NULL, /* pSetWindowExt */
2180 NULL, /* pSetWindowOrg */
2181 NULL, /* pSetWorldTransform */
2182 NULL, /* pStartDoc */
2183 NULL, /* pStartPage */
2184 NULL, /* pStretchBlt */
2185 NULL, /* pStretchDIBits */
2186 NULL, /* pStrokeAndFillPath */
2187 NULL, /* pStrokePath */
2188 NULL, /* pUnrealizePalette */
2189 NULL, /* pWidenPath */
2190 NULL, /* pD3DKMTCheckVidPnExclusiveOwnership */
2191 NULL, /* pD3DKMTSetVidPnSourceOwner */
2192 NULL, /* wine_get_wgl_driver */
2193 NULL, /* wine_get_vulkan_driver */
2194 GDI_PRIORITY_PATH_DRV /* priority */