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 pPath->numEntriesUsed++;
233 /* add a number of points, converting them to device coords */
234 /* return a pointer to the first type byte so it can be fixed up if necessary */
235 static BYTE *add_log_points( struct path_physdev *physdev, const POINT *points, DWORD count, BYTE type )
238 GdiPath *path = physdev->path;
240 if (!PATH_ReserveEntries( path, path->numEntriesUsed + count )) return NULL;
242 ret = &path->pFlags[path->numEntriesUsed];
243 memcpy( &path->pPoints[path->numEntriesUsed], points, count * sizeof(*points) );
244 LPtoDP( physdev->dev.hdc, &path->pPoints[path->numEntriesUsed], count );
245 memset( ret, type, count );
246 path->numEntriesUsed += count;
250 /* start a new path stroke if necessary */
251 static BOOL start_new_stroke( struct path_physdev *physdev )
254 GdiPath *path = physdev->path;
256 if (!path->newStroke && path->numEntriesUsed &&
257 !(path->pFlags[path->numEntriesUsed - 1] & PT_CLOSEFIGURE))
260 path->newStroke = FALSE;
261 GetCurrentPositionEx( physdev->dev.hdc, &pos );
262 return add_log_points( physdev, &pos, 1, PT_MOVETO ) != NULL;
265 /* PATH_AssignGdiPath
267 * Copies the GdiPath structure "pPathSrc" to "pPathDest". A deep copy is
268 * performed, i.e. the contents of the pPoints and pFlags arrays are copied,
269 * not just the pointers. Since this means that the arrays in pPathDest may
270 * need to be resized, pPathDest should have been initialized using
271 * PATH_InitGdiPath (in C++, this function would be an assignment operator,
272 * not a copy constructor).
273 * Returns TRUE if successful, else FALSE.
275 static BOOL PATH_AssignGdiPath(GdiPath *pPathDest, const GdiPath *pPathSrc)
277 /* Make sure destination arrays are big enough */
278 if(!PATH_ReserveEntries(pPathDest, pPathSrc->numEntriesUsed))
281 /* Perform the copy operation */
282 memcpy(pPathDest->pPoints, pPathSrc->pPoints,
283 sizeof(POINT)*pPathSrc->numEntriesUsed);
284 memcpy(pPathDest->pFlags, pPathSrc->pFlags,
285 sizeof(BYTE)*pPathSrc->numEntriesUsed);
287 pPathDest->state=pPathSrc->state;
288 pPathDest->numEntriesUsed=pPathSrc->numEntriesUsed;
289 pPathDest->newStroke=pPathSrc->newStroke;
296 * Helper function for RoundRect() and Rectangle()
298 static void PATH_CheckCorners( HDC hdc, POINT corners[], INT x1, INT y1, INT x2, INT y2 )
302 /* Convert points to device coordinates */
307 LPtoDP( hdc, corners, 2 );
309 /* Make sure first corner is top left and second corner is bottom right */
310 if(corners[0].x>corners[1].x)
313 corners[0].x=corners[1].x;
316 if(corners[0].y>corners[1].y)
319 corners[0].y=corners[1].y;
323 /* In GM_COMPATIBLE, don't include bottom and right edges */
324 if (GetGraphicsMode( hdc ) == GM_COMPATIBLE)
331 /* PATH_AddFlatBezier
333 static BOOL PATH_AddFlatBezier(GdiPath *pPath, POINT *pt, BOOL closed)
338 pts = GDI_Bezier( pt, 4, &no );
339 if(!pts) return FALSE;
341 for(i = 1; i < no; i++)
342 PATH_AddEntry(pPath, &pts[i], (i == no-1 && closed) ? PT_LINETO | PT_CLOSEFIGURE : PT_LINETO);
343 HeapFree( GetProcessHeap(), 0, pts );
349 * Replaces Beziers with line segments
352 static BOOL PATH_FlattenPath(GdiPath *pPath)
357 memset(&newPath, 0, sizeof(newPath));
358 newPath.state = PATH_Open;
359 for(srcpt = 0; srcpt < pPath->numEntriesUsed; srcpt++) {
360 switch(pPath->pFlags[srcpt] & ~PT_CLOSEFIGURE) {
363 PATH_AddEntry(&newPath, &pPath->pPoints[srcpt],
364 pPath->pFlags[srcpt]);
367 PATH_AddFlatBezier(&newPath, &pPath->pPoints[srcpt-1],
368 pPath->pFlags[srcpt+2] & PT_CLOSEFIGURE);
373 newPath.state = PATH_Closed;
374 PATH_AssignGdiPath(pPath, &newPath);
375 PATH_DestroyGdiPath(&newPath);
381 * Creates a region from the specified path using the specified polygon
382 * filling mode. The path is left unchanged. A handle to the region that
383 * was created is stored in *pHrgn. If successful, TRUE is returned; if an
384 * error occurs, SetLastError is called with the appropriate value and
387 static BOOL PATH_PathToRegion(GdiPath *pPath, INT nPolyFillMode,
390 int numStrokes, iStroke, i;
391 INT *pNumPointsInStroke;
394 PATH_FlattenPath(pPath);
396 /* FIXME: What happens when number of points is zero? */
398 /* First pass: Find out how many strokes there are in the path */
399 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
401 for(i=0; i<pPath->numEntriesUsed; i++)
402 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
405 /* Allocate memory for number-of-points-in-stroke array */
406 pNumPointsInStroke=HeapAlloc( GetProcessHeap(), 0, sizeof(int) * numStrokes );
407 if(!pNumPointsInStroke)
409 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
413 /* Second pass: remember number of points in each polygon */
414 iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
415 for(i=0; i<pPath->numEntriesUsed; i++)
417 /* Is this the beginning of a new stroke? */
418 if((pPath->pFlags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
421 pNumPointsInStroke[iStroke]=0;
424 pNumPointsInStroke[iStroke]++;
427 /* Create a region from the strokes */
428 hrgn=CreatePolyPolygonRgn(pPath->pPoints, pNumPointsInStroke,
429 numStrokes, nPolyFillMode);
431 /* Free memory for number-of-points-in-stroke array */
432 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
436 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
445 /* PATH_ScaleNormalizedPoint
447 * Scales a normalized point (x, y) with respect to the box whose corners are
448 * passed in "corners". The point is stored in "*pPoint". The normalized
449 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
450 * (1.0, 1.0) correspond to corners[1].
452 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
453 double y, POINT *pPoint)
455 pPoint->x=GDI_ROUND( (double)corners[0].x + (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
456 pPoint->y=GDI_ROUND( (double)corners[0].y + (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
459 /* PATH_NormalizePoint
461 * Normalizes a point with respect to the box whose corners are passed in
462 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
464 static void PATH_NormalizePoint(FLOAT_POINT corners[],
465 const FLOAT_POINT *pPoint,
466 double *pX, double *pY)
468 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) * 2.0 - 1.0;
469 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) * 2.0 - 1.0;
474 * Creates a Bezier spline that corresponds to part of an arc and appends the
475 * corresponding points to the path. The start and end angles are passed in
476 * "angleStart" and "angleEnd"; these angles should span a quarter circle
477 * at most. If "startEntryType" is non-zero, an entry of that type for the first
478 * control point is added to the path; otherwise, it is assumed that the current
479 * position is equal to the first control point.
481 static BOOL PATH_DoArcPart(GdiPath *pPath, FLOAT_POINT corners[],
482 double angleStart, double angleEnd, BYTE startEntryType)
485 double xNorm[4], yNorm[4];
489 assert(fabs(angleEnd-angleStart)<=M_PI_2);
491 /* FIXME: Is there an easier way of computing this? */
493 /* Compute control points */
494 halfAngle=(angleEnd-angleStart)/2.0;
495 if(fabs(halfAngle)>1e-8)
497 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
498 xNorm[0]=cos(angleStart);
499 yNorm[0]=sin(angleStart);
500 xNorm[1]=xNorm[0] - a*yNorm[0];
501 yNorm[1]=yNorm[0] + a*xNorm[0];
502 xNorm[3]=cos(angleEnd);
503 yNorm[3]=sin(angleEnd);
504 xNorm[2]=xNorm[3] + a*yNorm[3];
505 yNorm[2]=yNorm[3] - a*xNorm[3];
510 xNorm[i]=cos(angleStart);
511 yNorm[i]=sin(angleStart);
514 /* Add starting point to path if desired */
517 PATH_ScaleNormalizedPoint(corners, xNorm[0], yNorm[0], &point);
518 if(!PATH_AddEntry(pPath, &point, startEntryType))
522 /* Add remaining control points */
525 PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &point);
526 if(!PATH_AddEntry(pPath, &point, PT_BEZIERTO))
534 /***********************************************************************
535 * BeginPath (GDI32.@)
537 BOOL WINAPI BeginPath(HDC hdc)
540 DC *dc = get_dc_ptr( hdc );
544 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pBeginPath );
545 ret = physdev->funcs->pBeginPath( physdev );
546 release_dc_ptr( dc );
552 /***********************************************************************
555 BOOL WINAPI EndPath(HDC hdc)
558 DC *dc = get_dc_ptr( hdc );
562 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEndPath );
563 ret = physdev->funcs->pEndPath( physdev );
564 release_dc_ptr( dc );
570 /******************************************************************************
571 * AbortPath [GDI32.@]
572 * Closes and discards paths from device context
575 * Check that SetLastError is being called correctly
578 * hdc [I] Handle to device context
584 BOOL WINAPI AbortPath( HDC hdc )
587 DC *dc = get_dc_ptr( hdc );
591 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pAbortPath );
592 ret = physdev->funcs->pAbortPath( physdev );
593 release_dc_ptr( dc );
599 /***********************************************************************
600 * CloseFigure (GDI32.@)
602 * FIXME: Check that SetLastError is being called correctly
604 BOOL WINAPI CloseFigure(HDC hdc)
607 DC *dc = get_dc_ptr( hdc );
611 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pCloseFigure );
612 ret = physdev->funcs->pCloseFigure( physdev );
613 release_dc_ptr( dc );
619 /***********************************************************************
622 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes,
627 DC *dc = get_dc_ptr( hdc );
633 /* Check that path is closed */
634 if(pPath->state!=PATH_Closed)
636 SetLastError(ERROR_CAN_NOT_COMPLETE);
641 ret = pPath->numEntriesUsed;
642 else if(nSize<pPath->numEntriesUsed)
644 SetLastError(ERROR_INVALID_PARAMETER);
649 memcpy(pPoints, pPath->pPoints, sizeof(POINT)*pPath->numEntriesUsed);
650 memcpy(pTypes, pPath->pFlags, sizeof(BYTE)*pPath->numEntriesUsed);
652 /* Convert the points to logical coordinates */
653 if(!DPtoLP(hdc, pPoints, pPath->numEntriesUsed))
655 /* FIXME: Is this the correct value? */
656 SetLastError(ERROR_CAN_NOT_COMPLETE);
659 else ret = pPath->numEntriesUsed;
662 release_dc_ptr( dc );
667 /***********************************************************************
668 * PathToRegion (GDI32.@)
671 * Check that SetLastError is being called correctly
673 * The documentation does not state this explicitly, but a test under Windows
674 * shows that the region which is returned should be in device coordinates.
676 HRGN WINAPI PathToRegion(HDC hdc)
680 DC *dc = get_dc_ptr( hdc );
682 /* Get pointer to path */
687 /* Check that path is closed */
688 if(pPath->state!=PATH_Closed) SetLastError(ERROR_CAN_NOT_COMPLETE);
691 /* FIXME: Should we empty the path even if conversion failed? */
692 if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgnRval))
693 PATH_EmptyPath(pPath);
697 release_dc_ptr( dc );
701 static BOOL PATH_FillPath( HDC hdc, GdiPath *pPath )
703 INT mapMode, graphicsMode;
704 SIZE ptViewportExt, ptWindowExt;
705 POINT ptViewportOrg, ptWindowOrg;
709 /* Construct a region from the path and fill it */
710 if(PATH_PathToRegion(pPath, GetPolyFillMode(hdc), &hrgn))
712 /* Since PaintRgn interprets the region as being in logical coordinates
713 * but the points we store for the path are already in device
714 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
715 * Using SaveDC to save information about the mapping mode / world
716 * transform would be easier but would require more overhead, especially
717 * now that SaveDC saves the current path.
720 /* Save the information about the old mapping mode */
721 mapMode=GetMapMode(hdc);
722 GetViewportExtEx(hdc, &ptViewportExt);
723 GetViewportOrgEx(hdc, &ptViewportOrg);
724 GetWindowExtEx(hdc, &ptWindowExt);
725 GetWindowOrgEx(hdc, &ptWindowOrg);
727 /* Save world transform
728 * NB: The Windows documentation on world transforms would lead one to
729 * believe that this has to be done only in GM_ADVANCED; however, my
730 * tests show that resetting the graphics mode to GM_COMPATIBLE does
731 * not reset the world transform.
733 GetWorldTransform(hdc, &xform);
736 SetMapMode(hdc, MM_TEXT);
737 SetViewportOrgEx(hdc, 0, 0, NULL);
738 SetWindowOrgEx(hdc, 0, 0, NULL);
739 graphicsMode=GetGraphicsMode(hdc);
740 SetGraphicsMode(hdc, GM_ADVANCED);
741 ModifyWorldTransform(hdc, &xform, MWT_IDENTITY);
742 SetGraphicsMode(hdc, graphicsMode);
744 /* Paint the region */
747 /* Restore the old mapping mode */
748 SetMapMode(hdc, mapMode);
749 SetViewportExtEx(hdc, ptViewportExt.cx, ptViewportExt.cy, NULL);
750 SetViewportOrgEx(hdc, ptViewportOrg.x, ptViewportOrg.y, NULL);
751 SetWindowExtEx(hdc, ptWindowExt.cx, ptWindowExt.cy, NULL);
752 SetWindowOrgEx(hdc, ptWindowOrg.x, ptWindowOrg.y, NULL);
754 /* Go to GM_ADVANCED temporarily to restore the world transform */
755 graphicsMode=GetGraphicsMode(hdc);
756 SetGraphicsMode(hdc, GM_ADVANCED);
757 SetWorldTransform(hdc, &xform);
758 SetGraphicsMode(hdc, graphicsMode);
765 /***********************************************************************
769 * Check that SetLastError is being called correctly
771 BOOL WINAPI FillPath(HDC hdc)
774 DC *dc = get_dc_ptr( hdc );
778 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFillPath );
779 ret = physdev->funcs->pFillPath( physdev );
780 release_dc_ptr( dc );
786 /***********************************************************************
787 * SelectClipPath (GDI32.@)
789 * Check that SetLastError is being called correctly
791 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
794 DC *dc = get_dc_ptr( hdc );
798 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectClipPath );
799 ret = physdev->funcs->pSelectClipPath( physdev, iMode );
800 release_dc_ptr( dc );
806 /***********************************************************************
809 static BOOL pathdrv_BeginPath( PHYSDEV dev )
811 /* path already open, nothing to do */
816 /***********************************************************************
819 static BOOL pathdrv_AbortPath( PHYSDEV dev )
821 DC *dc = get_dc_ptr( dev->hdc );
823 if (!dc) return FALSE;
824 PATH_EmptyPath( &dc->path );
825 pop_path_driver( dc );
826 release_dc_ptr( dc );
831 /***********************************************************************
834 static BOOL pathdrv_EndPath( PHYSDEV dev )
836 DC *dc = get_dc_ptr( dev->hdc );
838 if (!dc) return FALSE;
839 dc->path.state = PATH_Closed;
840 pop_path_driver( dc );
841 release_dc_ptr( dc );
846 /***********************************************************************
849 static BOOL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
850 LPCWSTR output, const DEVMODEW *devmode )
852 struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) );
855 if (!physdev) return FALSE;
856 dc = get_dc_ptr( (*dev)->hdc );
857 physdev->path = &dc->path;
858 push_dc_driver( dev, &physdev->dev, &path_driver );
859 release_dc_ptr( dc );
864 /*************************************************************
867 static BOOL pathdrv_DeleteDC( PHYSDEV dev )
869 assert( 0 ); /* should never be called */
876 * Initializes the GdiPath structure.
878 void PATH_InitGdiPath(GdiPath *pPath)
882 pPath->state=PATH_Null;
885 pPath->numEntriesUsed=0;
886 pPath->numEntriesAllocated=0;
889 /* PATH_DestroyGdiPath
891 * Destroys a GdiPath structure (frees the memory in the arrays).
893 void PATH_DestroyGdiPath(GdiPath *pPath)
897 HeapFree( GetProcessHeap(), 0, pPath->pPoints );
898 HeapFree( GetProcessHeap(), 0, pPath->pFlags );
901 BOOL PATH_SavePath( DC *dst, DC *src )
903 PATH_InitGdiPath( &dst->path );
904 return PATH_AssignGdiPath( &dst->path, &src->path );
907 BOOL PATH_RestorePath( DC *dst, DC *src )
911 if (src->path.state == PATH_Open && dst->path.state != PATH_Open)
913 if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
914 ret = PATH_AssignGdiPath( &dst->path, &src->path );
915 if (!ret) pop_path_driver( dst );
917 else if (src->path.state != PATH_Open && dst->path.state == PATH_Open)
919 ret = PATH_AssignGdiPath( &dst->path, &src->path );
920 if (ret) pop_path_driver( dst );
922 else ret = PATH_AssignGdiPath( &dst->path, &src->path );
927 /*************************************************************
930 static BOOL pathdrv_MoveTo( PHYSDEV dev, INT x, INT y )
932 struct path_physdev *physdev = get_path_physdev( dev );
933 physdev->path->newStroke = TRUE;
938 /*************************************************************
941 static BOOL pathdrv_LineTo( PHYSDEV dev, INT x, INT y )
943 struct path_physdev *physdev = get_path_physdev( dev );
946 if (!start_new_stroke( physdev )) return FALSE;
949 return add_log_points( physdev, &point, 1, PT_LINETO ) != NULL;
953 /*************************************************************
956 * FIXME: it adds the same entries to the path as windows does, but there
957 * is an error in the bezier drawing code so that there are small pixel-size
958 * gaps when the resulting path is drawn by StrokePath()
960 static BOOL pathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height )
962 struct path_physdev *physdev = get_path_physdev( dev );
963 POINT corners[2], pointTemp;
964 FLOAT_POINT ellCorners[2];
966 PATH_CheckCorners(dev->hdc,corners,x1,y1,x2,y2);
968 /* Add points to the roundrect path */
969 ellCorners[0].x = corners[1].x-ell_width;
970 ellCorners[0].y = corners[0].y;
971 ellCorners[1].x = corners[1].x;
972 ellCorners[1].y = corners[0].y+ell_height;
973 if(!PATH_DoArcPart(physdev->path, ellCorners, 0, -M_PI_2, PT_MOVETO))
975 pointTemp.x = corners[0].x+ell_width/2;
976 pointTemp.y = corners[0].y;
977 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
979 ellCorners[0].x = corners[0].x;
980 ellCorners[1].x = corners[0].x+ell_width;
981 if(!PATH_DoArcPart(physdev->path, ellCorners, -M_PI_2, -M_PI, FALSE))
983 pointTemp.x = corners[0].x;
984 pointTemp.y = corners[1].y-ell_height/2;
985 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
987 ellCorners[0].y = corners[1].y-ell_height;
988 ellCorners[1].y = corners[1].y;
989 if(!PATH_DoArcPart(physdev->path, ellCorners, M_PI, M_PI_2, FALSE))
991 pointTemp.x = corners[1].x-ell_width/2;
992 pointTemp.y = corners[1].y;
993 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
995 ellCorners[0].x = corners[1].x-ell_width;
996 ellCorners[1].x = corners[1].x;
997 if(!PATH_DoArcPart(physdev->path, ellCorners, M_PI_2, 0, FALSE))
1000 /* Close the roundrect figure */
1001 return CloseFigure( dev->hdc );
1005 /*************************************************************
1008 static BOOL pathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
1010 struct path_physdev *physdev = get_path_physdev( dev );
1011 POINT corners[2], pointTemp;
1013 PATH_CheckCorners(dev->hdc,corners,x1,y1,x2,y2);
1015 /* Add four points to the path */
1016 pointTemp.x=corners[1].x;
1017 pointTemp.y=corners[0].y;
1018 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_MOVETO))
1020 if(!PATH_AddEntry(physdev->path, corners, PT_LINETO))
1022 pointTemp.x=corners[0].x;
1023 pointTemp.y=corners[1].y;
1024 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
1026 if(!PATH_AddEntry(physdev->path, corners+1, PT_LINETO))
1029 /* Close the rectangle figure */
1030 return CloseFigure( dev->hdc );
1036 * Should be called when a call to Arc is performed on a DC that has
1037 * an open path. This adds up to five Bezier splines representing the arc
1038 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
1039 * when 'lines' is 2, we add 2 extra lines to get a pie, and when 'lines' is
1040 * -1 we add 1 extra line from the current DC position to the starting position
1041 * of the arc before drawing the arc itself (arcto). Returns TRUE if successful,
1044 static BOOL PATH_Arc( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2,
1045 INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines )
1047 struct path_physdev *physdev = get_path_physdev( dev );
1048 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
1049 /* Initialize angleEndQuadrant to silence gcc's warning */
1051 FLOAT_POINT corners[2], pointStart, pointEnd;
1054 INT temp, direction = GetArcDirection(dev->hdc);
1056 /* FIXME: Do we have to respect newStroke? */
1058 /* Check for zero height / width */
1059 /* FIXME: Only in GM_COMPATIBLE? */
1060 if(x1==x2 || y1==y2)
1063 /* Convert points to device coordinates */
1068 pointStart.x = xStart;
1069 pointStart.y = yStart;
1072 INTERNAL_LPTODP_FLOAT(dev->hdc, corners, 2);
1073 INTERNAL_LPTODP_FLOAT(dev->hdc, &pointStart, 1);
1074 INTERNAL_LPTODP_FLOAT(dev->hdc, &pointEnd, 1);
1076 /* Make sure first corner is top left and second corner is bottom right */
1077 if(corners[0].x>corners[1].x)
1080 corners[0].x=corners[1].x;
1083 if(corners[0].y>corners[1].y)
1086 corners[0].y=corners[1].y;
1090 /* Compute start and end angle */
1091 PATH_NormalizePoint(corners, &pointStart, &x, &y);
1092 angleStart=atan2(y, x);
1093 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
1094 angleEnd=atan2(y, x);
1096 /* Make sure the end angle is "on the right side" of the start angle */
1097 if (direction == AD_CLOCKWISE)
1099 if(angleEnd<=angleStart)
1102 assert(angleEnd>=angleStart);
1107 if(angleEnd>=angleStart)
1110 assert(angleEnd<=angleStart);
1114 /* In GM_COMPATIBLE, don't include bottom and right edges */
1115 if (GetGraphicsMode(dev->hdc) == GM_COMPATIBLE)
1121 /* arcto: Add a PT_MOVETO only if this is the first entry in a stroke */
1122 if (lines==-1 && !start_new_stroke( physdev )) return FALSE;
1124 /* Add the arc to the path with one Bezier spline per quadrant that the
1130 /* Determine the start and end angles for this quadrant */
1133 angleStartQuadrant=angleStart;
1134 if (direction == AD_CLOCKWISE)
1135 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
1137 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
1141 angleStartQuadrant=angleEndQuadrant;
1142 if (direction == AD_CLOCKWISE)
1143 angleEndQuadrant+=M_PI_2;
1145 angleEndQuadrant-=M_PI_2;
1148 /* Have we reached the last part of the arc? */
1149 if((direction == AD_CLOCKWISE && angleEnd<angleEndQuadrant) ||
1150 (direction == AD_COUNTERCLOCKWISE && angleEnd>angleEndQuadrant))
1152 /* Adjust the end angle for this quadrant */
1153 angleEndQuadrant=angleEnd;
1157 /* Add the Bezier spline to the path */
1158 PATH_DoArcPart(physdev->path, corners, angleStartQuadrant, angleEndQuadrant,
1159 start ? (lines==-1 ? PT_LINETO : PT_MOVETO) : FALSE);
1163 /* chord: close figure. pie: add line and close figure */
1166 return CloseFigure(dev->hdc);
1170 centre.x = (corners[0].x+corners[1].x)/2;
1171 centre.y = (corners[0].y+corners[1].y)/2;
1172 if(!PATH_AddEntry(physdev->path, ¢re, PT_LINETO | PT_CLOSEFIGURE))
1180 /*************************************************************
1183 static BOOL pathdrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT eStartAngle, FLOAT eSweepAngle)
1185 INT x1, y1, x2, y2, arcdir;
1188 x1 = GDI_ROUND( x + cos(eStartAngle*M_PI/180) * radius );
1189 y1 = GDI_ROUND( y - sin(eStartAngle*M_PI/180) * radius );
1190 x2 = GDI_ROUND( x + cos((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1191 y2 = GDI_ROUND( y - sin((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1192 arcdir = SetArcDirection( dev->hdc, eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE);
1193 ret = PATH_Arc( dev, x-radius, y-radius, x+radius, y+radius, x1, y1, x2, y2, -1 );
1194 SetArcDirection( dev->hdc, arcdir );
1199 /*************************************************************
1202 static BOOL pathdrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1203 INT xstart, INT ystart, INT xend, INT yend )
1205 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 0 );
1209 /*************************************************************
1212 static BOOL pathdrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1213 INT xstart, INT ystart, INT xend, INT yend )
1215 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, -1 );
1219 /*************************************************************
1222 static BOOL pathdrv_Chord( 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, 1);
1229 /*************************************************************
1232 static BOOL pathdrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1233 INT xstart, INT ystart, INT xend, INT yend )
1235 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 2 );
1239 /*************************************************************
1242 static BOOL pathdrv_Ellipse( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
1244 return PATH_Arc( dev, x1, y1, x2, y2, x1, (y1+y2)/2, x1, (y1+y2)/2, 0 ) && CloseFigure( dev->hdc );
1248 /*************************************************************
1249 * pathdrv_PolyBezierTo
1251 static BOOL pathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1253 struct path_physdev *physdev = get_path_physdev( dev );
1255 if (!start_new_stroke( physdev )) return FALSE;
1256 return add_log_points( physdev, pts, cbPoints, PT_BEZIERTO ) != NULL;
1260 /*************************************************************
1261 * pathdrv_PolyBezier
1263 static BOOL pathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1265 struct path_physdev *physdev = get_path_physdev( dev );
1266 BYTE *type = add_log_points( physdev, pts, cbPoints, PT_BEZIERTO );
1268 if (!type) return FALSE;
1269 type[0] = PT_MOVETO;
1274 /*************************************************************
1277 static BOOL pathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD cbPoints )
1279 struct path_physdev *physdev = get_path_physdev( dev );
1280 POINT lastmove, orig_pos;
1283 GetCurrentPositionEx( dev->hdc, &orig_pos );
1284 lastmove = orig_pos;
1286 for(i = physdev->path->numEntriesUsed - 1; i >= 0; i--){
1287 if(physdev->path->pFlags[i] == PT_MOVETO){
1288 lastmove = physdev->path->pPoints[i];
1289 DPtoLP(dev->hdc, &lastmove, 1);
1294 for(i = 0; i < cbPoints; i++)
1299 MoveToEx( dev->hdc, pts[i].x, pts[i].y, NULL );
1302 case PT_LINETO | PT_CLOSEFIGURE:
1303 LineTo( dev->hdc, pts[i].x, pts[i].y );
1306 if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
1307 (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
1309 PolyBezierTo( dev->hdc, &pts[i], 3 );
1315 if (i) /* restore original position */
1317 if (!(types[i - 1] & PT_CLOSEFIGURE)) lastmove = pts[i - 1];
1318 if (lastmove.x != orig_pos.x || lastmove.y != orig_pos.y)
1319 MoveToEx( dev->hdc, orig_pos.x, orig_pos.y, NULL );
1324 if(types[i] & PT_CLOSEFIGURE){
1325 physdev->path->pFlags[physdev->path->numEntriesUsed-1] |= PT_CLOSEFIGURE;
1326 MoveToEx( dev->hdc, lastmove.x, lastmove.y, NULL );
1334 /*************************************************************
1337 static BOOL pathdrv_Polyline( PHYSDEV dev, const POINT *pts, INT cbPoints )
1339 struct path_physdev *physdev = get_path_physdev( dev );
1340 BYTE *type = add_log_points( physdev, pts, cbPoints, PT_LINETO );
1342 if (!type) return FALSE;
1343 if (cbPoints) type[0] = PT_MOVETO;
1348 /*************************************************************
1349 * pathdrv_PolylineTo
1351 static BOOL pathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT cbPoints )
1353 struct path_physdev *physdev = get_path_physdev( dev );
1355 if (!start_new_stroke( physdev )) return FALSE;
1356 return add_log_points( physdev, pts, cbPoints, PT_LINETO ) != NULL;
1360 /*************************************************************
1363 static BOOL pathdrv_Polygon( PHYSDEV dev, const POINT *pts, INT cbPoints )
1365 struct path_physdev *physdev = get_path_physdev( dev );
1366 BYTE *type = add_log_points( physdev, pts, cbPoints, PT_LINETO );
1368 if (!type) return FALSE;
1369 if (cbPoints) type[0] = PT_MOVETO;
1370 if (cbPoints > 1) type[cbPoints - 1] = PT_LINETO | PT_CLOSEFIGURE;
1375 /*************************************************************
1376 * pathdrv_PolyPolygon
1378 static BOOL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
1380 struct path_physdev *physdev = get_path_physdev( dev );
1384 for(poly = 0; poly < polygons; poly++) {
1385 type = add_log_points( physdev, pts, counts[poly], PT_LINETO );
1386 if (!type) return FALSE;
1387 type[0] = PT_MOVETO;
1388 /* win98 adds an extra line to close the figure for some reason */
1389 add_log_points( physdev, pts, 1, PT_LINETO | PT_CLOSEFIGURE );
1390 pts += counts[poly];
1396 /*************************************************************
1397 * pathdrv_PolyPolyline
1399 static BOOL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
1401 struct path_physdev *physdev = get_path_physdev( dev );
1405 for (poly = count = 0; poly < polylines; poly++) count += counts[poly];
1407 type = add_log_points( physdev, pts, count, PT_LINETO );
1408 if (!type) return FALSE;
1410 /* make the first point of each polyline a PT_MOVETO */
1411 for (poly = 0; poly < polylines; poly++, type += counts[poly]) *type = PT_MOVETO;
1416 /**********************************************************************
1419 * internally used by PATH_add_outline
1421 static void PATH_BezierTo(GdiPath *pPath, POINT *lppt, INT n)
1427 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1431 PATH_AddEntry(pPath, &lppt[0], PT_BEZIERTO);
1432 PATH_AddEntry(pPath, &lppt[1], PT_BEZIERTO);
1433 PATH_AddEntry(pPath, &lppt[2], PT_BEZIERTO);
1447 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1448 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1449 PATH_BezierTo(pPath, pt, 3);
1457 PATH_BezierTo(pPath, pt, 3);
1461 static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y,
1462 TTPOLYGONHEADER *header, DWORD size)
1464 TTPOLYGONHEADER *start;
1469 while ((char *)header < (char *)start + size)
1473 if (header->dwType != TT_POLYGON_TYPE)
1475 FIXME("Unknown header type %d\n", header->dwType);
1479 pt.x = x + int_from_fixed(header->pfxStart.x);
1480 pt.y = y - int_from_fixed(header->pfxStart.y);
1481 PATH_AddEntry(physdev->path, &pt, PT_MOVETO);
1483 curve = (TTPOLYCURVE *)(header + 1);
1485 while ((char *)curve < (char *)header + header->cb)
1487 /*TRACE("curve->wType %d\n", curve->wType);*/
1489 switch(curve->wType)
1495 for (i = 0; i < curve->cpfx; i++)
1497 pt.x = x + int_from_fixed(curve->apfx[i].x);
1498 pt.y = y - int_from_fixed(curve->apfx[i].y);
1499 PATH_AddEntry(physdev->path, &pt, PT_LINETO);
1504 case TT_PRIM_QSPLINE:
1505 case TT_PRIM_CSPLINE:
1509 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1511 if (!pts) return FALSE;
1513 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1515 pts[0].x = x + int_from_fixed(ptfx.x);
1516 pts[0].y = y - int_from_fixed(ptfx.y);
1518 for(i = 0; i < curve->cpfx; i++)
1520 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1521 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1524 PATH_BezierTo(physdev->path, pts, curve->cpfx + 1);
1526 HeapFree(GetProcessHeap(), 0, pts);
1531 FIXME("Unknown curve type %04x\n", curve->wType);
1535 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1538 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1541 return CloseFigure(physdev->dev.hdc);
1544 /*************************************************************
1545 * pathdrv_ExtTextOut
1547 static BOOL pathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprc,
1548 LPCWSTR str, UINT count, const INT *dx )
1550 struct path_physdev *physdev = get_path_physdev( dev );
1552 POINT offset = {0, 0};
1554 if (!count) return TRUE;
1556 for (idx = 0; idx < count; idx++)
1558 static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
1563 dwSize = GetGlyphOutlineW(dev->hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE,
1564 &gm, 0, NULL, &identity);
1565 if (dwSize == GDI_ERROR) return FALSE;
1567 /* add outline only if char is printable */
1570 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1571 if (!outline) return FALSE;
1573 GetGlyphOutlineW(dev->hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE,
1574 &gm, dwSize, outline, &identity);
1576 PATH_add_outline(physdev, x + offset.x, y + offset.y, outline, dwSize);
1578 HeapFree(GetProcessHeap(), 0, outline);
1585 offset.x += dx[idx * 2];
1586 offset.y += dx[idx * 2 + 1];
1589 offset.x += dx[idx];
1593 offset.x += gm.gmCellIncX;
1594 offset.y += gm.gmCellIncY;
1601 /*************************************************************
1602 * pathdrv_CloseFigure
1604 static BOOL pathdrv_CloseFigure( PHYSDEV dev )
1606 struct path_physdev *physdev = get_path_physdev( dev );
1608 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
1609 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
1610 if (physdev->path->numEntriesUsed)
1611 physdev->path->pFlags[physdev->path->numEntriesUsed - 1] |= PT_CLOSEFIGURE;
1616 /*******************************************************************
1617 * FlattenPath [GDI32.@]
1621 BOOL WINAPI FlattenPath(HDC hdc)
1624 DC *dc = get_dc_ptr( hdc );
1628 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath );
1629 ret = physdev->funcs->pFlattenPath( physdev );
1630 release_dc_ptr( dc );
1636 static BOOL PATH_StrokePath( HDC hdc, GdiPath *pPath )
1638 INT i, nLinePts, nAlloc;
1640 POINT ptViewportOrg, ptWindowOrg;
1641 SIZE szViewportExt, szWindowExt;
1642 DWORD mapMode, graphicsMode;
1646 /* Save the mapping mode info */
1647 mapMode=GetMapMode(hdc);
1648 GetViewportExtEx(hdc, &szViewportExt);
1649 GetViewportOrgEx(hdc, &ptViewportOrg);
1650 GetWindowExtEx(hdc, &szWindowExt);
1651 GetWindowOrgEx(hdc, &ptWindowOrg);
1652 GetWorldTransform(hdc, &xform);
1655 SetMapMode(hdc, MM_TEXT);
1656 SetViewportOrgEx(hdc, 0, 0, NULL);
1657 SetWindowOrgEx(hdc, 0, 0, NULL);
1658 graphicsMode=GetGraphicsMode(hdc);
1659 SetGraphicsMode(hdc, GM_ADVANCED);
1660 ModifyWorldTransform(hdc, &xform, MWT_IDENTITY);
1661 SetGraphicsMode(hdc, graphicsMode);
1663 /* Allocate enough memory for the worst case without beziers (one PT_MOVETO
1664 * and the rest PT_LINETO with PT_CLOSEFIGURE at the end) plus some buffer
1665 * space in case we get one to keep the number of reallocations small. */
1666 nAlloc = pPath->numEntriesUsed + 1 + 300;
1667 pLinePts = HeapAlloc(GetProcessHeap(), 0, nAlloc * sizeof(POINT));
1670 for(i = 0; i < pPath->numEntriesUsed; i++) {
1671 if((i == 0 || (pPath->pFlags[i-1] & PT_CLOSEFIGURE)) &&
1672 (pPath->pFlags[i] != PT_MOVETO)) {
1673 ERR("Expected PT_MOVETO %s, got path flag %d\n",
1674 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1675 (INT)pPath->pFlags[i]);
1679 switch(pPath->pFlags[i]) {
1681 TRACE("Got PT_MOVETO (%d, %d)\n",
1682 pPath->pPoints[i].x, pPath->pPoints[i].y);
1684 Polyline(hdc, pLinePts, nLinePts);
1686 pLinePts[nLinePts++] = pPath->pPoints[i];
1689 case (PT_LINETO | PT_CLOSEFIGURE):
1690 TRACE("Got PT_LINETO (%d, %d)\n",
1691 pPath->pPoints[i].x, pPath->pPoints[i].y);
1692 pLinePts[nLinePts++] = pPath->pPoints[i];
1695 TRACE("Got PT_BEZIERTO\n");
1696 if(pPath->pFlags[i+1] != PT_BEZIERTO ||
1697 (pPath->pFlags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
1698 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
1702 INT nBzrPts, nMinAlloc;
1703 POINT *pBzrPts = GDI_Bezier(&pPath->pPoints[i-1], 4, &nBzrPts);
1704 /* Make sure we have allocated enough memory for the lines of
1705 * this bezier and the rest of the path, assuming we won't get
1706 * another one (since we won't reallocate again then). */
1707 nMinAlloc = nLinePts + (pPath->numEntriesUsed - i) + nBzrPts;
1708 if(nAlloc < nMinAlloc)
1710 nAlloc = nMinAlloc * 2;
1711 pLinePts = HeapReAlloc(GetProcessHeap(), 0, pLinePts,
1712 nAlloc * sizeof(POINT));
1714 memcpy(&pLinePts[nLinePts], &pBzrPts[1],
1715 (nBzrPts - 1) * sizeof(POINT));
1716 nLinePts += nBzrPts - 1;
1717 HeapFree(GetProcessHeap(), 0, pBzrPts);
1722 ERR("Got path flag %d\n", (INT)pPath->pFlags[i]);
1726 if(pPath->pFlags[i] & PT_CLOSEFIGURE)
1727 pLinePts[nLinePts++] = pLinePts[0];
1730 Polyline(hdc, pLinePts, nLinePts);
1733 HeapFree(GetProcessHeap(), 0, pLinePts);
1735 /* Restore the old mapping mode */
1736 SetMapMode(hdc, mapMode);
1737 SetWindowExtEx(hdc, szWindowExt.cx, szWindowExt.cy, NULL);
1738 SetWindowOrgEx(hdc, ptWindowOrg.x, ptWindowOrg.y, NULL);
1739 SetViewportExtEx(hdc, szViewportExt.cx, szViewportExt.cy, NULL);
1740 SetViewportOrgEx(hdc, ptViewportOrg.x, ptViewportOrg.y, NULL);
1742 /* Go to GM_ADVANCED temporarily to restore the world transform */
1743 graphicsMode=GetGraphicsMode(hdc);
1744 SetGraphicsMode(hdc, GM_ADVANCED);
1745 SetWorldTransform(hdc, &xform);
1746 SetGraphicsMode(hdc, graphicsMode);
1748 /* If we've moved the current point then get its new position
1749 which will be in device (MM_TEXT) co-ords, convert it to
1750 logical co-ords and re-set it. This basically updates
1751 dc->CurPosX|Y so that their values are in the correct mapping
1756 GetCurrentPositionEx(hdc, &pt);
1757 DPtoLP(hdc, &pt, 1);
1758 MoveToEx(hdc, pt.x, pt.y, NULL);
1764 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1766 static BOOL PATH_WidenPath(DC *dc)
1768 INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
1770 GdiPath *pPath, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
1772 DWORD obj_type, joint, endcap, penType;
1776 PATH_FlattenPath(pPath);
1778 size = GetObjectW( dc->hPen, 0, NULL );
1780 SetLastError(ERROR_CAN_NOT_COMPLETE);
1784 elp = HeapAlloc( GetProcessHeap(), 0, size );
1785 GetObjectW( dc->hPen, size, elp );
1787 obj_type = GetObjectType(dc->hPen);
1788 if(obj_type == OBJ_PEN) {
1789 penStyle = ((LOGPEN*)elp)->lopnStyle;
1791 else if(obj_type == OBJ_EXTPEN) {
1792 penStyle = elp->elpPenStyle;
1795 SetLastError(ERROR_CAN_NOT_COMPLETE);
1796 HeapFree( GetProcessHeap(), 0, elp );
1800 penWidth = elp->elpWidth;
1801 HeapFree( GetProcessHeap(), 0, elp );
1803 endcap = (PS_ENDCAP_MASK & penStyle);
1804 joint = (PS_JOIN_MASK & penStyle);
1805 penType = (PS_TYPE_MASK & penStyle);
1807 /* The function cannot apply to cosmetic pens */
1808 if(obj_type == OBJ_EXTPEN && penType == PS_COSMETIC) {
1809 SetLastError(ERROR_CAN_NOT_COMPLETE);
1813 penWidthIn = penWidth / 2;
1814 penWidthOut = penWidth / 2;
1815 if(penWidthIn + penWidthOut < penWidth)
1820 for(i = 0, j = 0; i < pPath->numEntriesUsed; i++, j++) {
1822 if((i == 0 || (pPath->pFlags[i-1] & PT_CLOSEFIGURE)) &&
1823 (pPath->pFlags[i] != PT_MOVETO)) {
1824 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1825 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1829 switch(pPath->pFlags[i]) {
1831 if(numStrokes > 0) {
1832 pStrokes[numStrokes - 1]->state = PATH_Closed;
1837 pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath*));
1839 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(GdiPath*));
1840 if(!pStrokes) return FALSE;
1841 pStrokes[numStrokes - 1] = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1842 PATH_InitGdiPath(pStrokes[numStrokes - 1]);
1843 pStrokes[numStrokes - 1]->state = PATH_Open;
1846 case (PT_LINETO | PT_CLOSEFIGURE):
1847 point.x = pPath->pPoints[i].x;
1848 point.y = pPath->pPoints[i].y;
1849 PATH_AddEntry(pStrokes[numStrokes - 1], &point, pPath->pFlags[i]);
1852 /* should never happen because of the FlattenPath call */
1853 ERR("Should never happen\n");
1856 ERR("Got path flag %c\n", pPath->pFlags[i]);
1861 pNewPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1862 PATH_InitGdiPath(pNewPath);
1863 pNewPath->state = PATH_Open;
1865 for(i = 0; i < numStrokes; i++) {
1866 pUpPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1867 PATH_InitGdiPath(pUpPath);
1868 pUpPath->state = PATH_Open;
1869 pDownPath = HeapAlloc(GetProcessHeap(), 0, sizeof(GdiPath));
1870 PATH_InitGdiPath(pDownPath);
1871 pDownPath->state = PATH_Open;
1873 for(j = 0; j < pStrokes[i]->numEntriesUsed; j++) {
1874 /* Beginning or end of the path if not closed */
1875 if((!(pStrokes[i]->pFlags[pStrokes[i]->numEntriesUsed - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->numEntriesUsed - 1) ) {
1876 /* Compute segment angle */
1877 double xo, yo, xa, ya, theta;
1879 FLOAT_POINT corners[2];
1881 xo = pStrokes[i]->pPoints[j].x;
1882 yo = pStrokes[i]->pPoints[j].y;
1883 xa = pStrokes[i]->pPoints[1].x;
1884 ya = pStrokes[i]->pPoints[1].y;
1887 xa = pStrokes[i]->pPoints[j - 1].x;
1888 ya = pStrokes[i]->pPoints[j - 1].y;
1889 xo = pStrokes[i]->pPoints[j].x;
1890 yo = pStrokes[i]->pPoints[j].y;
1892 theta = atan2( ya - yo, xa - xo );
1894 case PS_ENDCAP_SQUARE :
1895 pt.x = xo + round(sqrt(2) * penWidthOut * cos(M_PI_4 + theta));
1896 pt.y = yo + round(sqrt(2) * penWidthOut * sin(M_PI_4 + theta));
1897 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO) );
1898 pt.x = xo + round(sqrt(2) * penWidthIn * cos(- M_PI_4 + theta));
1899 pt.y = yo + round(sqrt(2) * penWidthIn * sin(- M_PI_4 + theta));
1900 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1902 case PS_ENDCAP_FLAT :
1903 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1904 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1905 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
1906 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1907 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1908 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1910 case PS_ENDCAP_ROUND :
1912 corners[0].x = xo - penWidthIn;
1913 corners[0].y = yo - penWidthIn;
1914 corners[1].x = xo + penWidthOut;
1915 corners[1].y = yo + penWidthOut;
1916 PATH_DoArcPart(pUpPath ,corners, theta + M_PI_2 , theta + 3 * M_PI_4, (j == 0 ? PT_MOVETO : FALSE));
1917 PATH_DoArcPart(pUpPath ,corners, theta + 3 * M_PI_4 , theta + M_PI, FALSE);
1918 PATH_DoArcPart(pUpPath ,corners, theta + M_PI, theta + 5 * M_PI_4, FALSE);
1919 PATH_DoArcPart(pUpPath ,corners, theta + 5 * M_PI_4 , theta + 3 * M_PI_2, FALSE);
1923 /* Corpse of the path */
1927 double xa, ya, xb, yb, xo, yo;
1928 double alpha, theta, miterWidth;
1929 DWORD _joint = joint;
1931 GdiPath *pInsidePath, *pOutsidePath;
1932 if(j > 0 && j < pStrokes[i]->numEntriesUsed - 1) {
1937 previous = pStrokes[i]->numEntriesUsed - 1;
1944 xo = pStrokes[i]->pPoints[j].x;
1945 yo = pStrokes[i]->pPoints[j].y;
1946 xa = pStrokes[i]->pPoints[previous].x;
1947 ya = pStrokes[i]->pPoints[previous].y;
1948 xb = pStrokes[i]->pPoints[next].x;
1949 yb = pStrokes[i]->pPoints[next].y;
1950 theta = atan2( yo - ya, xo - xa );
1951 alpha = atan2( yb - yo, xb - xo ) - theta;
1952 if (alpha > 0) alpha -= M_PI;
1954 if(_joint == PS_JOIN_MITER && dc->miterLimit < fabs(1 / sin(alpha/2))) {
1955 _joint = PS_JOIN_BEVEL;
1958 pInsidePath = pUpPath;
1959 pOutsidePath = pDownPath;
1961 else if(alpha < 0) {
1962 pInsidePath = pDownPath;
1963 pOutsidePath = pUpPath;
1968 /* Inside angle points */
1970 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1971 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1974 pt.x = xo + round( penWidthIn * cos(theta + M_PI_2) );
1975 pt.y = yo + round( penWidthIn * sin(theta + M_PI_2) );
1977 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1979 pt.x = xo + round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1980 pt.y = yo + round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1983 pt.x = xo - round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1984 pt.y = yo - round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1986 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1987 /* Outside angle point */
1989 case PS_JOIN_MITER :
1990 miterWidth = fabs(penWidthOut / cos(M_PI_2 - fabs(alpha) / 2));
1991 pt.x = xo + round( miterWidth * cos(theta + alpha / 2) );
1992 pt.y = yo + round( miterWidth * sin(theta + alpha / 2) );
1993 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1995 case PS_JOIN_BEVEL :
1997 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1998 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
2001 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
2002 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
2004 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
2006 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2007 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2010 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2011 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2013 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
2015 case PS_JOIN_ROUND :
2018 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
2019 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
2022 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
2023 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
2025 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2026 pt.x = xo + round( penWidthOut * cos(theta + alpha / 2) );
2027 pt.y = yo + round( penWidthOut * sin(theta + alpha / 2) );
2028 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2030 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2031 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2034 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
2035 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2037 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2042 for(j = 0; j < pUpPath->numEntriesUsed; j++) {
2044 pt.x = pUpPath->pPoints[j].x;
2045 pt.y = pUpPath->pPoints[j].y;
2046 PATH_AddEntry(pNewPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
2048 for(j = 0; j < pDownPath->numEntriesUsed; j++) {
2050 pt.x = pDownPath->pPoints[pDownPath->numEntriesUsed - j - 1].x;
2051 pt.y = pDownPath->pPoints[pDownPath->numEntriesUsed - j - 1].y;
2052 PATH_AddEntry(pNewPath, &pt, ( (j == 0 && (pStrokes[i]->pFlags[pStrokes[i]->numEntriesUsed - 1] & PT_CLOSEFIGURE)) ? PT_MOVETO : PT_LINETO));
2055 PATH_DestroyGdiPath(pStrokes[i]);
2056 HeapFree(GetProcessHeap(), 0, pStrokes[i]);
2057 PATH_DestroyGdiPath(pUpPath);
2058 HeapFree(GetProcessHeap(), 0, pUpPath);
2059 PATH_DestroyGdiPath(pDownPath);
2060 HeapFree(GetProcessHeap(), 0, pDownPath);
2062 HeapFree(GetProcessHeap(), 0, pStrokes);
2064 pNewPath->state = PATH_Closed;
2065 if (!(ret = PATH_AssignGdiPath(pPath, pNewPath)))
2066 ERR("Assign path failed\n");
2067 PATH_DestroyGdiPath(pNewPath);
2068 HeapFree(GetProcessHeap(), 0, pNewPath);
2073 /*******************************************************************
2074 * StrokeAndFillPath [GDI32.@]
2078 BOOL WINAPI StrokeAndFillPath(HDC hdc)
2081 DC *dc = get_dc_ptr( hdc );
2085 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath );
2086 ret = physdev->funcs->pStrokeAndFillPath( physdev );
2087 release_dc_ptr( dc );
2093 /*******************************************************************
2094 * StrokePath [GDI32.@]
2098 BOOL WINAPI StrokePath(HDC hdc)
2101 DC *dc = get_dc_ptr( hdc );
2105 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath );
2106 ret = physdev->funcs->pStrokePath( physdev );
2107 release_dc_ptr( dc );
2113 /*******************************************************************
2114 * WidenPath [GDI32.@]
2118 BOOL WINAPI WidenPath(HDC hdc)
2121 DC *dc = get_dc_ptr( hdc );
2125 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath );
2126 ret = physdev->funcs->pWidenPath( physdev );
2127 release_dc_ptr( dc );
2133 /***********************************************************************
2134 * null driver fallback implementations
2137 BOOL nulldrv_BeginPath( PHYSDEV dev )
2139 DC *dc = get_nulldrv_dc( dev );
2141 if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL )) return FALSE;
2142 PATH_EmptyPath(&dc->path);
2143 dc->path.newStroke = TRUE;
2144 dc->path.state = PATH_Open;
2148 BOOL nulldrv_EndPath( PHYSDEV dev )
2150 SetLastError( ERROR_CAN_NOT_COMPLETE );
2154 BOOL nulldrv_AbortPath( PHYSDEV dev )
2156 DC *dc = get_nulldrv_dc( dev );
2158 PATH_EmptyPath( &dc->path );
2162 BOOL nulldrv_CloseFigure( PHYSDEV dev )
2164 SetLastError( ERROR_CAN_NOT_COMPLETE );
2168 BOOL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
2172 DC *dc = get_nulldrv_dc( dev );
2174 if (dc->path.state != PATH_Closed)
2176 SetLastError( ERROR_CAN_NOT_COMPLETE );
2179 if (!PATH_PathToRegion( &dc->path, GetPolyFillMode(dev->hdc), &hrgn )) return FALSE;
2180 ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR;
2181 if (ret) PATH_EmptyPath( &dc->path );
2182 /* FIXME: Should this function delete the path even if it failed? */
2183 DeleteObject( hrgn );
2187 BOOL nulldrv_FillPath( PHYSDEV dev )
2189 DC *dc = get_nulldrv_dc( dev );
2191 if (dc->path.state != PATH_Closed)
2193 SetLastError( ERROR_CAN_NOT_COMPLETE );
2196 if (!PATH_FillPath( dev->hdc, &dc->path )) return FALSE;
2197 /* FIXME: Should the path be emptied even if conversion failed? */
2198 PATH_EmptyPath( &dc->path );
2202 BOOL nulldrv_StrokeAndFillPath( 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( dev->hdc, &dc->path )) return FALSE;
2212 if (!PATH_StrokePath( dev->hdc, &dc->path )) return FALSE;
2213 PATH_EmptyPath( &dc->path );
2217 BOOL nulldrv_StrokePath( 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_StrokePath( dev->hdc, &dc->path )) return FALSE;
2227 PATH_EmptyPath( &dc->path );
2231 BOOL nulldrv_FlattenPath( PHYSDEV dev )
2233 DC *dc = get_nulldrv_dc( dev );
2235 if (dc->path.state != PATH_Closed)
2237 SetLastError( ERROR_CAN_NOT_COMPLETE );
2240 return PATH_FlattenPath( &dc->path );
2243 BOOL nulldrv_WidenPath( PHYSDEV dev )
2245 DC *dc = get_nulldrv_dc( dev );
2247 if (dc->path.state != PATH_Closed)
2249 SetLastError( ERROR_CAN_NOT_COMPLETE );
2252 return PATH_WidenPath( dc );
2255 const struct gdi_dc_funcs path_driver =
2257 NULL, /* pAbortDoc */
2258 pathdrv_AbortPath, /* pAbortPath */
2259 NULL, /* pAlphaBlend */
2260 pathdrv_AngleArc, /* pAngleArc */
2261 pathdrv_Arc, /* pArc */
2262 pathdrv_ArcTo, /* pArcTo */
2263 pathdrv_BeginPath, /* pBeginPath */
2264 NULL, /* pBlendImage */
2265 NULL, /* pChoosePixelFormat */
2266 pathdrv_Chord, /* pChord */
2267 pathdrv_CloseFigure, /* pCloseFigure */
2268 NULL, /* pCreateBitmap */
2269 NULL, /* pCreateCompatibleDC */
2270 pathdrv_CreateDC, /* pCreateDC */
2271 NULL, /* pCreateDIBSection */
2272 NULL, /* pDeleteBitmap */
2273 pathdrv_DeleteDC, /* pDeleteDC */
2274 NULL, /* pDeleteObject */
2275 NULL, /* pDescribePixelFormat */
2276 NULL, /* pDeviceCapabilities */
2277 pathdrv_Ellipse, /* pEllipse */
2279 NULL, /* pEndPage */
2280 pathdrv_EndPath, /* pEndPath */
2281 NULL, /* pEnumFonts */
2282 NULL, /* pEnumICMProfiles */
2283 NULL, /* pExcludeClipRect */
2284 NULL, /* pExtDeviceMode */
2285 NULL, /* pExtEscape */
2286 NULL, /* pExtFloodFill */
2287 NULL, /* pExtSelectClipRgn */
2288 pathdrv_ExtTextOut, /* pExtTextOut */
2289 NULL, /* pFillPath */
2290 NULL, /* pFillRgn */
2291 NULL, /* pFlattenPath */
2292 NULL, /* pFontIsLinked */
2293 NULL, /* pFrameRgn */
2294 NULL, /* pGdiComment */
2295 NULL, /* pGdiRealizationInfo */
2296 NULL, /* pGetCharABCWidths */
2297 NULL, /* pGetCharABCWidthsI */
2298 NULL, /* pGetCharWidth */
2299 NULL, /* pGetDeviceCaps */
2300 NULL, /* pGetDeviceGammaRamp */
2301 NULL, /* pGetFontData */
2302 NULL, /* pGetFontUnicodeRanges */
2303 NULL, /* pGetGlyphIndices */
2304 NULL, /* pGetGlyphOutline */
2305 NULL, /* pGetICMProfile */
2306 NULL, /* pGetImage */
2307 NULL, /* pGetKerningPairs */
2308 NULL, /* pGetNearestColor */
2309 NULL, /* pGetOutlineTextMetrics */
2310 NULL, /* pGetPixel */
2311 NULL, /* pGetPixelFormat */
2312 NULL, /* pGetSystemPaletteEntries */
2313 NULL, /* pGetTextCharsetInfo */
2314 NULL, /* pGetTextExtentExPoint */
2315 NULL, /* pGetTextExtentExPointI */
2316 NULL, /* pGetTextFace */
2317 NULL, /* pGetTextMetrics */
2318 NULL, /* pIntersectClipRect */
2319 NULL, /* pInvertRgn */
2320 pathdrv_LineTo, /* pLineTo */
2321 NULL, /* pModifyWorldTransform */
2322 pathdrv_MoveTo, /* pMoveTo */
2323 NULL, /* pOffsetClipRgn */
2324 NULL, /* pOffsetViewportOrg */
2325 NULL, /* pOffsetWindowOrg */
2326 NULL, /* pPaintRgn */
2328 pathdrv_Pie, /* pPie */
2329 pathdrv_PolyBezier, /* pPolyBezier */
2330 pathdrv_PolyBezierTo, /* pPolyBezierTo */
2331 pathdrv_PolyDraw, /* pPolyDraw */
2332 pathdrv_PolyPolygon, /* pPolyPolygon */
2333 pathdrv_PolyPolyline, /* pPolyPolyline */
2334 pathdrv_Polygon, /* pPolygon */
2335 pathdrv_Polyline, /* pPolyline */
2336 pathdrv_PolylineTo, /* pPolylineTo */
2337 NULL, /* pPutImage */
2338 NULL, /* pRealizeDefaultPalette */
2339 NULL, /* pRealizePalette */
2340 pathdrv_Rectangle, /* pRectangle */
2341 NULL, /* pResetDC */
2342 NULL, /* pRestoreDC */
2343 pathdrv_RoundRect, /* pRoundRect */
2345 NULL, /* pScaleViewportExt */
2346 NULL, /* pScaleWindowExt */
2347 NULL, /* pSelectBitmap */
2348 NULL, /* pSelectBrush */
2349 NULL, /* pSelectClipPath */
2350 NULL, /* pSelectFont */
2351 NULL, /* pSelectPalette */
2352 NULL, /* pSelectPen */
2353 NULL, /* pSetArcDirection */
2354 NULL, /* pSetBkColor */
2355 NULL, /* pSetBkMode */
2356 NULL, /* pSetDCBrushColor */
2357 NULL, /* pSetDCPenColor */
2358 NULL, /* pSetDIBColorTable */
2359 NULL, /* pSetDIBitsToDevice */
2360 NULL, /* pSetDeviceClipping */
2361 NULL, /* pSetDeviceGammaRamp */
2362 NULL, /* pSetLayout */
2363 NULL, /* pSetMapMode */
2364 NULL, /* pSetMapperFlags */
2365 NULL, /* pSetPixel */
2366 NULL, /* pSetPixelFormat */
2367 NULL, /* pSetPolyFillMode */
2368 NULL, /* pSetROP2 */
2369 NULL, /* pSetRelAbs */
2370 NULL, /* pSetStretchBltMode */
2371 NULL, /* pSetTextAlign */
2372 NULL, /* pSetTextCharacterExtra */
2373 NULL, /* pSetTextColor */
2374 NULL, /* pSetTextJustification */
2375 NULL, /* pSetViewportExt */
2376 NULL, /* pSetViewportOrg */
2377 NULL, /* pSetWindowExt */
2378 NULL, /* pSetWindowOrg */
2379 NULL, /* pSetWorldTransform */
2380 NULL, /* pStartDoc */
2381 NULL, /* pStartPage */
2382 NULL, /* pStretchBlt */
2383 NULL, /* pStretchDIBits */
2384 NULL, /* pStrokeAndFillPath */
2385 NULL, /* pStrokePath */
2386 NULL, /* pSwapBuffers */
2387 NULL, /* pUnrealizePalette */
2388 NULL, /* pWidenPath */
2389 /* OpenGL not supported */