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 Dc_Attr
= dc
->pDc_Attr
;
37 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
40 if ( Dc_Attr
->ulDirty_
& DIRTY_PTLCURRENT
) // Double hit!
42 Point
->x
= Dc_Attr
->ptfxCurrent
.x
; // ret prev before change.
43 Point
->y
= Dc_Attr
->ptfxCurrent
.y
;
44 IntDPtoLP ( dc
, Point
, 1); // reconvert back.
48 Point
->x
= Dc_Attr
->ptlCurrent
.x
;
49 Point
->y
= Dc_Attr
->ptlCurrent
.y
;
52 Dc_Attr
->ptlCurrent
.x
= X
;
53 Dc_Attr
->ptlCurrent
.y
= Y
;
54 Dc_Attr
->ptfxCurrent
= Dc_Attr
->ptlCurrent
;
55 CoordLPtoDP(dc
, &Dc_Attr
->ptfxCurrent
); // Update fx
56 Dc_Attr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
58 PathIsOpen
= PATH_IsPathOpen(dc
->w
.path
);
61 return PATH_MoveTo ( dc
);
66 // Should use Fx in pt
69 IntGetCurrentPositionEx(PDC dc
, LPPOINT pt
)
71 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
72 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
76 if (Dc_Attr
->ulDirty_
& DIRTY_PTFXCURRENT
)
78 Dc_Attr
->ptfxCurrent
= Dc_Attr
->ptlCurrent
;
79 CoordLPtoDP(dc
, &Dc_Attr
->ptfxCurrent
); // Update fx
80 Dc_Attr
->ulDirty_
&= ~(DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
82 pt
->x
= Dc_Attr
->ptlCurrent
.x
;
83 pt
->y
= Dc_Attr
->ptlCurrent
.y
;
94 PGDIBRUSHOBJ PenBrushObj
;
95 GDIBRUSHINST PenBrushInst
;
98 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
100 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
102 if (PATH_IsPathOpen(dc
->w
.path
))
104 Ret
= PATH_LineTo(dc
, XEnd
, YEnd
);
107 // FIXME - PATH_LineTo should maybe do this...
108 Dc_Attr
->ptlCurrent
.x
= XEnd
;
109 Dc_Attr
->ptlCurrent
.y
= YEnd
;
110 Dc_Attr
->ptfxCurrent
= Dc_Attr
->ptlCurrent
;
111 CoordLPtoDP(dc
, &Dc_Attr
->ptfxCurrent
); // Update fx
112 Dc_Attr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
118 BitmapObj
= BITMAPOBJ_LockBitmap ( dc
->w
.hBitmap
);
119 if (NULL
== BitmapObj
)
121 SetLastWin32Error(ERROR_INVALID_HANDLE
);
125 Points
[0].x
= Dc_Attr
->ptlCurrent
.x
;
126 Points
[0].y
= Dc_Attr
->ptlCurrent
.y
;
130 IntLPtoDP(dc
, Points
, 2);
132 /* FIXME: Is it correct to do this after the transformation? */
133 Points
[0].x
+= dc
->w
.DCOrgX
;
134 Points
[0].y
+= dc
->w
.DCOrgY
;
135 Points
[1].x
+= dc
->w
.DCOrgX
;
136 Points
[1].y
+= dc
->w
.DCOrgY
;
138 Bounds
.left
= min(Points
[0].x
, Points
[1].x
);
139 Bounds
.top
= min(Points
[0].y
, Points
[1].y
);
140 Bounds
.right
= max(Points
[0].x
, Points
[1].x
);
141 Bounds
.bottom
= max(Points
[0].y
, Points
[1].y
);
143 /* get BRUSHOBJ from current pen. */
144 PenBrushObj
= PENOBJ_LockPen( Dc_Attr
->hpen
);
145 /* FIXME - PenBrushObj can be NULL!!!! Don't assert here! */
148 if (!(PenBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
150 IntGdiInitBrushInstance(&PenBrushInst
, PenBrushObj
, dc
->XlatePen
);
151 Ret
= IntEngLineTo(&BitmapObj
->SurfObj
,
153 &PenBrushInst
.BrushObject
,
154 Points
[0].x
, Points
[0].y
,
155 Points
[1].x
, Points
[1].y
,
157 ROP2_TO_MIX(Dc_Attr
->jROP2
));
160 BITMAPOBJ_UnlockBitmap ( BitmapObj
);
161 PENOBJ_UnlockPen( PenBrushObj
);
166 Dc_Attr
->ptlCurrent
.x
= XEnd
;
167 Dc_Attr
->ptlCurrent
.y
= YEnd
;
168 Dc_Attr
->ptfxCurrent
= Dc_Attr
->ptlCurrent
;
169 CoordLPtoDP(dc
, &Dc_Attr
->ptfxCurrent
); // Update fx
170 Dc_Attr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
177 IntGdiPolyBezier(DC
*dc
,
181 BOOL ret
= FALSE
; // default to FAILURE
183 if ( PATH_IsPathOpen(dc
->w
.path
) )
185 return PATH_PolyBezier ( dc
, pt
, Count
);
188 /* We'll convert it into line segments and draw them using Polyline */
193 Pts
= GDI_Bezier ( pt
, Count
, &nOut
);
196 ret
= IntGdiPolyline(dc
, Pts
, nOut
);
205 IntGdiPolyBezierTo(DC
*dc
,
209 BOOL ret
= FALSE
; // default to failure
210 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
212 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
213 if ( PATH_IsPathOpen(dc
->w
.path
) )
214 ret
= PATH_PolyBezierTo ( dc
, pt
, Count
);
215 else /* We'll do it using PolyBezier */
218 npt
= ExAllocatePoolWithTag(PagedPool
,
219 sizeof(POINT
) * (Count
+ 1),
223 npt
[0].x
= Dc_Attr
->ptlCurrent
.x
;
224 npt
[0].y
= Dc_Attr
->ptlCurrent
.y
;
225 memcpy(npt
+ 1, pt
, sizeof(POINT
) * Count
);
226 ret
= IntGdiPolyBezier(dc
, npt
, Count
+1);
232 Dc_Attr
->ptlCurrent
.x
= pt
[Count
-1].x
;
233 Dc_Attr
->ptlCurrent
.y
= pt
[Count
-1].y
;
234 Dc_Attr
->ptfxCurrent
= Dc_Attr
->ptlCurrent
;
235 CoordLPtoDP(dc
, &Dc_Attr
->ptfxCurrent
); // Update fx
236 Dc_Attr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
243 IntGdiPolyline(DC
*dc
,
247 BITMAPOBJ
*BitmapObj
;
248 GDIBRUSHOBJ
*PenBrushObj
;
249 GDIBRUSHINST PenBrushInst
;
253 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
255 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
256 if (PATH_IsPathOpen(dc
->w
.path
))
257 return PATH_Polyline(dc
, pt
, Count
);
259 /* Get BRUSHOBJ from current pen. */
260 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
261 /* FIXME - PenBrushObj can be NULL! Don't assert here! */
264 if (!(PenBrushObj
->flAttrs
& GDIBRUSH_IS_NULL
))
266 Points
= EngAllocMem(0, Count
* sizeof(POINT
), TAG_COORD
);
269 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
270 /* FIXME - BitmapObj can be NULL!!!!
271 Don't assert but handle this case gracefully! */
274 RtlCopyMemory(Points
, pt
, Count
* sizeof(POINT
));
275 IntLPtoDP(dc
, Points
, Count
);
277 /* Offset the array of point by the dc->w.DCOrg */
278 for (i
= 0; i
< Count
; i
++)
280 Points
[i
].x
+= dc
->w
.DCOrgX
;
281 Points
[i
].y
+= dc
->w
.DCOrgY
;
284 IntGdiInitBrushInstance(&PenBrushInst
, PenBrushObj
, dc
->XlatePen
);
285 Ret
= IntEngPolyline(&BitmapObj
->SurfObj
,
287 &PenBrushInst
.BrushObject
,
290 ROP2_TO_MIX(Dc_Attr
->jROP2
));
292 BITMAPOBJ_UnlockBitmap(BitmapObj
);
301 PENOBJ_UnlockPen(PenBrushObj
);
307 IntGdiPolylineTo(DC
*dc
,
311 BOOL ret
= FALSE
; // default to failure
312 PDC_ATTR Dc_Attr
= dc
->pDc_Attr
;
314 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
315 if (PATH_IsPathOpen(dc
->w
.path
))
317 ret
= PATH_PolylineTo(dc
, pt
, Count
);
319 else /* do it using Polyline */
321 POINT
*pts
= ExAllocatePoolWithTag(PagedPool
,
322 sizeof(POINT
) * (Count
+ 1),
326 pts
[0].x
= Dc_Attr
->ptlCurrent
.x
;
327 pts
[0].y
= Dc_Attr
->ptlCurrent
.y
;
328 memcpy( pts
+ 1, pt
, sizeof(POINT
) * Count
);
329 ret
= IntGdiPolyline(dc
, pts
, Count
+ 1);
335 Dc_Attr
->ptlCurrent
.x
= pt
[Count
-1].x
;
336 Dc_Attr
->ptlCurrent
.y
= pt
[Count
-1].y
;
337 Dc_Attr
->ptfxCurrent
= Dc_Attr
->ptlCurrent
;
338 CoordLPtoDP(dc
, &Dc_Attr
->ptfxCurrent
); // Update fx
339 Dc_Attr
->ulDirty_
&= ~(DIRTY_PTLCURRENT
|DIRTY_PTFXCURRENT
|DIRTY_STYLESTATE
);
347 IntGdiPolyPolyline(DC
*dc
,
355 BOOL ret
= FALSE
; // default to failure
359 for (i
= 0; i
< Count
; i
++)
361 ret
= IntGdiPolyline ( dc
, pts
, *pc
);
372 /******************************************************************************/
381 IN DWORD dwStartAngle
,
382 IN DWORD dwSweepAngle
)
401 SetLastWin32Error(ERROR_INVALID_HANDLE
);
404 if (dc
->DC_Type
== DC_TYPE_INFO
)
407 /* Yes, Windows really returns TRUE in this case */
411 Ret
= IntGdiLineTo(dc
, XEnd
, YEnd
);
429 PDC_ATTR Dc_Attr
= NULL
;
432 if (!dc
) return FALSE
;
433 Dc_Attr
= dc
->pDc_Attr
;
434 if (!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
438 ProbeArrayForRead(lppt
, sizeof(POINT
), cCount
, sizeof(LONG
));
439 ProbeArrayForRead(lpbTypes
, sizeof(BYTE
), cCount
, sizeof(BYTE
));
441 /* check for each bezierto if there are two more points */
442 for ( i
= 0; i
< cCount
; i
++ )
444 if ( lpbTypes
[i
] != PT_MOVETO
&&
445 lpbTypes
[i
] & PT_BEZIERTO
)
447 if ( cCount
< i
+3 ) _SEH_LEAVE
;
452 /* if no moveto occurs, we will close the figure here */
453 lastmove
.x
= Dc_Attr
->ptlCurrent
.x
;
454 lastmove
.y
= Dc_Attr
->ptlCurrent
.y
;
457 for ( i
= 0; i
< cCount
; i
++ )
459 if ( lpbTypes
[i
] == PT_MOVETO
)
461 IntGdiMoveToEx( dc
, lppt
[i
].x
, lppt
[i
].y
, NULL
);
462 lastmove
.x
= Dc_Attr
->ptlCurrent
.x
;
463 lastmove
.y
= Dc_Attr
->ptlCurrent
.y
;
465 else if ( lpbTypes
[i
] & PT_LINETO
)
466 IntGdiLineTo( dc
, lppt
[i
].x
, lppt
[i
].y
);
467 else if ( lpbTypes
[i
] & PT_BEZIERTO
)
470 pts
[0].x
= Dc_Attr
->ptlCurrent
.x
;
471 pts
[0].y
= Dc_Attr
->ptlCurrent
.y
;
472 RtlCopyMemory(pts
+ 1, &lppt
[i
], sizeof(POINT
) * 3);
473 IntGdiPolyBezier(dc
, pts
, 4);
478 if ( lpbTypes
[i
] & PT_CLOSEFIGURE
)
480 if ( PATH_IsPathOpen(dc
->w
.path
) )
482 IntGdiCloseFigure( dc
);
484 else IntGdiLineTo( dc
, lastmove
.x
, lastmove
.y
);
492 SetLastNtError(_SEH_GetExceptionCode());