gdi32: Pass a DC pointer to the point adding routines.
[wine.git] / dlls / gdi32 / path.c
blob24a94361bab4bea0a0801c44c3f88ea5d0b1601e
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( HDC hdc, 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 LPtoDP( hdc, 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 (GetGraphicsMode( hdc ) == 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(!DPtoLP(hdc, 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, GetPolyFillMode( hdc ));
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_dc_ptr( dev->hdc );
772 path_driver.pDeleteDC( pop_dc_driver( dc, &path_driver ));
773 release_dc_ptr( dc );
774 return TRUE;
778 /***********************************************************************
779 * pathdrv_EndPath
781 static BOOL pathdrv_EndPath( PHYSDEV dev )
783 struct path_physdev *physdev = get_path_physdev( dev );
784 DC *dc = get_dc_ptr( dev->hdc );
786 dc->path = physdev->path;
787 pop_dc_driver( dc, &path_driver );
788 HeapFree( GetProcessHeap(), 0, physdev );
789 release_dc_ptr( dc );
790 return TRUE;
794 /***********************************************************************
795 * pathdrv_CreateDC
797 static BOOL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
798 LPCWSTR output, const DEVMODEW *devmode )
800 struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) );
801 DC *dc;
803 if (!physdev) return FALSE;
804 dc = get_dc_ptr( (*dev)->hdc );
805 push_dc_driver( dev, &physdev->dev, &path_driver );
806 release_dc_ptr( dc );
807 return TRUE;
811 /*************************************************************
812 * pathdrv_DeleteDC
814 static BOOL pathdrv_DeleteDC( PHYSDEV dev )
816 struct path_physdev *physdev = get_path_physdev( dev );
818 free_gdi_path( physdev->path );
819 HeapFree( GetProcessHeap(), 0, physdev );
820 return TRUE;
824 BOOL PATH_SavePath( DC *dst, DC *src )
826 PHYSDEV dev;
828 if (src->path)
830 if (!(dst->path = copy_gdi_path( src->path ))) return FALSE;
832 else if ((dev = find_dc_driver( src, &path_driver )))
834 struct path_physdev *physdev = get_path_physdev( dev );
835 if (!(dst->path = copy_gdi_path( physdev->path ))) return FALSE;
836 dst->path_open = TRUE;
838 else dst->path = NULL;
839 return TRUE;
842 BOOL PATH_RestorePath( DC *dst, DC *src )
844 PHYSDEV dev;
845 struct path_physdev *physdev;
847 if ((dev = pop_dc_driver( dst, &path_driver )))
849 physdev = get_path_physdev( dev );
850 free_gdi_path( physdev->path );
851 HeapFree( GetProcessHeap(), 0, physdev );
854 if (src->path && src->path_open)
856 if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
857 physdev = get_path_physdev( find_dc_driver( dst, &path_driver ));
858 physdev->path = src->path;
859 src->path_open = FALSE;
860 src->path = NULL;
863 if (dst->path) free_gdi_path( dst->path );
864 dst->path = src->path;
865 src->path = NULL;
866 return TRUE;
870 /*************************************************************
871 * pathdrv_MoveTo
873 static BOOL pathdrv_MoveTo( PHYSDEV dev, INT x, INT y )
875 struct path_physdev *physdev = get_path_physdev( dev );
876 physdev->path->newStroke = TRUE;
877 physdev->path->pos.x = x;
878 physdev->path->pos.y = y;
879 LPtoDP( physdev->dev.hdc, &physdev->path->pos, 1 );
880 return TRUE;
884 /*************************************************************
885 * pathdrv_LineTo
887 static BOOL pathdrv_LineTo( PHYSDEV dev, INT x, INT y )
889 struct path_physdev *physdev = get_path_physdev( dev );
890 DC *dc = get_physdev_dc( dev );
891 POINT point;
893 point.x = x;
894 point.y = y;
895 return add_log_points_new_stroke( dc, physdev->path, &point, 1, PT_LINETO );
899 /*************************************************************
900 * pathdrv_Rectangle
902 static BOOL pathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
904 struct path_physdev *physdev = get_path_physdev( dev );
905 POINT corners[2], points[4];
906 BYTE *type;
908 if (!PATH_CheckCorners( dev->hdc, corners, x1, y1, x2, y2 )) return TRUE;
910 points[0].x = corners[1].x;
911 points[0].y = corners[0].y;
912 points[1] = corners[0];
913 points[2].x = corners[0].x;
914 points[2].y = corners[1].y;
915 points[3] = corners[1];
916 if (GetArcDirection( dev->hdc ) == AD_CLOCKWISE) reverse_points( points, 4 );
918 if (!(type = add_points( physdev->path, points, 4, PT_LINETO ))) return FALSE;
919 type[0] = PT_MOVETO;
920 close_figure( physdev->path );
921 return TRUE;
925 /*************************************************************
926 * pathdrv_RoundRect
928 static BOOL pathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height )
930 const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */
931 struct path_physdev *physdev = get_path_physdev( dev );
932 POINT corners[2], ellipse[2], points[16];
933 BYTE *type;
934 double width, height;
936 if (!ell_width || !ell_height) return pathdrv_Rectangle( dev, x1, y1, x2, y2 );
938 if (!PATH_CheckCorners( dev->hdc, corners, x1, y1, x2, y2 )) return TRUE;
940 ellipse[0].x = ellipse[0].y = 0;
941 ellipse[1].x = ell_width;
942 ellipse[1].y = ell_height;
943 LPtoDP( dev->hdc, (POINT *)&ellipse, 2 );
944 ell_width = min( abs( ellipse[1].x - ellipse[0].x ), corners[1].x - corners[0].x );
945 ell_height = min( abs( ellipse[1].y - ellipse[0].y ), corners[1].y - corners[0].y );
946 width = ell_width / 2.0;
947 height = ell_height / 2.0;
949 /* starting point */
950 points[0].x = corners[1].x;
951 points[0].y = corners[0].y + GDI_ROUND( height );
952 /* first curve */
953 points[1].x = corners[1].x;
954 points[1].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
955 points[2].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
956 points[2].y = corners[0].y;
957 points[3].x = corners[1].x - GDI_ROUND( width );
958 points[3].y = corners[0].y;
959 /* horizontal line */
960 points[4].x = corners[0].x + GDI_ROUND( width );
961 points[4].y = corners[0].y;
962 /* second curve */
963 points[5].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
964 points[5].y = corners[0].y;
965 points[6].x = corners[0].x;
966 points[6].y = corners[0].y + GDI_ROUND( height * (1 - factor) );
967 points[7].x = corners[0].x;
968 points[7].y = corners[0].y + GDI_ROUND( height );
969 /* vertical line */
970 points[8].x = corners[0].x;
971 points[8].y = corners[1].y - GDI_ROUND( height );
972 /* third curve */
973 points[9].x = corners[0].x;
974 points[9].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
975 points[10].x = corners[0].x + GDI_ROUND( width * (1 - factor) );
976 points[10].y = corners[1].y;
977 points[11].x = corners[0].x + GDI_ROUND( width );
978 points[11].y = corners[1].y;
979 /* horizontal line */
980 points[12].x = corners[1].x - GDI_ROUND( width );
981 points[12].y = corners[1].y;
982 /* fourth curve */
983 points[13].x = corners[1].x - GDI_ROUND( width * (1 - factor) );
984 points[13].y = corners[1].y;
985 points[14].x = corners[1].x;
986 points[14].y = corners[1].y - GDI_ROUND( height * (1 - factor) );
987 points[15].x = corners[1].x;
988 points[15].y = corners[1].y - GDI_ROUND( height );
990 if (GetArcDirection( dev->hdc ) == AD_CLOCKWISE) reverse_points( points, 16 );
991 if (!(type = add_points( physdev->path, points, 16, PT_BEZIERTO ))) return FALSE;
992 type[0] = PT_MOVETO;
993 type[4] = type[8] = type[12] = PT_LINETO;
994 close_figure( physdev->path );
995 return TRUE;
999 /*************************************************************
1000 * pathdrv_Ellipse
1002 static BOOL pathdrv_Ellipse( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
1004 const double factor = 0.55428475; /* 4 / 3 * (sqrt(2) - 1) */
1005 struct path_physdev *physdev = get_path_physdev( dev );
1006 POINT corners[2], points[13];
1007 BYTE *type;
1008 double width, height;
1010 if (!PATH_CheckCorners( dev->hdc, 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 (GetArcDirection( dev->hdc ) == 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 (GetGraphicsMode(dev->hdc) == 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 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1226 GetArcDirection( dev->hdc ), 0 );
1230 /*************************************************************
1231 * pathdrv_ArcTo
1233 static BOOL pathdrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1234 INT xstart, INT ystart, INT xend, INT yend )
1236 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1237 GetArcDirection( dev->hdc ), -1 );
1241 /*************************************************************
1242 * pathdrv_Chord
1244 static BOOL pathdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1245 INT xstart, INT ystart, INT xend, INT yend )
1247 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1248 GetArcDirection( dev->hdc ), 1 );
1252 /*************************************************************
1253 * pathdrv_Pie
1255 static BOOL pathdrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1256 INT xstart, INT ystart, INT xend, INT yend )
1258 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend,
1259 GetArcDirection( dev->hdc ), 2 );
1263 /*************************************************************
1264 * pathdrv_PolyBezierTo
1266 static BOOL pathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1268 struct path_physdev *physdev = get_path_physdev( dev );
1269 DC *dc = get_physdev_dc( dev );
1271 return add_log_points_new_stroke( dc, physdev->path, pts, cbPoints, PT_BEZIERTO );
1275 /*************************************************************
1276 * pathdrv_PolyBezier
1278 static BOOL pathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1280 struct path_physdev *physdev = get_path_physdev( dev );
1281 DC *dc = get_physdev_dc( dev );
1282 BYTE *type = add_log_points( dc, physdev->path, pts, cbPoints, PT_BEZIERTO );
1284 if (!type) return FALSE;
1285 type[0] = PT_MOVETO;
1286 return TRUE;
1290 /*************************************************************
1291 * pathdrv_PolyDraw
1293 static BOOL pathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD cbPoints )
1295 struct path_physdev *physdev = get_path_physdev( dev );
1296 struct gdi_path *path = physdev->path;
1297 DC *dc = get_physdev_dc( dev );
1298 POINT orig_pos;
1299 INT i, lastmove = 0;
1301 for (i = 0; i < path->count; i++) if (path->flags[i] == PT_MOVETO) lastmove = i;
1302 orig_pos = path->pos;
1304 for(i = 0; i < cbPoints; i++)
1306 switch (types[i])
1308 case PT_MOVETO:
1309 path->newStroke = TRUE;
1310 path->pos = pts[i];
1311 LPtoDP( dev->hdc, &path->pos, 1 );
1312 lastmove = path->count;
1313 break;
1314 case PT_LINETO:
1315 case PT_LINETO | PT_CLOSEFIGURE:
1316 if (!add_log_points_new_stroke( dc, path, &pts[i], 1, PT_LINETO )) return FALSE;
1317 break;
1318 case PT_BEZIERTO:
1319 if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
1320 (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
1322 if (!add_log_points_new_stroke( dc, path, &pts[i], 3, PT_BEZIERTO )) return FALSE;
1323 i += 2;
1324 break;
1326 /* fall through */
1327 default:
1328 /* restore original position */
1329 path->pos = orig_pos;
1330 return FALSE;
1333 if (types[i] & PT_CLOSEFIGURE)
1335 close_figure( path );
1336 path->pos = path->points[lastmove];
1339 return TRUE;
1343 /*************************************************************
1344 * pathdrv_Polyline
1346 static BOOL pathdrv_Polyline( PHYSDEV dev, const POINT *pts, INT count )
1348 struct path_physdev *physdev = get_path_physdev( dev );
1349 DC *dc = get_physdev_dc( dev );
1350 BYTE *type;
1352 if (count < 2) return FALSE;
1353 if (!(type = add_log_points( dc, physdev->path, pts, count, PT_LINETO ))) return FALSE;
1354 type[0] = PT_MOVETO;
1355 return TRUE;
1359 /*************************************************************
1360 * pathdrv_PolylineTo
1362 static BOOL pathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT count )
1364 struct path_physdev *physdev = get_path_physdev( dev );
1365 DC *dc = get_physdev_dc( dev );
1367 if (count < 1) return FALSE;
1368 return add_log_points_new_stroke( dc, physdev->path, pts, count, PT_LINETO );
1372 /*************************************************************
1373 * pathdrv_Polygon
1375 static BOOL pathdrv_Polygon( PHYSDEV dev, const POINT *pts, INT count )
1377 struct path_physdev *physdev = get_path_physdev( dev );
1378 DC *dc = get_physdev_dc( dev );
1379 BYTE *type;
1381 if (count < 2) return FALSE;
1382 if (!(type = add_log_points( dc, physdev->path, pts, count, PT_LINETO ))) return FALSE;
1383 type[0] = PT_MOVETO;
1384 type[count - 1] = PT_LINETO | PT_CLOSEFIGURE;
1385 return TRUE;
1389 /*************************************************************
1390 * pathdrv_PolyPolygon
1392 static BOOL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
1394 struct path_physdev *physdev = get_path_physdev( dev );
1395 DC *dc = get_physdev_dc( dev );
1396 UINT poly, count;
1397 BYTE *type;
1399 if (!polygons) return FALSE;
1400 for (poly = count = 0; poly < polygons; poly++)
1402 if (counts[poly] < 2) return FALSE;
1403 count += counts[poly];
1406 type = add_log_points( dc, physdev->path, pts, count, PT_LINETO );
1407 if (!type) return FALSE;
1409 /* make the first point of each polyline a PT_MOVETO, and close the last one */
1410 for (poly = 0; poly < polygons; type += counts[poly++])
1412 type[0] = PT_MOVETO;
1413 type[counts[poly] - 1] = PT_LINETO | PT_CLOSEFIGURE;
1415 return TRUE;
1419 /*************************************************************
1420 * pathdrv_PolyPolyline
1422 static BOOL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
1424 struct path_physdev *physdev = get_path_physdev( dev );
1425 DC *dc = get_physdev_dc( dev );
1426 UINT poly, count;
1427 BYTE *type;
1429 if (!polylines) return FALSE;
1430 for (poly = count = 0; poly < polylines; poly++)
1432 if (counts[poly] < 2) return FALSE;
1433 count += counts[poly];
1436 type = add_log_points( dc, physdev->path, pts, count, PT_LINETO );
1437 if (!type) return FALSE;
1439 /* make the first point of each polyline a PT_MOVETO */
1440 for (poly = 0; poly < polylines; type += counts[poly++]) *type = PT_MOVETO;
1441 return TRUE;
1445 /**********************************************************************
1446 * PATH_BezierTo
1448 * internally used by PATH_add_outline
1450 static void PATH_BezierTo(struct gdi_path *pPath, POINT *lppt, INT n)
1452 if (n < 2) return;
1454 if (n == 2)
1456 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1458 else if (n == 3)
1460 add_points( pPath, lppt, 3, PT_BEZIERTO );
1462 else
1464 POINT pt[3];
1465 INT i = 0;
1467 pt[2] = lppt[0];
1468 n--;
1470 while (n > 2)
1472 pt[0] = pt[2];
1473 pt[1] = lppt[i+1];
1474 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1475 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1476 add_points( pPath, pt, 3, PT_BEZIERTO );
1477 n--;
1478 i++;
1481 pt[0] = pt[2];
1482 pt[1] = lppt[i+1];
1483 pt[2] = lppt[i+2];
1484 add_points( pPath, pt, 3, PT_BEZIERTO );
1488 static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y,
1489 TTPOLYGONHEADER *header, DWORD size)
1491 TTPOLYGONHEADER *start;
1492 POINT pt;
1494 start = header;
1496 while ((char *)header < (char *)start + size)
1498 TTPOLYCURVE *curve;
1500 if (header->dwType != TT_POLYGON_TYPE)
1502 FIXME("Unknown header type %d\n", header->dwType);
1503 return FALSE;
1506 pt.x = x + int_from_fixed(header->pfxStart.x);
1507 pt.y = y - int_from_fixed(header->pfxStart.y);
1508 PATH_AddEntry(physdev->path, &pt, PT_MOVETO);
1510 curve = (TTPOLYCURVE *)(header + 1);
1512 while ((char *)curve < (char *)header + header->cb)
1514 /*TRACE("curve->wType %d\n", curve->wType);*/
1516 switch(curve->wType)
1518 case TT_PRIM_LINE:
1520 WORD i;
1522 for (i = 0; i < curve->cpfx; i++)
1524 pt.x = x + int_from_fixed(curve->apfx[i].x);
1525 pt.y = y - int_from_fixed(curve->apfx[i].y);
1526 PATH_AddEntry(physdev->path, &pt, PT_LINETO);
1528 break;
1531 case TT_PRIM_QSPLINE:
1532 case TT_PRIM_CSPLINE:
1534 WORD i;
1535 POINTFX ptfx;
1536 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1538 if (!pts) return FALSE;
1540 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1542 pts[0].x = x + int_from_fixed(ptfx.x);
1543 pts[0].y = y - int_from_fixed(ptfx.y);
1545 for(i = 0; i < curve->cpfx; i++)
1547 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1548 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1551 PATH_BezierTo(physdev->path, pts, curve->cpfx + 1);
1553 HeapFree(GetProcessHeap(), 0, pts);
1554 break;
1557 default:
1558 FIXME("Unknown curve type %04x\n", curve->wType);
1559 return FALSE;
1562 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1565 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1568 close_figure( physdev->path );
1569 return TRUE;
1572 /*************************************************************
1573 * pathdrv_ExtTextOut
1575 static BOOL pathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprc,
1576 LPCWSTR str, UINT count, const INT *dx )
1578 struct path_physdev *physdev = get_path_physdev( dev );
1579 unsigned int idx, ggo_flags = GGO_NATIVE;
1580 POINT offset = {0, 0};
1582 if (!count) return TRUE;
1583 if (flags & ETO_GLYPH_INDEX) ggo_flags |= GGO_GLYPH_INDEX;
1585 for (idx = 0; idx < count; idx++)
1587 static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
1588 GLYPHMETRICS gm;
1589 DWORD dwSize;
1590 void *outline;
1592 dwSize = GetGlyphOutlineW(dev->hdc, str[idx], ggo_flags, &gm, 0, NULL, &identity);
1593 if (dwSize == GDI_ERROR) return FALSE;
1595 /* add outline only if char is printable */
1596 if(dwSize)
1598 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1599 if (!outline) return FALSE;
1601 GetGlyphOutlineW(dev->hdc, str[idx], ggo_flags, &gm, dwSize, outline, &identity);
1602 PATH_add_outline(physdev, x + offset.x, y + offset.y, outline, dwSize);
1604 HeapFree(GetProcessHeap(), 0, outline);
1607 if (dx)
1609 if(flags & ETO_PDY)
1611 offset.x += dx[idx * 2];
1612 offset.y += dx[idx * 2 + 1];
1614 else
1615 offset.x += dx[idx];
1617 else
1619 offset.x += gm.gmCellIncX;
1620 offset.y += gm.gmCellIncY;
1623 return TRUE;
1627 /*************************************************************
1628 * pathdrv_CloseFigure
1630 static BOOL pathdrv_CloseFigure( PHYSDEV dev )
1632 struct path_physdev *physdev = get_path_physdev( dev );
1634 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
1635 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
1636 if (physdev->path->count) close_figure( physdev->path );
1637 return TRUE;
1641 /*******************************************************************
1642 * FlattenPath [GDI32.@]
1646 BOOL WINAPI FlattenPath(HDC hdc)
1648 BOOL ret = FALSE;
1649 DC *dc = get_dc_ptr( hdc );
1651 if (dc)
1653 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath );
1654 ret = physdev->funcs->pFlattenPath( physdev );
1655 release_dc_ptr( dc );
1657 return ret;
1661 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1663 static struct gdi_path *PATH_WidenPath(DC *dc)
1665 INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
1666 struct gdi_path *flat_path, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
1667 EXTLOGPEN *elp;
1668 BYTE *type;
1669 DWORD obj_type, joint, endcap, penType;
1671 size = GetObjectW( dc->hPen, 0, NULL );
1672 if (!size) {
1673 SetLastError(ERROR_CAN_NOT_COMPLETE);
1674 return NULL;
1677 elp = HeapAlloc( GetProcessHeap(), 0, size );
1678 GetObjectW( dc->hPen, size, elp );
1680 obj_type = GetObjectType(dc->hPen);
1681 if(obj_type == OBJ_PEN) {
1682 penStyle = ((LOGPEN*)elp)->lopnStyle;
1684 else if(obj_type == OBJ_EXTPEN) {
1685 penStyle = elp->elpPenStyle;
1687 else {
1688 SetLastError(ERROR_CAN_NOT_COMPLETE);
1689 HeapFree( GetProcessHeap(), 0, elp );
1690 return NULL;
1693 penWidth = elp->elpWidth;
1694 HeapFree( GetProcessHeap(), 0, elp );
1696 endcap = (PS_ENDCAP_MASK & penStyle);
1697 joint = (PS_JOIN_MASK & penStyle);
1698 penType = (PS_TYPE_MASK & penStyle);
1700 /* The function cannot apply to cosmetic pens */
1701 if(obj_type == OBJ_EXTPEN && penType == PS_COSMETIC) {
1702 SetLastError(ERROR_CAN_NOT_COMPLETE);
1703 return NULL;
1706 if (!(flat_path = PATH_FlattenPath( dc->path ))) return NULL;
1708 penWidthIn = penWidth / 2;
1709 penWidthOut = penWidth / 2;
1710 if(penWidthIn + penWidthOut < penWidth)
1711 penWidthOut++;
1713 numStrokes = 0;
1715 for(i = 0, j = 0; i < flat_path->count; i++, j++) {
1716 POINT point;
1717 if((i == 0 || (flat_path->flags[i-1] & PT_CLOSEFIGURE)) &&
1718 (flat_path->flags[i] != PT_MOVETO)) {
1719 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1720 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1721 flat_path->flags[i]);
1722 free_gdi_path( flat_path );
1723 return NULL;
1725 switch(flat_path->flags[i]) {
1726 case PT_MOVETO:
1727 numStrokes++;
1728 j = 0;
1729 if(numStrokes == 1)
1730 pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(*pStrokes));
1731 else
1732 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes));
1733 if(!pStrokes) return NULL;
1734 pStrokes[numStrokes - 1] = alloc_gdi_path(0);
1735 /* fall through */
1736 case PT_LINETO:
1737 case (PT_LINETO | PT_CLOSEFIGURE):
1738 point.x = flat_path->points[i].x;
1739 point.y = flat_path->points[i].y;
1740 PATH_AddEntry(pStrokes[numStrokes - 1], &point, flat_path->flags[i]);
1741 break;
1742 case PT_BEZIERTO:
1743 /* should never happen because of the FlattenPath call */
1744 ERR("Should never happen\n");
1745 break;
1746 default:
1747 ERR("Got path flag %c\n", flat_path->flags[i]);
1748 return NULL;
1752 pNewPath = alloc_gdi_path( flat_path->count );
1754 for(i = 0; i < numStrokes; i++) {
1755 pUpPath = alloc_gdi_path( pStrokes[i]->count );
1756 pDownPath = alloc_gdi_path( pStrokes[i]->count );
1758 for(j = 0; j < pStrokes[i]->count; j++) {
1759 /* Beginning or end of the path if not closed */
1760 if((!(pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->count - 1) ) {
1761 /* Compute segment angle */
1762 double xo, yo, xa, ya, theta;
1763 POINT pt;
1764 FLOAT_POINT corners[2];
1765 if(j == 0) {
1766 xo = pStrokes[i]->points[j].x;
1767 yo = pStrokes[i]->points[j].y;
1768 xa = pStrokes[i]->points[1].x;
1769 ya = pStrokes[i]->points[1].y;
1771 else {
1772 xa = pStrokes[i]->points[j - 1].x;
1773 ya = pStrokes[i]->points[j - 1].y;
1774 xo = pStrokes[i]->points[j].x;
1775 yo = pStrokes[i]->points[j].y;
1777 theta = atan2( ya - yo, xa - xo );
1778 switch(endcap) {
1779 case PS_ENDCAP_SQUARE :
1780 pt.x = xo + round(sqrt(2) * penWidthOut * cos(M_PI_4 + theta));
1781 pt.y = yo + round(sqrt(2) * penWidthOut * sin(M_PI_4 + theta));
1782 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO) );
1783 pt.x = xo + round(sqrt(2) * penWidthIn * cos(- M_PI_4 + theta));
1784 pt.y = yo + round(sqrt(2) * penWidthIn * sin(- M_PI_4 + theta));
1785 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1786 break;
1787 case PS_ENDCAP_FLAT :
1788 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1789 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1790 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
1791 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1792 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1793 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1794 break;
1795 case PS_ENDCAP_ROUND :
1796 default :
1797 corners[0].x = xo - penWidthIn;
1798 corners[0].y = yo - penWidthIn;
1799 corners[1].x = xo + penWidthOut;
1800 corners[1].y = yo + penWidthOut;
1801 PATH_DoArcPart(pUpPath ,corners, theta + M_PI_2 , theta + 3 * M_PI_4, (j == 0 ? PT_MOVETO : 0));
1802 PATH_DoArcPart(pUpPath ,corners, theta + 3 * M_PI_4 , theta + M_PI, 0);
1803 PATH_DoArcPart(pUpPath ,corners, theta + M_PI, theta + 5 * M_PI_4, 0);
1804 PATH_DoArcPart(pUpPath ,corners, theta + 5 * M_PI_4 , theta + 3 * M_PI_2, 0);
1805 break;
1808 /* Corpse of the path */
1809 else {
1810 /* Compute angle */
1811 INT previous, next;
1812 double xa, ya, xb, yb, xo, yo;
1813 double alpha, theta, miterWidth;
1814 DWORD _joint = joint;
1815 POINT pt;
1816 struct gdi_path *pInsidePath, *pOutsidePath;
1817 if(j > 0 && j < pStrokes[i]->count - 1) {
1818 previous = j - 1;
1819 next = j + 1;
1821 else if (j == 0) {
1822 previous = pStrokes[i]->count - 1;
1823 next = j + 1;
1825 else {
1826 previous = j - 1;
1827 next = 0;
1829 xo = pStrokes[i]->points[j].x;
1830 yo = pStrokes[i]->points[j].y;
1831 xa = pStrokes[i]->points[previous].x;
1832 ya = pStrokes[i]->points[previous].y;
1833 xb = pStrokes[i]->points[next].x;
1834 yb = pStrokes[i]->points[next].y;
1835 theta = atan2( yo - ya, xo - xa );
1836 alpha = atan2( yb - yo, xb - xo ) - theta;
1837 if (alpha > 0) alpha -= M_PI;
1838 else alpha += M_PI;
1839 if(_joint == PS_JOIN_MITER && dc->miterLimit < fabs(1 / sin(alpha/2))) {
1840 _joint = PS_JOIN_BEVEL;
1842 if(alpha > 0) {
1843 pInsidePath = pUpPath;
1844 pOutsidePath = pDownPath;
1846 else if(alpha < 0) {
1847 pInsidePath = pDownPath;
1848 pOutsidePath = pUpPath;
1850 else {
1851 continue;
1853 /* Inside angle points */
1854 if(alpha > 0) {
1855 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1856 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1858 else {
1859 pt.x = xo + round( penWidthIn * cos(theta + M_PI_2) );
1860 pt.y = yo + round( penWidthIn * sin(theta + M_PI_2) );
1862 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1863 if(alpha > 0) {
1864 pt.x = xo + round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1865 pt.y = yo + round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1867 else {
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 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1872 /* Outside angle point */
1873 switch(_joint) {
1874 case PS_JOIN_MITER :
1875 miterWidth = fabs(penWidthOut / cos(M_PI_2 - fabs(alpha) / 2));
1876 pt.x = xo + round( miterWidth * cos(theta + alpha / 2) );
1877 pt.y = yo + round( miterWidth * sin(theta + alpha / 2) );
1878 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1879 break;
1880 case PS_JOIN_BEVEL :
1881 if(alpha > 0) {
1882 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1883 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1885 else {
1886 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1887 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1889 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1890 if(alpha > 0) {
1891 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1892 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1894 else {
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 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1899 break;
1900 case PS_JOIN_ROUND :
1901 default :
1902 if(alpha > 0) {
1903 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1904 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1906 else {
1907 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1908 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1910 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1911 pt.x = xo + round( penWidthOut * cos(theta + alpha / 2) );
1912 pt.y = yo + round( penWidthOut * sin(theta + alpha / 2) );
1913 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1914 if(alpha > 0) {
1915 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1916 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1918 else {
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 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1923 break;
1927 type = add_points( pNewPath, pUpPath->points, pUpPath->count, PT_LINETO );
1928 type[0] = PT_MOVETO;
1929 reverse_points( pDownPath->points, pDownPath->count );
1930 type = add_points( pNewPath, pDownPath->points, pDownPath->count, PT_LINETO );
1931 if (pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE) type[0] = PT_MOVETO;
1933 free_gdi_path( pStrokes[i] );
1934 free_gdi_path( pUpPath );
1935 free_gdi_path( pDownPath );
1937 HeapFree(GetProcessHeap(), 0, pStrokes);
1938 free_gdi_path( flat_path );
1939 return pNewPath;
1943 /*******************************************************************
1944 * StrokeAndFillPath [GDI32.@]
1948 BOOL WINAPI StrokeAndFillPath(HDC hdc)
1950 BOOL ret = FALSE;
1951 DC *dc = get_dc_ptr( hdc );
1953 if (dc)
1955 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath );
1956 ret = physdev->funcs->pStrokeAndFillPath( physdev );
1957 release_dc_ptr( dc );
1959 return ret;
1963 /*******************************************************************
1964 * StrokePath [GDI32.@]
1968 BOOL WINAPI StrokePath(HDC hdc)
1970 BOOL ret = FALSE;
1971 DC *dc = get_dc_ptr( hdc );
1973 if (dc)
1975 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath );
1976 ret = physdev->funcs->pStrokePath( physdev );
1977 release_dc_ptr( dc );
1979 return ret;
1983 /*******************************************************************
1984 * WidenPath [GDI32.@]
1988 BOOL WINAPI WidenPath(HDC hdc)
1990 BOOL ret = FALSE;
1991 DC *dc = get_dc_ptr( hdc );
1993 if (dc)
1995 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath );
1996 ret = physdev->funcs->pWidenPath( physdev );
1997 release_dc_ptr( dc );
1999 return ret;
2003 /***********************************************************************
2004 * null driver fallback implementations
2007 BOOL nulldrv_BeginPath( PHYSDEV dev )
2009 DC *dc = get_nulldrv_dc( dev );
2010 struct path_physdev *physdev;
2011 struct gdi_path *path = alloc_gdi_path(0);
2013 if (!path) return FALSE;
2014 if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
2016 free_gdi_path( path );
2017 return FALSE;
2019 physdev = get_path_physdev( find_dc_driver( dc, &path_driver ));
2020 physdev->path = path;
2021 path->pos = dc->cur_pos;
2022 LPtoDP( dev->hdc, &path->pos, 1 );
2023 if (dc->path) free_gdi_path( dc->path );
2024 dc->path = NULL;
2025 return TRUE;
2028 BOOL nulldrv_EndPath( PHYSDEV dev )
2030 SetLastError( ERROR_CAN_NOT_COMPLETE );
2031 return FALSE;
2034 BOOL nulldrv_AbortPath( PHYSDEV dev )
2036 DC *dc = get_nulldrv_dc( dev );
2038 if (dc->path) free_gdi_path( dc->path );
2039 dc->path = NULL;
2040 return TRUE;
2043 BOOL nulldrv_CloseFigure( PHYSDEV dev )
2045 SetLastError( ERROR_CAN_NOT_COMPLETE );
2046 return FALSE;
2049 BOOL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
2051 BOOL ret = FALSE;
2052 HRGN hrgn = PathToRegion( dev->hdc );
2054 if (hrgn)
2056 ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR;
2057 DeleteObject( hrgn );
2059 return ret;
2062 BOOL nulldrv_FillPath( PHYSDEV dev )
2064 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2065 AbortPath( dev->hdc );
2066 return TRUE;
2069 BOOL nulldrv_StrokeAndFillPath( PHYSDEV dev )
2071 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2072 AbortPath( dev->hdc );
2073 return TRUE;
2076 BOOL nulldrv_StrokePath( PHYSDEV dev )
2078 if (GetPath( dev->hdc, NULL, NULL, 0 ) == -1) return FALSE;
2079 AbortPath( dev->hdc );
2080 return TRUE;
2083 BOOL nulldrv_FlattenPath( PHYSDEV dev )
2085 DC *dc = get_nulldrv_dc( dev );
2086 struct gdi_path *path;
2088 if (!dc->path)
2090 SetLastError( ERROR_CAN_NOT_COMPLETE );
2091 return FALSE;
2093 if (!(path = PATH_FlattenPath( dc->path ))) return FALSE;
2094 free_gdi_path( dc->path );
2095 dc->path = path;
2096 return TRUE;
2099 BOOL nulldrv_WidenPath( PHYSDEV dev )
2101 DC *dc = get_nulldrv_dc( dev );
2102 struct gdi_path *path;
2104 if (!dc->path)
2106 SetLastError( ERROR_CAN_NOT_COMPLETE );
2107 return FALSE;
2109 if (!(path = PATH_WidenPath( dc ))) return FALSE;
2110 free_gdi_path( dc->path );
2111 dc->path = path;
2112 return TRUE;
2115 const struct gdi_dc_funcs path_driver =
2117 NULL, /* pAbortDoc */
2118 pathdrv_AbortPath, /* pAbortPath */
2119 NULL, /* pAlphaBlend */
2120 pathdrv_AngleArc, /* pAngleArc */
2121 pathdrv_Arc, /* pArc */
2122 pathdrv_ArcTo, /* pArcTo */
2123 pathdrv_BeginPath, /* pBeginPath */
2124 NULL, /* pBlendImage */
2125 pathdrv_Chord, /* pChord */
2126 pathdrv_CloseFigure, /* pCloseFigure */
2127 NULL, /* pCreateCompatibleDC */
2128 pathdrv_CreateDC, /* pCreateDC */
2129 pathdrv_DeleteDC, /* pDeleteDC */
2130 NULL, /* pDeleteObject */
2131 NULL, /* pDeviceCapabilities */
2132 pathdrv_Ellipse, /* pEllipse */
2133 NULL, /* pEndDoc */
2134 NULL, /* pEndPage */
2135 pathdrv_EndPath, /* pEndPath */
2136 NULL, /* pEnumFonts */
2137 NULL, /* pEnumICMProfiles */
2138 NULL, /* pExcludeClipRect */
2139 NULL, /* pExtDeviceMode */
2140 NULL, /* pExtEscape */
2141 NULL, /* pExtFloodFill */
2142 NULL, /* pExtSelectClipRgn */
2143 pathdrv_ExtTextOut, /* pExtTextOut */
2144 NULL, /* pFillPath */
2145 NULL, /* pFillRgn */
2146 NULL, /* pFlattenPath */
2147 NULL, /* pFontIsLinked */
2148 NULL, /* pFrameRgn */
2149 NULL, /* pGdiComment */
2150 NULL, /* pGetBoundsRect */
2151 NULL, /* pGetCharABCWidths */
2152 NULL, /* pGetCharABCWidthsI */
2153 NULL, /* pGetCharWidth */
2154 NULL, /* pGetDeviceCaps */
2155 NULL, /* pGetDeviceGammaRamp */
2156 NULL, /* pGetFontData */
2157 NULL, /* pGetFontRealizationInfo */
2158 NULL, /* pGetFontUnicodeRanges */
2159 NULL, /* pGetGlyphIndices */
2160 NULL, /* pGetGlyphOutline */
2161 NULL, /* pGetICMProfile */
2162 NULL, /* pGetImage */
2163 NULL, /* pGetKerningPairs */
2164 NULL, /* pGetNearestColor */
2165 NULL, /* pGetOutlineTextMetrics */
2166 NULL, /* pGetPixel */
2167 NULL, /* pGetSystemPaletteEntries */
2168 NULL, /* pGetTextCharsetInfo */
2169 NULL, /* pGetTextExtentExPoint */
2170 NULL, /* pGetTextExtentExPointI */
2171 NULL, /* pGetTextFace */
2172 NULL, /* pGetTextMetrics */
2173 NULL, /* pGradientFill */
2174 NULL, /* pIntersectClipRect */
2175 NULL, /* pInvertRgn */
2176 pathdrv_LineTo, /* pLineTo */
2177 NULL, /* pModifyWorldTransform */
2178 pathdrv_MoveTo, /* pMoveTo */
2179 NULL, /* pOffsetClipRgn */
2180 NULL, /* pOffsetViewportOrg */
2181 NULL, /* pOffsetWindowOrg */
2182 NULL, /* pPaintRgn */
2183 NULL, /* pPatBlt */
2184 pathdrv_Pie, /* pPie */
2185 pathdrv_PolyBezier, /* pPolyBezier */
2186 pathdrv_PolyBezierTo, /* pPolyBezierTo */
2187 pathdrv_PolyDraw, /* pPolyDraw */
2188 pathdrv_PolyPolygon, /* pPolyPolygon */
2189 pathdrv_PolyPolyline, /* pPolyPolyline */
2190 pathdrv_Polygon, /* pPolygon */
2191 pathdrv_Polyline, /* pPolyline */
2192 pathdrv_PolylineTo, /* pPolylineTo */
2193 NULL, /* pPutImage */
2194 NULL, /* pRealizeDefaultPalette */
2195 NULL, /* pRealizePalette */
2196 pathdrv_Rectangle, /* pRectangle */
2197 NULL, /* pResetDC */
2198 NULL, /* pRestoreDC */
2199 pathdrv_RoundRect, /* pRoundRect */
2200 NULL, /* pSaveDC */
2201 NULL, /* pScaleViewportExt */
2202 NULL, /* pScaleWindowExt */
2203 NULL, /* pSelectBitmap */
2204 NULL, /* pSelectBrush */
2205 NULL, /* pSelectClipPath */
2206 NULL, /* pSelectFont */
2207 NULL, /* pSelectPalette */
2208 NULL, /* pSelectPen */
2209 NULL, /* pSetArcDirection */
2210 NULL, /* pSetBkColor */
2211 NULL, /* pSetBkMode */
2212 NULL, /* pSetDCBrushColor */
2213 NULL, /* pSetDCPenColor */
2214 NULL, /* pSetDIBColorTable */
2215 NULL, /* pSetDIBitsToDevice */
2216 NULL, /* pSetDeviceClipping */
2217 NULL, /* pSetDeviceGammaRamp */
2218 NULL, /* pSetLayout */
2219 NULL, /* pSetMapMode */
2220 NULL, /* pSetMapperFlags */
2221 NULL, /* pSetPixel */
2222 NULL, /* pSetPolyFillMode */
2223 NULL, /* pSetROP2 */
2224 NULL, /* pSetRelAbs */
2225 NULL, /* pSetStretchBltMode */
2226 NULL, /* pSetTextAlign */
2227 NULL, /* pSetTextCharacterExtra */
2228 NULL, /* pSetTextColor */
2229 NULL, /* pSetTextJustification */
2230 NULL, /* pSetViewportExt */
2231 NULL, /* pSetViewportOrg */
2232 NULL, /* pSetWindowExt */
2233 NULL, /* pSetWindowOrg */
2234 NULL, /* pSetWorldTransform */
2235 NULL, /* pStartDoc */
2236 NULL, /* pStartPage */
2237 NULL, /* pStretchBlt */
2238 NULL, /* pStretchDIBits */
2239 NULL, /* pStrokeAndFillPath */
2240 NULL, /* pStrokePath */
2241 NULL, /* pUnrealizePalette */
2242 NULL, /* pWidenPath */
2243 NULL, /* wine_get_wgl_driver */
2244 GDI_PRIORITY_PATH_DRV /* priority */