7 * a couple macros to fill a single pixel or a line
9 #define PUTPIXEL(x,y,BrushInst) \
10 ret = ret && IntEngLineTo(&psurf->SurfObj, \
11 dc->rosdc.CombinedClip, \
12 &BrushInst.BrushObject, \
15 ROP2_TO_MIX(pdcattr->jROP2));
17 #define PUTLINE(x1,y1,x2,y2,BrushInst) \
18 ret = ret && IntEngLineTo(&psurf->SurfObj, \
19 dc->rosdc.CombinedClip, \
20 &BrushInst.BrushObject, \
23 ROP2_TO_MIX(pdcattr->jROP2));
25 #define Rsin(d) ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
26 #define Rcos(d) ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
28 BOOL FASTCALL
IntFillArc( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, double StartArc
, double EndArc
, ARCTYPE arctype
);
29 BOOL FASTCALL
IntDrawArc( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, double StartArc
, double EndArc
, ARCTYPE arctype
, PBRUSH pbrush
);
46 RECTL RectBounds
, RectSEpts
;
50 LONG PenWidth
, PenOrigWidth
;
51 double AngleStart
, AngleEnd
;
52 LONG RadiusX
, RadiusY
, CenterX
, CenterY
;
53 LONG SfCx
, SfCy
, EfCx
, EfCy
;
57 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
61 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
63 if ((Left
== Right
) ||
65 (((arctype
!= GdiTypeArc
) || (arctype
!= GdiTypeArcTo
)) &&
66 ((Right
- Left
== 1) ||
67 (Bottom
- Top
== 1))))
70 pdcattr
= dc
->pdcattr
;
72 pbrushPen
= PEN_LockPen(pdcattr
->hpen
);
75 DPRINT1("Arc Fail 1\n");
76 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
80 PenOrigWidth
= PenWidth
= pbrushPen
->ptPenWidth
.x
;
81 if (pbrushPen
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
83 if (pbrushPen
->ulPenStyle
== PS_INSIDEFRAME
)
85 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
86 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
88 Right
-= (PenWidth
- 1) / 2;
90 Bottom
-= (PenWidth
- 1) / 2;
93 if (!PenWidth
) PenWidth
= 1;
94 pbrushPen
->ptPenWidth
.x
= PenWidth
;
96 RectBounds
.left
= Left
;
97 RectBounds
.right
= Right
;
99 RectBounds
.bottom
= Bottom
;
101 RectSEpts
.left
= XRadialStart
;
102 RectSEpts
.top
= YRadialStart
;
103 RectSEpts
.right
= XRadialEnd
;
104 RectSEpts
.bottom
= YRadialEnd
;
106 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
107 IntLPtoDP(dc
, (LPPOINT
)&RectSEpts
, 2);
109 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
110 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
111 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
112 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
114 RectSEpts
.left
+= dc
->ptlDCOrig
.x
;
115 RectSEpts
.top
+= dc
->ptlDCOrig
.y
;
116 RectSEpts
.right
+= dc
->ptlDCOrig
.x
;
117 RectSEpts
.bottom
+= dc
->ptlDCOrig
.y
;
119 DPRINT("1: StartX: %d, StartY: %d, EndX: %d, EndY: %d\n",
120 RectSEpts
.left
,RectSEpts
.top
,RectSEpts
.right
,RectSEpts
.bottom
);
122 DPRINT("1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
123 RectBounds
.left
,RectBounds
.top
,RectBounds
.right
,RectBounds
.bottom
);
125 RadiusX
= max((RectBounds
.right
- RectBounds
.left
) / 2, 1);
126 RadiusY
= max((RectBounds
.bottom
- RectBounds
.top
) / 2, 1);
127 CenterX
= (RectBounds
.right
+ RectBounds
.left
) / 2;
128 CenterY
= (RectBounds
.bottom
+ RectBounds
.top
) / 2;
129 AngleEnd
= atan2((RectSEpts
.bottom
- CenterY
), RectSEpts
.right
- CenterX
)*(360.0/(M_PI
*2));
130 AngleStart
= atan2((RectSEpts
.top
- CenterY
), RectSEpts
.left
- CenterX
)*(360.0/(M_PI
*2));
132 SfCx
= (Rcos(AngleStart
) * RadiusX
);
133 SfCy
= (Rsin(AngleStart
) * RadiusY
);
134 EfCx
= (Rcos(AngleEnd
) * RadiusX
);
135 EfCy
= (Rsin(AngleEnd
) * RadiusY
);
137 if ((arctype
== GdiTypePie
) || (arctype
== GdiTypeChord
))
139 ret
= IntFillArc( dc
,
142 abs(RectBounds
.right
-RectBounds
.left
), // Width
143 abs(RectBounds
.bottom
-RectBounds
.top
), // Height
149 ret
= IntDrawArc( dc
,
152 abs(RectBounds
.right
-RectBounds
.left
), // Width
153 abs(RectBounds
.bottom
-RectBounds
.top
), // Height
159 psurf
= dc
->dclevel
.pSurface
;
162 DPRINT1("Arc Fail 2\n");
163 PEN_UnlockPen(pbrushPen
);
164 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
168 if (arctype
== GdiTypePie
)
170 PUTLINE(CenterX
, CenterY
, SfCx
+ CenterX
, SfCy
+ CenterY
, dc
->eboLine
);
171 PUTLINE(EfCx
+ CenterX
, EfCy
+ CenterY
, CenterX
, CenterY
, dc
->eboLine
);
173 if (arctype
== GdiTypeChord
)
174 PUTLINE(EfCx
+ CenterX
, EfCy
+ CenterY
, SfCx
+ CenterX
, SfCy
+ CenterY
, dc
->eboLine
);
176 pbrushPen
->ptPenWidth
.x
= PenOrigWidth
;
177 PEN_UnlockPen(pbrushPen
);
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
))
220 pdcattr
= dc
->pdcattr
;
222 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
223 DC_vUpdateFillBrush(dc
);
225 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
226 DC_vUpdateLineBrush(dc
);
228 if (arctype
== GdiTypeArcTo
)
230 if (dc
->dclevel
.flPath
& DCPATH_CLOCKWISE
)
231 IntGdiLineTo(dc
, XEndArc
, YEndArc
);
233 IntGdiLineTo(dc
, XStartArc
, YStartArc
);
247 if (arctype
== GdiTypeArcTo
)
249 if (dc
->dclevel
.flPath
& DCPATH_CLOCKWISE
)
250 IntGdiMoveToEx(dc
, XStartArc
, YStartArc
, NULL
, TRUE
);
252 IntGdiMoveToEx(dc
, XEndArc
, YEndArc
, NULL
, TRUE
);
259 IntGdiAngleArc( PDC pDC
,
266 INT x1
, y1
, x2
, y2
, arcdir
;
269 /* Calculate the end point */
270 x2
= x
+ (INT
)(cos(((eStartAngle
+eSweepAngle
)/360)*(M_PI
*2)) * dwRadius
);
271 y2
= y
- (INT
)(sin(((eStartAngle
+eSweepAngle
)/360)*(M_PI
*2)) * dwRadius
);
273 x1
= x
+ (INT
)(cos((eStartAngle
/360)*(M_PI
*2)) * dwRadius
);
274 y1
= y
- (INT
)(sin((eStartAngle
/360)*(M_PI
*2)) * dwRadius
);
276 arcdir
= pDC
->dclevel
.flPath
& DCPATH_CLOCKWISE
;
277 if (eSweepAngle
>= 0)
278 pDC
->dclevel
.flPath
&= ~DCPATH_CLOCKWISE
;
280 pDC
->dclevel
.flPath
|= DCPATH_CLOCKWISE
;
282 result
= IntGdiArcInternal( GdiTypeArcTo
,
293 pDC
->dclevel
.flPath
|= (arcdir
& DCPATH_CLOCKWISE
);
297 IntGdiMoveToEx(pDC
, x2
, y2
, NULL
, TRUE
);
302 /* FUNCTIONS *****************************************************************/
311 IN DWORD dwStartAngle
,
312 IN DWORD dwSweepAngle
)
316 gxf_long worker
, worker1
;
318 pDC
= DC_LockDc (hDC
);
321 SetLastWin32Error(ERROR_INVALID_HANDLE
);
324 if (pDC
->dctype
== DC_TYPE_INFO
)
327 /* Yes, Windows really returns TRUE in this case */
330 worker
.l
= dwStartAngle
;
331 worker1
.l
= dwSweepAngle
;
332 Ret
= IntGdiAngleArc( pDC
, x
, y
, dwRadius
, worker
.f
, worker1
.f
);
354 dc
= DC_LockDc (hDC
);
357 SetLastWin32Error(ERROR_INVALID_HANDLE
);
360 if (dc
->dctype
== DC_TYPE_INFO
)
363 /* Yes, Windows really returns TRUE in this case */
367 Ret
= IntGdiArcInternal(