1 // Some code from the WINE project source (www.winehq.com)
3 #undef WIN32_LEAN_AND_MEAN
5 #include <internal/safe.h>
8 #include <win32k/line.h>
9 #include <win32k/path.h>
10 #include <win32k/pen.h>
11 #include <win32k/region.h>
12 #include <include/inteng.h>
15 #include <win32k/debug1.h>
42 DC *dc = DC_HandleToPtr(hDC);
45 if(PATH_IsPathOpen(dc->w.path))
46 return PATH_Arc(hDC, LeftRect, TopRect, RightRect, BottomRect,
47 XStartArc, YStartArc, XEndArc, YEndArc);
50 // EngArc(dc, LeftRect, TopRect, RightRect, BottomRect, UNIMPLEMENTED
51 // XStartArc, YStartArc, XEndArc, YEndArc);
67 DC *dc = DC_HandleToPtr(hDC);
70 // Line from current position to starting point of arc
71 W32kLineTo(hDC, XRadial1, YRadial1);
73 // Then the arc is drawn.
74 result = W32kArc(hDC, LeftRect, TopRect, RightRect, BottomRect,
75 XRadial1, YRadial1, XRadial2, YRadial2);
77 // If no error occured, the current position is moved to the ending point of the arc.
80 W32kMoveToEx(hDC, XRadial2, YRadial2, NULL);
88 W32kGetArcDirection(HDC hDC)
93 dc = DC_HandleToPtr (hDC);
99 ret = dc->w.ArcDirection;
100 DC_ReleasePtr( hDC );
110 DC *dc = DC_HandleToPtr(hDC);
111 SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
119 if(!dc) return FALSE;
121 if(PATH_IsPathOpen(dc->w.path)) {
122 ret = PATH_LineTo(hDC, XEnd, YEnd);
124 pen = (PPENOBJ) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
125 reg = (PROSRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
128 // not yet implemented ASSERT( reg );
131 defaultrect.left = 0;
133 defaultrect.right = 640;
134 defaultrect.bottom = 480;
140 /* Draw the line according to the DC origin */
141 ret = IntEngLineTo(SurfObj,
143 PenToBrushObj(dc, pen),
144 dc->w.DCOrgX + dc->w.CursPosX, dc->w.DCOrgY + dc->w.CursPosY,
145 dc->w.DCOrgX + XEnd, dc->w.DCOrgY + YEnd,
146 reg, // Bounding rectangle
147 dc->w.ROPmode); // MIX
149 GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
150 GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
153 dc->w.CursPosX = XEnd;
154 dc->w.CursPosY = YEnd;
156 DC_ReleasePtr( hDC );
162 W32kMoveToEx(HDC hDC,
167 DC *dc = DC_HandleToPtr( hDC );
169 if(!dc) return FALSE;
172 Point->x = dc->w.CursPosX;
173 Point->y = dc->w.CursPosY;
178 if(PATH_IsPathOpen(dc->w.path)){
179 DC_ReleasePtr( hDC );
180 return PATH_MoveTo(hDC);
182 DC_ReleasePtr( hDC );
188 W32kPolyBezier(HDC hDC,
192 DC *dc = DC_HandleToPtr(hDC);
193 if(!dc) return FALSE;
195 if(PATH_IsPathOpen(dc->w.path)){
196 DC_ReleasePtr( hDC );
197 return PATH_PolyBezier(hDC, pt, Count);
200 /* We'll convert it into line segments and draw them using Polyline */
206 Pts = GDI_Bezier(pt, Count, &nOut);
207 if(!Pts) return FALSE;
208 DbgPrint("Pts = %p, no = %d\n", Pts, nOut);
209 ret = W32kPolyline(dc->hSelf, Pts, nOut);
211 DC_ReleasePtr( hDC );
218 W32kPolyBezierTo(HDC hDC,
222 DC *dc = DC_HandleToPtr(hDC);
225 if(!dc) return FALSE;
227 if(PATH_IsPathOpen(dc->w.path))
228 ret = PATH_PolyBezierTo(hDC, pt, Count);
229 else { /* We'll do it using PolyBezier */
231 npt = ExAllocatePool(NonPagedPool, sizeof(POINT) * (Count + 1));
232 if(!npt) return FALSE;
233 npt[0].x = dc->w.CursPosX;
234 npt[0].y = dc->w.CursPosY;
235 memcpy(npt + 1, pt, sizeof(POINT) * Count);
236 ret = W32kPolyBezier(dc->hSelf, npt, Count+1);
240 dc->w.CursPosX = pt[Count-1].x;
241 dc->w.CursPosY = pt[Count-1].y;
243 DC_ReleasePtr( hDC );
249 W32kPolyDraw(HDC hDC,
259 W32kPolyline(HDC hDC,
263 DC *dc = DC_HandleToPtr(hDC);
264 SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject(dc->Surface);
274 if(PATH_IsPathOpen(dc->w.path))
276 ret = PATH_Polyline(hDC, pt, Count);
280 pen = (PPENOBJ) GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC);
281 reg = (PROSRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC);
285 //FIXME: Do somthing with reg...
287 //Allocate "Count" bytes of memory to hold a safe copy of pt
288 if (!(pts=ExAllocatePool(NonPagedPool, sizeof(POINT) * Count)))
290 GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
291 GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
292 DC_ReleasePtr( hDC );
296 //safly copy pt to local version
297 if (STATUS_SUCCESS!=MmCopyFromCaller(pts, pt, sizeof(POINT) * Count))
300 GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
301 GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
302 DC_ReleasePtr( hDC );
306 //offset the array of point by the dc->w.DCOrg
307 for(i=0; i<Count; i++)
309 pts[i].x += dc->w.DCOrgX;
310 pts[i].y += dc->w.DCOrgY;
313 //get IntEngPolyline to do the drawing.
314 ret = IntEngPolyline(SurfObj,
316 PenToBrushObj(dc, pen),
323 GDIOBJ_UnlockObj( dc->w.hGCClipRgn, GO_REGION_MAGIC );
324 GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC);
327 DC_ReleasePtr( hDC );
333 W32kPolylineTo(HDC hDC,
337 DC *dc = DC_HandleToPtr(hDC);
340 if(!dc) return FALSE;
342 if(PATH_IsPathOpen(dc->w.path))
344 ret = PATH_PolylineTo(hDC, pt, Count);
346 else { /* do it using Polyline */
347 POINT *pts = ExAllocatePool(NonPagedPool, sizeof(POINT) * (Count + 1));
348 if(!pts) return FALSE;
350 pts[0].x = dc->w.CursPosX;
351 pts[0].y = dc->w.CursPosY;
352 memcpy( pts + 1, pt, sizeof(POINT) * Count);
353 ret = W32kPolyline(hDC, pts, Count + 1);
357 dc->w.CursPosX = pt[Count-1].x;
358 dc->w.CursPosY = pt[Count-1].y;
360 DC_ReleasePtr( hDC );
366 W32kPolyPolyline(HDC hDC,
368 CONST LPDWORD PolyPoints,
376 W32kSetArcDirection(HDC hDC,
382 dc = DC_HandleToPtr (hDC);
387 if (ArcDirection != AD_COUNTERCLOCKWISE && ArcDirection != AD_CLOCKWISE)
389 // SetLastError(ERROR_INVALID_PARAMETER);
390 DC_ReleasePtr( hDC );
394 nOldDirection = dc->w.ArcDirection;
395 dc->w.ArcDirection = ArcDirection;
396 DC_ReleasePtr( hDC );
397 return nOldDirection;