2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 // Some code from the WINE project source (www.winehq.com)
27 // Should use Fx in Point
30 IntGdiMoveToEx(DC
*dc
,
36 PDC_ATTR pdcattr
= dc
->pdcattr
;
39 if ( pdcattr
->ulDirty_
& DIRTY_PTLCURRENT
) // Double hit!
41 Point
->x
= pdcattr
->ptfxCurrent
.x
; // ret prev before change.
42 Point
->y
= pdcattr
->ptfxCurrent
.y
;
43 IntDPtoLP ( dc
, Point
, 1); // reconvert back.
47 Point
->x
= pdcattr
->ptlCurrent
.x
;
48 Point
->y
= pdcattr
->ptlCurrent
.y
;
51 pdcattr
->ptlCurrent
.x
= X
;
52 pdcattr
->ptlCurrent
.y
= Y
;
53 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
54 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
55 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
57 PathIsOpen
= PATH_IsPathOpen(dc
->dclevel
);
60 return PATH_MoveTo ( dc
);
65 // Should use Fx in pt
68 IntGetCurrentPositionEx(PDC dc
, LPPOINT pt
)
70 PDC_ATTR pdcattr
= dc
->pdcattr
;
74 if (pdcattr
->ulDirty_
& DIRTY_PTFXCURRENT
)
76 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
77 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
78 pdcattr
->ulDirty_
&= ~(DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
80 pt
->x
= pdcattr
->ptlCurrent
.x
;
81 pt
->y
= pdcattr
->ptlCurrent
.y
;
95 PDC_ATTR pdcattr
= dc
->pdcattr
;
97 if (PATH_IsPathOpen(dc
->dclevel
))
99 Ret
= PATH_LineTo(dc
, XEnd
, YEnd
);
102 // FIXME - PATH_LineTo should maybe do this? No
103 pdcattr
->ptlCurrent
.x
= XEnd
;
104 pdcattr
->ptlCurrent
.y
= YEnd
;
105 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
106 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
107 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
113 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
114 DC_vUpdateLineBrush(dc
);
116 psurf
= dc
->dclevel
.pSurface
;
119 SetLastWin32Error(ERROR_INVALID_HANDLE
);
123 Points
[0].x
= pdcattr
->ptlCurrent
.x
;
124 Points
[0].y
= pdcattr
->ptlCurrent
.y
;
128 IntLPtoDP(dc
, Points
, 2);
130 /* The DCOrg is in device coordinates */
131 Points
[0].x
+= dc
->ptlDCOrig
.x
;
132 Points
[0].y
+= dc
->ptlDCOrig
.y
;
133 Points
[1].x
+= dc
->ptlDCOrig
.x
;
134 Points
[1].y
+= dc
->ptlDCOrig
.y
;
136 Bounds
.left
= min(Points
[0].x
, Points
[1].x
);
137 Bounds
.top
= min(Points
[0].y
, Points
[1].y
);
138 Bounds
.right
= max(Points
[0].x
, Points
[1].x
);
139 Bounds
.bottom
= max(Points
[0].y
, Points
[1].y
);
141 /* get BRUSH from current pen. */
142 pbrLine
= dc
->dclevel
.pbrLine
;
145 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
147 Ret
= IntEngLineTo(&psurf
->SurfObj
,
148 dc
->rosdc
.CombinedClip
,
149 &dc
->eboLine
.BrushObject
,
150 Points
[0].x
, Points
[0].y
,
151 Points
[1].x
, Points
[1].y
,
153 ROP2_TO_MIX(pdcattr
->jROP2
));
160 pdcattr
->ptlCurrent
.x
= XEnd
;
161 pdcattr
->ptlCurrent
.y
= YEnd
;
162 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
163 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
164 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
171 IntGdiPolyBezier(DC
*dc
,
175 BOOL ret
= FALSE
; // default to FAILURE
177 if ( PATH_IsPathOpen(dc
->dclevel
) )
179 return PATH_PolyBezier ( dc
, pt
, Count
);
182 /* We'll convert it into line segments and draw them using Polyline */
187 Pts
= GDI_Bezier ( pt
, Count
, &nOut
);
190 ret
= IntGdiPolyline(dc
, Pts
, nOut
);
191 ExFreePoolWithTag(Pts
, TAG_BEZIER
);
199 IntGdiPolyBezierTo(DC
*dc
,
203 BOOL ret
= FALSE
; // default to failure
204 PDC_ATTR pdcattr
= dc
->pdcattr
;
206 if ( PATH_IsPathOpen(dc
->dclevel
) )
207 ret
= PATH_PolyBezierTo ( dc
, pt
, Count
);
208 else /* We'll do it using PolyBezier */
211 npt
= ExAllocatePoolWithTag(PagedPool
,
212 sizeof(POINT
) * (Count
+ 1),
216 npt
[0].x
= pdcattr
->ptlCurrent
.x
;
217 npt
[0].y
= pdcattr
->ptlCurrent
.y
;
218 memcpy(npt
+ 1, pt
, sizeof(POINT
) * Count
);
219 ret
= IntGdiPolyBezier(dc
, npt
, Count
+1);
220 ExFreePoolWithTag(npt
, TAG_BEZIER
);
225 pdcattr
->ptlCurrent
.x
= pt
[Count
-1].x
;
226 pdcattr
->ptlCurrent
.y
= pt
[Count
-1].y
;
227 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
228 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
229 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
236 IntGdiPolyline(DC
*dc
,
245 PDC_ATTR pdcattr
= dc
->pdcattr
;
247 if (PATH_IsPathOpen(dc
->dclevel
))
248 return PATH_Polyline(dc
, pt
, Count
);
250 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
251 DC_vUpdateFillBrush(dc
);
253 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
254 DC_vUpdateLineBrush(dc
);
256 /* Get BRUSHOBJ from current pen. */
257 pbrLine
= dc
->dclevel
.pbrLine
;
260 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
262 Points
= EngAllocMem(0, Count
* sizeof(POINT
), TAG_COORD
);
265 psurf
= dc
->dclevel
.pSurface
;
266 /* FIXME - psurf can be NULL!!!!
267 Don't assert but handle this case gracefully! */
270 RtlCopyMemory(Points
, pt
, Count
* sizeof(POINT
));
271 IntLPtoDP(dc
, Points
, Count
);
273 /* Offset the array of points by the DC origin */
274 for (i
= 0; i
< Count
; i
++)
276 Points
[i
].x
+= dc
->ptlDCOrig
.x
;
277 Points
[i
].y
+= dc
->ptlDCOrig
.y
;
280 Ret
= IntEngPolyline(&psurf
->SurfObj
,
281 dc
->rosdc
.CombinedClip
,
282 &dc
->eboLine
.BrushObject
,
285 ROP2_TO_MIX(pdcattr
->jROP2
));
299 IntGdiPolylineTo(DC
*dc
,
303 BOOL ret
= FALSE
; // default to failure
304 PDC_ATTR pdcattr
= dc
->pdcattr
;
306 if (PATH_IsPathOpen(dc
->dclevel
))
308 ret
= PATH_PolylineTo(dc
, pt
, Count
);
310 else /* do it using Polyline */
312 POINT
*pts
= ExAllocatePoolWithTag(PagedPool
,
313 sizeof(POINT
) * (Count
+ 1),
317 pts
[0].x
= pdcattr
->ptlCurrent
.x
;
318 pts
[0].y
= pdcattr
->ptlCurrent
.y
;
319 memcpy( pts
+ 1, pt
, sizeof(POINT
) * Count
);
320 ret
= IntGdiPolyline(dc
, pts
, Count
+ 1);
321 ExFreePoolWithTag(pts
, TAG_SHAPE
);
326 pdcattr
->ptlCurrent
.x
= pt
[Count
-1].x
;
327 pdcattr
->ptlCurrent
.y
= pt
[Count
-1].y
;
328 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
329 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
330 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
338 IntGdiPolyPolyline(DC
*dc
,
346 BOOL ret
= FALSE
; // default to failure
350 if (PATH_IsPathOpen(dc
->dclevel
))
351 return PATH_PolyPolyline( dc
, pt
, PolyPoints
, Count
);
353 for (i
= 0; i
< Count
; i
++)
355 ret
= IntGdiPolyline ( dc
, pts
, *pc
);
366 /******************************************************************************/
380 SetLastWin32Error(ERROR_INVALID_HANDLE
);
383 if (dc
->dctype
== DC_TYPE_INFO
)
386 /* Yes, Windows really returns TRUE in this case */
390 Ret
= IntGdiLineTo(dc
, XEnd
, YEnd
);
412 if (!dc
) return FALSE
;
413 pdcattr
= dc
->pdcattr
;
417 ProbeArrayForRead(lppt
, sizeof(POINT
), cCount
, sizeof(LONG
));
418 ProbeArrayForRead(lpbTypes
, sizeof(BYTE
), cCount
, sizeof(BYTE
));
420 /* check for each bezierto if there are two more points */
421 for ( i
= 0; i
< cCount
; i
++ )
423 if ( lpbTypes
[i
] != PT_MOVETO
&&
424 lpbTypes
[i
] & PT_BEZIERTO
)
426 if ( cCount
< i
+3 ) _SEH2_LEAVE
;
431 /* if no moveto occurs, we will close the figure here */
432 lastmove
.x
= pdcattr
->ptlCurrent
.x
;
433 lastmove
.y
= pdcattr
->ptlCurrent
.y
;
436 for ( i
= 0; i
< cCount
; i
++ )
438 if ( lpbTypes
[i
] == PT_MOVETO
)
440 IntGdiMoveToEx( dc
, lppt
[i
].x
, lppt
[i
].y
, NULL
);
441 lastmove
.x
= pdcattr
->ptlCurrent
.x
;
442 lastmove
.y
= pdcattr
->ptlCurrent
.y
;
444 else if ( lpbTypes
[i
] & PT_LINETO
)
445 IntGdiLineTo( dc
, lppt
[i
].x
, lppt
[i
].y
);
446 else if ( lpbTypes
[i
] & PT_BEZIERTO
)
449 pts
[0].x
= pdcattr
->ptlCurrent
.x
;
450 pts
[0].y
= pdcattr
->ptlCurrent
.y
;
451 RtlCopyMemory(pts
+ 1, &lppt
[i
], sizeof(POINT
) * 3);
452 IntGdiPolyBezier(dc
, pts
, 4);
457 if ( lpbTypes
[i
] & PT_CLOSEFIGURE
)
459 if ( PATH_IsPathOpen(dc
->dclevel
) )
461 pPath
= PATH_LockPath( dc
->dclevel
.hPath
);
464 IntGdiCloseFigure( pPath
);
465 PATH_UnlockPath( pPath
);
468 else IntGdiLineTo( dc
, lastmove
.x
, lastmove
.y
);
474 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
476 SetLastNtError(_SEH2_GetExceptionCode());
494 OUT OPTIONAL LPPOINT pptOut
)