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 */
78 /* A floating point version of the POINT structure */
79 typedef struct tagFLOAT_POINT
95 struct gdi_physdev dev;
96 struct gdi_path *path;
99 static inline struct path_physdev *get_path_physdev( PHYSDEV dev )
101 return (struct path_physdev *)dev;
104 static inline void pop_path_driver( DC *dc, struct path_physdev *physdev )
106 pop_dc_driver( dc, &physdev->dev );
107 HeapFree( GetProcessHeap(), 0, physdev );
110 static inline struct path_physdev *find_path_physdev( DC *dc )
114 for (dev = dc->physDev; dev->funcs != &null_driver; dev = dev->next)
115 if (dev->funcs == &path_driver) return get_path_physdev( dev );
119 void free_gdi_path( struct gdi_path *path )
121 HeapFree( GetProcessHeap(), 0, path->points );
122 HeapFree( GetProcessHeap(), 0, path->flags );
123 HeapFree( GetProcessHeap(), 0, path );
126 static struct gdi_path *alloc_gdi_path( int count )
128 struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) );
132 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
135 count = max( NUM_ENTRIES_INITIAL, count );
136 path->points = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*path->points) );
137 path->flags = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*path->flags) );
138 if (!path->points || !path->flags)
140 free_gdi_path( path );
141 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
145 path->allocated = count;
146 path->newStroke = TRUE;
150 static struct gdi_path *copy_gdi_path( const struct gdi_path *src_path )
152 struct gdi_path *path = HeapAlloc( GetProcessHeap(), 0, sizeof(*path) );
156 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
159 path->count = path->allocated = src_path->count;
160 path->newStroke = src_path->newStroke;
161 path->points = HeapAlloc( GetProcessHeap(), 0, path->count * sizeof(*path->points) );
162 path->flags = HeapAlloc( GetProcessHeap(), 0, path->count * sizeof(*path->flags) );
163 if (!path->points || !path->flags)
165 free_gdi_path( path );
166 SetLastError( ERROR_NOT_ENOUGH_MEMORY );
169 memcpy( path->points, src_path->points, path->count * sizeof(*path->points) );
170 memcpy( path->flags, src_path->flags, path->count * sizeof(*path->flags) );
174 /* Performs a world-to-viewport transformation on the specified point (which
175 * is in floating point format).
177 static inline void INTERNAL_LPTODP_FLOAT( HDC hdc, FLOAT_POINT *point, int count )
179 DC *dc = get_dc_ptr( hdc );
186 point->x = x * dc->xformWorld2Vport.eM11 + y * dc->xformWorld2Vport.eM21 + dc->xformWorld2Vport.eDx;
187 point->y = x * dc->xformWorld2Vport.eM12 + y * dc->xformWorld2Vport.eM22 + dc->xformWorld2Vport.eDy;
190 release_dc_ptr( dc );
193 static inline INT int_from_fixed(FIXED f)
195 return (f.fract >= 0x8000) ? (f.value + 1) : f.value;
199 /* PATH_ReserveEntries
201 * Ensures that at least "numEntries" entries (for points and flags) have
202 * been allocated; allocates larger arrays and copies the existing entries
203 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
205 static BOOL PATH_ReserveEntries(struct gdi_path *pPath, INT count)
212 /* Do we have to allocate more memory? */
213 if(count > pPath->allocated)
215 /* Find number of entries to allocate. We let the size of the array
216 * grow exponentially, since that will guarantee linear time
218 count = max( pPath->allocated * 2, count );
220 pPointsNew = HeapReAlloc( GetProcessHeap(), 0, pPath->points, count * sizeof(POINT) );
221 if (!pPointsNew) return FALSE;
222 pPath->points = pPointsNew;
224 pFlagsNew = HeapReAlloc( GetProcessHeap(), 0, pPath->flags, count * sizeof(BYTE) );
225 if (!pFlagsNew) return FALSE;
226 pPath->flags = pFlagsNew;
228 pPath->allocated = count;
235 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
236 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
237 * successful, FALSE otherwise (e.g. if not enough memory was available).
239 static BOOL PATH_AddEntry(struct gdi_path *pPath, const POINT *pPoint, BYTE flags)
241 /* FIXME: If newStroke is true, perhaps we want to check that we're
242 * getting a PT_MOVETO
244 TRACE("(%d,%d) - %d\n", pPoint->x, pPoint->y, flags);
246 /* Reserve enough memory for an extra path entry */
247 if(!PATH_ReserveEntries(pPath, pPath->count+1))
250 /* Store information in path entry */
251 pPath->points[pPath->count]=*pPoint;
252 pPath->flags[pPath->count]=flags;
259 /* add a number of points, converting them to device coords */
260 /* return a pointer to the first type byte so it can be fixed up if necessary */
261 static BYTE *add_log_points( struct path_physdev *physdev, const POINT *points, DWORD count, BYTE type )
264 struct gdi_path *path = physdev->path;
266 if (!PATH_ReserveEntries( path, path->count + count )) return NULL;
268 ret = &path->flags[path->count];
269 memcpy( &path->points[path->count], points, count * sizeof(*points) );
270 LPtoDP( physdev->dev.hdc, &path->points[path->count], count );
271 memset( ret, type, count );
272 path->count += count;
276 /* start a new path stroke if necessary */
277 static BOOL start_new_stroke( struct path_physdev *physdev )
280 struct gdi_path *path = physdev->path;
282 if (!path->newStroke && path->count &&
283 !(path->flags[path->count - 1] & PT_CLOSEFIGURE))
286 path->newStroke = FALSE;
287 GetCurrentPositionEx( physdev->dev.hdc, &pos );
288 return add_log_points( physdev, &pos, 1, PT_MOVETO ) != NULL;
293 * Helper function for RoundRect() and Rectangle()
295 static void PATH_CheckCorners( HDC hdc, POINT corners[], INT x1, INT y1, INT x2, INT y2 )
299 /* Convert points to device coordinates */
304 LPtoDP( hdc, corners, 2 );
306 /* Make sure first corner is top left and second corner is bottom right */
307 if(corners[0].x>corners[1].x)
310 corners[0].x=corners[1].x;
313 if(corners[0].y>corners[1].y)
316 corners[0].y=corners[1].y;
320 /* In GM_COMPATIBLE, don't include bottom and right edges */
321 if (GetGraphicsMode( hdc ) == GM_COMPATIBLE)
328 /* PATH_AddFlatBezier
330 static BOOL PATH_AddFlatBezier(struct gdi_path *pPath, POINT *pt, BOOL closed)
335 pts = GDI_Bezier( pt, 4, &no );
336 if(!pts) return FALSE;
338 for(i = 1; i < no; i++)
339 PATH_AddEntry(pPath, &pts[i], (i == no-1 && closed) ? PT_LINETO | PT_CLOSEFIGURE : PT_LINETO);
340 HeapFree( GetProcessHeap(), 0, pts );
346 * Replaces Beziers with line segments
349 static struct gdi_path *PATH_FlattenPath(const struct gdi_path *pPath)
351 struct gdi_path *new_path;
354 if (!(new_path = alloc_gdi_path( pPath->count ))) return NULL;
356 for(srcpt = 0; srcpt < pPath->count; srcpt++) {
357 switch(pPath->flags[srcpt] & ~PT_CLOSEFIGURE) {
360 if (!PATH_AddEntry(new_path, &pPath->points[srcpt], pPath->flags[srcpt]))
362 free_gdi_path( new_path );
367 if (!PATH_AddFlatBezier(new_path, &pPath->points[srcpt-1],
368 pPath->flags[srcpt+2] & PT_CLOSEFIGURE))
370 free_gdi_path( new_path );
382 * Creates a region from the specified path using the specified polygon
383 * filling mode. The path is left unchanged.
385 static HRGN PATH_PathToRegion(const struct gdi_path *pPath, INT nPolyFillMode)
387 struct gdi_path *rgn_path;
388 int numStrokes, iStroke, i;
389 INT *pNumPointsInStroke;
392 if (!(rgn_path = PATH_FlattenPath( pPath ))) return 0;
394 /* FIXME: What happens when number of points is zero? */
396 /* First pass: Find out how many strokes there are in the path */
397 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
399 for(i=0; i<rgn_path->count; i++)
400 if((rgn_path->flags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
403 /* Allocate memory for number-of-points-in-stroke array */
404 pNumPointsInStroke=HeapAlloc( GetProcessHeap(), 0, sizeof(int) * numStrokes );
405 if(!pNumPointsInStroke)
407 free_gdi_path( rgn_path );
408 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
412 /* Second pass: remember number of points in each polygon */
413 iStroke=-1; /* Will get incremented to 0 at beginning of first stroke */
414 for(i=0; i<rgn_path->count; i++)
416 /* Is this the beginning of a new stroke? */
417 if((rgn_path->flags[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)
420 pNumPointsInStroke[iStroke]=0;
423 pNumPointsInStroke[iStroke]++;
426 /* Create a region from the strokes */
427 hrgn=CreatePolyPolygonRgn(rgn_path->points, pNumPointsInStroke,
428 numStrokes, nPolyFillMode);
430 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke );
431 free_gdi_path( rgn_path );
435 /* PATH_ScaleNormalizedPoint
437 * Scales a normalized point (x, y) with respect to the box whose corners are
438 * passed in "corners". The point is stored in "*pPoint". The normalized
439 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
440 * (1.0, 1.0) correspond to corners[1].
442 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners[], double x,
443 double y, POINT *pPoint)
445 pPoint->x=GDI_ROUND( (double)corners[0].x + (double)(corners[1].x-corners[0].x)*0.5*(x+1.0) );
446 pPoint->y=GDI_ROUND( (double)corners[0].y + (double)(corners[1].y-corners[0].y)*0.5*(y+1.0) );
449 /* PATH_NormalizePoint
451 * Normalizes a point with respect to the box whose corners are passed in
452 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
454 static void PATH_NormalizePoint(FLOAT_POINT corners[],
455 const FLOAT_POINT *pPoint,
456 double *pX, double *pY)
458 *pX=(double)(pPoint->x-corners[0].x)/(double)(corners[1].x-corners[0].x) * 2.0 - 1.0;
459 *pY=(double)(pPoint->y-corners[0].y)/(double)(corners[1].y-corners[0].y) * 2.0 - 1.0;
464 * Creates a Bezier spline that corresponds to part of an arc and appends the
465 * corresponding points to the path. The start and end angles are passed in
466 * "angleStart" and "angleEnd"; these angles should span a quarter circle
467 * at most. If "startEntryType" is non-zero, an entry of that type for the first
468 * control point is added to the path; otherwise, it is assumed that the current
469 * position is equal to the first control point.
471 static BOOL PATH_DoArcPart(struct gdi_path *pPath, FLOAT_POINT corners[],
472 double angleStart, double angleEnd, BYTE startEntryType)
475 double xNorm[4], yNorm[4];
479 assert(fabs(angleEnd-angleStart)<=M_PI_2);
481 /* FIXME: Is there an easier way of computing this? */
483 /* Compute control points */
484 halfAngle=(angleEnd-angleStart)/2.0;
485 if(fabs(halfAngle)>1e-8)
487 a=4.0/3.0*(1-cos(halfAngle))/sin(halfAngle);
488 xNorm[0]=cos(angleStart);
489 yNorm[0]=sin(angleStart);
490 xNorm[1]=xNorm[0] - a*yNorm[0];
491 yNorm[1]=yNorm[0] + a*xNorm[0];
492 xNorm[3]=cos(angleEnd);
493 yNorm[3]=sin(angleEnd);
494 xNorm[2]=xNorm[3] + a*yNorm[3];
495 yNorm[2]=yNorm[3] - a*xNorm[3];
500 xNorm[i]=cos(angleStart);
501 yNorm[i]=sin(angleStart);
504 /* Add starting point to path if desired */
507 PATH_ScaleNormalizedPoint(corners, xNorm[0], yNorm[0], &point);
508 if(!PATH_AddEntry(pPath, &point, startEntryType))
512 /* Add remaining control points */
515 PATH_ScaleNormalizedPoint(corners, xNorm[i], yNorm[i], &point);
516 if(!PATH_AddEntry(pPath, &point, PT_BEZIERTO))
524 /***********************************************************************
525 * BeginPath (GDI32.@)
527 BOOL WINAPI BeginPath(HDC hdc)
530 DC *dc = get_dc_ptr( hdc );
534 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pBeginPath );
535 ret = physdev->funcs->pBeginPath( physdev );
536 release_dc_ptr( dc );
542 /***********************************************************************
545 BOOL WINAPI EndPath(HDC hdc)
548 DC *dc = get_dc_ptr( hdc );
552 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEndPath );
553 ret = physdev->funcs->pEndPath( physdev );
554 release_dc_ptr( dc );
560 /******************************************************************************
561 * AbortPath [GDI32.@]
562 * Closes and discards paths from device context
565 * Check that SetLastError is being called correctly
568 * hdc [I] Handle to device context
574 BOOL WINAPI AbortPath( HDC hdc )
577 DC *dc = get_dc_ptr( hdc );
581 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pAbortPath );
582 ret = physdev->funcs->pAbortPath( physdev );
583 release_dc_ptr( dc );
589 /***********************************************************************
590 * CloseFigure (GDI32.@)
592 * FIXME: Check that SetLastError is being called correctly
594 BOOL WINAPI CloseFigure(HDC hdc)
597 DC *dc = get_dc_ptr( hdc );
601 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pCloseFigure );
602 ret = physdev->funcs->pCloseFigure( physdev );
603 release_dc_ptr( dc );
609 /***********************************************************************
612 INT WINAPI GetPath(HDC hdc, LPPOINT pPoints, LPBYTE pTypes, INT nSize)
615 DC *dc = get_dc_ptr( hdc );
621 SetLastError(ERROR_CAN_NOT_COMPLETE);
626 ret = dc->path->count;
627 else if(nSize<dc->path->count)
629 SetLastError(ERROR_INVALID_PARAMETER);
634 memcpy(pPoints, dc->path->points, sizeof(POINT)*dc->path->count);
635 memcpy(pTypes, dc->path->flags, sizeof(BYTE)*dc->path->count);
637 /* Convert the points to logical coordinates */
638 if(!DPtoLP(hdc, pPoints, dc->path->count))
640 /* FIXME: Is this the correct value? */
641 SetLastError(ERROR_CAN_NOT_COMPLETE);
644 else ret = dc->path->count;
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)
664 DC *dc = get_dc_ptr( hdc );
666 /* Get pointer to path */
669 if (!dc->path) SetLastError(ERROR_CAN_NOT_COMPLETE);
672 if ((hrgnRval = PATH_PathToRegion(dc->path, GetPolyFillMode(hdc))))
674 /* FIXME: Should we empty the path even if conversion failed? */
675 free_gdi_path( dc->path );
679 release_dc_ptr( dc );
683 static BOOL PATH_FillPath( HDC hdc, const struct gdi_path *pPath )
685 INT mapMode, graphicsMode;
686 SIZE ptViewportExt, ptWindowExt;
687 POINT ptViewportOrg, ptWindowOrg;
691 /* Construct a region from the path and fill it */
692 if ((hrgn = PATH_PathToRegion(pPath, GetPolyFillMode(hdc))))
694 /* Since PaintRgn interprets the region as being in logical coordinates
695 * but the points we store for the path are already in device
696 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
697 * Using SaveDC to save information about the mapping mode / world
698 * transform would be easier but would require more overhead, especially
699 * now that SaveDC saves the current path.
702 /* Save the information about the old mapping mode */
703 mapMode=GetMapMode(hdc);
704 GetViewportExtEx(hdc, &ptViewportExt);
705 GetViewportOrgEx(hdc, &ptViewportOrg);
706 GetWindowExtEx(hdc, &ptWindowExt);
707 GetWindowOrgEx(hdc, &ptWindowOrg);
709 /* Save world transform
710 * NB: The Windows documentation on world transforms would lead one to
711 * believe that this has to be done only in GM_ADVANCED; however, my
712 * tests show that resetting the graphics mode to GM_COMPATIBLE does
713 * not reset the world transform.
715 GetWorldTransform(hdc, &xform);
718 SetMapMode(hdc, MM_TEXT);
719 SetViewportOrgEx(hdc, 0, 0, NULL);
720 SetWindowOrgEx(hdc, 0, 0, NULL);
721 graphicsMode=GetGraphicsMode(hdc);
722 SetGraphicsMode(hdc, GM_ADVANCED);
723 ModifyWorldTransform(hdc, &xform, MWT_IDENTITY);
724 SetGraphicsMode(hdc, graphicsMode);
726 /* Paint the region */
729 /* Restore the old mapping mode */
730 SetMapMode(hdc, mapMode);
731 SetViewportExtEx(hdc, ptViewportExt.cx, ptViewportExt.cy, NULL);
732 SetViewportOrgEx(hdc, ptViewportOrg.x, ptViewportOrg.y, NULL);
733 SetWindowExtEx(hdc, ptWindowExt.cx, ptWindowExt.cy, NULL);
734 SetWindowOrgEx(hdc, ptWindowOrg.x, ptWindowOrg.y, NULL);
736 /* Go to GM_ADVANCED temporarily to restore the world transform */
737 graphicsMode=GetGraphicsMode(hdc);
738 SetGraphicsMode(hdc, GM_ADVANCED);
739 SetWorldTransform(hdc, &xform);
740 SetGraphicsMode(hdc, graphicsMode);
747 /***********************************************************************
751 * Check that SetLastError is being called correctly
753 BOOL WINAPI FillPath(HDC hdc)
756 DC *dc = get_dc_ptr( hdc );
760 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFillPath );
761 ret = physdev->funcs->pFillPath( physdev );
762 release_dc_ptr( dc );
768 /***********************************************************************
769 * SelectClipPath (GDI32.@)
771 * Check that SetLastError is being called correctly
773 BOOL WINAPI SelectClipPath(HDC hdc, INT iMode)
776 DC *dc = get_dc_ptr( hdc );
780 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectClipPath );
781 ret = physdev->funcs->pSelectClipPath( physdev, iMode );
782 release_dc_ptr( dc );
788 /***********************************************************************
791 static BOOL pathdrv_BeginPath( PHYSDEV dev )
793 /* path already open, nothing to do */
798 /***********************************************************************
801 static BOOL pathdrv_AbortPath( PHYSDEV dev )
803 struct path_physdev *physdev = get_path_physdev( dev );
804 DC *dc = get_dc_ptr( dev->hdc );
806 if (!dc) return FALSE;
807 free_gdi_path( physdev->path );
808 pop_path_driver( dc, physdev );
809 release_dc_ptr( dc );
814 /***********************************************************************
817 static BOOL pathdrv_EndPath( PHYSDEV dev )
819 struct path_physdev *physdev = get_path_physdev( dev );
820 DC *dc = get_dc_ptr( dev->hdc );
822 if (!dc) return FALSE;
823 dc->path = physdev->path;
824 pop_path_driver( dc, physdev );
825 release_dc_ptr( dc );
830 /***********************************************************************
833 static BOOL pathdrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
834 LPCWSTR output, const DEVMODEW *devmode )
836 struct path_physdev *physdev = HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev) );
839 if (!physdev) return FALSE;
840 dc = get_dc_ptr( (*dev)->hdc );
841 push_dc_driver( dev, &physdev->dev, &path_driver );
842 release_dc_ptr( dc );
847 /*************************************************************
850 static BOOL pathdrv_DeleteDC( PHYSDEV dev )
852 assert( 0 ); /* should never be called */
857 BOOL PATH_SavePath( DC *dst, DC *src )
859 struct path_physdev *physdev;
863 if (!(dst->path = copy_gdi_path( src->path ))) return FALSE;
865 else if ((physdev = find_path_physdev( src )))
867 if (!(dst->path = copy_gdi_path( physdev->path ))) return FALSE;
868 dst->path_open = TRUE;
870 else dst->path = NULL;
874 BOOL PATH_RestorePath( DC *dst, DC *src )
876 struct path_physdev *physdev = find_path_physdev( dst );
878 if (src->path && src->path_open)
882 if (!path_driver.pCreateDC( &dst->physDev, NULL, NULL, NULL, NULL )) return FALSE;
883 physdev = get_path_physdev( dst->physDev );
885 else free_gdi_path( physdev->path );
887 physdev->path = src->path;
888 src->path_open = FALSE;
893 free_gdi_path( physdev->path );
894 pop_path_driver( dst, physdev );
896 if (dst->path) free_gdi_path( dst->path );
897 dst->path = src->path;
903 /*************************************************************
906 static BOOL pathdrv_MoveTo( PHYSDEV dev, INT x, INT y )
908 struct path_physdev *physdev = get_path_physdev( dev );
909 physdev->path->newStroke = TRUE;
914 /*************************************************************
917 static BOOL pathdrv_LineTo( PHYSDEV dev, INT x, INT y )
919 struct path_physdev *physdev = get_path_physdev( dev );
922 if (!start_new_stroke( physdev )) return FALSE;
925 return add_log_points( physdev, &point, 1, PT_LINETO ) != NULL;
929 /*************************************************************
932 * FIXME: it adds the same entries to the path as windows does, but there
933 * is an error in the bezier drawing code so that there are small pixel-size
934 * gaps when the resulting path is drawn by StrokePath()
936 static BOOL pathdrv_RoundRect( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2, INT ell_width, INT ell_height )
938 struct path_physdev *physdev = get_path_physdev( dev );
939 POINT corners[2], pointTemp;
940 FLOAT_POINT ellCorners[2];
942 PATH_CheckCorners(dev->hdc,corners,x1,y1,x2,y2);
944 /* Add points to the roundrect path */
945 ellCorners[0].x = corners[1].x-ell_width;
946 ellCorners[0].y = corners[0].y;
947 ellCorners[1].x = corners[1].x;
948 ellCorners[1].y = corners[0].y+ell_height;
949 if(!PATH_DoArcPart(physdev->path, ellCorners, 0, -M_PI_2, PT_MOVETO))
951 pointTemp.x = corners[0].x+ell_width/2;
952 pointTemp.y = corners[0].y;
953 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
955 ellCorners[0].x = corners[0].x;
956 ellCorners[1].x = corners[0].x+ell_width;
957 if(!PATH_DoArcPart(physdev->path, ellCorners, -M_PI_2, -M_PI, FALSE))
959 pointTemp.x = corners[0].x;
960 pointTemp.y = corners[1].y-ell_height/2;
961 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
963 ellCorners[0].y = corners[1].y-ell_height;
964 ellCorners[1].y = corners[1].y;
965 if(!PATH_DoArcPart(physdev->path, ellCorners, M_PI, M_PI_2, FALSE))
967 pointTemp.x = corners[1].x-ell_width/2;
968 pointTemp.y = corners[1].y;
969 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
971 ellCorners[0].x = corners[1].x-ell_width;
972 ellCorners[1].x = corners[1].x;
973 if(!PATH_DoArcPart(physdev->path, ellCorners, M_PI_2, 0, FALSE))
976 /* Close the roundrect figure */
977 return CloseFigure( dev->hdc );
981 /*************************************************************
984 static BOOL pathdrv_Rectangle( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
986 struct path_physdev *physdev = get_path_physdev( dev );
987 POINT corners[2], pointTemp;
989 PATH_CheckCorners(dev->hdc,corners,x1,y1,x2,y2);
991 /* Add four points to the path */
992 pointTemp.x=corners[1].x;
993 pointTemp.y=corners[0].y;
994 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_MOVETO))
996 if(!PATH_AddEntry(physdev->path, corners, PT_LINETO))
998 pointTemp.x=corners[0].x;
999 pointTemp.y=corners[1].y;
1000 if(!PATH_AddEntry(physdev->path, &pointTemp, PT_LINETO))
1002 if(!PATH_AddEntry(physdev->path, corners+1, PT_LINETO))
1005 /* Close the rectangle figure */
1006 return CloseFigure( dev->hdc );
1012 * Should be called when a call to Arc is performed on a DC that has
1013 * an open path. This adds up to five Bezier splines representing the arc
1014 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
1015 * when 'lines' is 2, we add 2 extra lines to get a pie, and when 'lines' is
1016 * -1 we add 1 extra line from the current DC position to the starting position
1017 * of the arc before drawing the arc itself (arcto). Returns TRUE if successful,
1020 static BOOL PATH_Arc( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2,
1021 INT xStart, INT yStart, INT xEnd, INT yEnd, INT lines )
1023 struct path_physdev *physdev = get_path_physdev( dev );
1024 double angleStart, angleEnd, angleStartQuadrant, angleEndQuadrant=0.0;
1025 /* Initialize angleEndQuadrant to silence gcc's warning */
1027 FLOAT_POINT corners[2], pointStart, pointEnd;
1030 INT temp, direction = GetArcDirection(dev->hdc);
1032 /* FIXME: Do we have to respect newStroke? */
1034 /* Check for zero height / width */
1035 /* FIXME: Only in GM_COMPATIBLE? */
1036 if(x1==x2 || y1==y2)
1039 /* Convert points to device coordinates */
1044 pointStart.x = xStart;
1045 pointStart.y = yStart;
1048 INTERNAL_LPTODP_FLOAT(dev->hdc, corners, 2);
1049 INTERNAL_LPTODP_FLOAT(dev->hdc, &pointStart, 1);
1050 INTERNAL_LPTODP_FLOAT(dev->hdc, &pointEnd, 1);
1052 /* Make sure first corner is top left and second corner is bottom right */
1053 if(corners[0].x>corners[1].x)
1056 corners[0].x=corners[1].x;
1059 if(corners[0].y>corners[1].y)
1062 corners[0].y=corners[1].y;
1066 /* Compute start and end angle */
1067 PATH_NormalizePoint(corners, &pointStart, &x, &y);
1068 angleStart=atan2(y, x);
1069 PATH_NormalizePoint(corners, &pointEnd, &x, &y);
1070 angleEnd=atan2(y, x);
1072 /* Make sure the end angle is "on the right side" of the start angle */
1073 if (direction == AD_CLOCKWISE)
1075 if(angleEnd<=angleStart)
1078 assert(angleEnd>=angleStart);
1083 if(angleEnd>=angleStart)
1086 assert(angleEnd<=angleStart);
1090 /* In GM_COMPATIBLE, don't include bottom and right edges */
1091 if (GetGraphicsMode(dev->hdc) == GM_COMPATIBLE)
1097 /* arcto: Add a PT_MOVETO only if this is the first entry in a stroke */
1098 if (lines==-1 && !start_new_stroke( physdev )) return FALSE;
1100 /* Add the arc to the path with one Bezier spline per quadrant that the
1106 /* Determine the start and end angles for this quadrant */
1109 angleStartQuadrant=angleStart;
1110 if (direction == AD_CLOCKWISE)
1111 angleEndQuadrant=(floor(angleStart/M_PI_2)+1.0)*M_PI_2;
1113 angleEndQuadrant=(ceil(angleStart/M_PI_2)-1.0)*M_PI_2;
1117 angleStartQuadrant=angleEndQuadrant;
1118 if (direction == AD_CLOCKWISE)
1119 angleEndQuadrant+=M_PI_2;
1121 angleEndQuadrant-=M_PI_2;
1124 /* Have we reached the last part of the arc? */
1125 if((direction == AD_CLOCKWISE && angleEnd<angleEndQuadrant) ||
1126 (direction == AD_COUNTERCLOCKWISE && angleEnd>angleEndQuadrant))
1128 /* Adjust the end angle for this quadrant */
1129 angleEndQuadrant=angleEnd;
1133 /* Add the Bezier spline to the path */
1134 PATH_DoArcPart(physdev->path, corners, angleStartQuadrant, angleEndQuadrant,
1135 start ? (lines==-1 ? PT_LINETO : PT_MOVETO) : FALSE);
1139 /* chord: close figure. pie: add line and close figure */
1142 return CloseFigure(dev->hdc);
1146 centre.x = (corners[0].x+corners[1].x)/2;
1147 centre.y = (corners[0].y+corners[1].y)/2;
1148 if(!PATH_AddEntry(physdev->path, ¢re, PT_LINETO | PT_CLOSEFIGURE))
1156 /*************************************************************
1159 static BOOL pathdrv_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT eStartAngle, FLOAT eSweepAngle)
1161 INT x1, y1, x2, y2, arcdir;
1164 x1 = GDI_ROUND( x + cos(eStartAngle*M_PI/180) * radius );
1165 y1 = GDI_ROUND( y - sin(eStartAngle*M_PI/180) * radius );
1166 x2 = GDI_ROUND( x + cos((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1167 y2 = GDI_ROUND( y - sin((eStartAngle+eSweepAngle)*M_PI/180) * radius );
1168 arcdir = SetArcDirection( dev->hdc, eSweepAngle >= 0 ? AD_COUNTERCLOCKWISE : AD_CLOCKWISE);
1169 ret = PATH_Arc( dev, x-radius, y-radius, x+radius, y+radius, x1, y1, x2, y2, -1 );
1170 SetArcDirection( dev->hdc, arcdir );
1175 /*************************************************************
1178 static BOOL pathdrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1179 INT xstart, INT ystart, INT xend, INT yend )
1181 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 0 );
1185 /*************************************************************
1188 static BOOL pathdrv_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1189 INT xstart, INT ystart, INT xend, INT yend )
1191 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, -1 );
1195 /*************************************************************
1198 static BOOL pathdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1199 INT xstart, INT ystart, INT xend, INT yend )
1201 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 1);
1205 /*************************************************************
1208 static BOOL pathdrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
1209 INT xstart, INT ystart, INT xend, INT yend )
1211 return PATH_Arc( dev, left, top, right, bottom, xstart, ystart, xend, yend, 2 );
1215 /*************************************************************
1218 static BOOL pathdrv_Ellipse( PHYSDEV dev, INT x1, INT y1, INT x2, INT y2 )
1220 return PATH_Arc( dev, x1, y1, x2, y2, x1, (y1+y2)/2, x1, (y1+y2)/2, 0 ) && CloseFigure( dev->hdc );
1224 /*************************************************************
1225 * pathdrv_PolyBezierTo
1227 static BOOL pathdrv_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1229 struct path_physdev *physdev = get_path_physdev( dev );
1231 if (!start_new_stroke( physdev )) return FALSE;
1232 return add_log_points( physdev, pts, cbPoints, PT_BEZIERTO ) != NULL;
1236 /*************************************************************
1237 * pathdrv_PolyBezier
1239 static BOOL pathdrv_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD cbPoints )
1241 struct path_physdev *physdev = get_path_physdev( dev );
1242 BYTE *type = add_log_points( physdev, pts, cbPoints, PT_BEZIERTO );
1244 if (!type) return FALSE;
1245 type[0] = PT_MOVETO;
1250 /*************************************************************
1253 static BOOL pathdrv_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD cbPoints )
1255 struct path_physdev *physdev = get_path_physdev( dev );
1256 POINT lastmove, orig_pos;
1259 GetCurrentPositionEx( dev->hdc, &orig_pos );
1260 lastmove = orig_pos;
1262 for(i = physdev->path->count - 1; i >= 0; i--){
1263 if(physdev->path->flags[i] == PT_MOVETO){
1264 lastmove = physdev->path->points[i];
1265 DPtoLP(dev->hdc, &lastmove, 1);
1270 for(i = 0; i < cbPoints; i++)
1275 MoveToEx( dev->hdc, pts[i].x, pts[i].y, NULL );
1278 case PT_LINETO | PT_CLOSEFIGURE:
1279 LineTo( dev->hdc, pts[i].x, pts[i].y );
1282 if ((i + 2 < cbPoints) && (types[i + 1] == PT_BEZIERTO) &&
1283 (types[i + 2] & ~PT_CLOSEFIGURE) == PT_BEZIERTO)
1285 PolyBezierTo( dev->hdc, &pts[i], 3 );
1291 if (i) /* restore original position */
1293 if (!(types[i - 1] & PT_CLOSEFIGURE)) lastmove = pts[i - 1];
1294 if (lastmove.x != orig_pos.x || lastmove.y != orig_pos.y)
1295 MoveToEx( dev->hdc, orig_pos.x, orig_pos.y, NULL );
1300 if(types[i] & PT_CLOSEFIGURE){
1301 physdev->path->flags[physdev->path->count-1] |= PT_CLOSEFIGURE;
1302 MoveToEx( dev->hdc, lastmove.x, lastmove.y, NULL );
1310 /*************************************************************
1313 static BOOL pathdrv_Polyline( PHYSDEV dev, const POINT *pts, INT cbPoints )
1315 struct path_physdev *physdev = get_path_physdev( dev );
1316 BYTE *type = add_log_points( physdev, pts, cbPoints, PT_LINETO );
1318 if (!type) return FALSE;
1319 if (cbPoints) type[0] = PT_MOVETO;
1324 /*************************************************************
1325 * pathdrv_PolylineTo
1327 static BOOL pathdrv_PolylineTo( PHYSDEV dev, const POINT *pts, INT cbPoints )
1329 struct path_physdev *physdev = get_path_physdev( dev );
1331 if (!start_new_stroke( physdev )) return FALSE;
1332 return add_log_points( physdev, pts, cbPoints, PT_LINETO ) != NULL;
1336 /*************************************************************
1339 static BOOL pathdrv_Polygon( PHYSDEV dev, const POINT *pts, INT cbPoints )
1341 struct path_physdev *physdev = get_path_physdev( dev );
1342 BYTE *type = add_log_points( physdev, pts, cbPoints, PT_LINETO );
1344 if (!type) return FALSE;
1345 if (cbPoints) type[0] = PT_MOVETO;
1346 if (cbPoints > 1) type[cbPoints - 1] = PT_LINETO | PT_CLOSEFIGURE;
1351 /*************************************************************
1352 * pathdrv_PolyPolygon
1354 static BOOL pathdrv_PolyPolygon( PHYSDEV dev, const POINT* pts, const INT* counts, UINT polygons )
1356 struct path_physdev *physdev = get_path_physdev( dev );
1360 for(poly = 0; poly < polygons; poly++) {
1361 type = add_log_points( physdev, pts, counts[poly], PT_LINETO );
1362 if (!type) return FALSE;
1363 type[0] = PT_MOVETO;
1364 /* win98 adds an extra line to close the figure for some reason */
1365 add_log_points( physdev, pts, 1, PT_LINETO | PT_CLOSEFIGURE );
1366 pts += counts[poly];
1372 /*************************************************************
1373 * pathdrv_PolyPolyline
1375 static BOOL pathdrv_PolyPolyline( PHYSDEV dev, const POINT* pts, const DWORD* counts, DWORD polylines )
1377 struct path_physdev *physdev = get_path_physdev( dev );
1381 for (poly = count = 0; poly < polylines; poly++) count += counts[poly];
1383 type = add_log_points( physdev, pts, count, PT_LINETO );
1384 if (!type) return FALSE;
1386 /* make the first point of each polyline a PT_MOVETO */
1387 for (poly = 0; poly < polylines; poly++, type += counts[poly]) *type = PT_MOVETO;
1392 /**********************************************************************
1395 * internally used by PATH_add_outline
1397 static void PATH_BezierTo(struct gdi_path *pPath, POINT *lppt, INT n)
1403 PATH_AddEntry(pPath, &lppt[1], PT_LINETO);
1407 PATH_AddEntry(pPath, &lppt[0], PT_BEZIERTO);
1408 PATH_AddEntry(pPath, &lppt[1], PT_BEZIERTO);
1409 PATH_AddEntry(pPath, &lppt[2], PT_BEZIERTO);
1423 pt[2].x = (lppt[i+2].x + lppt[i+1].x) / 2;
1424 pt[2].y = (lppt[i+2].y + lppt[i+1].y) / 2;
1425 PATH_BezierTo(pPath, pt, 3);
1433 PATH_BezierTo(pPath, pt, 3);
1437 static BOOL PATH_add_outline(struct path_physdev *physdev, INT x, INT y,
1438 TTPOLYGONHEADER *header, DWORD size)
1440 TTPOLYGONHEADER *start;
1445 while ((char *)header < (char *)start + size)
1449 if (header->dwType != TT_POLYGON_TYPE)
1451 FIXME("Unknown header type %d\n", header->dwType);
1455 pt.x = x + int_from_fixed(header->pfxStart.x);
1456 pt.y = y - int_from_fixed(header->pfxStart.y);
1457 PATH_AddEntry(physdev->path, &pt, PT_MOVETO);
1459 curve = (TTPOLYCURVE *)(header + 1);
1461 while ((char *)curve < (char *)header + header->cb)
1463 /*TRACE("curve->wType %d\n", curve->wType);*/
1465 switch(curve->wType)
1471 for (i = 0; i < curve->cpfx; i++)
1473 pt.x = x + int_from_fixed(curve->apfx[i].x);
1474 pt.y = y - int_from_fixed(curve->apfx[i].y);
1475 PATH_AddEntry(physdev->path, &pt, PT_LINETO);
1480 case TT_PRIM_QSPLINE:
1481 case TT_PRIM_CSPLINE:
1485 POINT *pts = HeapAlloc(GetProcessHeap(), 0, (curve->cpfx + 1) * sizeof(POINT));
1487 if (!pts) return FALSE;
1489 ptfx = *(POINTFX *)((char *)curve - sizeof(POINTFX));
1491 pts[0].x = x + int_from_fixed(ptfx.x);
1492 pts[0].y = y - int_from_fixed(ptfx.y);
1494 for(i = 0; i < curve->cpfx; i++)
1496 pts[i + 1].x = x + int_from_fixed(curve->apfx[i].x);
1497 pts[i + 1].y = y - int_from_fixed(curve->apfx[i].y);
1500 PATH_BezierTo(physdev->path, pts, curve->cpfx + 1);
1502 HeapFree(GetProcessHeap(), 0, pts);
1507 FIXME("Unknown curve type %04x\n", curve->wType);
1511 curve = (TTPOLYCURVE *)&curve->apfx[curve->cpfx];
1514 header = (TTPOLYGONHEADER *)((char *)header + header->cb);
1517 return CloseFigure(physdev->dev.hdc);
1520 /*************************************************************
1521 * pathdrv_ExtTextOut
1523 static BOOL pathdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprc,
1524 LPCWSTR str, UINT count, const INT *dx )
1526 struct path_physdev *physdev = get_path_physdev( dev );
1528 POINT offset = {0, 0};
1530 if (!count) return TRUE;
1532 for (idx = 0; idx < count; idx++)
1534 static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
1539 dwSize = GetGlyphOutlineW(dev->hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE,
1540 &gm, 0, NULL, &identity);
1541 if (dwSize == GDI_ERROR) return FALSE;
1543 /* add outline only if char is printable */
1546 outline = HeapAlloc(GetProcessHeap(), 0, dwSize);
1547 if (!outline) return FALSE;
1549 GetGlyphOutlineW(dev->hdc, str[idx], GGO_GLYPH_INDEX | GGO_NATIVE,
1550 &gm, dwSize, outline, &identity);
1552 PATH_add_outline(physdev, x + offset.x, y + offset.y, outline, dwSize);
1554 HeapFree(GetProcessHeap(), 0, outline);
1561 offset.x += dx[idx * 2];
1562 offset.y += dx[idx * 2 + 1];
1565 offset.x += dx[idx];
1569 offset.x += gm.gmCellIncX;
1570 offset.y += gm.gmCellIncY;
1577 /*************************************************************
1578 * pathdrv_CloseFigure
1580 static BOOL pathdrv_CloseFigure( PHYSDEV dev )
1582 struct path_physdev *physdev = get_path_physdev( dev );
1584 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
1585 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
1586 if (physdev->path->count)
1587 physdev->path->flags[physdev->path->count - 1] |= PT_CLOSEFIGURE;
1592 /*******************************************************************
1593 * FlattenPath [GDI32.@]
1597 BOOL WINAPI FlattenPath(HDC hdc)
1600 DC *dc = get_dc_ptr( hdc );
1604 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pFlattenPath );
1605 ret = physdev->funcs->pFlattenPath( physdev );
1606 release_dc_ptr( dc );
1612 static BOOL PATH_StrokePath( HDC hdc, const struct gdi_path *pPath )
1614 INT i, nLinePts, nAlloc;
1616 POINT ptViewportOrg, ptWindowOrg;
1617 SIZE szViewportExt, szWindowExt;
1618 DWORD mapMode, graphicsMode;
1622 /* Save the mapping mode info */
1623 mapMode=GetMapMode(hdc);
1624 GetViewportExtEx(hdc, &szViewportExt);
1625 GetViewportOrgEx(hdc, &ptViewportOrg);
1626 GetWindowExtEx(hdc, &szWindowExt);
1627 GetWindowOrgEx(hdc, &ptWindowOrg);
1628 GetWorldTransform(hdc, &xform);
1631 SetMapMode(hdc, MM_TEXT);
1632 SetViewportOrgEx(hdc, 0, 0, NULL);
1633 SetWindowOrgEx(hdc, 0, 0, NULL);
1634 graphicsMode=GetGraphicsMode(hdc);
1635 SetGraphicsMode(hdc, GM_ADVANCED);
1636 ModifyWorldTransform(hdc, &xform, MWT_IDENTITY);
1637 SetGraphicsMode(hdc, graphicsMode);
1639 /* Allocate enough memory for the worst case without beziers (one PT_MOVETO
1640 * and the rest PT_LINETO with PT_CLOSEFIGURE at the end) plus some buffer
1641 * space in case we get one to keep the number of reallocations small. */
1642 nAlloc = pPath->count + 1 + 300;
1643 pLinePts = HeapAlloc(GetProcessHeap(), 0, nAlloc * sizeof(POINT));
1646 for(i = 0; i < pPath->count; i++) {
1647 if((i == 0 || (pPath->flags[i-1] & PT_CLOSEFIGURE)) &&
1648 (pPath->flags[i] != PT_MOVETO)) {
1649 ERR("Expected PT_MOVETO %s, got path flag %d\n",
1650 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1655 switch(pPath->flags[i]) {
1657 TRACE("Got PT_MOVETO (%d, %d)\n",
1658 pPath->points[i].x, pPath->points[i].y);
1660 Polyline(hdc, pLinePts, nLinePts);
1662 pLinePts[nLinePts++] = pPath->points[i];
1665 case (PT_LINETO | PT_CLOSEFIGURE):
1666 TRACE("Got PT_LINETO (%d, %d)\n",
1667 pPath->points[i].x, pPath->points[i].y);
1668 pLinePts[nLinePts++] = pPath->points[i];
1671 TRACE("Got PT_BEZIERTO\n");
1672 if(pPath->flags[i+1] != PT_BEZIERTO ||
1673 (pPath->flags[i+2] & ~PT_CLOSEFIGURE) != PT_BEZIERTO) {
1674 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
1678 INT nBzrPts, nMinAlloc;
1679 POINT *pBzrPts = GDI_Bezier(&pPath->points[i-1], 4, &nBzrPts);
1680 /* Make sure we have allocated enough memory for the lines of
1681 * this bezier and the rest of the path, assuming we won't get
1682 * another one (since we won't reallocate again then). */
1683 nMinAlloc = nLinePts + (pPath->count - i) + nBzrPts;
1684 if(nAlloc < nMinAlloc)
1686 nAlloc = nMinAlloc * 2;
1687 pLinePts = HeapReAlloc(GetProcessHeap(), 0, pLinePts,
1688 nAlloc * sizeof(POINT));
1690 memcpy(&pLinePts[nLinePts], &pBzrPts[1],
1691 (nBzrPts - 1) * sizeof(POINT));
1692 nLinePts += nBzrPts - 1;
1693 HeapFree(GetProcessHeap(), 0, pBzrPts);
1698 ERR("Got path flag %d\n", pPath->flags[i]);
1702 if(pPath->flags[i] & PT_CLOSEFIGURE)
1703 pLinePts[nLinePts++] = pLinePts[0];
1706 Polyline(hdc, pLinePts, nLinePts);
1709 HeapFree(GetProcessHeap(), 0, pLinePts);
1711 /* Restore the old mapping mode */
1712 SetMapMode(hdc, mapMode);
1713 SetWindowExtEx(hdc, szWindowExt.cx, szWindowExt.cy, NULL);
1714 SetWindowOrgEx(hdc, ptWindowOrg.x, ptWindowOrg.y, NULL);
1715 SetViewportExtEx(hdc, szViewportExt.cx, szViewportExt.cy, NULL);
1716 SetViewportOrgEx(hdc, ptViewportOrg.x, ptViewportOrg.y, NULL);
1718 /* Go to GM_ADVANCED temporarily to restore the world transform */
1719 graphicsMode=GetGraphicsMode(hdc);
1720 SetGraphicsMode(hdc, GM_ADVANCED);
1721 SetWorldTransform(hdc, &xform);
1722 SetGraphicsMode(hdc, graphicsMode);
1724 /* If we've moved the current point then get its new position
1725 which will be in device (MM_TEXT) co-ords, convert it to
1726 logical co-ords and re-set it. This basically updates
1727 dc->CurPosX|Y so that their values are in the correct mapping
1732 GetCurrentPositionEx(hdc, &pt);
1733 DPtoLP(hdc, &pt, 1);
1734 MoveToEx(hdc, pt.x, pt.y, NULL);
1740 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1742 static struct gdi_path *PATH_WidenPath(DC *dc)
1744 INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
1745 struct gdi_path *flat_path, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
1747 DWORD obj_type, joint, endcap, penType;
1749 size = GetObjectW( dc->hPen, 0, NULL );
1751 SetLastError(ERROR_CAN_NOT_COMPLETE);
1755 elp = HeapAlloc( GetProcessHeap(), 0, size );
1756 GetObjectW( dc->hPen, size, elp );
1758 obj_type = GetObjectType(dc->hPen);
1759 if(obj_type == OBJ_PEN) {
1760 penStyle = ((LOGPEN*)elp)->lopnStyle;
1762 else if(obj_type == OBJ_EXTPEN) {
1763 penStyle = elp->elpPenStyle;
1766 SetLastError(ERROR_CAN_NOT_COMPLETE);
1767 HeapFree( GetProcessHeap(), 0, elp );
1771 penWidth = elp->elpWidth;
1772 HeapFree( GetProcessHeap(), 0, elp );
1774 endcap = (PS_ENDCAP_MASK & penStyle);
1775 joint = (PS_JOIN_MASK & penStyle);
1776 penType = (PS_TYPE_MASK & penStyle);
1778 /* The function cannot apply to cosmetic pens */
1779 if(obj_type == OBJ_EXTPEN && penType == PS_COSMETIC) {
1780 SetLastError(ERROR_CAN_NOT_COMPLETE);
1784 if (!(flat_path = PATH_FlattenPath( dc->path ))) return NULL;
1786 penWidthIn = penWidth / 2;
1787 penWidthOut = penWidth / 2;
1788 if(penWidthIn + penWidthOut < penWidth)
1793 for(i = 0, j = 0; i < flat_path->count; i++, j++) {
1795 if((i == 0 || (flat_path->flags[i-1] & PT_CLOSEFIGURE)) &&
1796 (flat_path->flags[i] != PT_MOVETO)) {
1797 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1798 i == 0 ? "as first point" : "after PT_CLOSEFIGURE",
1799 flat_path->flags[i]);
1800 free_gdi_path( flat_path );
1803 switch(flat_path->flags[i]) {
1808 pStrokes = HeapAlloc(GetProcessHeap(), 0, sizeof(*pStrokes));
1810 pStrokes = HeapReAlloc(GetProcessHeap(), 0, pStrokes, numStrokes * sizeof(*pStrokes));
1811 if(!pStrokes) return NULL;
1812 pStrokes[numStrokes - 1] = alloc_gdi_path(0);
1815 case (PT_LINETO | PT_CLOSEFIGURE):
1816 point.x = flat_path->points[i].x;
1817 point.y = flat_path->points[i].y;
1818 PATH_AddEntry(pStrokes[numStrokes - 1], &point, flat_path->flags[i]);
1821 /* should never happen because of the FlattenPath call */
1822 ERR("Should never happen\n");
1825 ERR("Got path flag %c\n", flat_path->flags[i]);
1830 pNewPath = alloc_gdi_path( flat_path->count );
1832 for(i = 0; i < numStrokes; i++) {
1833 pUpPath = alloc_gdi_path( pStrokes[i]->count );
1834 pDownPath = alloc_gdi_path( pStrokes[i]->count );
1836 for(j = 0; j < pStrokes[i]->count; j++) {
1837 /* Beginning or end of the path if not closed */
1838 if((!(pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE)) && (j == 0 || j == pStrokes[i]->count - 1) ) {
1839 /* Compute segment angle */
1840 double xo, yo, xa, ya, theta;
1842 FLOAT_POINT corners[2];
1844 xo = pStrokes[i]->points[j].x;
1845 yo = pStrokes[i]->points[j].y;
1846 xa = pStrokes[i]->points[1].x;
1847 ya = pStrokes[i]->points[1].y;
1850 xa = pStrokes[i]->points[j - 1].x;
1851 ya = pStrokes[i]->points[j - 1].y;
1852 xo = pStrokes[i]->points[j].x;
1853 yo = pStrokes[i]->points[j].y;
1855 theta = atan2( ya - yo, xa - xo );
1857 case PS_ENDCAP_SQUARE :
1858 pt.x = xo + round(sqrt(2) * penWidthOut * cos(M_PI_4 + theta));
1859 pt.y = yo + round(sqrt(2) * penWidthOut * sin(M_PI_4 + theta));
1860 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO) );
1861 pt.x = xo + round(sqrt(2) * penWidthIn * cos(- M_PI_4 + theta));
1862 pt.y = yo + round(sqrt(2) * penWidthIn * sin(- M_PI_4 + theta));
1863 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1865 case PS_ENDCAP_FLAT :
1866 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1867 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1868 PATH_AddEntry(pUpPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
1869 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1870 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1871 PATH_AddEntry(pUpPath, &pt, PT_LINETO);
1873 case PS_ENDCAP_ROUND :
1875 corners[0].x = xo - penWidthIn;
1876 corners[0].y = yo - penWidthIn;
1877 corners[1].x = xo + penWidthOut;
1878 corners[1].y = yo + penWidthOut;
1879 PATH_DoArcPart(pUpPath ,corners, theta + M_PI_2 , theta + 3 * M_PI_4, (j == 0 ? PT_MOVETO : FALSE));
1880 PATH_DoArcPart(pUpPath ,corners, theta + 3 * M_PI_4 , theta + M_PI, FALSE);
1881 PATH_DoArcPart(pUpPath ,corners, theta + M_PI, theta + 5 * M_PI_4, FALSE);
1882 PATH_DoArcPart(pUpPath ,corners, theta + 5 * M_PI_4 , theta + 3 * M_PI_2, FALSE);
1886 /* Corpse of the path */
1890 double xa, ya, xb, yb, xo, yo;
1891 double alpha, theta, miterWidth;
1892 DWORD _joint = joint;
1894 struct gdi_path *pInsidePath, *pOutsidePath;
1895 if(j > 0 && j < pStrokes[i]->count - 1) {
1900 previous = pStrokes[i]->count - 1;
1907 xo = pStrokes[i]->points[j].x;
1908 yo = pStrokes[i]->points[j].y;
1909 xa = pStrokes[i]->points[previous].x;
1910 ya = pStrokes[i]->points[previous].y;
1911 xb = pStrokes[i]->points[next].x;
1912 yb = pStrokes[i]->points[next].y;
1913 theta = atan2( yo - ya, xo - xa );
1914 alpha = atan2( yb - yo, xb - xo ) - theta;
1915 if (alpha > 0) alpha -= M_PI;
1917 if(_joint == PS_JOIN_MITER && dc->miterLimit < fabs(1 / sin(alpha/2))) {
1918 _joint = PS_JOIN_BEVEL;
1921 pInsidePath = pUpPath;
1922 pOutsidePath = pDownPath;
1924 else if(alpha < 0) {
1925 pInsidePath = pDownPath;
1926 pOutsidePath = pUpPath;
1931 /* Inside angle points */
1933 pt.x = xo - round( penWidthIn * cos(theta + M_PI_2) );
1934 pt.y = yo - round( penWidthIn * sin(theta + M_PI_2) );
1937 pt.x = xo + round( penWidthIn * cos(theta + M_PI_2) );
1938 pt.y = yo + round( penWidthIn * sin(theta + M_PI_2) );
1940 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1942 pt.x = xo + round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1943 pt.y = yo + round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1946 pt.x = xo - round( penWidthIn * cos(M_PI_2 + alpha + theta) );
1947 pt.y = yo - round( penWidthIn * sin(M_PI_2 + alpha + theta) );
1949 PATH_AddEntry(pInsidePath, &pt, PT_LINETO);
1950 /* Outside angle point */
1952 case PS_JOIN_MITER :
1953 miterWidth = fabs(penWidthOut / cos(M_PI_2 - fabs(alpha) / 2));
1954 pt.x = xo + round( miterWidth * cos(theta + alpha / 2) );
1955 pt.y = yo + round( miterWidth * sin(theta + alpha / 2) );
1956 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1958 case PS_JOIN_BEVEL :
1960 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1961 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1964 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1965 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1967 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1969 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1970 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1973 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1974 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1976 PATH_AddEntry(pOutsidePath, &pt, PT_LINETO);
1978 case PS_JOIN_ROUND :
1981 pt.x = xo + round( penWidthOut * cos(theta + M_PI_2) );
1982 pt.y = yo + round( penWidthOut * sin(theta + M_PI_2) );
1985 pt.x = xo - round( penWidthOut * cos(theta + M_PI_2) );
1986 pt.y = yo - round( penWidthOut * sin(theta + M_PI_2) );
1988 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1989 pt.x = xo + round( penWidthOut * cos(theta + alpha / 2) );
1990 pt.y = yo + round( penWidthOut * sin(theta + alpha / 2) );
1991 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
1993 pt.x = xo - round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1994 pt.y = yo - round( penWidthOut * sin(M_PI_2 + alpha + theta) );
1997 pt.x = xo + round( penWidthOut * cos(M_PI_2 + alpha + theta) );
1998 pt.y = yo + round( penWidthOut * sin(M_PI_2 + alpha + theta) );
2000 PATH_AddEntry(pOutsidePath, &pt, PT_BEZIERTO);
2005 for(j = 0; j < pUpPath->count; j++) {
2007 pt.x = pUpPath->points[j].x;
2008 pt.y = pUpPath->points[j].y;
2009 PATH_AddEntry(pNewPath, &pt, (j == 0 ? PT_MOVETO : PT_LINETO));
2011 for(j = 0; j < pDownPath->count; j++) {
2013 pt.x = pDownPath->points[pDownPath->count - j - 1].x;
2014 pt.y = pDownPath->points[pDownPath->count - j - 1].y;
2015 PATH_AddEntry(pNewPath, &pt, ( (j == 0 && (pStrokes[i]->flags[pStrokes[i]->count - 1] & PT_CLOSEFIGURE)) ? PT_MOVETO : PT_LINETO));
2018 free_gdi_path( pStrokes[i] );
2019 free_gdi_path( pUpPath );
2020 free_gdi_path( pDownPath );
2022 HeapFree(GetProcessHeap(), 0, pStrokes);
2023 free_gdi_path( flat_path );
2028 /*******************************************************************
2029 * StrokeAndFillPath [GDI32.@]
2033 BOOL WINAPI StrokeAndFillPath(HDC hdc)
2036 DC *dc = get_dc_ptr( hdc );
2040 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokeAndFillPath );
2041 ret = physdev->funcs->pStrokeAndFillPath( physdev );
2042 release_dc_ptr( dc );
2048 /*******************************************************************
2049 * StrokePath [GDI32.@]
2053 BOOL WINAPI StrokePath(HDC hdc)
2056 DC *dc = get_dc_ptr( hdc );
2060 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pStrokePath );
2061 ret = physdev->funcs->pStrokePath( physdev );
2062 release_dc_ptr( dc );
2068 /*******************************************************************
2069 * WidenPath [GDI32.@]
2073 BOOL WINAPI WidenPath(HDC hdc)
2076 DC *dc = get_dc_ptr( hdc );
2080 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pWidenPath );
2081 ret = physdev->funcs->pWidenPath( physdev );
2082 release_dc_ptr( dc );
2088 /***********************************************************************
2089 * null driver fallback implementations
2092 BOOL nulldrv_BeginPath( PHYSDEV dev )
2094 DC *dc = get_nulldrv_dc( dev );
2095 struct path_physdev *physdev;
2096 struct gdi_path *path = alloc_gdi_path(0);
2098 if (!path) return FALSE;
2099 if (!path_driver.pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
2101 free_gdi_path( path );
2104 physdev = get_path_physdev( dc->physDev );
2105 physdev->path = path;
2106 if (dc->path) free_gdi_path( dc->path );
2111 BOOL nulldrv_EndPath( PHYSDEV dev )
2113 SetLastError( ERROR_CAN_NOT_COMPLETE );
2117 BOOL nulldrv_AbortPath( PHYSDEV dev )
2119 DC *dc = get_nulldrv_dc( dev );
2121 if (dc->path) free_gdi_path( dc->path );
2126 BOOL nulldrv_CloseFigure( PHYSDEV dev )
2128 SetLastError( ERROR_CAN_NOT_COMPLETE );
2132 BOOL nulldrv_SelectClipPath( PHYSDEV dev, INT mode )
2136 DC *dc = get_nulldrv_dc( dev );
2140 SetLastError( ERROR_CAN_NOT_COMPLETE );
2143 if (!(hrgn = PATH_PathToRegion( dc->path, GetPolyFillMode(dev->hdc)))) return FALSE;
2144 ret = ExtSelectClipRgn( dev->hdc, hrgn, mode ) != ERROR;
2147 free_gdi_path( dc->path );
2150 /* FIXME: Should this function delete the path even if it failed? */
2151 DeleteObject( hrgn );
2155 BOOL nulldrv_FillPath( PHYSDEV dev )
2157 DC *dc = get_nulldrv_dc( dev );
2161 SetLastError( ERROR_CAN_NOT_COMPLETE );
2164 if (!PATH_FillPath( dev->hdc, dc->path )) return FALSE;
2165 /* FIXME: Should the path be emptied even if conversion failed? */
2166 free_gdi_path( dc->path );
2171 BOOL nulldrv_StrokeAndFillPath( PHYSDEV dev )
2173 DC *dc = get_nulldrv_dc( dev );
2177 SetLastError( ERROR_CAN_NOT_COMPLETE );
2180 if (!PATH_FillPath( dev->hdc, dc->path )) return FALSE;
2181 if (!PATH_StrokePath( dev->hdc, dc->path )) return FALSE;
2182 free_gdi_path( dc->path );
2187 BOOL nulldrv_StrokePath( PHYSDEV dev )
2189 DC *dc = get_nulldrv_dc( dev );
2193 SetLastError( ERROR_CAN_NOT_COMPLETE );
2196 if (!PATH_StrokePath( dev->hdc, dc->path )) return FALSE;
2197 free_gdi_path( dc->path );
2202 BOOL nulldrv_FlattenPath( PHYSDEV dev )
2204 DC *dc = get_nulldrv_dc( dev );
2205 struct gdi_path *path;
2209 SetLastError( ERROR_CAN_NOT_COMPLETE );
2212 if (!(path = PATH_FlattenPath( dc->path ))) return FALSE;
2213 free_gdi_path( dc->path );
2218 BOOL nulldrv_WidenPath( PHYSDEV dev )
2220 DC *dc = get_nulldrv_dc( dev );
2221 struct gdi_path *path;
2225 SetLastError( ERROR_CAN_NOT_COMPLETE );
2228 if (!(path = PATH_WidenPath( dc ))) return FALSE;
2229 free_gdi_path( dc->path );
2234 const struct gdi_dc_funcs path_driver =
2236 NULL, /* pAbortDoc */
2237 pathdrv_AbortPath, /* pAbortPath */
2238 NULL, /* pAlphaBlend */
2239 pathdrv_AngleArc, /* pAngleArc */
2240 pathdrv_Arc, /* pArc */
2241 pathdrv_ArcTo, /* pArcTo */
2242 pathdrv_BeginPath, /* pBeginPath */
2243 NULL, /* pBlendImage */
2244 pathdrv_Chord, /* pChord */
2245 pathdrv_CloseFigure, /* pCloseFigure */
2246 NULL, /* pCreateCompatibleDC */
2247 pathdrv_CreateDC, /* pCreateDC */
2248 pathdrv_DeleteDC, /* pDeleteDC */
2249 NULL, /* pDeleteObject */
2250 NULL, /* pDescribePixelFormat */
2251 NULL, /* pDeviceCapabilities */
2252 pathdrv_Ellipse, /* pEllipse */
2254 NULL, /* pEndPage */
2255 pathdrv_EndPath, /* pEndPath */
2256 NULL, /* pEnumFonts */
2257 NULL, /* pEnumICMProfiles */
2258 NULL, /* pExcludeClipRect */
2259 NULL, /* pExtDeviceMode */
2260 NULL, /* pExtEscape */
2261 NULL, /* pExtFloodFill */
2262 NULL, /* pExtSelectClipRgn */
2263 pathdrv_ExtTextOut, /* pExtTextOut */
2264 NULL, /* pFillPath */
2265 NULL, /* pFillRgn */
2266 NULL, /* pFlattenPath */
2267 NULL, /* pFontIsLinked */
2268 NULL, /* pFrameRgn */
2269 NULL, /* pGdiComment */
2270 NULL, /* pGdiRealizationInfo */
2271 NULL, /* pGetBoundsRect */
2272 NULL, /* pGetCharABCWidths */
2273 NULL, /* pGetCharABCWidthsI */
2274 NULL, /* pGetCharWidth */
2275 NULL, /* pGetDeviceCaps */
2276 NULL, /* pGetDeviceGammaRamp */
2277 NULL, /* pGetFontData */
2278 NULL, /* pGetFontUnicodeRanges */
2279 NULL, /* pGetGlyphIndices */
2280 NULL, /* pGetGlyphOutline */
2281 NULL, /* pGetICMProfile */
2282 NULL, /* pGetImage */
2283 NULL, /* pGetKerningPairs */
2284 NULL, /* pGetNearestColor */
2285 NULL, /* pGetOutlineTextMetrics */
2286 NULL, /* pGetPixel */
2287 NULL, /* pGetSystemPaletteEntries */
2288 NULL, /* pGetTextCharsetInfo */
2289 NULL, /* pGetTextExtentExPoint */
2290 NULL, /* pGetTextExtentExPointI */
2291 NULL, /* pGetTextFace */
2292 NULL, /* pGetTextMetrics */
2293 NULL, /* pGradientFill */
2294 NULL, /* pIntersectClipRect */
2295 NULL, /* pInvertRgn */
2296 pathdrv_LineTo, /* pLineTo */
2297 NULL, /* pModifyWorldTransform */
2298 pathdrv_MoveTo, /* pMoveTo */
2299 NULL, /* pOffsetClipRgn */
2300 NULL, /* pOffsetViewportOrg */
2301 NULL, /* pOffsetWindowOrg */
2302 NULL, /* pPaintRgn */
2304 pathdrv_Pie, /* pPie */
2305 pathdrv_PolyBezier, /* pPolyBezier */
2306 pathdrv_PolyBezierTo, /* pPolyBezierTo */
2307 pathdrv_PolyDraw, /* pPolyDraw */
2308 pathdrv_PolyPolygon, /* pPolyPolygon */
2309 pathdrv_PolyPolyline, /* pPolyPolyline */
2310 pathdrv_Polygon, /* pPolygon */
2311 pathdrv_Polyline, /* pPolyline */
2312 pathdrv_PolylineTo, /* pPolylineTo */
2313 NULL, /* pPutImage */
2314 NULL, /* pRealizeDefaultPalette */
2315 NULL, /* pRealizePalette */
2316 pathdrv_Rectangle, /* pRectangle */
2317 NULL, /* pResetDC */
2318 NULL, /* pRestoreDC */
2319 pathdrv_RoundRect, /* pRoundRect */
2321 NULL, /* pScaleViewportExt */
2322 NULL, /* pScaleWindowExt */
2323 NULL, /* pSelectBitmap */
2324 NULL, /* pSelectBrush */
2325 NULL, /* pSelectClipPath */
2326 NULL, /* pSelectFont */
2327 NULL, /* pSelectPalette */
2328 NULL, /* pSelectPen */
2329 NULL, /* pSetArcDirection */
2330 NULL, /* pSetBkColor */
2331 NULL, /* pSetBkMode */
2332 NULL, /* pSetDCBrushColor */
2333 NULL, /* pSetDCPenColor */
2334 NULL, /* pSetDIBColorTable */
2335 NULL, /* pSetDIBitsToDevice */
2336 NULL, /* pSetDeviceClipping */
2337 NULL, /* pSetDeviceGammaRamp */
2338 NULL, /* pSetLayout */
2339 NULL, /* pSetMapMode */
2340 NULL, /* pSetMapperFlags */
2341 NULL, /* pSetPixel */
2342 NULL, /* pSetPixelFormat */
2343 NULL, /* pSetPolyFillMode */
2344 NULL, /* pSetROP2 */
2345 NULL, /* pSetRelAbs */
2346 NULL, /* pSetStretchBltMode */
2347 NULL, /* pSetTextAlign */
2348 NULL, /* pSetTextCharacterExtra */
2349 NULL, /* pSetTextColor */
2350 NULL, /* pSetTextJustification */
2351 NULL, /* pSetViewportExt */
2352 NULL, /* pSetViewportOrg */
2353 NULL, /* pSetWindowExt */
2354 NULL, /* pSetWindowOrg */
2355 NULL, /* pSetWorldTransform */
2356 NULL, /* pStartDoc */
2357 NULL, /* pStartPage */
2358 NULL, /* pStretchBlt */
2359 NULL, /* pStretchDIBits */
2360 NULL, /* pStrokeAndFillPath */
2361 NULL, /* pStrokePath */
2362 NULL, /* pSwapBuffers */
2363 NULL, /* pUnrealizePalette */
2364 NULL, /* pWidenPath */
2365 NULL, /* wine_get_wgl_driver */
2366 GDI_PRIORITY_PATH_DRV /* priority */