2 * Graphics paths (BeginPath, EndPath etc.)
4 * Copyright 1997, 1998 Martin Boehme
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
25 #include "wine/port.h"
32 #if defined(HAVE_FLOAT_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
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.
76 #define NUM_ENTRIES_INITIAL 16 /* Initial size of points / flags arrays */
77 #define GROW_FACTOR_NUMER 2 /* Numerator of grow factor for the array */
78 #define GROW_FACTOR_DENOM 1 /* Denominator of grow factor */
80 /* A floating point version of the POINT structure */
81 typedef struct tagFLOAT_POINT
89 struct gdi_physdev dev;
93 static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
95 return (struct path_physdev *)dev;
98 static inline void pop_path_driver( DC *dc )
100 PHYSDEV dev = pop_dc_driver( &dc->physDev );
101 assert( dev->funcs == &path_driver );
102 HeapFree( GetProcessHeap(), 0, dev );
106 /* Performs a world-to-viewport transformation on the specified point (which
107 * is in floating point format).
109 static inline void INTERNAL_LPTODP_FLOAT( HDC hdc, FLOAT_POINT *point, int count )
111 DC *dc = get_dc_ptr( hdc );
118 point->x = x * dc->xformWorld2Vport.eM11 + y * dc->xformWorld2Vport.eM21 + dc->xformWorld2Vport.eDx;
119 point->y = x * dc->xformWorld2Vport.eM12 + y * dc->xformWorld2Vport.eM22 + dc->xformWorld2Vport.eDy;
122 release_dc_ptr( dc );
125 static inline INT int_from_fixed(FIXED f)
127 return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
133 * Removes all entries from the path and sets the path state to PATH_Null.
135 static void PATH_EmptyPath(GdiPath *pPath)
137 pPath->state=PATH_Null;
138 pPath->numEntriesUsed=0;
141 /* PATH_ReserveEntries
143 * Ensures that at least "numEntries" entries (for points and flags) have
144 * been allocated; allocates larger arrays and copies the existing entries
145 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
147 static BOOL PATH_ReserveEntries(GdiPath *pPath, INT numEntries)
149 INT numEntriesToAllocate;
153 assert(numEntries>=0);
155 /* Do we have to allocate more memory? */
156 if(numEntries > pPath->numEntriesAllocated)
158 /* Find number of entries to allocate. We let the size of the array
159 * grow exponentially, since that will guarantee linear time
161 if(pPath->numEntriesAllocated)
163 numEntriesToAllocate=pPath->numEntriesAllocated;
164 while(numEntriesToAllocate<numEntries)
165 numEntriesToAllocate=numEntriesToAllocate*GROW_FACTOR_NUMER/
169 numEntriesToAllocate=numEntries;
171 /* Allocate new arrays */
172 pPointsNew=HeapAlloc( GetProcessHeap(), 0, numEntriesToAllocate * sizeof(POINT) );
175 pFlagsNew=HeapAlloc( GetProcessHeap(), 0, numEntriesToAllocate * sizeof(BYTE) );
178 HeapFree( GetProcessHeap(), 0, pPointsNew );
182 /* Copy old arrays to new arrays and discard old arrays */
185 assert(pPath->pFlags);
187 memcpy(pPointsNew, pPath->pPoints,
188 sizeof(POINT)*pPath->numEntriesUsed);
189 memcpy(pFlagsNew, pPath->pFlags,
190 sizeof(BYTE)*pPath->numEntriesUsed);
192 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
193 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
195 pPath->pPoints=pPointsNew;
196 pPath->pFlags=pFlagsNew;
197 pPath->numEntriesAllocated=numEntriesToAllocate;
205 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
206 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
207 * successful, FALSE otherwise (e.g. if not enough memory was available).
209 static BOOL PATH_AddEntry(GdiPath *pPath, const POINT *pPoint, BYTE flags)
211 /* FIXME: If newStroke is true, perhaps we want to check that we're
212 * getting a PT_MOVETO
214 TRACE("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags);
216 /* Check that path is open */
217 if(pPath->state!=PATH_Open)
220 /* Reserve enough memory for an extra path entry */
221 if(!PATH_ReserveEntries(pPath, pPath->numEntriesUsed+1))
224 /* Store information in path entry */
225 pPath->pPoints[pPath->numEntriesUsed]=*pPoint;
226 pPath->pFlags[pPath->numEntriesUsed]=flags;
228 /* If this is PT_CLOSEFIGURE, we have to start a new stroke next time */
229 if((flags & PT_CLOSEFIGURE) == PT_CLOSEFIGURE)
230 pPath->newStroke=TRUE;
232 /* Increment entry count */
233 pPath->numEntriesUsed++;
238 /* start a new path stroke if necessary */
239 static BOOL start_new_stroke( struct path_physdev *physdev )
243 if (!physdev->path->newStroke) return TRUE;
244 physdev->path->newStroke = FALSE;
245 GetCurrentPositionEx( physdev->dev.hdc, &pos );
246 LPtoDP( physdev->dev.hdc, &pos, 1 );
247 return PATH_AddEntry( physdev->path, &pos, PT_MOVETO );
250 /* PATH_AssignGdiPath
252 * Copies the GdiPath structure "pPathSrc" to "pPathDest". A deep copy is
253 * performed, i.e. the contents of the pPoints and pFlags arrays are copied,
254 * not just the pointers. Since this means that the arrays in pPathDest may
255 * need to be resized, pPathDest should have been initialized using
256 * PATH_InitGdiPath (in C++, this function would be an assignment operator,
257 * not a copy constructor).
258 * Returns TRUE if successful, else FALSE.
260 static BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc)
262 /* Make sure destination arrays are big enough */
263 if(!PATH_ReserveEntries(pPathDest, pPathSrc->numEntriesUsed))
266 /* Perform the copy operation */
267 memcpy(pPathDest->pPoints, pPathSrc->pPoints,
268 sizeof(POINT)*pPathSrc->numEntriesUsed);
269 memcpy(pPathDest->pFlags, pPathSrc->pFlags,
270 sizeof(BYTE)*pPathSrc->numEntriesUsed);
272 pPathDest->state=pPathSrc->state;
273 pPathDest->numEntriesUsed=pPathSrc->numEntriesUsed;
274 pPathDest->newStroke=pPathSrc->newStroke;
281 * Helper function for RoundRect() and Rectangle()
283 static void PATH_CheckCorners( HDC hdc, POINT corners[], INT x1, INT y1, INT x2, INT y2 )
287 /* Convert points to device coordinates */
292 LPtoDP( hdc, corners, 2 );
294 /* Make sure first corner is top left and second corner is bottom right */
295 if(corners[0].x>corners[1].x)
298 corners[0].x=corners[1].x;
301 if(corners[0].y>corners[1].y)
304 corners[0].y=corners[1].y;
308 /* In GM_COMPATIBLE, don't include bottom and right edges */
309 if (GetGraphicsMode( hdc ) == GM_COMPATIBLE)
316 /* PATH_AddFlatBezier
318 static BOOL PATH_AddFlatBezier(GdiPath *pPath, POINT *pt, BOOL closed)
323 pts = GDI_Bezier( pt, 4, &no );
324 if(!pts) return FALSE;
326 for(i = 1; i < no; i++)
327 PATH_AddEntry(pPath, &pts[i], (i == no-1 && closed) ? PT_LINETO | PT_CLOSEFIGURE : PT_LINETO);
328 HeapFree( GetProcessHeap(), 0, pts );
334 * Replaces Beziers with line segments
337 static BOOL PATH_FlattenPath(GdiPath *pPath)
342 memset(&newPath, 0, sizeof(newPath));
343 newPath.state = PATH_Open;
344 for(srcpt = 0; srcpt < pPath->numEntriesUsed; srcpt++) {
345 switch(pPath->pFlags[srcpt] & ~PT_CLOSEFIGURE) {
348 PATH_AddEntry(&newPath, &pPath->pPoints[srcpt],
349 pPath->pFlags[srcpt]);
352 PATH_AddFlatBezier(&newPath, &pPath->pPoints[srcpt-1],
353 pPath->pFlags[srcpt+2] & PT_CLOSEFIGURE);
358 newPath.state = PATH_Closed;
359 PATH_AssignGdiPath(pPath, &newPath);
360 PATH_DestroyGdiPath(&newPath);
366 * Creates a region from the specified path using the specified polygon
367 * filling mode. The path is left unchanged. A handle to the region that
368 * was created is stored in *pHrgn. If successful, TRUE is returned; if an
369 * error occurs, SetLastError is called with the appropriate value and
372 static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
375 int numStrokes, iStroke, i;
376 INT *pNumPointsInStroke;
379 PATH_FlattenPath(pPath);
381 /* FIXME: What happens when number of points is zero? */
383 /* First pass: Find out how many strokes there are in the path */
384 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
386 for(i=0; i<pPath->numEntriesUsed; i++)
387 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
390 /* Allocate memory for number-of-points-in-stroke array */
391 pNumPointsInStroke=HeapAlloc( GetProcessHeap(), 0, sizeof(int) * numStrokes );
392 if(!pNumPointsInStroke)
394 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
398 /* Second pass: remember number of points in each polygon */
399 iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
400 for(i=0; i<pPath->numEntriesUsed; i++)
402 /* Is this the beginning of a new stroke? */
403 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
406 pNumPointsInStroke[iStroke]=0;
409 pNumPointsInStroke[iStroke]++;
412 /* Create a region from the strokes */
413 hrgn=CreatePolyPolygonRgn(pPath->pPoints, pNumPointsInStroke,
414 numStrokes, nPolyFillMode);
416 /* Free memory for number-of-points-in-stroke array */
417 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
421 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
430 /* PATH_ScaleNormalizedPoint
432 * Scales a normalized point (x, y) with respect to the box whose corners are
433 * passed in "corners". The point is stored in "*pPoint". The normalized
434 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
435 * (1.0, 1.0) correspond to corners[1].
437 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
438 double y, POINT *pPoint)
440 pPoint->x=GDI_ROUND( (double)corners[0].x + (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
441 pPoint->y=GDI_ROUND( (double)corners[0].y + (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
444 /* PATH_NormalizePoint
446 * Normalizes a point with respect to the box whose corners are passed in
447 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
449 static void PATH_NormalizePoint(FLOAT_POINT corners[],
450 const FLOAT_POINT *pPoint,
451 double *pX, double *pY)
453 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) * 2.0 - 1.0;
454 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) * 2.0 - 1.0;
459 * Creates a Bezier spline that corresponds to part of an arc and appends the
460 * corresponding points to the path. The start and end angles are passed in
461 * "angleStart" and "angleEnd"; these angles should span a quarter circle
462 * at most. If "startEntryType" is non-zero, an entry of that type for the first
463 * control point is added to the path; otherwise, it is assumed that the current
464 * position is equal to the first control point.
466 static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
467 double angleStart, double angleEnd, BYTE startEntryType)
470 double xNorm[4], yNorm[4];
474 assert(fabs(angleEnd-angleStart)<=M_PI_2);
476 /* FIXME: Is there an easier way of computing this? */
478 /* Compute control points */
479 halfAngle=(angleEnd-angleStart)/2.0;
480 if(fabs(halfAngle)>1e-8)
482 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
483 xNorm[0]=cos(angleStart);
484 yNorm[0]=sin(angleStart);
485 xNorm[1]=xNorm[0] - a*yNorm[0];
486 yNorm[1]=yNorm[0] + a*xNorm[0];
487 xNorm[3]=cos(angleEnd);
488 yNorm[3]=sin(angleEnd);
489 xNorm[2]=xNorm[3] + a*yNorm[3];
490 yNorm[2]=yNorm[3] - a*xNorm[3];
495 xNorm[i]=cos(angleStart);
496 yNorm[i]=sin(angleStart);
499 /* Add starting point to path if desired */
502 PATH_ScaleNormalizedPoint(corners, xNorm[0], yNorm[0], &point);
503 if(!PATH_AddEntry(pPath, &point, startEntryType))
507 /* Add remaining control points */
510 PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &point);
511 if(!PATH_AddEntry(pPath, &point, PT_BEZIERTO))
519 /***********************************************************************
520 * BeginPath (GDI32.@)
522 BOOL WINAPI BeginPath(HDC hdc)
525 DC *dc = get_dc_ptr( hdc );
529 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pBeginPath );
530 ret = physdev->funcs->pBeginPath( physdev );
531 release_dc_ptr( dc );
537 /***********************************************************************
540 BOOL WINAPI EndPath(HDC hdc)
543 DC *dc = get_dc_ptr( hdc );
547 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEndPath );
548 ret = physdev->funcs->pEndPath( physdev );
549 release_dc_ptr( dc );
555 /******************************************************************************
556 * AbortPath [GDI32.@]
557 * Closes and discards paths from device context
560 * Check that SetLastError is being called correctly
563 * hdc [I] Handle to device context
569 BOOL WINAPI AbortPath( HDC hdc )
572 DC *dc = get_dc_ptr( hdc );
576 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pAbortPath );
577 ret = physdev->funcs->pAbortPath( physdev );
578 release_dc_ptr( dc );
584 /***********************************************************************
585 * CloseFigure (GDI32.@)
587 * FIXME: Check that SetLastError is being called correctly
589 BOOL WINAPI CloseFigure(HDC hdc)
592 DC *dc = get_dc_ptr( hdc );
596 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pCloseFigure );
597 ret = physdev->funcs->pCloseFigure( physdev );
598 release_dc_ptr( dc );
604 /***********************************************************************
607 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes,
612 DC *dc = get_dc_ptr( hdc );
618 /* Check that path is closed */
619 if(pPath->state!=PATH_Closed)
621 SetLastError(ERROR_CAN_NOT_COMPLETE);
626 ret = pPath->numEntriesUsed;
627 else if(nSize<pPath->numEntriesUsed)
629 SetLastError(ERROR_INVALID_PARAMETER);
634 memcpy(pPoints, pPath->pPoints, sizeof(POINT)*pPath->numEntriesUsed);
635 memcpy(pTypes, pPath->pFlags, sizeof(BYTE)*pPath->numEntriesUsed);
637 /* Convert the points to logical coordinates */
638 if(!DPtoLP(hdc, pPoints, pPath->numEntriesUsed))
640 /* FIXME: Is this the correct value? */
641 SetLastError(ERROR_CAN_NOT_COMPLETE);
644 else ret = pPath->numEntriesUsed;
647 release_dc_ptr( dc );
652 /***********************************************************************
653 * PathToRegion (GDI32.@)
656 * Check that SetLastError is being called correctly
658 * The documentation does not state this explicitly, but a test under Windows
659 * shows that the region which is returned should be in device coordinates.
661 HRGN WINAPI PathToRegion(HDC hdc)
665 DC *dc = get_dc_ptr( hdc );
667 /* Get pointer to path */
672 /* Check that path is closed */
673 if(pPath->state!=PATH_Closed) SetLastError(ERROR_CAN_NOT_COMPLETE);
676 /* FIXME: Should we empty the path even if conversion failed? */
677 if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnRval))
678 PATH_EmptyPath(pPath);
682 release_dc_ptr( dc );
686 static BOOL PATH_FillPath(DC *dc, GdiPath *pPath)
688 INT mapMode, graphicsMode;
689 SIZE ptViewportExt, ptWindowExt;
690 POINT ptViewportOrg, ptWindowOrg;
694 /* Construct a region from the path and fill it */
695 if(PATH_PathToRegion(pPath, dc->polyFillMode, &hrgn))
697 /* Since PaintRgn interprets the region as being in logical coordinates
698 * but the points we store for the path are already in device
699 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
700 * Using SaveDC to save information about the mapping mode / world
701 * transform would be easier but would require more overhead, especially
702 * now that SaveDC saves the current path.
705 /* Save the information about the old mapping mode */
706 mapMode=GetMapMode(dc->hSelf);
707 GetViewportExtEx(dc->hSelf, &ptViewportExt);
708 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
709 GetWindowExtEx(dc->hSelf, &ptWindowExt);
710 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
712 /* Save world transform
713 * NB: The Windows documentation on world transforms would lead one to
714 * believe that this has to be done only in GM_ADVANCED; however, my
715 * tests show that resetting the graphics mode to GM_COMPATIBLE does
716 * not reset the world transform.
718 GetWorldTransform(dc->hSelf, &xform);
721 SetMapMode(dc->hSelf, MM_TEXT);
722 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
723 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
724 graphicsMode=GetGraphicsMode(dc->hSelf);
725 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
726 ModifyWorldTransform(dc->hSelf, &xform, MWT_IDENTITY);
727 SetGraphicsMode(dc->hSelf, graphicsMode);
729 /* Paint the region */
730 PaintRgn(dc->hSelf, hrgn);
732 /* Restore the old mapping mode */
733 SetMapMode(dc->hSelf, mapMode);
734 SetViewportExtEx(dc->hSelf, ptViewportExt.cx, ptViewportExt.cy, NULL);
735 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
736 SetWindowExtEx(dc->hSelf, ptWindowExt.cx, ptWindowExt.cy, NULL);
737 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
739 /* Go to GM_ADVANCED temporarily to restore the world transform */
740 graphicsMode=GetGraphicsMode(dc->hSelf);
741 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
742 SetWorldTransform(dc->hSelf, &xform);
743 SetGraphicsMode(dc->hSelf, graphicsMode);
750 /***********************************************************************
754 * Check that SetLastError is being called correctly
756 BOOL WINAPI FillPath(HDC hdc)
759 DC *dc = get_dc_ptr( hdc );
763 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFillPath );
764 ret = physdev->funcs->pFillPath( physdev );
765 release_dc_ptr( dc );
771 /***********************************************************************
772 * SelectClipPath (GDI32.@)
774 * Check that SetLastError is being called correctly
776 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
779 DC *dc = get_dc_ptr( hdc );
783 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectClipPath );
784 ret = physdev->funcs->pSelectClipPath( physdev, iMode );
785 release_dc_ptr( dc );
791 /***********************************************************************
794 static BOOL pathdrv_AbortPath( PHYSDEV dev )
796 DC *dc = get_dc_ptr( dev->hdc );
798 if (!dc) return FALSE;
799 PATH_EmptyPath( &dc->path );
800 pop_path_driver( dc );
801 release_dc_ptr( dc );
806 /***********************************************************************
809 static BOOL pathdrv_EndPath( PHYSDEV dev )
811 DC *dc = get_dc_ptr( dev->hdc );
813 if (!dc) return FALSE;
814 dc->path.state = PATH_Closed;
815 pop_path_driver( dc );
816 release_dc_ptr( dc );
821 /***********************************************************************
824 static BOOL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
825 LPCWSTR output, const DEVMODEW *devmode )
827 struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) );
830 if (!physdev) return FALSE;
831 dc = get_dc_ptr( (*dev)->hdc );
832 physdev->path = &dc->path;
833 push_dc_driver( dev, &physdev->dev, &path_driver );
834 release_dc_ptr( dc );
839 /*************************************************************
842 static BOOL pathdrv_DeleteDC( PHYSDEV dev )
844 assert( 0 ); /* should never be called */
851 * Initializes the GdiPath structure.
853 void PATH_InitGdiPath(GdiPath *pPath)
857 pPath->state=PATH_Null;
860 pPath->numEntriesUsed=0;
861 pPath->numEntriesAllocated=0;
864 /* PATH_DestroyGdiPath
866 * Destroys a GdiPath structure (frees the memory in the arrays).
868 void PATH_DestroyGdiPath(GdiPath *pPath)
872 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
873 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
876 BOOL PATH_SavePath( DC *dst, DC *src )
878 PATH_InitGdiPath( &dst->path );
879 return PATH_AssignGdiPath( &dst->path, &src->path );
882 BOOL PATH_RestorePath( DC *dst, DC *src )
886 if (src->path.state == PATH_Open && dst->path.state != PATH_Open)
888 if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
889 ret = PATH_AssignGdiPath( &dst->path, &src->path );
890 if (!ret) pop_path_driver( dst );
892 else if (src->path.state != PATH_Open && dst->path.state == PATH_Open)
894 ret = PATH_AssignGdiPath( &dst->path, &src->path );
895 if (ret) pop_path_driver( dst );
897 else ret = PATH_AssignGdiPath( &dst->path, &src->path );
902 /*************************************************************
905 static BOOL pathdrv_MoveTo( PHYSDEV dev, INT x, INT y )
907 struct path_physdev *physdev = get_path_physdev( dev );
908 physdev->path->newStroke = TRUE;
913 /*************************************************************
916 static BOOL pathdrv_LineTo( PHYSDEV dev, INT x, INT y )
918 struct path_physdev *physdev = get_path_physdev( dev );
921 /* Convert point to device coordinates */
924 LPtoDP( dev->hdc, &point, 1 );
926 if (!start_new_stroke( physdev )) return FALSE;
928 return PATH_AddEntry(physdev->path, &point, PT_LINETO);
932 /*************************************************************
935 * FIXME: it adds the same entries to the path as windows does, but there
936 * is an error in the bezier drawing code so that there are small pixel-size
937 * gaps when the resulting path is drawn by StrokePath()
939 static BOOL pathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height )
941 struct path_physdev *physdev = get_path_physdev( dev );
942 POINT corners[2], pointTemp;
943 FLOAT_POINT ellCorners[2];
945 PATH_CheckCorners(dev->hdc,corners,x1,y1,x2,y2);
947 /* Add points to the roundrect path */
948 ellCorners[0].x = corners[1].x-ell_width;
949 ellCorners[0].y = corners[0].y;
950 ellCorners[1].x = corners[1].x;
951 ellCorners[1].y = corners[0].y+ell_height;
952 if(!PATH_DoArcPart(physdev->path, ellCorners, 0, -M_PI_2, PT_MOVETO))
954 pointTemp.x = corners[0].x+ell_width/2;
955 pointTemp.y = corners[0].y;
956 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
958 ellCorners[0].x = corners[0].x;
959 ellCorners[1].x = corners[0].x+ell_width;
960 if(!PATH_DoArcPart(physdev->path, ellCorners, -M_PI_2, -M_PI, FALSE))
962 pointTemp.x = corners[0].x;
963 pointTemp.y = corners[1].y-ell_height/2;
964 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
966 ellCorners[0].y = corners[1].y-ell_height;
967 ellCorners[1].y = corners[1].y;
968 if(!PATH_DoArcPart(physdev->path, ellCorners, M_PI, M_PI_2, FALSE))
970 pointTemp.x = corners[1].x-ell_width/2;
971 pointTemp.y = corners[1].y;
972 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
974 ellCorners[0].x = corners[1].x-ell_width;
975 ellCorners[1].x = corners[1].x;
976 if(!PATH_DoArcPart(physdev->path, ellCorners, M_PI_2, 0, FALSE))
979 /* Close the roundrect figure */
980 return CloseFigure( dev->hdc );
984 /*************************************************************
987 static BOOL pathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
989 struct path_physdev *physdev = get_path_physdev( dev );
990 POINT corners[2], pointTemp;
992 PATH_CheckCorners(dev->hdc,corners,x1,y1,x2,y2);
994 /* Add four points to the path */
995 pointTemp.x=corners[1].x;
996 pointTemp.y=corners[0].y;
997 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_MOVETO))
999 if(!PATH_AddEntry(physdev->path, corners, PT_LINETO))
1001 pointTemp.x=corners[0].x;
1002 pointTemp.y=corners[1].y;
1003 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
1005 if(!PATH_AddEntry(physdev->path, corners+1, PT_LINETO))
1008 /* Close the rectangle figure */
1009 return CloseFigure( dev->hdc );
1015 * Should be called when a call to Arc is performed on a DC that has
1016 * an open path. This adds up to five Bezier splines representing the arc
1017 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
1018 * when 'lines' is 2, we add 2 extra lines to get a pie, and when 'lines' is
1019 * -1 we add 1 extra line from the current DC position to the starting position
1020 * of the arc before drawing the arc itself (arcto). Returns TRUE if successful,
1023 static BOOL PATH_Arc( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2,
1024 INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines )
1026 struct path_physdev *physdev = get_path_physdev( dev );
1027 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
1028 /* Initialize angleEndQuadrant to silence gcc's warning */
1030 FLOAT_POINT corners[2], pointStart, pointEnd;
1033 INT temp, direction = GetArcDirection(dev->hdc);
1035 /* FIXME: Do we have to respect newStroke? */
1037 /* Check for zero height / width */
1038 /* FIXME: Only in GM_COMPATIBLE? */
1039 if(x1==x2 || y1==y2)
1042 /* Convert points to device coordinates */
1047 pointStart.x = xStart;
1048 pointStart.y = yStart;
1051 INTERNAL_LPTODP_FLOAT(dev->hdc, corners, 2);
1052 INTERNAL_LPTODP_FLOAT(dev->hdc, &pointStart, 1);
1053 INTERNAL_LPTODP_FLOAT(dev->hdc, &pointEnd, 1);
1055 /* Make sure first corner is top left and second corner is bottom right */
1056 if(corners[0].x>corners[1].x)
1059 corners[0].x=corners[1].x;
1062 if(corners[0].y>corners[1].y)
1065 corners[0].y=corners[1].y;
1069 /* Compute start and end angle */
1070 PATH_NormalizePoint(corners, &pointStart, &x, &y);
1071 angleStart=atan2(y, x);
1072 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
1073 angleEnd=atan2(y, x);
1075 /* Make sure the end angle is "on the right side" of the start angle */
1076 if (direction == AD_CLOCKWISE)
1078 if(angleEnd<=angleStart)
1081 assert(angleEnd>=angleStart);
1086 if(angleEnd>=angleStart)
1089 assert(angleEnd<=angleStart);
1093 /* In GM_COMPATIBLE, don't include bottom and right edges */
1094 if (GetGraphicsMode(dev->hdc) == GM_COMPATIBLE)
1100 /* arcto: Add a PT_MOVETO only if this is the first entry in a stroke */
1101 if (lines==-1 && !start_new_stroke( physdev )) return FALSE;
1103 /* Add the arc to the path with one Bezier spline per quadrant that the
1109 /* Determine the start and end angles for this quadrant */
1112 angleStartQuadrant=angleStart;
1113 if (direction == AD_CLOCKWISE)
1114 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
1116 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
1120 angleStartQuadrant=angleEndQuadrant;
1121 if (direction == AD_CLOCKWISE)
1122 angleEndQuadrant+=M_PI_2;
1124 angleEndQuadrant-=M_PI_2;
1127 /* Have we reached the last part of the arc? */
1128 if((direction == AD_CLOCKWISE && angleEnd<angleEndQuadrant) ||
1129 (direction == AD_COUNTERCLOCKWISE && angleEnd>angleEndQuadrant))
1131 /* Adjust the end angle for this quadrant */
1132 angleEndQuadrant=angleEnd;
1136 /* Add the Bezier spline to the path */
1137 PATH_DoArcPart(physdev->path, corners, angleStartQuadrant, angleEndQuadrant,
1138 start ? (lines==-1 ? PT_LINETO : PT_MOVETO) : FALSE);
1142 /* chord: close figure. pie: add line and close figure */
1145 return CloseFigure(dev->hdc);
1149 centre.x = (corners[0].x+corners[1].x)/2;
1150 centre.y = (corners[0].y+corners[1].y)/2;
1151 if(!PATH_AddEntry(physdev->path, ¢re, PT_LINETO | PT_CLOSEFIGURE))
1159 /*************************************************************
1162 static BOOL pathdrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT eStartAngle, FLOAT eSweepAngle)
1164 INT x1, y1, x2, y2, arcdir;
1167 x1 = GDI_ROUND( x + cos(eStartAngle*M_PI/180) * radius );
1168 y1 = GDI_ROUND( y - sin(eStartAngle*M_PI/180) * radius );
1169 x2 = GDI_ROUND( x + cos((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1170 y2 = GDI_ROUND( y - sin((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1171 arcdir = SetArcDirection( dev->hdc, eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE);
1172 ret = PATH_Arc( dev, x-radius, y-radius, x+radius, y+radius, x1, y1, x2, y2, -1 );
1173 SetArcDirection( dev->hdc, arcdir );
1178 /*************************************************************
1181 static BOOL pathdrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1182 INT xstart, INT ystart, INT xend, INT yend )
1184 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 0 );
1188 /*************************************************************
1191 static BOOL pathdrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1192 INT xstart, INT ystart, INT xend, INT yend )
1194 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, -1 );
1198 /*************************************************************
1201 static BOOL pathdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1202 INT xstart, INT ystart, INT xend, INT yend )
1204 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 1);
1208 /*************************************************************
1211 static BOOL pathdrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1212 INT xstart, INT ystart, INT xend, INT yend )
1214 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 2 );
1218 /*************************************************************
1221 static BOOL pathdrv_Ellipse( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
1223 return PATH_Arc( dev, x1, y1, x2, y2, x1, (y1+y2)/2, x1, (y1+y2)/2, 0 ) && CloseFigure( dev->hdc );
1227 /*************************************************************
1228 * pathdrv_PolyBezierTo
1230 static BOOL pathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1232 struct path_physdev *physdev = get_path_physdev( dev );
1236 if (!start_new_stroke( physdev )) return FALSE;
1238 for(i = 0; i < cbPoints; i++) {
1240 LPtoDP( dev->hdc, &pt, 1 );
1241 PATH_AddEntry(physdev->path, &pt, PT_BEZIERTO);
1247 /*************************************************************
1248 * pathdrv_PolyBezier
1250 static BOOL pathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1252 struct path_physdev *physdev = get_path_physdev( dev );
1256 for(i = 0; i < cbPoints; i++) {
1258 LPtoDP( dev->hdc, &pt, 1 );
1259 PATH_AddEntry(physdev->path, &pt, (i == 0) ? PT_MOVETO : PT_BEZIERTO);
1265 /*************************************************************
1268 static BOOL pathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD cbPoints )
1270 struct path_physdev *physdev = get_path_physdev( dev );
1271 POINT lastmove, orig_pos;
1274 GetCurrentPositionEx( dev->hdc, &orig_pos );
1275 lastmove = orig_pos;
1277 for(i = physdev->path->numEntriesUsed - 1; i >= 0; i--){
1278 if(physdev->path->pFlags[i] == PT_MOVETO){
1279 lastmove = physdev->path->pPoints[i];
1280 DPtoLP(dev->hdc, &lastmove, 1);
1285 for(i = 0; i < cbPoints; i++)
1290 MoveToEx( dev->hdc, pts[i].x, pts[i].y, NULL );
1293 case PT_LINETO | PT_CLOSEFIGURE:
1294 LineTo( dev->hdc, pts[i].x, pts[i].y );
1297 if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
1298 (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
1300 PolyBezierTo( dev->hdc, &pts[i], 3 );
1306 if (i) /* restore original position */
1308 if (!(types[i - 1] & PT_CLOSEFIGURE)) lastmove = pts[i - 1];
1309 if (lastmove.x != orig_pos.x || lastmove.y != orig_pos.y)
1310 MoveToEx( dev->hdc, orig_pos.x, orig_pos.y, NULL );
1315 if(types[i] & PT_CLOSEFIGURE){
1316 physdev->path->pFlags[physdev->path->numEntriesUsed-1] |= PT_CLOSEFIGURE;
1317 MoveToEx( dev->hdc, lastmove.x, lastmove.y, NULL );
1325 /*************************************************************
1328 static BOOL pathdrv_Polyline( PHYSDEV dev, const POINT *pts, INT cbPoints )
1330 struct path_physdev *physdev = get_path_physdev( dev );
1334 for(i = 0; i < cbPoints; i++) {
1336 LPtoDP( dev->hdc, &pt, 1 );
1337 PATH_AddEntry(physdev->path, &pt, (i == 0) ? PT_MOVETO : PT_LINETO);
1343 /*************************************************************
1344 * pathdrv_PolylineTo
1346 static BOOL pathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT cbPoints )
1348 struct path_physdev *physdev = get_path_physdev( dev );
1352 if (!start_new_stroke( physdev )) return FALSE;
1354 for(i = 0; i < cbPoints; i++) {
1356 LPtoDP( dev->hdc, &pt, 1 );
1357 PATH_AddEntry(physdev->path, &pt, PT_LINETO);
1364 /*************************************************************
1367 static BOOL pathdrv_Polygon( PHYSDEV dev, const POINT *pts, INT cbPoints )
1369 struct path_physdev *physdev = get_path_physdev( dev );
1373 for(i = 0; i < cbPoints; i++) {
1375 LPtoDP( dev->hdc, &pt, 1 );
1376 PATH_AddEntry(physdev->path, &pt, (i == 0) ? PT_MOVETO :
1377 ((i == cbPoints-1) ? PT_LINETO | PT_CLOSEFIGURE :
1384 /*************************************************************
1385 * pathdrv_PolyPolygon
1387 static BOOL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
1389 struct path_physdev *physdev = get_path_physdev( dev );
1394 for(i = 0, poly = 0; poly < polygons; poly++) {
1395 for(point = 0; point < counts[poly]; point++, i++) {
1397 LPtoDP( dev->hdc, &pt, 1 );
1398 if(point == 0) startpt = pt;
1399 PATH_AddEntry(physdev->path, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1401 /* win98 adds an extra line to close the figure for some reason */
1402 PATH_AddEntry(physdev->path, &startpt, PT_LINETO | PT_CLOSEFIGURE);
1408 /*************************************************************
1409 * pathdrv_PolyPolyline
1411 static BOOL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
1413 struct path_physdev *physdev = get_path_physdev( dev );
1415 UINT poly, point, i;
1417 for(i = 0, poly = 0; poly < polylines; poly++) {
1418 for(point = 0; point < counts[poly]; point++, i++) {
1420 LPtoDP( dev->hdc, &pt, 1 );
1421 PATH_AddEntry(physdev->path, &pt, (point == 0) ? PT_MOVETO : PT_LINETO);
1428 /**********************************************************************
1431 * internally used by PATH_add_outline
1433 static void PATH_BezierTo(GdiPath *pPath, POINT *lppt, INT n)
1439 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1443 PATH_AddEntry(pPath, &lppt[0], PT_BEZIERTO);
1444 PATH_AddEntry(pPath, &lppt[1], PT_BEZIERTO);
1445 PATH_AddEntry(pPath, &lppt[2], PT_BEZIERTO);
1459 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1460 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1461 PATH_BezierTo(pPath, pt, 3);
1469 PATH_BezierTo(pPath, pt, 3);
1473 static BOOL PATH_add_outline(DC *dc, INT x, INT y, TTPOLYGONHEADER *header, DWORD size)
1475 GdiPath *pPath = &dc->path;
1476 TTPOLYGONHEADER *start;
1481 while ((char *)header < (char *)start + size)
1485 if (header->dwType != TT_POLYGON_TYPE)
1487 FIXME("Unknown header type %d\n", header->dwType);
1491 pt.x = x + int_from_fixed(header->pfxStart.x);
1492 pt.y = y - int_from_fixed(header->pfxStart.y);
1493 PATH_AddEntry(pPath, &pt, PT_MOVETO);
1495 curve = (TTPOLYCURVE *)(header + 1);
1497 while ((char *)curve < (char *)header + header->cb)
1499 /*TRACE("curve->wType %d\n", curve->wType);*/
1501 switch(curve->wType)
1507 for (i = 0; i < curve->cpfx; i++)
1509 pt.x = x + int_from_fixed(curve->apfx[i].x);
1510 pt.y = y - int_from_fixed(curve->apfx[i].y);
1511 PATH_AddEntry(pPath, &pt, PT_LINETO);
1516 case TT_PRIM_QSPLINE:
1517 case TT_PRIM_CSPLINE:
1521 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1523 if (!pts) return FALSE;
1525 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1527 pts[0].x = x + int_from_fixed(ptfx.x);
1528 pts[0].y = y - int_from_fixed(ptfx.y);
1530 for(i = 0; i < curve->cpfx; i++)
1532 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1533 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1536 PATH_BezierTo(pPath, pts, curve->cpfx + 1);
1538 HeapFree(GetProcessHeap(), 0, pts);
1543 FIXME("Unknown curve type %04x\n", curve->wType);
1547 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1550 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1553 return CloseFigure(dc->hSelf);
1556 /**********************************************************************
1559 BOOL PATH_ExtTextOut(DC *dc, INT x, INT y, UINT flags, const RECT *lprc,
1560 LPCWSTR str, UINT count, const INT *dx)
1563 HDC hdc = dc->hSelf;
1564 POINT offset = {0, 0};
1566 TRACE("%p, %d, %d, %08x, %s, %s, %d, %p)\n", hdc, x, y, flags,
1567 wine_dbgstr_rect(lprc), debugstr_wn(str, count), count, dx);
1569 if (!count) return TRUE;
1571 for (idx = 0; idx < count; idx++)
1573 static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
1578 dwSize = GetGlyphOutlineW(hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE, &gm, 0, NULL, &identity);
1579 if (dwSize == GDI_ERROR) return FALSE;
1581 /* add outline only if char is printable */
1584 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1585 if (!outline) return FALSE;
1587 GetGlyphOutlineW(hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE, &gm, dwSize, outline, &identity);
1589 PATH_add_outline(dc, x + offset.x, y + offset.y, outline, dwSize);
1591 HeapFree(GetProcessHeap(), 0, outline);
1598 offset.x += dx[idx * 2];
1599 offset.y += dx[idx * 2 + 1];
1602 offset.x += dx[idx];
1606 offset.x += gm.gmCellIncX;
1607 offset.y += gm.gmCellIncY;
1614 /*******************************************************************
1615 * FlattenPath [GDI32.@]
1619 BOOL WINAPI FlattenPath(HDC hdc)
1622 DC *dc = get_dc_ptr( hdc );
1626 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath );
1627 ret = physdev->funcs->pFlattenPath( physdev );
1628 release_dc_ptr( dc );
1634 static BOOL PATH_StrokePath(DC *dc, GdiPath *pPath)
1636 INT i, nLinePts, nAlloc;
1638 POINT ptViewportOrg, ptWindowOrg;
1639 SIZE szViewportExt, szWindowExt;
1640 DWORD mapMode, graphicsMode;
1644 /* Save the mapping mode info */
1645 mapMode=GetMapMode(dc->hSelf);
1646 GetViewportExtEx(dc->hSelf, &szViewportExt);
1647 GetViewportOrgEx(dc->hSelf, &ptViewportOrg);
1648 GetWindowExtEx(dc->hSelf, &szWindowExt);
1649 GetWindowOrgEx(dc->hSelf, &ptWindowOrg);
1650 GetWorldTransform(dc->hSelf, &xform);
1653 SetMapMode(dc->hSelf, MM_TEXT);
1654 SetViewportOrgEx(dc->hSelf, 0, 0, NULL);
1655 SetWindowOrgEx(dc->hSelf, 0, 0, NULL);
1656 graphicsMode=GetGraphicsMode(dc->hSelf);
1657 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
1658 ModifyWorldTransform(dc->hSelf, &xform, MWT_IDENTITY);
1659 SetGraphicsMode(dc->hSelf, graphicsMode);
1661 /* Allocate enough memory for the worst case without beziers (one PT_MOVETO
1662 * and the rest PT_LINETO with PT_CLOSEFIGURE at the end) plus some buffer
1663 * space in case we get one to keep the number of reallocations small. */
1664 nAlloc = pPath->numEntriesUsed + 1 + 300;
1665 pLinePts = HeapAlloc(GetProcessHeap(), 0, nAlloc * sizeof(POINT));
1668 for(i = 0; i < pPath->numEntriesUsed; i++) {
1669 if((i == 0 || (pPath->pFlags[i-1] & PT_CLOSEFIGURE)) &&
1670 (pPath->pFlags[i] != PT_MOVETO)) {
1671 ERR("Expected PT_MOVETO %s, got path flag %d\n",
1672 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1673 (INT)pPath->pFlags[i]);
1677 switch(pPath->pFlags[i]) {
1679 TRACE("Got PT_MOVETO (%d, %d)\n",
1680 pPath->pPoints[i].x, pPath->pPoints[i].y);
1682 Polyline(dc->hSelf, pLinePts, nLinePts);
1684 pLinePts[nLinePts++] = pPath->pPoints[i];
1687 case (PT_LINETO | PT_CLOSEFIGURE):
1688 TRACE("Got PT_LINETO (%d, %d)\n",
1689 pPath->pPoints[i].x, pPath->pPoints[i].y);
1690 pLinePts[nLinePts++] = pPath->pPoints[i];
1693 TRACE("Got PT_BEZIERTO\n");
1694 if(pPath->pFlags[i+1] != PT_BEZIERTO ||
1695 (pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
1696 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
1700 INT nBzrPts, nMinAlloc;
1701 POINT *pBzrPts = GDI_Bezier(&pPath->pPoints[i-1], 4, &nBzrPts);
1702 /* Make sure we have allocated enough memory for the lines of
1703 * this bezier and the rest of the path, assuming we won't get
1704 * another one (since we won't reallocate again then). */
1705 nMinAlloc = nLinePts + (pPath->numEntriesUsed - i) + nBzrPts;
1706 if(nAlloc < nMinAlloc)
1708 nAlloc = nMinAlloc * 2;
1709 pLinePts = HeapReAlloc(GetProcessHeap(), 0, pLinePts,
1710 nAlloc * sizeof(POINT));
1712 memcpy(&pLinePts[nLinePts], &pBzrPts[1],
1713 (nBzrPts - 1) * sizeof(POINT));
1714 nLinePts += nBzrPts - 1;
1715 HeapFree(GetProcessHeap(), 0, pBzrPts);
1720 ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
1724 if(pPath->pFlags[i] & PT_CLOSEFIGURE)
1725 pLinePts[nLinePts++] = pLinePts[0];
1728 Polyline(dc->hSelf, pLinePts, nLinePts);
1731 HeapFree(GetProcessHeap(), 0, pLinePts);
1733 /* Restore the old mapping mode */
1734 SetMapMode(dc->hSelf, mapMode);
1735 SetWindowExtEx(dc->hSelf, szWindowExt.cx, szWindowExt.cy, NULL);
1736 SetWindowOrgEx(dc->hSelf, ptWindowOrg.x, ptWindowOrg.y, NULL);
1737 SetViewportExtEx(dc->hSelf, szViewportExt.cx, szViewportExt.cy, NULL);
1738 SetViewportOrgEx(dc->hSelf, ptViewportOrg.x, ptViewportOrg.y, NULL);
1740 /* Go to GM_ADVANCED temporarily to restore the world transform */
1741 graphicsMode=GetGraphicsMode(dc->hSelf);
1742 SetGraphicsMode(dc->hSelf, GM_ADVANCED);
1743 SetWorldTransform(dc->hSelf, &xform);
1744 SetGraphicsMode(dc->hSelf, graphicsMode);
1746 /* If we've moved the current point then get its new position
1747 which will be in device (MM_TEXT) co-ords, convert it to
1748 logical co-ords and re-set it. This basically updates
1749 dc->CurPosX|Y so that their values are in the correct mapping
1754 GetCurrentPositionEx(dc->hSelf, &pt);
1755 DPtoLP(dc->hSelf, &pt, 1);
1756 MoveToEx(dc->hSelf, pt.x, pt.y, NULL);
1762 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1764 static BOOL PATH_WidenPath(DC *dc)
1766 INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
1768 GdiPath *pPath, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
1770 DWORD obj_type, joint, endcap, penType;
1774 PATH_FlattenPath(pPath);
1776 size = GetObjectW( dc->hPen, 0, NULL );
1778 SetLastError(ERROR_CAN_NOT_COMPLETE);
1782 elp = HeapAlloc( GetProcessHeap(), 0, size );
1783 GetObjectW( dc->hPen, size, elp );
1785 obj_type = GetObjectType(dc->hPen);
1786 if(obj_type == OBJ_PEN) {
1787 penStyle = ((LOGPEN*)elp)->lopnStyle;
1789 else if(obj_type == OBJ_EXTPEN) {
1790 penStyle = elp->elpPenStyle;
1793 SetLastError(ERROR_CAN_NOT_COMPLETE);
1794 HeapFree( GetProcessHeap(), 0, elp );
1798 penWidth = elp->elpWidth;
1799 HeapFree( GetProcessHeap(), 0, elp );
1801 endcap = (PS_ENDCAP_MASK & penStyle);
1802 joint = (PS_JOIN_MASK & penStyle);
1803 penType = (PS_TYPE_MASK & penStyle);
1805 /* The function cannot apply to cosmetic pens */
1806 if(obj_type == OBJ_EXTPEN && penType == PS_COSMETIC) {
1807 SetLastError(ERROR_CAN_NOT_COMPLETE);
1811 penWidthIn = penWidth / 2;
1812 penWidthOut = penWidth / 2;
1813 if(penWidthIn + penWidthOut < penWidth)
1818 for(i = 0, j = 0; i < pPath->numEntriesUsed; i++, j++) {
1820 if((i == 0 || (pPath->pFlags[i-1] & PT_CLOSEFIGURE)) &&
1821 (pPath->pFlags[i] != PT_MOVETO)) {
1822 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1823 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1827 switch(pPath->pFlags[i]) {
1829 if(numStrokes > 0) {
1830 pStrokes[numStrokes - 1]->state = PATH_Closed;
1835 pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath*));
1837 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(GdiPath*));
1838 if(!pStrokes) return FALSE;
1839 pStrokes[numStrokes - 1] = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1840 PATH_InitGdiPath(pStrokes[numStrokes - 1]);
1841 pStrokes[numStrokes - 1]->state = PATH_Open;
1844 case (PT_LINETO | PT_CLOSEFIGURE):
1845 point.x = pPath->pPoints[i].x;
1846 point.y = pPath->pPoints[i].y;
1847 PATH_AddEntry(pStrokes[numStrokes - 1], &point, pPath->pFlags[i]);
1850 /* should never happen because of the FlattenPath call */
1851 ERR("Should never happen\n");
1854 ERR("Got path flag %c\n", pPath->pFlags[i]);
1859 pNewPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1860 PATH_InitGdiPath(pNewPath);
1861 pNewPath->state = PATH_Open;
1863 for(i = 0; i < numStrokes; i++) {
1864 pUpPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1865 PATH_InitGdiPath(pUpPath);
1866 pUpPath->state = PATH_Open;
1867 pDownPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1868 PATH_InitGdiPath(pDownPath);
1869 pDownPath->state = PATH_Open;
1871 for(j = 0; j < pStrokes[i]->numEntriesUsed; j++) {
1872 /* Beginning or end of the path if not closed */
1873 if((!(pStrokes[i]->pFlags[pStrokes[i]->numEntriesUsed - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->numEntriesUsed - 1) ) {
1874 /* Compute segment angle */
1875 double xo, yo, xa, ya, theta;
1877 FLOAT_POINT corners[2];
1879 xo = pStrokes[i]->pPoints[j].x;
1880 yo = pStrokes[i]->pPoints[j].y;
1881 xa = pStrokes[i]->pPoints[1].x;
1882 ya = pStrokes[i]->pPoints[1].y;
1885 xa = pStrokes[i]->pPoints[j - 1].x;
1886 ya = pStrokes[i]->pPoints[j - 1].y;
1887 xo = pStrokes[i]->pPoints[j].x;
1888 yo = pStrokes[i]->pPoints[j].y;
1890 theta = atan2( ya - yo, xa - xo );
1892 case PS_ENDCAP_SQUARE :
1893 pt.x = xo + round(sqrt(2) * penWidthOut * cos(M_PI_4 + theta));
1894 pt.y = yo + round(sqrt(2) * penWidthOut * sin(M_PI_4 + theta));
1895 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO) );
1896 pt.x = xo + round(sqrt(2) * penWidthIn * cos(- M_PI_4 + theta));
1897 pt.y = yo + round(sqrt(2) * penWidthIn * sin(- M_PI_4 + theta));
1898 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1900 case PS_ENDCAP_FLAT :
1901 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1902 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1903 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
1904 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1905 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1906 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1908 case PS_ENDCAP_ROUND :
1910 corners[0].x = xo - penWidthIn;
1911 corners[0].y = yo - penWidthIn;
1912 corners[1].x = xo + penWidthOut;
1913 corners[1].y = yo + penWidthOut;
1914 PATH_DoArcPart(pUpPath ,corners, theta + M_PI_2 , theta + 3 * M_PI_4, (j == 0 ? PT_MOVETO : FALSE));
1915 PATH_DoArcPart(pUpPath ,corners, theta + 3 * M_PI_4 , theta + M_PI, FALSE);
1916 PATH_DoArcPart(pUpPath ,corners, theta + M_PI, theta + 5 * M_PI_4, FALSE);
1917 PATH_DoArcPart(pUpPath ,corners, theta + 5 * M_PI_4 , theta + 3 * M_PI_2, FALSE);
1921 /* Corpse of the path */
1925 double xa, ya, xb, yb, xo, yo;
1926 double alpha, theta, miterWidth;
1927 DWORD _joint = joint;
1929 GdiPath *pInsidePath, *pOutsidePath;
1930 if(j > 0 && j < pStrokes[i]->numEntriesUsed - 1) {
1935 previous = pStrokes[i]->numEntriesUsed - 1;
1942 xo = pStrokes[i]->pPoints[j].x;
1943 yo = pStrokes[i]->pPoints[j].y;
1944 xa = pStrokes[i]->pPoints[previous].x;
1945 ya = pStrokes[i]->pPoints[previous].y;
1946 xb = pStrokes[i]->pPoints[next].x;
1947 yb = pStrokes[i]->pPoints[next].y;
1948 theta = atan2( yo - ya, xo - xa );
1949 alpha = atan2( yb - yo, xb - xo ) - theta;
1950 if (alpha > 0) alpha -= M_PI;
1952 if(_joint == PS_JOIN_MITER && dc->miterLimit < fabs(1 / sin(alpha/2))) {
1953 _joint = PS_JOIN_BEVEL;
1956 pInsidePath = pUpPath;
1957 pOutsidePath = pDownPath;
1959 else if(alpha < 0) {
1960 pInsidePath = pDownPath;
1961 pOutsidePath = pUpPath;
1966 /* Inside angle points */
1968 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1969 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1972 pt.x = xo + round( penWidthIn * cos(theta + M_PI_2) );
1973 pt.y = yo + round( penWidthIn * sin(theta + M_PI_2) );
1975 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1977 pt.x = xo + round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1978 pt.y = yo + round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1981 pt.x = xo - round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1982 pt.y = yo - round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1984 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1985 /* Outside angle point */
1987 case PS_JOIN_MITER :
1988 miterWidth = fabs(penWidthOut / cos(M_PI_2 - fabs(alpha) / 2));
1989 pt.x = xo + round( miterWidth * cos(theta + alpha / 2) );
1990 pt.y = yo + round( miterWidth * sin(theta + alpha / 2) );
1991 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1993 case PS_JOIN_BEVEL :
1995 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1996 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1999 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
2000 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
2002 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
2004 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2005 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2008 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2009 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2011 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
2013 case PS_JOIN_ROUND :
2016 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
2017 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
2020 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
2021 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
2023 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2024 pt.x = xo + round( penWidthOut * cos(theta + alpha / 2) );
2025 pt.y = yo + round( penWidthOut * sin(theta + alpha / 2) );
2026 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2028 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2029 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2032 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2033 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2035 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2040 for(j = 0; j < pUpPath->numEntriesUsed; j++) {
2042 pt.x = pUpPath->pPoints[j].x;
2043 pt.y = pUpPath->pPoints[j].y;
2044 PATH_AddEntry(pNewPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
2046 for(j = 0; j < pDownPath->numEntriesUsed; j++) {
2048 pt.x = pDownPath->pPoints[pDownPath->numEntriesUsed - j - 1].x;
2049 pt.y = pDownPath->pPoints[pDownPath->numEntriesUsed - j - 1].y;
2050 PATH_AddEntry(pNewPath, &pt, ( (j == 0 && (pStrokes[i]->pFlags[pStrokes[i]->numEntriesUsed - 1] & PT_CLOSEFIGURE)) ? PT_MOVETO : PT_LINETO));
2053 PATH_DestroyGdiPath(pStrokes[i]);
2054 HeapFree(GetProcessHeap(), 0, pStrokes[i]);
2055 PATH_DestroyGdiPath(pUpPath);
2056 HeapFree(GetProcessHeap(), 0, pUpPath);
2057 PATH_DestroyGdiPath(pDownPath);
2058 HeapFree(GetProcessHeap(), 0, pDownPath);
2060 HeapFree(GetProcessHeap(), 0, pStrokes);
2062 pNewPath->state = PATH_Closed;
2063 if (!(ret = PATH_AssignGdiPath(pPath, pNewPath)))
2064 ERR("Assign path failed\n");
2065 PATH_DestroyGdiPath(pNewPath);
2066 HeapFree(GetProcessHeap(), 0, pNewPath);
2071 /*******************************************************************
2072 * StrokeAndFillPath [GDI32.@]
2076 BOOL WINAPI StrokeAndFillPath(HDC hdc)
2079 DC *dc = get_dc_ptr( hdc );
2083 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath );
2084 ret = physdev->funcs->pStrokeAndFillPath( physdev );
2085 release_dc_ptr( dc );
2091 /*******************************************************************
2092 * StrokePath [GDI32.@]
2096 BOOL WINAPI StrokePath(HDC hdc)
2099 DC *dc = get_dc_ptr( hdc );
2103 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath );
2104 ret = physdev->funcs->pStrokePath( physdev );
2105 release_dc_ptr( dc );
2111 /*******************************************************************
2112 * WidenPath [GDI32.@]
2116 BOOL WINAPI WidenPath(HDC hdc)
2119 DC *dc = get_dc_ptr( hdc );
2123 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath );
2124 ret = physdev->funcs->pWidenPath( physdev );
2125 release_dc_ptr( dc );
2131 /***********************************************************************
2132 * null driver fallback implementations
2135 BOOL nulldrv_BeginPath( PHYSDEV dev )
2137 DC *dc = get_nulldrv_dc( dev );
2139 /* If path is already open, do nothing */
2140 if (dc->path.state != PATH_Open)
2142 if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL )) return FALSE;
2143 PATH_EmptyPath(&dc->path);
2144 dc->path.newStroke = TRUE;
2145 dc->path.state = PATH_Open;
2150 BOOL nulldrv_EndPath( PHYSDEV dev )
2152 SetLastError( ERROR_CAN_NOT_COMPLETE );
2156 BOOL nulldrv_AbortPath( PHYSDEV dev )
2158 DC *dc = get_nulldrv_dc( dev );
2160 PATH_EmptyPath( &dc->path );
2164 BOOL nulldrv_CloseFigure( PHYSDEV dev )
2166 DC *dc = get_nulldrv_dc( dev );
2168 if (dc->path.state != PATH_Open)
2170 SetLastError( ERROR_CAN_NOT_COMPLETE );
2173 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
2174 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
2175 if (dc->path.numEntriesUsed)
2177 dc->path.pFlags[dc->path.numEntriesUsed - 1] |= PT_CLOSEFIGURE;
2178 dc->path.newStroke = TRUE;
2183 BOOL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
2187 DC *dc = get_nulldrv_dc( dev );
2189 if (dc->path.state != PATH_Closed)
2191 SetLastError( ERROR_CAN_NOT_COMPLETE );
2194 if (!PATH_PathToRegion( &dc->path, GetPolyFillMode(dev->hdc), &hrgn )) return FALSE;
2195 ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR;
2196 if (ret) PATH_EmptyPath( &dc->path );
2197 /* FIXME: Should this function delete the path even if it failed? */
2198 DeleteObject( hrgn );
2202 BOOL nulldrv_FillPath( PHYSDEV dev )
2204 DC *dc = get_nulldrv_dc( dev );
2206 if (dc->path.state != PATH_Closed)
2208 SetLastError( ERROR_CAN_NOT_COMPLETE );
2211 if (!PATH_FillPath( dc, &dc->path )) return FALSE;
2212 /* FIXME: Should the path be emptied even if conversion failed? */
2213 PATH_EmptyPath( &dc->path );
2217 BOOL nulldrv_StrokeAndFillPath( PHYSDEV dev )
2219 DC *dc = get_nulldrv_dc( dev );
2221 if (dc->path.state != PATH_Closed)
2223 SetLastError( ERROR_CAN_NOT_COMPLETE );
2226 if (!PATH_FillPath( dc, &dc->path )) return FALSE;
2227 if (!PATH_StrokePath( dc, &dc->path )) return FALSE;
2228 PATH_EmptyPath( &dc->path );
2232 BOOL nulldrv_StrokePath( PHYSDEV dev )
2234 DC *dc = get_nulldrv_dc( dev );
2236 if (dc->path.state != PATH_Closed)
2238 SetLastError( ERROR_CAN_NOT_COMPLETE );
2241 if (!PATH_StrokePath( dc, &dc->path )) return FALSE;
2242 PATH_EmptyPath( &dc->path );
2246 BOOL nulldrv_FlattenPath( PHYSDEV dev )
2248 DC *dc = get_nulldrv_dc( dev );
2250 if (dc->path.state != PATH_Closed)
2252 SetLastError( ERROR_CAN_NOT_COMPLETE );
2255 return PATH_FlattenPath( &dc->path );
2258 BOOL nulldrv_WidenPath( PHYSDEV dev )
2260 DC *dc = get_nulldrv_dc( dev );
2262 if (dc->path.state != PATH_Closed)
2264 SetLastError( ERROR_CAN_NOT_COMPLETE );
2267 return PATH_WidenPath( dc );
2270 const struct gdi_dc_funcs path_driver =
2272 NULL, /* pAbortDoc */
2273 pathdrv_AbortPath, /* pAbortPath */
2274 NULL, /* pAlphaBlend */
2275 pathdrv_AngleArc, /* pAngleArc */
2276 pathdrv_Arc, /* pArc */
2277 pathdrv_ArcTo, /* pArcTo */
2278 NULL, /* pBeginPath */
2279 NULL, /* pBlendImage */
2280 NULL, /* pChoosePixelFormat */
2281 pathdrv_Chord, /* pChord */
2282 NULL, /* pCloseFigure */
2283 NULL, /* pCreateBitmap */
2284 NULL, /* pCreateCompatibleDC */
2285 pathdrv_CreateDC, /* pCreateDC */
2286 NULL, /* pCreateDIBSection */
2287 NULL, /* pDeleteBitmap */
2288 pathdrv_DeleteDC, /* pDeleteDC */
2289 NULL, /* pDeleteObject */
2290 NULL, /* pDescribePixelFormat */
2291 NULL, /* pDeviceCapabilities */
2292 pathdrv_Ellipse, /* pEllipse */
2294 NULL, /* pEndPage */
2295 pathdrv_EndPath, /* pEndPath */
2296 NULL, /* pEnumFonts */
2297 NULL, /* pEnumICMProfiles */
2298 NULL, /* pExcludeClipRect */
2299 NULL, /* pExtDeviceMode */
2300 NULL, /* pExtEscape */
2301 NULL, /* pExtFloodFill */
2302 NULL, /* pExtSelectClipRgn */
2303 NULL, /* pExtTextOut */
2304 NULL, /* pFillPath */
2305 NULL, /* pFillRgn */
2306 NULL, /* pFlattenPath */
2307 NULL, /* pFontIsLinked */
2308 NULL, /* pFrameRgn */
2309 NULL, /* pGdiComment */
2310 NULL, /* pGdiRealizationInfo */
2311 NULL, /* pGetCharABCWidths */
2312 NULL, /* pGetCharABCWidthsI */
2313 NULL, /* pGetCharWidth */
2314 NULL, /* pGetDeviceCaps */
2315 NULL, /* pGetDeviceGammaRamp */
2316 NULL, /* pGetFontData */
2317 NULL, /* pGetFontUnicodeRanges */
2318 NULL, /* pGetGlyphIndices */
2319 NULL, /* pGetGlyphOutline */
2320 NULL, /* pGetICMProfile */
2321 NULL, /* pGetImage */
2322 NULL, /* pGetKerningPairs */
2323 NULL, /* pGetNearestColor */
2324 NULL, /* pGetOutlineTextMetrics */
2325 NULL, /* pGetPixel */
2326 NULL, /* pGetPixelFormat */
2327 NULL, /* pGetSystemPaletteEntries */
2328 NULL, /* pGetTextCharsetInfo */
2329 NULL, /* pGetTextExtentExPoint */
2330 NULL, /* pGetTextExtentExPointI */
2331 NULL, /* pGetTextFace */
2332 NULL, /* pGetTextMetrics */
2333 NULL, /* pIntersectClipRect */
2334 NULL, /* pInvertRgn */
2335 pathdrv_LineTo, /* pLineTo */
2336 NULL, /* pModifyWorldTransform */
2337 pathdrv_MoveTo, /* pMoveTo */
2338 NULL, /* pOffsetClipRgn */
2339 NULL, /* pOffsetViewportOrg */
2340 NULL, /* pOffsetWindowOrg */
2341 NULL, /* pPaintRgn */
2343 pathdrv_Pie, /* pPie */
2344 pathdrv_PolyBezier, /* pPolyBezier */
2345 pathdrv_PolyBezierTo, /* pPolyBezierTo */
2346 pathdrv_PolyDraw, /* pPolyDraw */
2347 pathdrv_PolyPolygon, /* pPolyPolygon */
2348 pathdrv_PolyPolyline, /* pPolyPolyline */
2349 pathdrv_Polygon, /* pPolygon */
2350 pathdrv_Polyline, /* pPolyline */
2351 pathdrv_PolylineTo, /* pPolylineTo */
2352 NULL, /* pPutImage */
2353 NULL, /* pRealizeDefaultPalette */
2354 NULL, /* pRealizePalette */
2355 pathdrv_Rectangle, /* pRectangle */
2356 NULL, /* pResetDC */
2357 NULL, /* pRestoreDC */
2358 pathdrv_RoundRect, /* pRoundRect */
2360 NULL, /* pScaleViewportExt */
2361 NULL, /* pScaleWindowExt */
2362 NULL, /* pSelectBitmap */
2363 NULL, /* pSelectBrush */
2364 NULL, /* pSelectClipPath */
2365 NULL, /* pSelectFont */
2366 NULL, /* pSelectPalette */
2367 NULL, /* pSelectPen */
2368 NULL, /* pSetArcDirection */
2369 NULL, /* pSetBkColor */
2370 NULL, /* pSetBkMode */
2371 NULL, /* pSetDCBrushColor */
2372 NULL, /* pSetDCPenColor */
2373 NULL, /* pSetDIBColorTable */
2374 NULL, /* pSetDIBitsToDevice */
2375 NULL, /* pSetDeviceClipping */
2376 NULL, /* pSetDeviceGammaRamp */
2377 NULL, /* pSetLayout */
2378 NULL, /* pSetMapMode */
2379 NULL, /* pSetMapperFlags */
2380 NULL, /* pSetPixel */
2381 NULL, /* pSetPixelFormat */
2382 NULL, /* pSetPolyFillMode */
2383 NULL, /* pSetROP2 */
2384 NULL, /* pSetRelAbs */
2385 NULL, /* pSetStretchBltMode */
2386 NULL, /* pSetTextAlign */
2387 NULL, /* pSetTextCharacterExtra */
2388 NULL, /* pSetTextColor */
2389 NULL, /* pSetTextJustification */
2390 NULL, /* pSetViewportExt */
2391 NULL, /* pSetViewportOrg */
2392 NULL, /* pSetWindowExt */
2393 NULL, /* pSetWindowOrg */
2394 NULL, /* pSetWorldTransform */
2395 NULL, /* pStartDoc */
2396 NULL, /* pStartPage */
2397 NULL, /* pStretchBlt */
2398 NULL, /* pStretchDIBits */
2399 NULL, /* pStrokeAndFillPath */
2400 NULL, /* pStrokePath */
2401 NULL, /* pSwapBuffers */
2402 NULL, /* pUnrealizePalette */
2403 NULL, /* pWidenPath */
2404 /* OpenGL not supported */