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>
13 #include <win32k/debug1.h>
39 DC *dc = DC_HandleToPtr(hDC);
42 if(PATH_IsPathOpen(dc->w.path))
43 return PATH_Arc(hDC, LeftRect, TopRect, RightRect, BottomRect,
44 XStartArc, YStartArc, XEndArc, YEndArc);
47 // EngArc(dc, LeftRect, TopRect, RightRect, BottomRect, UNIMPLEMENTED
48 // XStartArc, YStartArc, XEndArc, YEndArc);
64 DC *dc = DC_HandleToPtr(hDC);
67 // Line from current position to starting point of arc
68 W32kLineTo(hDC, XRadial1, YRadial1);
70 // Then the arc is drawn.
71 result = W32kArc(hDC, LeftRect, TopRect, RightRect, BottomRect,
72 XRadial1, YRadial1, XRadial2, YRadial2);
74 // If no error occured, the current position is moved to the ending point of the arc.
77 W32kMoveToEx(hDC, XRadial2, YRadial2, NULL);
85 W32kGetArcDirection(HDC hDC)
90 dc = DC_HandleToPtr (hDC);
96 ret = dc->w.ArcDirection;
107 DC *dc = DC_HandleToPtr(hDC);
108 SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
113 if(!dc) return FALSE;
115 if(PATH_IsPathOpen(dc->w.path)) {
116 ret = PATH_LineTo(hDC, XEnd, YEnd);
118 pen = (PPENOBJ) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
119 reg = (PROSRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
122 // not yet implemented ASSERT( reg );
124 /* Draw the line according to the DC origin */
125 ret = EngLineTo(SurfObj,
127 PenToBrushObj(dc, pen),
128 dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
129 dc->w.DCOrgX + XEnd, dc->w.DCOrgY + YEnd,
130 reg, // Bounding rectangle
131 dc->w.ROPmode); // MIX
133 GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
134 GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
137 dc->w.CursPosX = XEnd;
138 dc->w.CursPosY = YEnd;
140 DC_ReleasePtr( hDC );
146 W32kMoveToEx(HDC hDC,
151 DC *dc = DC_HandleToPtr( hDC );
153 if(!dc) return FALSE;
156 Point->x = dc->w.CursPosX;
157 Point->y = dc->w.CursPosY;
162 if(PATH_IsPathOpen(dc->w.path)){
163 DC_ReleasePtr( hDC );
164 return PATH_MoveTo(hDC);
166 DC_ReleasePtr( hDC );
172 W32kPolyBezier(HDC hDC,
176 DC *dc = DC_HandleToPtr(hDC);
177 if(!dc) return FALSE;
179 if(PATH_IsPathOpen(dc->w.path)){
180 DC_ReleasePtr( hDC );
181 return PATH_PolyBezier(hDC, pt, Count);
184 /* We'll convert it into line segments and draw them using Polyline */
190 Pts = GDI_Bezier(pt, Count, &nOut);
191 if(!Pts) return FALSE;
192 DbgPrint("Pts = %p, no = %d\n", Pts, nOut);
193 ret = W32kPolyline(dc->hSelf, Pts, nOut);
195 DC_ReleasePtr( hDC );
202 W32kPolyBezierTo(HDC hDC,
206 DC *dc = DC_HandleToPtr(hDC);
209 if(!dc) return FALSE;
211 if(PATH_IsPathOpen(dc->w.path))
212 ret = PATH_PolyBezierTo(hDC, pt, Count);
213 else { /* We'll do it using PolyBezier */
215 npt = ExAllocatePool(NonPagedPool, sizeof(POINT) * (Count + 1));
216 if(!npt) return FALSE;
217 npt[0].x = dc->w.CursPosX;
218 npt[0].y = dc->w.CursPosY;
219 memcpy(npt + 1, pt, sizeof(POINT) * Count);
220 ret = W32kPolyBezier(dc->hSelf, npt, Count+1);
224 dc->w.CursPosX = pt[Count-1].x;
225 dc->w.CursPosY = pt[Count-1].y;
227 DC_ReleasePtr( hDC );
233 W32kPolyDraw(HDC hDC,
243 W32kPolyline(HDC hDC,
252 W32kPolylineTo(HDC hDC,
256 DC *dc = DC_HandleToPtr(hDC);
259 if(!dc) return FALSE;
261 if(PATH_IsPathOpen(dc->w.path))
263 ret = PATH_PolylineTo(hDC, pt, Count);
265 else { /* do it using Polyline */
266 POINT *pts = ExAllocatePool(NonPagedPool, sizeof(POINT) * (Count + 1));
267 if(!pts) return FALSE;
269 pts[0].x = dc->w.CursPosX;
270 pts[0].y = dc->w.CursPosY;
271 memcpy( pts + 1, pt, sizeof(POINT) * Count);
272 ret = W32kPolyline(hDC, pts, Count + 1);
276 dc->w.CursPosX = pt[Count-1].x;
277 dc->w.CursPosY = pt[Count-1].y;
279 DC_ReleasePtr( hDC );
285 W32kPolyPolyline(HDC hDC,
287 CONST LPDWORD PolyPoints,
295 W32kSetArcDirection(HDC hDC,
301 dc = DC_HandleToPtr (hDC);
306 if (ArcDirection != AD_COUNTERCLOCKWISE && ArcDirection != AD_CLOCKWISE)
308 // SetLastError(ERROR_INVALID_PARAMETER);
309 DC_ReleasePtr( hDC );
313 nOldDirection = dc->w.ArcDirection;
314 dc->w.ArcDirection = ArcDirection;
315 DC_ReleasePtr( hDC );
316 return nOldDirection;