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 void free_gdi_path( struct gdi_path
*path
)
106 HeapFree( GetProcessHeap(), 0, path
->points
);
107 HeapFree( GetProcessHeap(), 0, path
->flags
);
108 HeapFree( GetProcessHeap(), 0, path
);
111 static struct gdi_path
*alloc_gdi_path( int count
)
113 struct gdi_path
*path
= HeapAlloc( GetProcessHeap(), 0, sizeof(*path
) );
117 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
120 count
= max( NUM_ENTRIES_INITIAL
, count
);
121 path
->points
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*path
->points
) );
122 path
->flags
= HeapAlloc( GetProcessHeap(), 0, count
* sizeof(*path
->flags
) );
123 if (!path
->points
|| !path
->flags
)
125 free_gdi_path( path
);
126 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
130 path
->allocated
= count
;
131 path
->newStroke
= TRUE
;
135 static struct gdi_path
*copy_gdi_path( const struct gdi_path
*src_path
)
137 struct gdi_path
*path
= HeapAlloc( GetProcessHeap(), 0, sizeof(*path
) );
141 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
144 path
->count
= path
->allocated
= src_path
->count
;
145 path
->newStroke
= src_path
->newStroke
;
146 path
->points
= HeapAlloc( GetProcessHeap(), 0, path
->count
* sizeof(*path
->points
) );
147 path
->flags
= HeapAlloc( GetProcessHeap(), 0, path
->count
* sizeof(*path
->flags
) );
148 if (!path
->points
|| !path
->flags
)
150 free_gdi_path( path
);
151 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
154 memcpy( path
->points
, src_path
->points
, path
->count
* sizeof(*path
->points
) );
155 memcpy( path
->flags
, src_path
->flags
, path
->count
* sizeof(*path
->flags
) );
159 /* Performs a world-to-viewport transformation on the specified point (which
160 * is in floating point format).
162 static inline void INTERNAL_LPTODP_FLOAT( HDC hdc
, FLOAT_POINT
*point
, int count
)
164 DC
*dc
= get_dc_ptr( hdc
);
171 point
->x
= x
* dc
->xformWorld2Vport
.eM11
+ y
* dc
->xformWorld2Vport
.eM21
+ dc
->xformWorld2Vport
.eDx
;
172 point
->y
= x
* dc
->xformWorld2Vport
.eM12
+ y
* dc
->xformWorld2Vport
.eM22
+ dc
->xformWorld2Vport
.eDy
;
175 release_dc_ptr( dc
);
178 static inline INT
int_from_fixed(FIXED f
)
180 return (f
.fract
>= 0x8000) ? (f
.value
+ 1) : f
.value
;
184 /* PATH_ReserveEntries
186 * Ensures that at least "numEntries" entries (for points and flags) have
187 * been allocated; allocates larger arrays and copies the existing entries
188 * to those arrays, if necessary. Returns TRUE if successful, else FALSE.
190 static BOOL
PATH_ReserveEntries(struct gdi_path
*pPath
, INT count
)
197 /* Do we have to allocate more memory? */
198 if(count
> pPath
->allocated
)
200 /* Find number of entries to allocate. We let the size of the array
201 * grow exponentially, since that will guarantee linear time
203 count
= max( pPath
->allocated
* 2, count
);
205 pPointsNew
= HeapReAlloc( GetProcessHeap(), 0, pPath
->points
, count
* sizeof(POINT
) );
206 if (!pPointsNew
) return FALSE
;
207 pPath
->points
= pPointsNew
;
209 pFlagsNew
= HeapReAlloc( GetProcessHeap(), 0, pPath
->flags
, count
* sizeof(BYTE
) );
210 if (!pFlagsNew
) return FALSE
;
211 pPath
->flags
= pFlagsNew
;
213 pPath
->allocated
= count
;
220 * Adds an entry to the path. For "flags", pass either PT_MOVETO, PT_LINETO
221 * or PT_BEZIERTO, optionally ORed with PT_CLOSEFIGURE. Returns TRUE if
222 * successful, FALSE otherwise (e.g. if not enough memory was available).
224 static BOOL
PATH_AddEntry(struct gdi_path
*pPath
, const POINT
*pPoint
, BYTE flags
)
226 /* FIXME: If newStroke is true, perhaps we want to check that we're
227 * getting a PT_MOVETO
229 TRACE("(%d,%d) - %d\n", pPoint
->x
, pPoint
->y
, flags
);
231 /* Reserve enough memory for an extra path entry */
232 if(!PATH_ReserveEntries(pPath
, pPath
->count
+1))
235 /* Store information in path entry */
236 pPath
->points
[pPath
->count
]=*pPoint
;
237 pPath
->flags
[pPath
->count
]=flags
;
244 /* add a number of points, converting them to device coords */
245 /* return a pointer to the first type byte so it can be fixed up if necessary */
246 static BYTE
*add_log_points( struct path_physdev
*physdev
, const POINT
*points
, DWORD count
, BYTE type
)
249 struct gdi_path
*path
= physdev
->path
;
251 if (!PATH_ReserveEntries( path
, path
->count
+ count
)) return NULL
;
253 ret
= &path
->flags
[path
->count
];
254 memcpy( &path
->points
[path
->count
], points
, count
* sizeof(*points
) );
255 LPtoDP( physdev
->dev
.hdc
, &path
->points
[path
->count
], count
);
256 memset( ret
, type
, count
);
257 path
->count
+= count
;
261 /* start a new path stroke if necessary */
262 static BOOL
start_new_stroke( struct path_physdev
*physdev
)
265 struct gdi_path
*path
= physdev
->path
;
267 if (!path
->newStroke
&& path
->count
&&
268 !(path
->flags
[path
->count
- 1] & PT_CLOSEFIGURE
))
271 path
->newStroke
= FALSE
;
272 GetCurrentPositionEx( physdev
->dev
.hdc
, &pos
);
273 return add_log_points( physdev
, &pos
, 1, PT_MOVETO
) != NULL
;
278 * Helper function for RoundRect() and Rectangle()
280 static void PATH_CheckCorners( HDC hdc
, POINT corners
[], INT x1
, INT y1
, INT x2
, INT y2
)
284 /* Convert points to device coordinates */
289 LPtoDP( hdc
, corners
, 2 );
291 /* Make sure first corner is top left and second corner is bottom right */
292 if(corners
[0].x
>corners
[1].x
)
295 corners
[0].x
=corners
[1].x
;
298 if(corners
[0].y
>corners
[1].y
)
301 corners
[0].y
=corners
[1].y
;
305 /* In GM_COMPATIBLE, don't include bottom and right edges */
306 if (GetGraphicsMode( hdc
) == GM_COMPATIBLE
)
313 /* PATH_AddFlatBezier
315 static BOOL
PATH_AddFlatBezier(struct gdi_path
*pPath
, POINT
*pt
, BOOL closed
)
320 pts
= GDI_Bezier( pt
, 4, &no
);
321 if(!pts
) return FALSE
;
323 for(i
= 1; i
< no
; i
++)
324 PATH_AddEntry(pPath
, &pts
[i
], (i
== no
-1 && closed
) ? PT_LINETO
| PT_CLOSEFIGURE
: PT_LINETO
);
325 HeapFree( GetProcessHeap(), 0, pts
);
331 * Replaces Beziers with line segments
334 static struct gdi_path
*PATH_FlattenPath(const struct gdi_path
*pPath
)
336 struct gdi_path
*new_path
;
339 if (!(new_path
= alloc_gdi_path( pPath
->count
))) return NULL
;
341 for(srcpt
= 0; srcpt
< pPath
->count
; srcpt
++) {
342 switch(pPath
->flags
[srcpt
] & ~PT_CLOSEFIGURE
) {
345 if (!PATH_AddEntry(new_path
, &pPath
->points
[srcpt
], pPath
->flags
[srcpt
]))
347 free_gdi_path( new_path
);
352 if (!PATH_AddFlatBezier(new_path
, &pPath
->points
[srcpt
-1],
353 pPath
->flags
[srcpt
+2] & PT_CLOSEFIGURE
))
355 free_gdi_path( new_path
);
367 * Creates a region from the specified path using the specified polygon
368 * filling mode. The path is left unchanged.
370 static HRGN
PATH_PathToRegion(const struct gdi_path
*pPath
, INT nPolyFillMode
)
372 struct gdi_path
*rgn_path
;
373 int numStrokes
, iStroke
, i
;
374 INT
*pNumPointsInStroke
;
377 if (!(rgn_path
= PATH_FlattenPath( pPath
))) return 0;
379 /* FIXME: What happens when number of points is zero? */
381 /* First pass: Find out how many strokes there are in the path */
382 /* FIXME: We could eliminate this with some bookkeeping in GdiPath */
384 for(i
=0; i
<rgn_path
->count
; i
++)
385 if((rgn_path
->flags
[i
] & ~PT_CLOSEFIGURE
) == PT_MOVETO
)
388 /* Allocate memory for number-of-points-in-stroke array */
389 pNumPointsInStroke
=HeapAlloc( GetProcessHeap(), 0, sizeof(int) * numStrokes
);
390 if(!pNumPointsInStroke
)
392 free_gdi_path( rgn_path
);
393 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
397 /* Second pass: remember number of points in each polygon */
398 iStroke
=-1; /* Will get incremented to 0 at beginning of first stroke */
399 for(i
=0; i
<rgn_path
->count
; i
++)
401 /* Is this the beginning of a new stroke? */
402 if((rgn_path
->flags
[i
] & ~PT_CLOSEFIGURE
) == PT_MOVETO
)
405 pNumPointsInStroke
[iStroke
]=0;
408 pNumPointsInStroke
[iStroke
]++;
411 /* Create a region from the strokes */
412 hrgn
=CreatePolyPolygonRgn(rgn_path
->points
, pNumPointsInStroke
,
413 numStrokes
, nPolyFillMode
);
415 HeapFree( GetProcessHeap(), 0, pNumPointsInStroke
);
416 free_gdi_path( rgn_path
);
420 /* PATH_ScaleNormalizedPoint
422 * Scales a normalized point (x, y) with respect to the box whose corners are
423 * passed in "corners". The point is stored in "*pPoint". The normalized
424 * coordinates (-1.0, -1.0) correspond to corners[0], the coordinates
425 * (1.0, 1.0) correspond to corners[1].
427 static void PATH_ScaleNormalizedPoint(FLOAT_POINT corners
[], double x
,
428 double y
, POINT
*pPoint
)
430 pPoint
->x
=GDI_ROUND( (double)corners
[0].x
+ (double)(corners
[1].x
-corners
[0].x
)*0.5*(x
+1.0) );
431 pPoint
->y
=GDI_ROUND( (double)corners
[0].y
+ (double)(corners
[1].y
-corners
[0].y
)*0.5*(y
+1.0) );
434 /* PATH_NormalizePoint
436 * Normalizes a point with respect to the box whose corners are passed in
437 * "corners". The normalized coordinates are stored in "*pX" and "*pY".
439 static void PATH_NormalizePoint(FLOAT_POINT corners
[],
440 const FLOAT_POINT
*pPoint
,
441 double *pX
, double *pY
)
443 *pX
=(double)(pPoint
->x
-corners
[0].x
)/(double)(corners
[1].x
-corners
[0].x
) * 2.0 - 1.0;
444 *pY
=(double)(pPoint
->y
-corners
[0].y
)/(double)(corners
[1].y
-corners
[0].y
) * 2.0 - 1.0;
449 * Creates a Bezier spline that corresponds to part of an arc and appends the
450 * corresponding points to the path. The start and end angles are passed in
451 * "angleStart" and "angleEnd"; these angles should span a quarter circle
452 * at most. If "startEntryType" is non-zero, an entry of that type for the first
453 * control point is added to the path; otherwise, it is assumed that the current
454 * position is equal to the first control point.
456 static BOOL
PATH_DoArcPart(struct gdi_path
*pPath
, FLOAT_POINT corners
[],
457 double angleStart
, double angleEnd
, BYTE startEntryType
)
460 double xNorm
[4], yNorm
[4];
464 assert(fabs(angleEnd
-angleStart
)<=M_PI_2
);
466 /* FIXME: Is there an easier way of computing this? */
468 /* Compute control points */
469 halfAngle
=(angleEnd
-angleStart
)/2.0;
470 if(fabs(halfAngle
)>1e-8)
472 a
=4.0/3.0*(1-cos(halfAngle
))/sin(halfAngle
);
473 xNorm
[0]=cos(angleStart
);
474 yNorm
[0]=sin(angleStart
);
475 xNorm
[1]=xNorm
[0] - a
*yNorm
[0];
476 yNorm
[1]=yNorm
[0] + a
*xNorm
[0];
477 xNorm
[3]=cos(angleEnd
);
478 yNorm
[3]=sin(angleEnd
);
479 xNorm
[2]=xNorm
[3] + a
*yNorm
[3];
480 yNorm
[2]=yNorm
[3] - a
*xNorm
[3];
485 xNorm
[i
]=cos(angleStart
);
486 yNorm
[i
]=sin(angleStart
);
489 /* Add starting point to path if desired */
492 PATH_ScaleNormalizedPoint(corners
, xNorm
[0], yNorm
[0], &point
);
493 if(!PATH_AddEntry(pPath
, &point
, startEntryType
))
497 /* Add remaining control points */
500 PATH_ScaleNormalizedPoint(corners
, xNorm
[i
], yNorm
[i
], &point
);
501 if(!PATH_AddEntry(pPath
, &point
, PT_BEZIERTO
))
509 /***********************************************************************
510 * BeginPath (GDI32.@)
512 BOOL WINAPI
BeginPath(HDC hdc
)
515 DC
*dc
= get_dc_ptr( hdc
);
519 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pBeginPath
);
520 ret
= physdev
->funcs
->pBeginPath( physdev
);
521 release_dc_ptr( dc
);
527 /***********************************************************************
530 BOOL WINAPI
EndPath(HDC hdc
)
533 DC
*dc
= get_dc_ptr( hdc
);
537 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pEndPath
);
538 ret
= physdev
->funcs
->pEndPath( physdev
);
539 release_dc_ptr( dc
);
545 /******************************************************************************
546 * AbortPath [GDI32.@]
547 * Closes and discards paths from device context
550 * Check that SetLastError is being called correctly
553 * hdc [I] Handle to device context
559 BOOL WINAPI
AbortPath( HDC hdc
)
562 DC
*dc
= get_dc_ptr( hdc
);
566 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pAbortPath
);
567 ret
= physdev
->funcs
->pAbortPath( physdev
);
568 release_dc_ptr( dc
);
574 /***********************************************************************
575 * CloseFigure (GDI32.@)
577 * FIXME: Check that SetLastError is being called correctly
579 BOOL WINAPI
CloseFigure(HDC hdc
)
582 DC
*dc
= get_dc_ptr( hdc
);
586 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pCloseFigure
);
587 ret
= physdev
->funcs
->pCloseFigure( physdev
);
588 release_dc_ptr( dc
);
594 /***********************************************************************
597 INT WINAPI
GetPath(HDC hdc
, LPPOINT pPoints
, LPBYTE pTypes
, INT nSize
)
600 DC
*dc
= get_dc_ptr( hdc
);
606 SetLastError(ERROR_CAN_NOT_COMPLETE
);
611 ret
= dc
->path
->count
;
612 else if(nSize
<dc
->path
->count
)
614 SetLastError(ERROR_INVALID_PARAMETER
);
619 memcpy(pPoints
, dc
->path
->points
, sizeof(POINT
)*dc
->path
->count
);
620 memcpy(pTypes
, dc
->path
->flags
, sizeof(BYTE
)*dc
->path
->count
);
622 /* Convert the points to logical coordinates */
623 if(!DPtoLP(hdc
, pPoints
, dc
->path
->count
))
625 /* FIXME: Is this the correct value? */
626 SetLastError(ERROR_CAN_NOT_COMPLETE
);
629 else ret
= dc
->path
->count
;
632 release_dc_ptr( dc
);
637 /***********************************************************************
638 * PathToRegion (GDI32.@)
641 * Check that SetLastError is being called correctly
643 * The documentation does not state this explicitly, but a test under Windows
644 * shows that the region which is returned should be in device coordinates.
646 HRGN WINAPI
PathToRegion(HDC hdc
)
649 DC
*dc
= get_dc_ptr( hdc
);
651 /* Get pointer to path */
654 if (!dc
->path
) SetLastError(ERROR_CAN_NOT_COMPLETE
);
657 if ((hrgnRval
= PATH_PathToRegion(dc
->path
, GetPolyFillMode(hdc
))))
659 /* FIXME: Should we empty the path even if conversion failed? */
660 free_gdi_path( dc
->path
);
664 release_dc_ptr( dc
);
668 static BOOL
PATH_FillPath( HDC hdc
, const struct gdi_path
*pPath
)
670 INT mapMode
, graphicsMode
;
671 SIZE ptViewportExt
, ptWindowExt
;
672 POINT ptViewportOrg
, ptWindowOrg
;
676 /* Construct a region from the path and fill it */
677 if ((hrgn
= PATH_PathToRegion(pPath
, GetPolyFillMode(hdc
))))
679 /* Since PaintRgn interprets the region as being in logical coordinates
680 * but the points we store for the path are already in device
681 * coordinates, we have to set the mapping mode to MM_TEXT temporarily.
682 * Using SaveDC to save information about the mapping mode / world
683 * transform would be easier but would require more overhead, especially
684 * now that SaveDC saves the current path.
687 /* Save the information about the old mapping mode */
688 mapMode
=GetMapMode(hdc
);
689 GetViewportExtEx(hdc
, &ptViewportExt
);
690 GetViewportOrgEx(hdc
, &ptViewportOrg
);
691 GetWindowExtEx(hdc
, &ptWindowExt
);
692 GetWindowOrgEx(hdc
, &ptWindowOrg
);
694 /* Save world transform
695 * NB: The Windows documentation on world transforms would lead one to
696 * believe that this has to be done only in GM_ADVANCED; however, my
697 * tests show that resetting the graphics mode to GM_COMPATIBLE does
698 * not reset the world transform.
700 GetWorldTransform(hdc
, &xform
);
703 SetMapMode(hdc
, MM_TEXT
);
704 SetViewportOrgEx(hdc
, 0, 0, NULL
);
705 SetWindowOrgEx(hdc
, 0, 0, NULL
);
706 graphicsMode
=GetGraphicsMode(hdc
);
707 SetGraphicsMode(hdc
, GM_ADVANCED
);
708 ModifyWorldTransform(hdc
, &xform
, MWT_IDENTITY
);
709 SetGraphicsMode(hdc
, graphicsMode
);
711 /* Paint the region */
714 /* Restore the old mapping mode */
715 SetMapMode(hdc
, mapMode
);
716 SetViewportExtEx(hdc
, ptViewportExt
.cx
, ptViewportExt
.cy
, NULL
);
717 SetViewportOrgEx(hdc
, ptViewportOrg
.x
, ptViewportOrg
.y
, NULL
);
718 SetWindowExtEx(hdc
, ptWindowExt
.cx
, ptWindowExt
.cy
, NULL
);
719 SetWindowOrgEx(hdc
, ptWindowOrg
.x
, ptWindowOrg
.y
, NULL
);
721 /* Go to GM_ADVANCED temporarily to restore the world transform */
722 graphicsMode
=GetGraphicsMode(hdc
);
723 SetGraphicsMode(hdc
, GM_ADVANCED
);
724 SetWorldTransform(hdc
, &xform
);
725 SetGraphicsMode(hdc
, graphicsMode
);
732 /***********************************************************************
736 * Check that SetLastError is being called correctly
738 BOOL WINAPI
FillPath(HDC hdc
)
741 DC
*dc
= get_dc_ptr( hdc
);
745 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pFillPath
);
746 ret
= physdev
->funcs
->pFillPath( physdev
);
747 release_dc_ptr( dc
);
753 /***********************************************************************
754 * SelectClipPath (GDI32.@)
756 * Check that SetLastError is being called correctly
758 BOOL WINAPI
SelectClipPath(HDC hdc
, INT iMode
)
761 DC
*dc
= get_dc_ptr( hdc
);
765 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pSelectClipPath
);
766 ret
= physdev
->funcs
->pSelectClipPath( physdev
, iMode
);
767 release_dc_ptr( dc
);
773 /***********************************************************************
776 static BOOL
pathdrv_BeginPath( PHYSDEV dev
)
778 /* path already open, nothing to do */
783 /***********************************************************************
786 static BOOL
pathdrv_AbortPath( PHYSDEV dev
)
788 struct path_physdev
*physdev
= get_path_physdev( dev
);
789 DC
*dc
= get_dc_ptr( dev
->hdc
);
791 if (!dc
) return FALSE
;
792 free_gdi_path( physdev
->path
);
793 pop_dc_driver( dc
, &path_driver
);
794 HeapFree( GetProcessHeap(), 0, physdev
);
795 release_dc_ptr( dc
);
800 /***********************************************************************
803 static BOOL
pathdrv_EndPath( PHYSDEV dev
)
805 struct path_physdev
*physdev
= get_path_physdev( dev
);
806 DC
*dc
= get_dc_ptr( dev
->hdc
);
808 if (!dc
) return FALSE
;
809 dc
->path
= physdev
->path
;
810 pop_dc_driver( dc
, &path_driver
);
811 HeapFree( GetProcessHeap(), 0, physdev
);
812 release_dc_ptr( dc
);
817 /***********************************************************************
820 static BOOL
pathdrv_CreateDC( PHYSDEV
*dev
, LPCWSTR driver
, LPCWSTR device
,
821 LPCWSTR output
, const DEVMODEW
*devmode
)
823 struct path_physdev
*physdev
= HeapAlloc( GetProcessHeap(), 0, sizeof(*physdev
) );
826 if (!physdev
) return FALSE
;
827 dc
= get_dc_ptr( (*dev
)->hdc
);
828 push_dc_driver( dev
, &physdev
->dev
, &path_driver
);
829 release_dc_ptr( dc
);
834 /*************************************************************
837 static BOOL
pathdrv_DeleteDC( PHYSDEV dev
)
839 assert( 0 ); /* should never be called */
844 BOOL
PATH_SavePath( DC
*dst
, DC
*src
)
850 if (!(dst
->path
= copy_gdi_path( src
->path
))) return FALSE
;
852 else if ((dev
= find_dc_driver( src
, &path_driver
)))
854 struct path_physdev
*physdev
= get_path_physdev( dev
);
855 if (!(dst
->path
= copy_gdi_path( physdev
->path
))) return FALSE
;
856 dst
->path_open
= TRUE
;
858 else dst
->path
= NULL
;
862 BOOL
PATH_RestorePath( DC
*dst
, DC
*src
)
865 struct path_physdev
*physdev
;
867 if ((dev
= pop_dc_driver( dst
, &path_driver
)))
869 physdev
= get_path_physdev( dev
);
870 free_gdi_path( physdev
->path
);
871 HeapFree( GetProcessHeap(), 0, physdev
);
874 if (src
->path
&& src
->path_open
)
876 if (!path_driver
.pCreateDC( &dst
->physDev
, NULL
, NULL
, NULL
, NULL
)) return FALSE
;
877 physdev
= get_path_physdev( find_dc_driver( dst
, &path_driver
));
878 physdev
->path
= src
->path
;
879 src
->path_open
= FALSE
;
883 if (dst
->path
) free_gdi_path( dst
->path
);
884 dst
->path
= src
->path
;
890 /*************************************************************
893 static BOOL
pathdrv_MoveTo( PHYSDEV dev
, INT x
, INT y
)
895 struct path_physdev
*physdev
= get_path_physdev( dev
);
896 physdev
->path
->newStroke
= TRUE
;
901 /*************************************************************
904 static BOOL
pathdrv_LineTo( PHYSDEV dev
, INT x
, INT y
)
906 struct path_physdev
*physdev
= get_path_physdev( dev
);
909 if (!start_new_stroke( physdev
)) return FALSE
;
912 return add_log_points( physdev
, &point
, 1, PT_LINETO
) != NULL
;
916 /*************************************************************
919 * FIXME: it adds the same entries to the path as windows does, but there
920 * is an error in the bezier drawing code so that there are small pixel-size
921 * gaps when the resulting path is drawn by StrokePath()
923 static BOOL
pathdrv_RoundRect( PHYSDEV dev
, INT x1
, INT y1
, INT x2
, INT y2
, INT ell_width
, INT ell_height
)
925 struct path_physdev
*physdev
= get_path_physdev( dev
);
926 POINT corners
[2], pointTemp
;
927 FLOAT_POINT ellCorners
[2];
929 PATH_CheckCorners(dev
->hdc
,corners
,x1
,y1
,x2
,y2
);
931 /* Add points to the roundrect path */
932 ellCorners
[0].x
= corners
[1].x
-ell_width
;
933 ellCorners
[0].y
= corners
[0].y
;
934 ellCorners
[1].x
= corners
[1].x
;
935 ellCorners
[1].y
= corners
[0].y
+ell_height
;
936 if(!PATH_DoArcPart(physdev
->path
, ellCorners
, 0, -M_PI_2
, PT_MOVETO
))
938 pointTemp
.x
= corners
[0].x
+ell_width
/2;
939 pointTemp
.y
= corners
[0].y
;
940 if(!PATH_AddEntry(physdev
->path
, &pointTemp
, PT_LINETO
))
942 ellCorners
[0].x
= corners
[0].x
;
943 ellCorners
[1].x
= corners
[0].x
+ell_width
;
944 if(!PATH_DoArcPart(physdev
->path
, ellCorners
, -M_PI_2
, -M_PI
, FALSE
))
946 pointTemp
.x
= corners
[0].x
;
947 pointTemp
.y
= corners
[1].y
-ell_height
/2;
948 if(!PATH_AddEntry(physdev
->path
, &pointTemp
, PT_LINETO
))
950 ellCorners
[0].y
= corners
[1].y
-ell_height
;
951 ellCorners
[1].y
= corners
[1].y
;
952 if(!PATH_DoArcPart(physdev
->path
, ellCorners
, M_PI
, M_PI_2
, FALSE
))
954 pointTemp
.x
= corners
[1].x
-ell_width
/2;
955 pointTemp
.y
= corners
[1].y
;
956 if(!PATH_AddEntry(physdev
->path
, &pointTemp
, PT_LINETO
))
958 ellCorners
[0].x
= corners
[1].x
-ell_width
;
959 ellCorners
[1].x
= corners
[1].x
;
960 if(!PATH_DoArcPart(physdev
->path
, ellCorners
, M_PI_2
, 0, FALSE
))
963 /* Close the roundrect figure */
964 return CloseFigure( dev
->hdc
);
968 /*************************************************************
971 static BOOL
pathdrv_Rectangle( PHYSDEV dev
, INT x1
, INT y1
, INT x2
, INT y2
)
973 struct path_physdev
*physdev
= get_path_physdev( dev
);
974 POINT corners
[2], pointTemp
;
976 PATH_CheckCorners(dev
->hdc
,corners
,x1
,y1
,x2
,y2
);
978 /* Add four points to the path */
979 pointTemp
.x
=corners
[1].x
;
980 pointTemp
.y
=corners
[0].y
;
981 if(!PATH_AddEntry(physdev
->path
, &pointTemp
, PT_MOVETO
))
983 if(!PATH_AddEntry(physdev
->path
, corners
, PT_LINETO
))
985 pointTemp
.x
=corners
[0].x
;
986 pointTemp
.y
=corners
[1].y
;
987 if(!PATH_AddEntry(physdev
->path
, &pointTemp
, PT_LINETO
))
989 if(!PATH_AddEntry(physdev
->path
, corners
+1, PT_LINETO
))
992 /* Close the rectangle figure */
993 return CloseFigure( dev
->hdc
);
999 * Should be called when a call to Arc is performed on a DC that has
1000 * an open path. This adds up to five Bezier splines representing the arc
1001 * to the path. When 'lines' is 1, we add 1 extra line to get a chord,
1002 * when 'lines' is 2, we add 2 extra lines to get a pie, and when 'lines' is
1003 * -1 we add 1 extra line from the current DC position to the starting position
1004 * of the arc before drawing the arc itself (arcto). Returns TRUE if successful,
1007 static BOOL
PATH_Arc( PHYSDEV dev
, INT x1
, INT y1
, INT x2
, INT y2
,
1008 INT xStart
, INT yStart
, INT xEnd
, INT yEnd
, INT lines
)
1010 struct path_physdev
*physdev
= get_path_physdev( dev
);
1011 double angleStart
, angleEnd
, angleStartQuadrant
, angleEndQuadrant
=0.0;
1012 /* Initialize angleEndQuadrant to silence gcc's warning */
1014 FLOAT_POINT corners
[2], pointStart
, pointEnd
;
1017 INT temp
, direction
= GetArcDirection(dev
->hdc
);
1019 /* FIXME: Do we have to respect newStroke? */
1021 /* Check for zero height / width */
1022 /* FIXME: Only in GM_COMPATIBLE? */
1023 if(x1
==x2
|| y1
==y2
)
1026 /* Convert points to device coordinates */
1031 pointStart
.x
= xStart
;
1032 pointStart
.y
= yStart
;
1035 INTERNAL_LPTODP_FLOAT(dev
->hdc
, corners
, 2);
1036 INTERNAL_LPTODP_FLOAT(dev
->hdc
, &pointStart
, 1);
1037 INTERNAL_LPTODP_FLOAT(dev
->hdc
, &pointEnd
, 1);
1039 /* Make sure first corner is top left and second corner is bottom right */
1040 if(corners
[0].x
>corners
[1].x
)
1043 corners
[0].x
=corners
[1].x
;
1046 if(corners
[0].y
>corners
[1].y
)
1049 corners
[0].y
=corners
[1].y
;
1053 /* Compute start and end angle */
1054 PATH_NormalizePoint(corners
, &pointStart
, &x
, &y
);
1055 angleStart
=atan2(y
, x
);
1056 PATH_NormalizePoint(corners
, &pointEnd
, &x
, &y
);
1057 angleEnd
=atan2(y
, x
);
1059 /* Make sure the end angle is "on the right side" of the start angle */
1060 if (direction
== AD_CLOCKWISE
)
1062 if(angleEnd
<=angleStart
)
1065 assert(angleEnd
>=angleStart
);
1070 if(angleEnd
>=angleStart
)
1073 assert(angleEnd
<=angleStart
);
1077 /* In GM_COMPATIBLE, don't include bottom and right edges */
1078 if (GetGraphicsMode(dev
->hdc
) == GM_COMPATIBLE
)
1084 /* arcto: Add a PT_MOVETO only if this is the first entry in a stroke */
1085 if (lines
==-1 && !start_new_stroke( physdev
)) return FALSE
;
1087 /* Add the arc to the path with one Bezier spline per quadrant that the
1093 /* Determine the start and end angles for this quadrant */
1096 angleStartQuadrant
=angleStart
;
1097 if (direction
== AD_CLOCKWISE
)
1098 angleEndQuadrant
=(floor(angleStart
/M_PI_2
)+1.0)*M_PI_2
;
1100 angleEndQuadrant
=(ceil(angleStart
/M_PI_2
)-1.0)*M_PI_2
;
1104 angleStartQuadrant
=angleEndQuadrant
;
1105 if (direction
== AD_CLOCKWISE
)
1106 angleEndQuadrant
+=M_PI_2
;
1108 angleEndQuadrant
-=M_PI_2
;
1111 /* Have we reached the last part of the arc? */
1112 if((direction
== AD_CLOCKWISE
&& angleEnd
<angleEndQuadrant
) ||
1113 (direction
== AD_COUNTERCLOCKWISE
&& angleEnd
>angleEndQuadrant
))
1115 /* Adjust the end angle for this quadrant */
1116 angleEndQuadrant
=angleEnd
;
1120 /* Add the Bezier spline to the path */
1121 PATH_DoArcPart(physdev
->path
, corners
, angleStartQuadrant
, angleEndQuadrant
,
1122 start
? (lines
==-1 ? PT_LINETO
: PT_MOVETO
) : FALSE
);
1126 /* chord: close figure. pie: add line and close figure */
1129 return CloseFigure(dev
->hdc
);
1133 centre
.x
= (corners
[0].x
+corners
[1].x
)/2;
1134 centre
.y
= (corners
[0].y
+corners
[1].y
)/2;
1135 if(!PATH_AddEntry(physdev
->path
, ¢re
, PT_LINETO
| PT_CLOSEFIGURE
))
1143 /*************************************************************
1146 static BOOL
pathdrv_AngleArc( PHYSDEV dev
, INT x
, INT y
, DWORD radius
, FLOAT eStartAngle
, FLOAT eSweepAngle
)
1148 INT x1
, y1
, x2
, y2
, arcdir
;
1151 x1
= GDI_ROUND( x
+ cos(eStartAngle
*M_PI
/180) * radius
);
1152 y1
= GDI_ROUND( y
- sin(eStartAngle
*M_PI
/180) * radius
);
1153 x2
= GDI_ROUND( x
+ cos((eStartAngle
+eSweepAngle
)*M_PI
/180) * radius
);
1154 y2
= GDI_ROUND( y
- sin((eStartAngle
+eSweepAngle
)*M_PI
/180) * radius
);
1155 arcdir
= SetArcDirection( dev
->hdc
, eSweepAngle
>= 0 ? AD_COUNTERCLOCKWISE
: AD_CLOCKWISE
);
1156 ret
= PATH_Arc( dev
, x
-radius
, y
-radius
, x
+radius
, y
+radius
, x1
, y1
, x2
, y2
, -1 );
1157 SetArcDirection( dev
->hdc
, arcdir
);
1162 /*************************************************************
1165 static BOOL
pathdrv_Arc( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
1166 INT xstart
, INT ystart
, INT xend
, INT yend
)
1168 return PATH_Arc( dev
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
, 0 );
1172 /*************************************************************
1175 static BOOL
pathdrv_ArcTo( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
1176 INT xstart
, INT ystart
, INT xend
, INT yend
)
1178 return PATH_Arc( dev
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
, -1 );
1182 /*************************************************************
1185 static BOOL
pathdrv_Chord( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
1186 INT xstart
, INT ystart
, INT xend
, INT yend
)
1188 return PATH_Arc( dev
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
, 1);
1192 /*************************************************************
1195 static BOOL
pathdrv_Pie( PHYSDEV dev
, INT left
, INT top
, INT right
, INT bottom
,
1196 INT xstart
, INT ystart
, INT xend
, INT yend
)
1198 return PATH_Arc( dev
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
, 2 );
1202 /*************************************************************
1205 static BOOL
pathdrv_Ellipse( PHYSDEV dev
, INT x1
, INT y1
, INT x2
, INT y2
)
1207 return PATH_Arc( dev
, x1
, y1
, x2
, y2
, x1
, (y1
+y2
)/2, x1
, (y1
+y2
)/2, 0 ) && CloseFigure( dev
->hdc
);
1211 /*************************************************************
1212 * pathdrv_PolyBezierTo
1214 static BOOL
pathdrv_PolyBezierTo( PHYSDEV dev
, const POINT
*pts
, DWORD cbPoints
)
1216 struct path_physdev
*physdev
= get_path_physdev( dev
);
1218 if (!start_new_stroke( physdev
)) return FALSE
;
1219 return add_log_points( physdev
, pts
, cbPoints
, PT_BEZIERTO
) != NULL
;
1223 /*************************************************************
1224 * pathdrv_PolyBezier
1226 static BOOL
pathdrv_PolyBezier( PHYSDEV dev
, const POINT
*pts
, DWORD cbPoints
)
1228 struct path_physdev
*physdev
= get_path_physdev( dev
);
1229 BYTE
*type
= add_log_points( physdev
, pts
, cbPoints
, PT_BEZIERTO
);
1231 if (!type
) return FALSE
;
1232 type
[0] = PT_MOVETO
;
1237 /*************************************************************
1240 static BOOL
pathdrv_PolyDraw( PHYSDEV dev
, const POINT
*pts
, const BYTE
*types
, DWORD cbPoints
)
1242 struct path_physdev
*physdev
= get_path_physdev( dev
);
1243 POINT lastmove
, orig_pos
;
1246 GetCurrentPositionEx( dev
->hdc
, &orig_pos
);
1247 lastmove
= orig_pos
;
1249 for(i
= physdev
->path
->count
- 1; i
>= 0; i
--){
1250 if(physdev
->path
->flags
[i
] == PT_MOVETO
){
1251 lastmove
= physdev
->path
->points
[i
];
1252 DPtoLP(dev
->hdc
, &lastmove
, 1);
1257 for(i
= 0; i
< cbPoints
; i
++)
1262 MoveToEx( dev
->hdc
, pts
[i
].x
, pts
[i
].y
, NULL
);
1265 case PT_LINETO
| PT_CLOSEFIGURE
:
1266 LineTo( dev
->hdc
, pts
[i
].x
, pts
[i
].y
);
1269 if ((i
+ 2 < cbPoints
) && (types
[i
+ 1] == PT_BEZIERTO
) &&
1270 (types
[i
+ 2] & ~PT_CLOSEFIGURE
) == PT_BEZIERTO
)
1272 PolyBezierTo( dev
->hdc
, &pts
[i
], 3 );
1278 if (i
) /* restore original position */
1280 if (!(types
[i
- 1] & PT_CLOSEFIGURE
)) lastmove
= pts
[i
- 1];
1281 if (lastmove
.x
!= orig_pos
.x
|| lastmove
.y
!= orig_pos
.y
)
1282 MoveToEx( dev
->hdc
, orig_pos
.x
, orig_pos
.y
, NULL
);
1287 if(types
[i
] & PT_CLOSEFIGURE
){
1288 physdev
->path
->flags
[physdev
->path
->count
-1] |= PT_CLOSEFIGURE
;
1289 MoveToEx( dev
->hdc
, lastmove
.x
, lastmove
.y
, NULL
);
1297 /*************************************************************
1300 static BOOL
pathdrv_Polyline( PHYSDEV dev
, const POINT
*pts
, INT cbPoints
)
1302 struct path_physdev
*physdev
= get_path_physdev( dev
);
1303 BYTE
*type
= add_log_points( physdev
, pts
, cbPoints
, PT_LINETO
);
1305 if (!type
) return FALSE
;
1306 if (cbPoints
) type
[0] = PT_MOVETO
;
1311 /*************************************************************
1312 * pathdrv_PolylineTo
1314 static BOOL
pathdrv_PolylineTo( PHYSDEV dev
, const POINT
*pts
, INT cbPoints
)
1316 struct path_physdev
*physdev
= get_path_physdev( dev
);
1318 if (!start_new_stroke( physdev
)) return FALSE
;
1319 return add_log_points( physdev
, pts
, cbPoints
, PT_LINETO
) != NULL
;
1323 /*************************************************************
1326 static BOOL
pathdrv_Polygon( PHYSDEV dev
, const POINT
*pts
, INT cbPoints
)
1328 struct path_physdev
*physdev
= get_path_physdev( dev
);
1329 BYTE
*type
= add_log_points( physdev
, pts
, cbPoints
, PT_LINETO
);
1331 if (!type
) return FALSE
;
1332 if (cbPoints
) type
[0] = PT_MOVETO
;
1333 if (cbPoints
> 1) type
[cbPoints
- 1] = PT_LINETO
| PT_CLOSEFIGURE
;
1338 /*************************************************************
1339 * pathdrv_PolyPolygon
1341 static BOOL
pathdrv_PolyPolygon( PHYSDEV dev
, const POINT
* pts
, const INT
* counts
, UINT polygons
)
1343 struct path_physdev
*physdev
= get_path_physdev( dev
);
1347 for(poly
= 0; poly
< polygons
; poly
++) {
1348 type
= add_log_points( physdev
, pts
, counts
[poly
], PT_LINETO
);
1349 if (!type
) return FALSE
;
1350 type
[0] = PT_MOVETO
;
1351 /* win98 adds an extra line to close the figure for some reason */
1352 add_log_points( physdev
, pts
, 1, PT_LINETO
| PT_CLOSEFIGURE
);
1353 pts
+= counts
[poly
];
1359 /*************************************************************
1360 * pathdrv_PolyPolyline
1362 static BOOL
pathdrv_PolyPolyline( PHYSDEV dev
, const POINT
* pts
, const DWORD
* counts
, DWORD polylines
)
1364 struct path_physdev
*physdev
= get_path_physdev( dev
);
1368 for (poly
= count
= 0; poly
< polylines
; poly
++) count
+= counts
[poly
];
1370 type
= add_log_points( physdev
, pts
, count
, PT_LINETO
);
1371 if (!type
) return FALSE
;
1373 /* make the first point of each polyline a PT_MOVETO */
1374 for (poly
= 0; poly
< polylines
; poly
++, type
+= counts
[poly
]) *type
= PT_MOVETO
;
1379 /**********************************************************************
1382 * internally used by PATH_add_outline
1384 static void PATH_BezierTo(struct gdi_path
*pPath
, POINT
*lppt
, INT n
)
1390 PATH_AddEntry(pPath
, &lppt
[1], PT_LINETO
);
1394 PATH_AddEntry(pPath
, &lppt
[0], PT_BEZIERTO
);
1395 PATH_AddEntry(pPath
, &lppt
[1], PT_BEZIERTO
);
1396 PATH_AddEntry(pPath
, &lppt
[2], PT_BEZIERTO
);
1410 pt
[2].x
= (lppt
[i
+2].x
+ lppt
[i
+1].x
) / 2;
1411 pt
[2].y
= (lppt
[i
+2].y
+ lppt
[i
+1].y
) / 2;
1412 PATH_BezierTo(pPath
, pt
, 3);
1420 PATH_BezierTo(pPath
, pt
, 3);
1424 static BOOL
PATH_add_outline(struct path_physdev
*physdev
, INT x
, INT y
,
1425 TTPOLYGONHEADER
*header
, DWORD size
)
1427 TTPOLYGONHEADER
*start
;
1432 while ((char *)header
< (char *)start
+ size
)
1436 if (header
->dwType
!= TT_POLYGON_TYPE
)
1438 FIXME("Unknown header type %d\n", header
->dwType
);
1442 pt
.x
= x
+ int_from_fixed(header
->pfxStart
.x
);
1443 pt
.y
= y
- int_from_fixed(header
->pfxStart
.y
);
1444 PATH_AddEntry(physdev
->path
, &pt
, PT_MOVETO
);
1446 curve
= (TTPOLYCURVE
*)(header
+ 1);
1448 while ((char *)curve
< (char *)header
+ header
->cb
)
1450 /*TRACE("curve->wType %d\n", curve->wType);*/
1452 switch(curve
->wType
)
1458 for (i
= 0; i
< curve
->cpfx
; i
++)
1460 pt
.x
= x
+ int_from_fixed(curve
->apfx
[i
].x
);
1461 pt
.y
= y
- int_from_fixed(curve
->apfx
[i
].y
);
1462 PATH_AddEntry(physdev
->path
, &pt
, PT_LINETO
);
1467 case TT_PRIM_QSPLINE
:
1468 case TT_PRIM_CSPLINE
:
1472 POINT
*pts
= HeapAlloc(GetProcessHeap(), 0, (curve
->cpfx
+ 1) * sizeof(POINT
));
1474 if (!pts
) return FALSE
;
1476 ptfx
= *(POINTFX
*)((char *)curve
- sizeof(POINTFX
));
1478 pts
[0].x
= x
+ int_from_fixed(ptfx
.x
);
1479 pts
[0].y
= y
- int_from_fixed(ptfx
.y
);
1481 for(i
= 0; i
< curve
->cpfx
; i
++)
1483 pts
[i
+ 1].x
= x
+ int_from_fixed(curve
->apfx
[i
].x
);
1484 pts
[i
+ 1].y
= y
- int_from_fixed(curve
->apfx
[i
].y
);
1487 PATH_BezierTo(physdev
->path
, pts
, curve
->cpfx
+ 1);
1489 HeapFree(GetProcessHeap(), 0, pts
);
1494 FIXME("Unknown curve type %04x\n", curve
->wType
);
1498 curve
= (TTPOLYCURVE
*)&curve
->apfx
[curve
->cpfx
];
1501 header
= (TTPOLYGONHEADER
*)((char *)header
+ header
->cb
);
1504 return CloseFigure(physdev
->dev
.hdc
);
1507 /*************************************************************
1508 * pathdrv_ExtTextOut
1510 static BOOL
pathdrv_ExtTextOut( PHYSDEV dev
, INT x
, INT y
, UINT flags
, const RECT
*lprc
,
1511 LPCWSTR str
, UINT count
, const INT
*dx
)
1513 struct path_physdev
*physdev
= get_path_physdev( dev
);
1515 POINT offset
= {0, 0};
1517 if (!count
) return TRUE
;
1519 for (idx
= 0; idx
< count
; idx
++)
1521 static const MAT2 identity
= { {0,1},{0,0},{0,0},{0,1} };
1526 dwSize
= GetGlyphOutlineW(dev
->hdc
, str
[idx
], GGO_GLYPH_INDEX
| GGO_NATIVE
,
1527 &gm
, 0, NULL
, &identity
);
1528 if (dwSize
== GDI_ERROR
) return FALSE
;
1530 /* add outline only if char is printable */
1533 outline
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
1534 if (!outline
) return FALSE
;
1536 GetGlyphOutlineW(dev
->hdc
, str
[idx
], GGO_GLYPH_INDEX
| GGO_NATIVE
,
1537 &gm
, dwSize
, outline
, &identity
);
1539 PATH_add_outline(physdev
, x
+ offset
.x
, y
+ offset
.y
, outline
, dwSize
);
1541 HeapFree(GetProcessHeap(), 0, outline
);
1548 offset
.x
+= dx
[idx
* 2];
1549 offset
.y
+= dx
[idx
* 2 + 1];
1552 offset
.x
+= dx
[idx
];
1556 offset
.x
+= gm
.gmCellIncX
;
1557 offset
.y
+= gm
.gmCellIncY
;
1564 /*************************************************************
1565 * pathdrv_CloseFigure
1567 static BOOL
pathdrv_CloseFigure( PHYSDEV dev
)
1569 struct path_physdev
*physdev
= get_path_physdev( dev
);
1571 /* Set PT_CLOSEFIGURE on the last entry and start a new stroke */
1572 /* It is not necessary to draw a line, PT_CLOSEFIGURE is a virtual closing line itself */
1573 if (physdev
->path
->count
)
1574 physdev
->path
->flags
[physdev
->path
->count
- 1] |= PT_CLOSEFIGURE
;
1579 /*******************************************************************
1580 * FlattenPath [GDI32.@]
1584 BOOL WINAPI
FlattenPath(HDC hdc
)
1587 DC
*dc
= get_dc_ptr( hdc
);
1591 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pFlattenPath
);
1592 ret
= physdev
->funcs
->pFlattenPath( physdev
);
1593 release_dc_ptr( dc
);
1599 static BOOL
PATH_StrokePath( HDC hdc
, const struct gdi_path
*pPath
)
1601 INT i
, nLinePts
, nAlloc
;
1603 POINT ptViewportOrg
, ptWindowOrg
;
1604 SIZE szViewportExt
, szWindowExt
;
1605 DWORD mapMode
, graphicsMode
;
1609 /* Save the mapping mode info */
1610 mapMode
=GetMapMode(hdc
);
1611 GetViewportExtEx(hdc
, &szViewportExt
);
1612 GetViewportOrgEx(hdc
, &ptViewportOrg
);
1613 GetWindowExtEx(hdc
, &szWindowExt
);
1614 GetWindowOrgEx(hdc
, &ptWindowOrg
);
1615 GetWorldTransform(hdc
, &xform
);
1618 SetMapMode(hdc
, MM_TEXT
);
1619 SetViewportOrgEx(hdc
, 0, 0, NULL
);
1620 SetWindowOrgEx(hdc
, 0, 0, NULL
);
1621 graphicsMode
=GetGraphicsMode(hdc
);
1622 SetGraphicsMode(hdc
, GM_ADVANCED
);
1623 ModifyWorldTransform(hdc
, &xform
, MWT_IDENTITY
);
1624 SetGraphicsMode(hdc
, graphicsMode
);
1626 /* Allocate enough memory for the worst case without beziers (one PT_MOVETO
1627 * and the rest PT_LINETO with PT_CLOSEFIGURE at the end) plus some buffer
1628 * space in case we get one to keep the number of reallocations small. */
1629 nAlloc
= pPath
->count
+ 1 + 300;
1630 pLinePts
= HeapAlloc(GetProcessHeap(), 0, nAlloc
* sizeof(POINT
));
1633 for(i
= 0; i
< pPath
->count
; i
++) {
1634 if((i
== 0 || (pPath
->flags
[i
-1] & PT_CLOSEFIGURE
)) &&
1635 (pPath
->flags
[i
] != PT_MOVETO
)) {
1636 ERR("Expected PT_MOVETO %s, got path flag %d\n",
1637 i
== 0 ? "as first point" : "after PT_CLOSEFIGURE",
1642 switch(pPath
->flags
[i
]) {
1644 TRACE("Got PT_MOVETO (%d, %d)\n",
1645 pPath
->points
[i
].x
, pPath
->points
[i
].y
);
1647 Polyline(hdc
, pLinePts
, nLinePts
);
1649 pLinePts
[nLinePts
++] = pPath
->points
[i
];
1652 case (PT_LINETO
| PT_CLOSEFIGURE
):
1653 TRACE("Got PT_LINETO (%d, %d)\n",
1654 pPath
->points
[i
].x
, pPath
->points
[i
].y
);
1655 pLinePts
[nLinePts
++] = pPath
->points
[i
];
1658 TRACE("Got PT_BEZIERTO\n");
1659 if(pPath
->flags
[i
+1] != PT_BEZIERTO
||
1660 (pPath
->flags
[i
+2] & ~PT_CLOSEFIGURE
) != PT_BEZIERTO
) {
1661 ERR("Path didn't contain 3 successive PT_BEZIERTOs\n");
1665 INT nBzrPts
, nMinAlloc
;
1666 POINT
*pBzrPts
= GDI_Bezier(&pPath
->points
[i
-1], 4, &nBzrPts
);
1667 /* Make sure we have allocated enough memory for the lines of
1668 * this bezier and the rest of the path, assuming we won't get
1669 * another one (since we won't reallocate again then). */
1670 nMinAlloc
= nLinePts
+ (pPath
->count
- i
) + nBzrPts
;
1671 if(nAlloc
< nMinAlloc
)
1673 nAlloc
= nMinAlloc
* 2;
1674 pLinePts
= HeapReAlloc(GetProcessHeap(), 0, pLinePts
,
1675 nAlloc
* sizeof(POINT
));
1677 memcpy(&pLinePts
[nLinePts
], &pBzrPts
[1],
1678 (nBzrPts
- 1) * sizeof(POINT
));
1679 nLinePts
+= nBzrPts
- 1;
1680 HeapFree(GetProcessHeap(), 0, pBzrPts
);
1685 ERR("Got path flag %d\n", pPath
->flags
[i
]);
1689 if(pPath
->flags
[i
] & PT_CLOSEFIGURE
)
1690 pLinePts
[nLinePts
++] = pLinePts
[0];
1693 Polyline(hdc
, pLinePts
, nLinePts
);
1696 HeapFree(GetProcessHeap(), 0, pLinePts
);
1698 /* Restore the old mapping mode */
1699 SetMapMode(hdc
, mapMode
);
1700 SetWindowExtEx(hdc
, szWindowExt
.cx
, szWindowExt
.cy
, NULL
);
1701 SetWindowOrgEx(hdc
, ptWindowOrg
.x
, ptWindowOrg
.y
, NULL
);
1702 SetViewportExtEx(hdc
, szViewportExt
.cx
, szViewportExt
.cy
, NULL
);
1703 SetViewportOrgEx(hdc
, ptViewportOrg
.x
, ptViewportOrg
.y
, NULL
);
1705 /* Go to GM_ADVANCED temporarily to restore the world transform */
1706 graphicsMode
=GetGraphicsMode(hdc
);
1707 SetGraphicsMode(hdc
, GM_ADVANCED
);
1708 SetWorldTransform(hdc
, &xform
);
1709 SetGraphicsMode(hdc
, graphicsMode
);
1711 /* If we've moved the current point then get its new position
1712 which will be in device (MM_TEXT) co-ords, convert it to
1713 logical co-ords and re-set it. This basically updates
1714 dc->CurPosX|Y so that their values are in the correct mapping
1719 GetCurrentPositionEx(hdc
, &pt
);
1720 DPtoLP(hdc
, &pt
, 1);
1721 MoveToEx(hdc
, pt
.x
, pt
.y
, NULL
);
1727 #define round(x) ((int)((x)>0?(x)+0.5:(x)-0.5))
1729 static struct gdi_path
*PATH_WidenPath(DC
*dc
)
1731 INT i
, j
, numStrokes
, penWidth
, penWidthIn
, penWidthOut
, size
, penStyle
;
1732 struct gdi_path
*flat_path
, *pNewPath
, **pStrokes
= NULL
, *pUpPath
, *pDownPath
;
1734 DWORD obj_type
, joint
, endcap
, penType
;
1736 size
= GetObjectW( dc
->hPen
, 0, NULL
);
1738 SetLastError(ERROR_CAN_NOT_COMPLETE
);
1742 elp
= HeapAlloc( GetProcessHeap(), 0, size
);
1743 GetObjectW( dc
->hPen
, size
, elp
);
1745 obj_type
= GetObjectType(dc
->hPen
);
1746 if(obj_type
== OBJ_PEN
) {
1747 penStyle
= ((LOGPEN
*)elp
)->lopnStyle
;
1749 else if(obj_type
== OBJ_EXTPEN
) {
1750 penStyle
= elp
->elpPenStyle
;
1753 SetLastError(ERROR_CAN_NOT_COMPLETE
);
1754 HeapFree( GetProcessHeap(), 0, elp
);
1758 penWidth
= elp
->elpWidth
;
1759 HeapFree( GetProcessHeap(), 0, elp
);
1761 endcap
= (PS_ENDCAP_MASK
& penStyle
);
1762 joint
= (PS_JOIN_MASK
& penStyle
);
1763 penType
= (PS_TYPE_MASK
& penStyle
);
1765 /* The function cannot apply to cosmetic pens */
1766 if(obj_type
== OBJ_EXTPEN
&& penType
== PS_COSMETIC
) {
1767 SetLastError(ERROR_CAN_NOT_COMPLETE
);
1771 if (!(flat_path
= PATH_FlattenPath( dc
->path
))) return NULL
;
1773 penWidthIn
= penWidth
/ 2;
1774 penWidthOut
= penWidth
/ 2;
1775 if(penWidthIn
+ penWidthOut
< penWidth
)
1780 for(i
= 0, j
= 0; i
< flat_path
->count
; i
++, j
++) {
1782 if((i
== 0 || (flat_path
->flags
[i
-1] & PT_CLOSEFIGURE
)) &&
1783 (flat_path
->flags
[i
] != PT_MOVETO
)) {
1784 ERR("Expected PT_MOVETO %s, got path flag %c\n",
1785 i
== 0 ? "as first point" : "after PT_CLOSEFIGURE",
1786 flat_path
->flags
[i
]);
1787 free_gdi_path( flat_path
);
1790 switch(flat_path
->flags
[i
]) {
1795 pStrokes
= HeapAlloc(GetProcessHeap(), 0, sizeof(*pStrokes
));
1797 pStrokes
= HeapReAlloc(GetProcessHeap(), 0, pStrokes
, numStrokes
* sizeof(*pStrokes
));
1798 if(!pStrokes
) return NULL
;
1799 pStrokes
[numStrokes
- 1] = alloc_gdi_path(0);
1802 case (PT_LINETO
| PT_CLOSEFIGURE
):
1803 point
.x
= flat_path
->points
[i
].x
;
1804 point
.y
= flat_path
->points
[i
].y
;
1805 PATH_AddEntry(pStrokes
[numStrokes
- 1], &point
, flat_path
->flags
[i
]);
1808 /* should never happen because of the FlattenPath call */
1809 ERR("Should never happen\n");
1812 ERR("Got path flag %c\n", flat_path
->flags
[i
]);
1817 pNewPath
= alloc_gdi_path( flat_path
->count
);
1819 for(i
= 0; i
< numStrokes
; i
++) {
1820 pUpPath
= alloc_gdi_path( pStrokes
[i
]->count
);
1821 pDownPath
= alloc_gdi_path( pStrokes
[i
]->count
);
1823 for(j
= 0; j
< pStrokes
[i
]->count
; j
++) {
1824 /* Beginning or end of the path if not closed */
1825 if((!(pStrokes
[i
]->flags
[pStrokes
[i
]->count
- 1] & PT_CLOSEFIGURE
)) && (j
== 0 || j
== pStrokes
[i
]->count
- 1) ) {
1826 /* Compute segment angle */
1827 double xo
, yo
, xa
, ya
, theta
;
1829 FLOAT_POINT corners
[2];
1831 xo
= pStrokes
[i
]->points
[j
].x
;
1832 yo
= pStrokes
[i
]->points
[j
].y
;
1833 xa
= pStrokes
[i
]->points
[1].x
;
1834 ya
= pStrokes
[i
]->points
[1].y
;
1837 xa
= pStrokes
[i
]->points
[j
- 1].x
;
1838 ya
= pStrokes
[i
]->points
[j
- 1].y
;
1839 xo
= pStrokes
[i
]->points
[j
].x
;
1840 yo
= pStrokes
[i
]->points
[j
].y
;
1842 theta
= atan2( ya
- yo
, xa
- xo
);
1844 case PS_ENDCAP_SQUARE
:
1845 pt
.x
= xo
+ round(sqrt(2) * penWidthOut
* cos(M_PI_4
+ theta
));
1846 pt
.y
= yo
+ round(sqrt(2) * penWidthOut
* sin(M_PI_4
+ theta
));
1847 PATH_AddEntry(pUpPath
, &pt
, (j
== 0 ? PT_MOVETO
: PT_LINETO
) );
1848 pt
.x
= xo
+ round(sqrt(2) * penWidthIn
* cos(- M_PI_4
+ theta
));
1849 pt
.y
= yo
+ round(sqrt(2) * penWidthIn
* sin(- M_PI_4
+ theta
));
1850 PATH_AddEntry(pUpPath
, &pt
, PT_LINETO
);
1852 case PS_ENDCAP_FLAT
:
1853 pt
.x
= xo
+ round( penWidthOut
* cos(theta
+ M_PI_2
) );
1854 pt
.y
= yo
+ round( penWidthOut
* sin(theta
+ M_PI_2
) );
1855 PATH_AddEntry(pUpPath
, &pt
, (j
== 0 ? PT_MOVETO
: PT_LINETO
));
1856 pt
.x
= xo
- round( penWidthIn
* cos(theta
+ M_PI_2
) );
1857 pt
.y
= yo
- round( penWidthIn
* sin(theta
+ M_PI_2
) );
1858 PATH_AddEntry(pUpPath
, &pt
, PT_LINETO
);
1860 case PS_ENDCAP_ROUND
:
1862 corners
[0].x
= xo
- penWidthIn
;
1863 corners
[0].y
= yo
- penWidthIn
;
1864 corners
[1].x
= xo
+ penWidthOut
;
1865 corners
[1].y
= yo
+ penWidthOut
;
1866 PATH_DoArcPart(pUpPath
,corners
, theta
+ M_PI_2
, theta
+ 3 * M_PI_4
, (j
== 0 ? PT_MOVETO
: FALSE
));
1867 PATH_DoArcPart(pUpPath
,corners
, theta
+ 3 * M_PI_4
, theta
+ M_PI
, FALSE
);
1868 PATH_DoArcPart(pUpPath
,corners
, theta
+ M_PI
, theta
+ 5 * M_PI_4
, FALSE
);
1869 PATH_DoArcPart(pUpPath
,corners
, theta
+ 5 * M_PI_4
, theta
+ 3 * M_PI_2
, FALSE
);
1873 /* Corpse of the path */
1877 double xa
, ya
, xb
, yb
, xo
, yo
;
1878 double alpha
, theta
, miterWidth
;
1879 DWORD _joint
= joint
;
1881 struct gdi_path
*pInsidePath
, *pOutsidePath
;
1882 if(j
> 0 && j
< pStrokes
[i
]->count
- 1) {
1887 previous
= pStrokes
[i
]->count
- 1;
1894 xo
= pStrokes
[i
]->points
[j
].x
;
1895 yo
= pStrokes
[i
]->points
[j
].y
;
1896 xa
= pStrokes
[i
]->points
[previous
].x
;
1897 ya
= pStrokes
[i
]->points
[previous
].y
;
1898 xb
= pStrokes
[i
]->points
[next
].x
;
1899 yb
= pStrokes
[i
]->points
[next
].y
;
1900 theta
= atan2( yo
- ya
, xo
- xa
);
1901 alpha
= atan2( yb
- yo
, xb
- xo
) - theta
;
1902 if (alpha
> 0) alpha
-= M_PI
;
1904 if(_joint
== PS_JOIN_MITER
&& dc
->miterLimit
< fabs(1 / sin(alpha
/2))) {
1905 _joint
= PS_JOIN_BEVEL
;
1908 pInsidePath
= pUpPath
;
1909 pOutsidePath
= pDownPath
;
1911 else if(alpha
< 0) {
1912 pInsidePath
= pDownPath
;
1913 pOutsidePath
= pUpPath
;
1918 /* Inside angle points */
1920 pt
.x
= xo
- round( penWidthIn
* cos(theta
+ M_PI_2
) );
1921 pt
.y
= yo
- round( penWidthIn
* sin(theta
+ M_PI_2
) );
1924 pt
.x
= xo
+ round( penWidthIn
* cos(theta
+ M_PI_2
) );
1925 pt
.y
= yo
+ round( penWidthIn
* sin(theta
+ M_PI_2
) );
1927 PATH_AddEntry(pInsidePath
, &pt
, PT_LINETO
);
1929 pt
.x
= xo
+ round( penWidthIn
* cos(M_PI_2
+ alpha
+ theta
) );
1930 pt
.y
= yo
+ round( penWidthIn
* sin(M_PI_2
+ alpha
+ theta
) );
1933 pt
.x
= xo
- round( penWidthIn
* cos(M_PI_2
+ alpha
+ theta
) );
1934 pt
.y
= yo
- round( penWidthIn
* sin(M_PI_2
+ alpha
+ theta
) );
1936 PATH_AddEntry(pInsidePath
, &pt
, PT_LINETO
);
1937 /* Outside angle point */
1939 case PS_JOIN_MITER
:
1940 miterWidth
= fabs(penWidthOut
/ cos(M_PI_2
- fabs(alpha
) / 2));
1941 pt
.x
= xo
+ round( miterWidth
* cos(theta
+ alpha
/ 2) );
1942 pt
.y
= yo
+ round( miterWidth
* sin(theta
+ alpha
/ 2) );
1943 PATH_AddEntry(pOutsidePath
, &pt
, PT_LINETO
);
1945 case PS_JOIN_BEVEL
:
1947 pt
.x
= xo
+ round( penWidthOut
* cos(theta
+ M_PI_2
) );
1948 pt
.y
= yo
+ round( penWidthOut
* sin(theta
+ M_PI_2
) );
1951 pt
.x
= xo
- round( penWidthOut
* cos(theta
+ M_PI_2
) );
1952 pt
.y
= yo
- round( penWidthOut
* sin(theta
+ M_PI_2
) );
1954 PATH_AddEntry(pOutsidePath
, &pt
, PT_LINETO
);
1956 pt
.x
= xo
- round( penWidthOut
* cos(M_PI_2
+ alpha
+ theta
) );
1957 pt
.y
= yo
- round( penWidthOut
* sin(M_PI_2
+ alpha
+ theta
) );
1960 pt
.x
= xo
+ round( penWidthOut
* cos(M_PI_2
+ alpha
+ theta
) );
1961 pt
.y
= yo
+ round( penWidthOut
* sin(M_PI_2
+ alpha
+ theta
) );
1963 PATH_AddEntry(pOutsidePath
, &pt
, PT_LINETO
);
1965 case PS_JOIN_ROUND
:
1968 pt
.x
= xo
+ round( penWidthOut
* cos(theta
+ M_PI_2
) );
1969 pt
.y
= yo
+ round( penWidthOut
* sin(theta
+ M_PI_2
) );
1972 pt
.x
= xo
- round( penWidthOut
* cos(theta
+ M_PI_2
) );
1973 pt
.y
= yo
- round( penWidthOut
* sin(theta
+ M_PI_2
) );
1975 PATH_AddEntry(pOutsidePath
, &pt
, PT_BEZIERTO
);
1976 pt
.x
= xo
+ round( penWidthOut
* cos(theta
+ alpha
/ 2) );
1977 pt
.y
= yo
+ round( penWidthOut
* sin(theta
+ alpha
/ 2) );
1978 PATH_AddEntry(pOutsidePath
, &pt
, PT_BEZIERTO
);
1980 pt
.x
= xo
- round( penWidthOut
* cos(M_PI_2
+ alpha
+ theta
) );
1981 pt
.y
= yo
- round( penWidthOut
* sin(M_PI_2
+ alpha
+ theta
) );
1984 pt
.x
= xo
+ round( penWidthOut
* cos(M_PI_2
+ alpha
+ theta
) );
1985 pt
.y
= yo
+ round( penWidthOut
* sin(M_PI_2
+ alpha
+ theta
) );
1987 PATH_AddEntry(pOutsidePath
, &pt
, PT_BEZIERTO
);
1992 for(j
= 0; j
< pUpPath
->count
; j
++) {
1994 pt
.x
= pUpPath
->points
[j
].x
;
1995 pt
.y
= pUpPath
->points
[j
].y
;
1996 PATH_AddEntry(pNewPath
, &pt
, (j
== 0 ? PT_MOVETO
: PT_LINETO
));
1998 for(j
= 0; j
< pDownPath
->count
; j
++) {
2000 pt
.x
= pDownPath
->points
[pDownPath
->count
- j
- 1].x
;
2001 pt
.y
= pDownPath
->points
[pDownPath
->count
- j
- 1].y
;
2002 PATH_AddEntry(pNewPath
, &pt
, ( (j
== 0 && (pStrokes
[i
]->flags
[pStrokes
[i
]->count
- 1] & PT_CLOSEFIGURE
)) ? PT_MOVETO
: PT_LINETO
));
2005 free_gdi_path( pStrokes
[i
] );
2006 free_gdi_path( pUpPath
);
2007 free_gdi_path( pDownPath
);
2009 HeapFree(GetProcessHeap(), 0, pStrokes
);
2010 free_gdi_path( flat_path
);
2015 /*******************************************************************
2016 * StrokeAndFillPath [GDI32.@]
2020 BOOL WINAPI
StrokeAndFillPath(HDC hdc
)
2023 DC
*dc
= get_dc_ptr( hdc
);
2027 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pStrokeAndFillPath
);
2028 ret
= physdev
->funcs
->pStrokeAndFillPath( physdev
);
2029 release_dc_ptr( dc
);
2035 /*******************************************************************
2036 * StrokePath [GDI32.@]
2040 BOOL WINAPI
StrokePath(HDC hdc
)
2043 DC
*dc
= get_dc_ptr( hdc
);
2047 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pStrokePath
);
2048 ret
= physdev
->funcs
->pStrokePath( physdev
);
2049 release_dc_ptr( dc
);
2055 /*******************************************************************
2056 * WidenPath [GDI32.@]
2060 BOOL WINAPI
WidenPath(HDC hdc
)
2063 DC
*dc
= get_dc_ptr( hdc
);
2067 PHYSDEV physdev
= GET_DC_PHYSDEV( dc
, pWidenPath
);
2068 ret
= physdev
->funcs
->pWidenPath( physdev
);
2069 release_dc_ptr( dc
);
2075 /***********************************************************************
2076 * null driver fallback implementations
2079 BOOL
nulldrv_BeginPath( PHYSDEV dev
)
2081 DC
*dc
= get_nulldrv_dc( dev
);
2082 struct path_physdev
*physdev
;
2083 struct gdi_path
*path
= alloc_gdi_path(0);
2085 if (!path
) return FALSE
;
2086 if (!path_driver
.pCreateDC( &dc
->physDev
, NULL
, NULL
, NULL
, NULL
))
2088 free_gdi_path( path
);
2091 physdev
= get_path_physdev( find_dc_driver( dc
, &path_driver
));
2092 physdev
->path
= path
;
2093 if (dc
->path
) free_gdi_path( dc
->path
);
2098 BOOL
nulldrv_EndPath( PHYSDEV dev
)
2100 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2104 BOOL
nulldrv_AbortPath( PHYSDEV dev
)
2106 DC
*dc
= get_nulldrv_dc( dev
);
2108 if (dc
->path
) free_gdi_path( dc
->path
);
2113 BOOL
nulldrv_CloseFigure( PHYSDEV dev
)
2115 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2119 BOOL
nulldrv_SelectClipPath( PHYSDEV dev
, INT mode
)
2123 DC
*dc
= get_nulldrv_dc( dev
);
2127 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2130 if (!(hrgn
= PATH_PathToRegion( dc
->path
, GetPolyFillMode(dev
->hdc
)))) return FALSE
;
2131 ret
= ExtSelectClipRgn( dev
->hdc
, hrgn
, mode
) != ERROR
;
2134 free_gdi_path( dc
->path
);
2137 /* FIXME: Should this function delete the path even if it failed? */
2138 DeleteObject( hrgn
);
2142 BOOL
nulldrv_FillPath( PHYSDEV dev
)
2144 DC
*dc
= get_nulldrv_dc( dev
);
2148 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2151 if (!PATH_FillPath( dev
->hdc
, dc
->path
)) return FALSE
;
2152 /* FIXME: Should the path be emptied even if conversion failed? */
2153 free_gdi_path( dc
->path
);
2158 BOOL
nulldrv_StrokeAndFillPath( PHYSDEV dev
)
2160 DC
*dc
= get_nulldrv_dc( dev
);
2164 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2167 if (!PATH_FillPath( dev
->hdc
, dc
->path
)) return FALSE
;
2168 if (!PATH_StrokePath( dev
->hdc
, dc
->path
)) return FALSE
;
2169 free_gdi_path( dc
->path
);
2174 BOOL
nulldrv_StrokePath( PHYSDEV dev
)
2176 DC
*dc
= get_nulldrv_dc( dev
);
2180 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2183 if (!PATH_StrokePath( dev
->hdc
, dc
->path
)) return FALSE
;
2184 free_gdi_path( dc
->path
);
2189 BOOL
nulldrv_FlattenPath( PHYSDEV dev
)
2191 DC
*dc
= get_nulldrv_dc( dev
);
2192 struct gdi_path
*path
;
2196 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2199 if (!(path
= PATH_FlattenPath( dc
->path
))) return FALSE
;
2200 free_gdi_path( dc
->path
);
2205 BOOL
nulldrv_WidenPath( PHYSDEV dev
)
2207 DC
*dc
= get_nulldrv_dc( dev
);
2208 struct gdi_path
*path
;
2212 SetLastError( ERROR_CAN_NOT_COMPLETE
);
2215 if (!(path
= PATH_WidenPath( dc
))) return FALSE
;
2216 free_gdi_path( dc
->path
);
2221 const struct gdi_dc_funcs path_driver
=
2223 NULL
, /* pAbortDoc */
2224 pathdrv_AbortPath
, /* pAbortPath */
2225 NULL
, /* pAlphaBlend */
2226 pathdrv_AngleArc
, /* pAngleArc */
2227 pathdrv_Arc
, /* pArc */
2228 pathdrv_ArcTo
, /* pArcTo */
2229 pathdrv_BeginPath
, /* pBeginPath */
2230 NULL
, /* pBlendImage */
2231 pathdrv_Chord
, /* pChord */
2232 pathdrv_CloseFigure
, /* pCloseFigure */
2233 NULL
, /* pCreateCompatibleDC */
2234 pathdrv_CreateDC
, /* pCreateDC */
2235 pathdrv_DeleteDC
, /* pDeleteDC */
2236 NULL
, /* pDeleteObject */
2237 NULL
, /* pDeviceCapabilities */
2238 pathdrv_Ellipse
, /* pEllipse */
2240 NULL
, /* pEndPage */
2241 pathdrv_EndPath
, /* pEndPath */
2242 NULL
, /* pEnumFonts */
2243 NULL
, /* pEnumICMProfiles */
2244 NULL
, /* pExcludeClipRect */
2245 NULL
, /* pExtDeviceMode */
2246 NULL
, /* pExtEscape */
2247 NULL
, /* pExtFloodFill */
2248 NULL
, /* pExtSelectClipRgn */
2249 pathdrv_ExtTextOut
, /* pExtTextOut */
2250 NULL
, /* pFillPath */
2251 NULL
, /* pFillRgn */
2252 NULL
, /* pFlattenPath */
2253 NULL
, /* pFontIsLinked */
2254 NULL
, /* pFrameRgn */
2255 NULL
, /* pGdiComment */
2256 NULL
, /* pGdiRealizationInfo */
2257 NULL
, /* pGetBoundsRect */
2258 NULL
, /* pGetCharABCWidths */
2259 NULL
, /* pGetCharABCWidthsI */
2260 NULL
, /* pGetCharWidth */
2261 NULL
, /* pGetDeviceCaps */
2262 NULL
, /* pGetDeviceGammaRamp */
2263 NULL
, /* pGetFontData */
2264 NULL
, /* pGetFontUnicodeRanges */
2265 NULL
, /* pGetGlyphIndices */
2266 NULL
, /* pGetGlyphOutline */
2267 NULL
, /* pGetICMProfile */
2268 NULL
, /* pGetImage */
2269 NULL
, /* pGetKerningPairs */
2270 NULL
, /* pGetNearestColor */
2271 NULL
, /* pGetOutlineTextMetrics */
2272 NULL
, /* pGetPixel */
2273 NULL
, /* pGetSystemPaletteEntries */
2274 NULL
, /* pGetTextCharsetInfo */
2275 NULL
, /* pGetTextExtentExPoint */
2276 NULL
, /* pGetTextExtentExPointI */
2277 NULL
, /* pGetTextFace */
2278 NULL
, /* pGetTextMetrics */
2279 NULL
, /* pGradientFill */
2280 NULL
, /* pIntersectClipRect */
2281 NULL
, /* pInvertRgn */
2282 pathdrv_LineTo
, /* pLineTo */
2283 NULL
, /* pModifyWorldTransform */
2284 pathdrv_MoveTo
, /* pMoveTo */
2285 NULL
, /* pOffsetClipRgn */
2286 NULL
, /* pOffsetViewportOrg */
2287 NULL
, /* pOffsetWindowOrg */
2288 NULL
, /* pPaintRgn */
2290 pathdrv_Pie
, /* pPie */
2291 pathdrv_PolyBezier
, /* pPolyBezier */
2292 pathdrv_PolyBezierTo
, /* pPolyBezierTo */
2293 pathdrv_PolyDraw
, /* pPolyDraw */
2294 pathdrv_PolyPolygon
, /* pPolyPolygon */
2295 pathdrv_PolyPolyline
, /* pPolyPolyline */
2296 pathdrv_Polygon
, /* pPolygon */
2297 pathdrv_Polyline
, /* pPolyline */
2298 pathdrv_PolylineTo
, /* pPolylineTo */
2299 NULL
, /* pPutImage */
2300 NULL
, /* pRealizeDefaultPalette */
2301 NULL
, /* pRealizePalette */
2302 pathdrv_Rectangle
, /* pRectangle */
2303 NULL
, /* pResetDC */
2304 NULL
, /* pRestoreDC */
2305 pathdrv_RoundRect
, /* pRoundRect */
2307 NULL
, /* pScaleViewportExt */
2308 NULL
, /* pScaleWindowExt */
2309 NULL
, /* pSelectBitmap */
2310 NULL
, /* pSelectBrush */
2311 NULL
, /* pSelectClipPath */
2312 NULL
, /* pSelectFont */
2313 NULL
, /* pSelectPalette */
2314 NULL
, /* pSelectPen */
2315 NULL
, /* pSetArcDirection */
2316 NULL
, /* pSetBkColor */
2317 NULL
, /* pSetBkMode */
2318 NULL
, /* pSetDCBrushColor */
2319 NULL
, /* pSetDCPenColor */
2320 NULL
, /* pSetDIBColorTable */
2321 NULL
, /* pSetDIBitsToDevice */
2322 NULL
, /* pSetDeviceClipping */
2323 NULL
, /* pSetDeviceGammaRamp */
2324 NULL
, /* pSetLayout */
2325 NULL
, /* pSetMapMode */
2326 NULL
, /* pSetMapperFlags */
2327 NULL
, /* pSetPixel */
2328 NULL
, /* pSetPolyFillMode */
2329 NULL
, /* pSetROP2 */
2330 NULL
, /* pSetRelAbs */
2331 NULL
, /* pSetStretchBltMode */
2332 NULL
, /* pSetTextAlign */
2333 NULL
, /* pSetTextCharacterExtra */
2334 NULL
, /* pSetTextColor */
2335 NULL
, /* pSetTextJustification */
2336 NULL
, /* pSetViewportExt */
2337 NULL
, /* pSetViewportOrg */
2338 NULL
, /* pSetWindowExt */
2339 NULL
, /* pSetWindowOrg */
2340 NULL
, /* pSetWorldTransform */
2341 NULL
, /* pStartDoc */
2342 NULL
, /* pStartPage */
2343 NULL
, /* pStretchBlt */
2344 NULL
, /* pStretchDIBits */
2345 NULL
, /* pStrokeAndFillPath */
2346 NULL
, /* pStrokePath */
2347 NULL
, /* pUnrealizePalette */
2348 NULL
, /* pWidenPath */
2349 NULL
, /* wine_get_wgl_driver */
2350 GDI_PRIORITY_PATH_DRV
/* priority */