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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 // Some code from the WINE project source (www.winehq.com)
27 // Should use Fx in Point
30 IntGdiMoveToEx(DC
*dc
,
37 PDC_ATTR pdcattr
= dc
->pdcattr
;
40 if ( pdcattr
->ulDirty_
& DIRTY_PTLCURRENT
) // Double hit!
42 Point
->x
= pdcattr
->ptfxCurrent
.x
; // ret prev before change.
43 Point
->y
= pdcattr
->ptfxCurrent
.y
;
44 IntDPtoLP ( dc
, Point
, 1); // reconvert back.
48 Point
->x
= pdcattr
->ptlCurrent
.x
;
49 Point
->y
= pdcattr
->ptlCurrent
.y
;
52 pdcattr
->ptlCurrent
.x
= X
;
53 pdcattr
->ptlCurrent
.y
= Y
;
54 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
55 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
56 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
58 if (BypassPath
) return TRUE
;
60 PathIsOpen
= PATH_IsPathOpen(dc
->dclevel
);
63 return PATH_MoveTo ( dc
);
68 // Should use Fx in pt
71 IntGetCurrentPositionEx(PDC dc
, LPPOINT pt
)
73 PDC_ATTR pdcattr
= dc
->pdcattr
;
77 if (pdcattr
->ulDirty_
& DIRTY_PTFXCURRENT
)
79 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
80 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
81 pdcattr
->ulDirty_
&= ~(DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
83 pt
->x
= pdcattr
->ptlCurrent
.x
;
84 pt
->y
= pdcattr
->ptlCurrent
.y
;
98 PDC_ATTR pdcattr
= dc
->pdcattr
;
100 if (PATH_IsPathOpen(dc
->dclevel
))
102 Ret
= PATH_LineTo(dc
, XEnd
, YEnd
);
105 // FIXME - PATH_LineTo should maybe do this? No
106 pdcattr
->ptlCurrent
.x
= XEnd
;
107 pdcattr
->ptlCurrent
.y
= YEnd
;
108 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
109 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
110 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
116 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
117 DC_vUpdateLineBrush(dc
);
119 psurf
= dc
->dclevel
.pSurface
;
122 SetLastWin32Error(ERROR_INVALID_HANDLE
);
126 Points
[0].x
= pdcattr
->ptlCurrent
.x
;
127 Points
[0].y
= pdcattr
->ptlCurrent
.y
;
131 IntLPtoDP(dc
, Points
, 2);
133 /* The DCOrg is in device coordinates */
134 Points
[0].x
+= dc
->ptlDCOrig
.x
;
135 Points
[0].y
+= dc
->ptlDCOrig
.y
;
136 Points
[1].x
+= dc
->ptlDCOrig
.x
;
137 Points
[1].y
+= dc
->ptlDCOrig
.y
;
139 Bounds
.left
= min(Points
[0].x
, Points
[1].x
);
140 Bounds
.top
= min(Points
[0].y
, Points
[1].y
);
141 Bounds
.right
= max(Points
[0].x
, Points
[1].x
);
142 Bounds
.bottom
= max(Points
[0].y
, Points
[1].y
);
144 /* get BRUSH from current pen. */
145 pbrLine
= dc
->dclevel
.pbrLine
;
148 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
150 Ret
= IntEngLineTo(&psurf
->SurfObj
,
151 dc
->rosdc
.CombinedClip
,
152 &dc
->eboLine
.BrushObject
,
153 Points
[0].x
, Points
[0].y
,
154 Points
[1].x
, Points
[1].y
,
156 ROP2_TO_MIX(pdcattr
->jROP2
));
163 pdcattr
->ptlCurrent
.x
= XEnd
;
164 pdcattr
->ptlCurrent
.y
= YEnd
;
165 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
166 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
167 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
174 IntGdiPolyBezier(DC
*dc
,
178 BOOL ret
= FALSE
; // default to FAILURE
180 if ( PATH_IsPathOpen(dc
->dclevel
) )
182 return PATH_PolyBezier ( dc
, pt
, Count
);
185 /* We'll convert it into line segments and draw them using Polyline */
190 Pts
= GDI_Bezier ( pt
, Count
, &nOut
);
193 ret
= IntGdiPolyline(dc
, Pts
, nOut
);
194 ExFreePoolWithTag(Pts
, TAG_BEZIER
);
202 IntGdiPolyBezierTo(DC
*dc
,
206 BOOL ret
= FALSE
; // default to failure
207 PDC_ATTR pdcattr
= dc
->pdcattr
;
209 if ( PATH_IsPathOpen(dc
->dclevel
) )
210 ret
= PATH_PolyBezierTo ( dc
, pt
, Count
);
211 else /* We'll do it using PolyBezier */
214 npt
= ExAllocatePoolWithTag(PagedPool
,
215 sizeof(POINT
) * (Count
+ 1),
219 npt
[0].x
= pdcattr
->ptlCurrent
.x
;
220 npt
[0].y
= pdcattr
->ptlCurrent
.y
;
221 memcpy(npt
+ 1, pt
, sizeof(POINT
) * Count
);
222 ret
= IntGdiPolyBezier(dc
, npt
, Count
+1);
223 ExFreePoolWithTag(npt
, TAG_BEZIER
);
228 pdcattr
->ptlCurrent
.x
= pt
[Count
-1].x
;
229 pdcattr
->ptlCurrent
.y
= pt
[Count
-1].y
;
230 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
231 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
232 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
239 IntGdiPolyline(DC
*dc
,
248 PDC_ATTR pdcattr
= dc
->pdcattr
;
250 if (PATH_IsPathOpen(dc
->dclevel
))
251 return PATH_Polyline(dc
, pt
, Count
);
253 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
254 DC_vUpdateFillBrush(dc
);
256 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
257 DC_vUpdateLineBrush(dc
);
259 /* Get BRUSHOBJ from current pen. */
260 pbrLine
= dc
->dclevel
.pbrLine
;
263 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
265 Points
= EngAllocMem(0, Count
* sizeof(POINT
), TAG_COORD
);
268 psurf
= dc
->dclevel
.pSurface
;
269 /* FIXME - psurf can be NULL!!!!
270 Don't assert but handle this case gracefully! */
273 RtlCopyMemory(Points
, pt
, Count
* sizeof(POINT
));
274 IntLPtoDP(dc
, Points
, Count
);
276 /* Offset the array of points by the DC origin */
277 for (i
= 0; i
< Count
; i
++)
279 Points
[i
].x
+= dc
->ptlDCOrig
.x
;
280 Points
[i
].y
+= dc
->ptlDCOrig
.y
;
283 Ret
= IntEngPolyline(&psurf
->SurfObj
,
284 dc
->rosdc
.CombinedClip
,
285 &dc
->eboLine
.BrushObject
,
288 ROP2_TO_MIX(pdcattr
->jROP2
));
302 IntGdiPolylineTo(DC
*dc
,
306 BOOL ret
= FALSE
; // default to failure
307 PDC_ATTR pdcattr
= dc
->pdcattr
;
309 if (PATH_IsPathOpen(dc
->dclevel
))
311 ret
= PATH_PolylineTo(dc
, pt
, Count
);
313 else /* do it using Polyline */
315 POINT
*pts
= ExAllocatePoolWithTag(PagedPool
,
316 sizeof(POINT
) * (Count
+ 1),
320 pts
[0].x
= pdcattr
->ptlCurrent
.x
;
321 pts
[0].y
= pdcattr
->ptlCurrent
.y
;
322 memcpy( pts
+ 1, pt
, sizeof(POINT
) * Count
);
323 ret
= IntGdiPolyline(dc
, pts
, Count
+ 1);
324 ExFreePoolWithTag(pts
, TAG_SHAPE
);
329 pdcattr
->ptlCurrent
.x
= pt
[Count
-1].x
;
330 pdcattr
->ptlCurrent
.y
= pt
[Count
-1].y
;
331 pdcattr
->ptfxCurrent
= pdcattr
->ptlCurrent
;
332 CoordLPtoDP(dc
, &pdcattr
->ptfxCurrent
); // Update fx
333 pdcattr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
341 IntGdiPolyPolyline(DC
*dc
,
349 BOOL ret
= FALSE
; // default to failure
353 if (PATH_IsPathOpen(dc
->dclevel
))
354 return PATH_PolyPolyline( dc
, pt
, PolyPoints
, Count
);
356 for (i
= 0; i
< Count
; i
++)
358 ret
= IntGdiPolyline ( dc
, pts
, *pc
);
369 /******************************************************************************/
383 SetLastWin32Error(ERROR_INVALID_HANDLE
);
386 if (dc
->dctype
== DC_TYPE_INFO
)
389 /* Yes, Windows really returns TRUE in this case */
393 Ret
= IntGdiLineTo(dc
, XEnd
, YEnd
);
415 if (!dc
) return FALSE
;
416 pdcattr
= dc
->pdcattr
;
420 ProbeArrayForRead(lppt
, sizeof(POINT
), cCount
, sizeof(LONG
));
421 ProbeArrayForRead(lpbTypes
, sizeof(BYTE
), cCount
, sizeof(BYTE
));
423 /* check for each bezierto if there are two more points */
424 for ( i
= 0; i
< cCount
; i
++ )
426 if ( lpbTypes
[i
] != PT_MOVETO
&&
427 lpbTypes
[i
] & PT_BEZIERTO
)
429 if ( cCount
< i
+3 ) _SEH2_LEAVE
;
434 /* if no moveto occurs, we will close the figure here */
435 lastmove
.x
= pdcattr
->ptlCurrent
.x
;
436 lastmove
.y
= pdcattr
->ptlCurrent
.y
;
439 for ( i
= 0; i
< cCount
; i
++ )
441 if ( lpbTypes
[i
] == PT_MOVETO
)
443 IntGdiMoveToEx( dc
, lppt
[i
].x
, lppt
[i
].y
, NULL
, FALSE
);
444 lastmove
.x
= pdcattr
->ptlCurrent
.x
;
445 lastmove
.y
= pdcattr
->ptlCurrent
.y
;
447 else if ( lpbTypes
[i
] & PT_LINETO
)
448 IntGdiLineTo( dc
, lppt
[i
].x
, lppt
[i
].y
);
449 else if ( lpbTypes
[i
] & PT_BEZIERTO
)
452 pts
[0].x
= pdcattr
->ptlCurrent
.x
;
453 pts
[0].y
= pdcattr
->ptlCurrent
.y
;
454 RtlCopyMemory(pts
+ 1, &lppt
[i
], sizeof(POINT
) * 3);
455 IntGdiPolyBezier(dc
, pts
, 4);
460 if ( lpbTypes
[i
] & PT_CLOSEFIGURE
)
462 if ( PATH_IsPathOpen(dc
->dclevel
) )
464 pPath
= PATH_LockPath( dc
->dclevel
.hPath
);
467 IntGdiCloseFigure( pPath
);
468 PATH_UnlockPath( pPath
);
471 else IntGdiLineTo( dc
, lastmove
.x
, lastmove
.y
);
477 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
479 SetLastNtError(_SEH2_GetExceptionCode());
497 OUT OPTIONAL LPPOINT pptOut
)