1 // Some code from the WINE project source (www.winehq.com)
3 #undef WIN32_LEAN_AND_MEAN
7 #include <win32k/line.h>
8 #include <win32k/path.h>
9 #include <win32k/pen.h>
10 #include <win32k/region.h>
11 #include <include/inteng.h>
14 #include <win32k/debug1.h>
41 DC
*dc
= DC_HandleToPtr(hDC
);
44 if(PATH_IsPathOpen(dc
->w
.path
))
45 return PATH_Arc(hDC
, LeftRect
, TopRect
, RightRect
, BottomRect
,
46 XStartArc
, YStartArc
, XEndArc
, YEndArc
);
49 // EngArc(dc, LeftRect, TopRect, RightRect, BottomRect, UNIMPLEMENTED
50 // XStartArc, YStartArc, XEndArc, YEndArc);
66 DC
*dc
= DC_HandleToPtr(hDC
);
69 // Line from current position to starting point of arc
70 W32kLineTo(hDC
, XRadial1
, YRadial1
);
72 // Then the arc is drawn.
73 result
= W32kArc(hDC
, LeftRect
, TopRect
, RightRect
, BottomRect
,
74 XRadial1
, YRadial1
, XRadial2
, YRadial2
);
76 // If no error occured, the current position is moved to the ending point of the arc.
79 W32kMoveToEx(hDC
, XRadial2
, YRadial2
, NULL
);
87 W32kGetArcDirection(HDC hDC
)
92 dc
= DC_HandleToPtr (hDC
);
98 ret
= dc
->w
.ArcDirection
;
109 DC
*dc
= DC_HandleToPtr(hDC
);
110 SURFOBJ
*SurfObj
= (SURFOBJ
*)AccessUserObject(dc
->Surface
);
118 if(!dc
) return FALSE
;
120 if(PATH_IsPathOpen(dc
->w
.path
)) {
121 ret
= PATH_LineTo(hDC
, XEnd
, YEnd
);
123 pen
= (PPENOBJ
) GDIOBJ_LockObj(dc
->w
.hPen
, GO_PEN_MAGIC
);
124 reg
= (PROSRGNDATA
)GDIOBJ_LockObj(dc
->w
.hGCClipRgn
, GO_REGION_MAGIC
);
127 // not yet implemented ASSERT( reg );
130 defaultrect
.left
= 0;
132 defaultrect
.right
= 640;
133 defaultrect
.bottom
= 480;
139 /* Draw the line according to the DC origin */
140 ret
= IntEngLineTo(SurfObj
,
142 PenToBrushObj(dc
, pen
),
143 dc
->w
.DCOrgX
+ dc
->w
.CursPosX
, dc
->w
.DCOrgY
+ dc
->w
.CursPosY
,
144 dc
->w
.DCOrgX
+ XEnd
, dc
->w
.DCOrgY
+ YEnd
,
145 reg
, // Bounding rectangle
146 dc
->w
.ROPmode
); // MIX
148 GDIOBJ_UnlockObj( dc
->w
.hGCClipRgn
, GO_REGION_MAGIC
);
149 GDIOBJ_UnlockObj( dc
->w
.hPen
, GO_PEN_MAGIC
);
152 dc
->w
.CursPosX
= XEnd
;
153 dc
->w
.CursPosY
= YEnd
;
155 DC_ReleasePtr( hDC
);
161 W32kMoveToEx(HDC hDC
,
166 DC
*dc
= DC_HandleToPtr( hDC
);
168 if(!dc
) return FALSE
;
171 Point
->x
= dc
->w
.CursPosX
;
172 Point
->y
= dc
->w
.CursPosY
;
177 if(PATH_IsPathOpen(dc
->w
.path
)){
178 DC_ReleasePtr( hDC
);
179 return PATH_MoveTo(hDC
);
181 DC_ReleasePtr( hDC
);
187 W32kPolyBezier(HDC hDC
,
191 DC
*dc
= DC_HandleToPtr(hDC
);
192 if(!dc
) return FALSE
;
194 if(PATH_IsPathOpen(dc
->w
.path
)){
195 DC_ReleasePtr( hDC
);
196 return PATH_PolyBezier(hDC
, pt
, Count
);
199 /* We'll convert it into line segments and draw them using Polyline */
205 Pts
= GDI_Bezier(pt
, Count
, &nOut
);
206 if(!Pts
) return FALSE
;
207 DbgPrint("Pts = %p, no = %d\n", Pts
, nOut
);
208 ret
= W32kPolyline(dc
->hSelf
, Pts
, nOut
);
210 DC_ReleasePtr( hDC
);
217 W32kPolyBezierTo(HDC hDC
,
221 DC
*dc
= DC_HandleToPtr(hDC
);
224 if(!dc
) return FALSE
;
226 if(PATH_IsPathOpen(dc
->w
.path
))
227 ret
= PATH_PolyBezierTo(hDC
, pt
, Count
);
228 else { /* We'll do it using PolyBezier */
230 npt
= ExAllocatePool(NonPagedPool
, sizeof(POINT
) * (Count
+ 1));
231 if(!npt
) return FALSE
;
232 npt
[0].x
= dc
->w
.CursPosX
;
233 npt
[0].y
= dc
->w
.CursPosY
;
234 memcpy(npt
+ 1, pt
, sizeof(POINT
) * Count
);
235 ret
= W32kPolyBezier(dc
->hSelf
, npt
, Count
+1);
239 dc
->w
.CursPosX
= pt
[Count
-1].x
;
240 dc
->w
.CursPosY
= pt
[Count
-1].y
;
242 DC_ReleasePtr( hDC
);
248 W32kPolyDraw(HDC hDC
,
258 W32kPolyline(HDC hDC
,
267 W32kPolylineTo(HDC hDC
,
271 DC
*dc
= DC_HandleToPtr(hDC
);
274 if(!dc
) return FALSE
;
276 if(PATH_IsPathOpen(dc
->w
.path
))
278 ret
= PATH_PolylineTo(hDC
, pt
, Count
);
280 else { /* do it using Polyline */
281 POINT
*pts
= ExAllocatePool(NonPagedPool
, sizeof(POINT
) * (Count
+ 1));
282 if(!pts
) return FALSE
;
284 pts
[0].x
= dc
->w
.CursPosX
;
285 pts
[0].y
= dc
->w
.CursPosY
;
286 memcpy( pts
+ 1, pt
, sizeof(POINT
) * Count
);
287 ret
= W32kPolyline(hDC
, pts
, Count
+ 1);
291 dc
->w
.CursPosX
= pt
[Count
-1].x
;
292 dc
->w
.CursPosY
= pt
[Count
-1].y
;
294 DC_ReleasePtr( hDC
);
300 W32kPolyPolyline(HDC hDC
,
302 CONST LPDWORD PolyPoints
,
310 W32kSetArcDirection(HDC hDC
,
316 dc
= DC_HandleToPtr (hDC
);
321 if (ArcDirection
!= AD_COUNTERCLOCKWISE
&& ArcDirection
!= AD_CLOCKWISE
)
323 // SetLastError(ERROR_INVALID_PARAMETER);
324 DC_ReleasePtr( hDC
);
328 nOldDirection
= dc
->w
.ArcDirection
;
329 dc
->w
.ArcDirection
= ArcDirection
;
330 DC_ReleasePtr( hDC
);
331 return nOldDirection
;