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 ret = EngLineTo(SurfObj,
126 PenToBrushObj(dc, pen),
127 dc->w.CursPosX, dc->w.CursPosY, XEnd, YEnd,
128 reg, // Bounding rectangle
129 dc->w.ROPmode); // MIX
131 GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
132 GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
135 dc->w.CursPosX = XEnd;
136 dc->w.CursPosY = YEnd;
138 DC_ReleasePtr( hDC );
144 W32kMoveToEx(HDC hDC,
149 DC *dc = DC_HandleToPtr( hDC );
151 if(!dc) return FALSE;
154 Point->x = dc->w.CursPosX;
155 Point->y = dc->w.CursPosY;
160 if(PATH_IsPathOpen(dc->w.path)){
161 DC_ReleasePtr( hDC );
162 return PATH_MoveTo(hDC);
164 DC_ReleasePtr( hDC );
170 W32kPolyBezier(HDC hDC,
174 DC *dc = DC_HandleToPtr(hDC);
175 if(!dc) return FALSE;
177 if(PATH_IsPathOpen(dc->w.path)){
178 DC_ReleasePtr( hDC );
179 return PATH_PolyBezier(hDC, pt, Count);
182 /* We'll convert it into line segments and draw them using Polyline */
188 Pts = GDI_Bezier(pt, Count, &nOut);
189 if(!Pts) return FALSE;
190 DbgPrint("Pts = %p, no = %d\n", Pts, nOut);
191 ret = W32kPolyline(dc->hSelf, Pts, nOut);
193 DC_ReleasePtr( hDC );
200 W32kPolyBezierTo(HDC hDC,
204 DC *dc = DC_HandleToPtr(hDC);
207 if(!dc) return FALSE;
209 if(PATH_IsPathOpen(dc->w.path))
210 ret = PATH_PolyBezierTo(hDC, pt, Count);
211 else { /* We'll do it using PolyBezier */
213 npt = ExAllocatePool(NonPagedPool, sizeof(POINT) * (Count + 1));
214 if(!npt) return FALSE;
215 npt[0].x = dc->w.CursPosX;
216 npt[0].y = dc->w.CursPosY;
217 memcpy(npt + 1, pt, sizeof(POINT) * Count);
218 ret = W32kPolyBezier(dc->hSelf, npt, Count+1);
222 dc->w.CursPosX = pt[Count-1].x;
223 dc->w.CursPosY = pt[Count-1].y;
225 DC_ReleasePtr( hDC );
231 W32kPolyDraw(HDC hDC,
241 W32kPolyline(HDC hDC,
250 W32kPolylineTo(HDC hDC,
254 DC *dc = DC_HandleToPtr(hDC);
257 if(!dc) return FALSE;
259 if(PATH_IsPathOpen(dc->w.path))
261 ret = PATH_PolylineTo(hDC, pt, Count);
263 else { /* do it using Polyline */
264 POINT *pts = ExAllocatePool(NonPagedPool, sizeof(POINT) * (Count + 1));
265 if(!pts) return FALSE;
267 pts[0].x = dc->w.CursPosX;
268 pts[0].y = dc->w.CursPosY;
269 memcpy( pts + 1, pt, sizeof(POINT) * Count);
270 ret = W32kPolyline(hDC, pts, Count + 1);
274 dc->w.CursPosX = pt[Count-1].x;
275 dc->w.CursPosY = pt[Count-1].y;
277 DC_ReleasePtr( hDC );
283 W32kPolyPolyline(HDC hDC,
285 CONST LPDWORD PolyPoints,
293 W32kSetArcDirection(HDC hDC,
299 dc = DC_HandleToPtr (hDC);
304 if (ArcDirection != AD_COUNTERCLOCKWISE && ArcDirection != AD_CLOCKWISE)
306 // SetLastError(ERROR_INVALID_PARAMETER);
307 DC_ReleasePtr( hDC );
311 nOldDirection = dc->w.ArcDirection;
312 dc->w.ArcDirection = ArcDirection;
313 DC_ReleasePtr( hDC );
314 return nOldDirection;