7 * A couple of macros to fill a single pixel or a line
9 #define PUTPIXEL(x,y,BrushInst) \
10 ret = ret && IntEngLineTo(&psurf->SurfObj, \
12 &BrushInst.BrushObject, \
15 ROP2_TO_MIX(pdcattr->jROP2));
17 #define PUTLINE(x1,y1,x2,y2,BrushInst) \
18 ret = ret && IntEngLineTo(&psurf->SurfObj, \
20 &BrushInst.BrushObject, \
23 ROP2_TO_MIX(pdcattr->jROP2));
40 RECTL RectBounds
, RectSEpts
;
44 LONG PenWidth
, PenOrigWidth
;
45 double AngleStart
, AngleEnd
;
46 LONG CenterX
, CenterY
;
50 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
54 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
57 /* Check if the target rect is empty */
58 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
60 // FIXME: this needs to be verified
61 if ((arctype
== GdiTypeChord
) || (arctype
== GdiTypePie
))
63 if ((Right
- Left
== 1) || (Bottom
- Top
== 1))
68 pdcattr
= dc
->pdcattr
;
70 pbrPen
= PEN_ShareLockPen(pdcattr
->hpen
);
73 DPRINT1("Arc Fail 1\n");
74 EngSetLastError(ERROR_INTERNAL_ERROR
);
78 PenOrigWidth
= PenWidth
= pbrPen
->lWidth
;
79 if (pbrPen
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
81 if (pbrPen
->ulPenStyle
== PS_INSIDEFRAME
)
83 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
84 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
86 Right
-= (PenWidth
- 1) / 2;
88 Bottom
-= (PenWidth
- 1) / 2;
91 if (!PenWidth
) PenWidth
= 1;
92 pbrPen
->lWidth
= PenWidth
;
94 RectBounds
.left
= Left
;
95 RectBounds
.right
= Right
;
97 RectBounds
.bottom
= Bottom
;
99 RectSEpts
.left
= XRadialStart
;
100 RectSEpts
.top
= YRadialStart
;
101 RectSEpts
.right
= XRadialEnd
;
102 RectSEpts
.bottom
= YRadialEnd
;
104 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
105 IntLPtoDP(dc
, (LPPOINT
)&RectSEpts
, 2);
107 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
108 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
109 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
110 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
112 RectSEpts
.left
+= dc
->ptlDCOrig
.x
;
113 RectSEpts
.top
+= dc
->ptlDCOrig
.y
;
114 RectSEpts
.right
+= dc
->ptlDCOrig
.x
;
115 RectSEpts
.bottom
+= dc
->ptlDCOrig
.y
;
117 DPRINT("1: StartX: %d, StartY: %d, EndX: %d, EndY: %d\n",
118 RectSEpts
.left
,RectSEpts
.top
,RectSEpts
.right
,RectSEpts
.bottom
);
120 DPRINT("1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
121 RectBounds
.left
,RectBounds
.top
,RectBounds
.right
,RectBounds
.bottom
);
123 CenterX
= (RectBounds
.right
+ RectBounds
.left
) / 2;
124 CenterY
= (RectBounds
.bottom
+ RectBounds
.top
) / 2;
125 AngleEnd
= atan2((RectSEpts
.bottom
- CenterY
), RectSEpts
.right
- CenterX
)*(360.0/(M_PI
*2));
126 AngleStart
= atan2((RectSEpts
.top
- CenterY
), RectSEpts
.left
- CenterX
)*(360.0/(M_PI
*2));
128 /* Edge Case: Check if the start segments overlaps(is equal) the end segment */
129 if (AngleEnd
== AngleStart
)
131 AngleStart
= AngleEnd
+ 360.0; // Arc(), ArcTo(), Pie() and Chord() are counterclockwise APIs.
134 if ((arctype
== GdiTypePie
) || (arctype
== GdiTypeChord
))
136 ret
= IntFillArc( dc
,
139 abs(RectBounds
.right
-RectBounds
.left
), // Width
140 abs(RectBounds
.bottom
-RectBounds
.top
), // Height
148 ret
= IntDrawArc( dc
,
151 abs(RectBounds
.right
-RectBounds
.left
), // Width
152 abs(RectBounds
.bottom
-RectBounds
.top
), // Height
159 psurf
= dc
->dclevel
.pSurface
;
162 DPRINT1("Arc Fail 2\n");
163 PEN_ShareUnlockPen(pbrPen
);
164 EngSetLastError(ERROR_INTERNAL_ERROR
);
168 if (arctype
== GdiTypePie
)
170 PUTLINE(CenterX
, CenterY
, RectSEpts
.left
, RectSEpts
.top
, dc
->eboLine
);
171 PUTLINE(RectSEpts
.right
, RectSEpts
.bottom
, CenterX
, CenterY
, dc
->eboLine
);
173 if (arctype
== GdiTypeChord
)
174 PUTLINE(RectSEpts
.right
, RectSEpts
.bottom
, RectSEpts
.left
, RectSEpts
.top
, dc
->eboLine
);
176 pbrPen
->lWidth
= PenOrigWidth
;
177 PEN_ShareUnlockPen(pbrPen
);
178 DPRINT("IntArc Exit.\n");
199 DPRINT("StartX: %d, StartY: %d, EndX: %d, EndY: %d\n",
200 XStartArc
,YStartArc
,XEndArc
,YEndArc
);
201 DPRINT("Left: %d, Top: %d, Right: %d, Bottom: %d\n",
202 LeftRect
,TopRect
,RightRect
,BottomRect
);
204 if ((LeftRect
== RightRect
) || (TopRect
== BottomRect
)) return TRUE
;
206 if (PATH_IsPathOpen(dc
->dclevel
))
221 //pdcattr = dc->pdcattr;
223 if (arctype
== GdiTypeArcTo
)
225 if (dc
->dclevel
.flPath
& DCPATH_CLOCKWISE
)
226 IntGdiLineTo(dc
, XEndArc
, YEndArc
);
228 IntGdiLineTo(dc
, XStartArc
, YStartArc
);
242 if (arctype
== GdiTypeArcTo
)
244 if (dc
->dclevel
.flPath
& DCPATH_CLOCKWISE
)
245 IntGdiMoveToEx(dc
, XStartArc
, YStartArc
, NULL
);
247 IntGdiMoveToEx(dc
, XEndArc
, YEndArc
, NULL
);
254 IntGdiAngleArc( PDC pDC
,
261 INT x1
, y1
, x2
, y2
, arcdir
;
264 /* Calculate the end point */
265 x2
= x
+ (INT
)(cos(((eStartAngle
+eSweepAngle
)/360)*(M_PI
*2)) * dwRadius
);
266 y2
= y
- (INT
)(sin(((eStartAngle
+eSweepAngle
)/360)*(M_PI
*2)) * dwRadius
);
268 x1
= x
+ (INT
)(cos((eStartAngle
/360)*(M_PI
*2)) * dwRadius
);
269 y1
= y
- (INT
)(sin((eStartAngle
/360)*(M_PI
*2)) * dwRadius
);
271 arcdir
= pDC
->dclevel
.flPath
& DCPATH_CLOCKWISE
;
272 if (eSweepAngle
>= 0)
273 pDC
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
275 pDC
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
277 result
= IntGdiArcInternal( GdiTypeArcTo
,
288 pDC
->dclevel
.flPath
|= (arcdir
& DCPATH_CLOCKWISE
);
292 IntGdiMoveToEx(pDC
, x2
, y2
, NULL
);
297 /* FUNCTIONS *****************************************************************/
306 IN DWORD dwStartAngle
,
307 IN DWORD dwSweepAngle
)
311 gxf_long worker
, worker1
;
312 KFLOATING_SAVE FloatSave
;
315 pDC
= DC_LockDc (hDC
);
318 EngSetLastError(ERROR_INVALID_HANDLE
);
322 status
= KeSaveFloatingPointState(&FloatSave
);
323 if (!NT_SUCCESS(status
))
329 worker
.l
= dwStartAngle
;
330 worker1
.l
= dwSweepAngle
;
331 DC_vPrepareDCsForBlit(pDC
, NULL
, NULL
, NULL
);
332 if (pDC
->pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
333 DC_vUpdateFillBrush(pDC
);
334 if (pDC
->pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
335 DC_vUpdateLineBrush(pDC
);
336 Ret
= IntGdiAngleArc( pDC
, x
, y
, dwRadius
, worker
.f
, worker1
.f
);
337 DC_vFinishBlit(pDC
, NULL
);
340 KeRestoreFloatingPointState(&FloatSave
);
361 KFLOATING_SAVE FloatSave
;
364 dc
= DC_LockDc (hDC
);
367 EngSetLastError(ERROR_INVALID_HANDLE
);
370 if (arctype
> GdiTypePie
)
373 EngSetLastError(ERROR_INVALID_PARAMETER
);
377 DC_vPrepareDCsForBlit(dc
, NULL
, NULL
, NULL
);
379 if (dc
->pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
380 DC_vUpdateFillBrush(dc
);
382 if (dc
->pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
383 DC_vUpdateLineBrush(dc
);
385 status
= KeSaveFloatingPointState(&FloatSave
);
386 if (!NT_SUCCESS(status
))
392 Ret
= IntGdiArcInternal(
404 KeRestoreFloatingPointState(&FloatSave
);
405 DC_vFinishBlit(dc
, NULL
);