2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
IntFillEllipse( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, PBRUSH pbrush
);
29 BOOL FASTCALL
IntDrawEllipse( PDC dc
, INT XLeft
, INT YLeft
, INT Width
, INT Height
, PBRUSH pbrush
);
30 BOOL FASTCALL
IntFillRoundRect( PDC dc
, INT Left
, INT Top
, INT Right
, INT Bottom
, INT Wellipse
, INT Hellipse
, PBRUSH pbrush
);
31 BOOL FASTCALL
IntDrawRoundRect( PDC dc
, INT Left
, INT Top
, INT Right
, INT Bottom
, INT Wellipse
, INT Hellipse
, PBRUSH pbrush
);
39 PBRUSH pbrLine
, pbrFill
;
40 BOOL ret
= FALSE
; // default to failure
48 ASSERT(dc
); // caller's responsibility to pass a valid dc
50 if (!Points
|| Count
< 2 )
52 EngSetLastError(ERROR_INVALID_PARAMETER
);
60 for (CurrentPoint = 1; CurrentPoint < Count; ++CurrentPoint) {
61 Left = min(Left, Points[CurrentPoint].x);
62 Top = min(Top, Points[CurrentPoint].y);
66 pdcattr
= dc
->pdcattr
;
68 /* Convert to screen coordinates */
69 IntLPtoDP(dc
, Points
, Count
);
70 for (CurrentPoint
= 0; CurrentPoint
< Count
; CurrentPoint
++)
72 Points
[CurrentPoint
].x
+= dc
->ptlDCOrig
.x
;
73 Points
[CurrentPoint
].y
+= dc
->ptlDCOrig
.y
;
75 // No need to have path here.
77 DestRect
.left
= Points
[0].x
;
78 DestRect
.right
= Points
[0].x
;
79 DestRect
.top
= Points
[0].y
;
80 DestRect
.bottom
= Points
[0].y
;
82 for (CurrentPoint
= 1; CurrentPoint
< Count
; ++CurrentPoint
)
84 DestRect
.left
= min(DestRect
.left
, Points
[CurrentPoint
].x
);
85 DestRect
.right
= max(DestRect
.right
, Points
[CurrentPoint
].x
);
86 DestRect
.top
= min(DestRect
.top
, Points
[CurrentPoint
].y
);
87 DestRect
.bottom
= max(DestRect
.bottom
, Points
[CurrentPoint
].y
);
90 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
91 DC_vUpdateFillBrush(dc
);
93 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
94 DC_vUpdateLineBrush(dc
);
96 /* Special locking order to avoid lock-ups */
97 pbrFill
= dc
->dclevel
.pbrFill
;
98 pbrLine
= dc
->dclevel
.pbrLine
;
99 psurf
= dc
->dclevel
.pSurface
;
100 /* FIXME - psurf can be NULL!!!! don't assert but handle this case gracefully! */
103 /* Now fill the polygon with the current fill brush. */
104 if (!(pbrFill
->flAttrs
& GDIBRUSH_IS_NULL
))
106 BrushOrigin
= *((PPOINTL
)&pbrFill
->ptOrigin
);
107 BrushOrigin
.x
+= dc
->ptlDCOrig
.x
;
108 BrushOrigin
.y
+= dc
->ptlDCOrig
.y
;
109 ret
= IntFillPolygon (dc
,
111 &dc
->eboFill
.BrushObject
,
118 // Draw the Polygon Edges with the current pen ( if not a NULL pen )
119 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
123 for (i
= 0; i
< Count
-1; i
++)
126 // DPRINT1("Polygon Making line from (%d,%d) to (%d,%d)\n",
127 // Points[0].x, Points[0].y,
128 // Points[1].x, Points[1].y );
130 ret
= IntEngLineTo(&psurf
->SurfObj
,
131 dc
->rosdc
.CombinedClip
,
132 &dc
->eboLine
.BrushObject
,
133 Points
[i
].x
, /* From */
135 Points
[i
+1].x
, /* To */
138 ROP2_TO_MIX(pdcattr
->jROP2
)); /* MIX */
141 /* Close the polygon */
144 ret
= IntEngLineTo(&psurf
->SurfObj
,
145 dc
->rosdc
.CombinedClip
,
146 &dc
->eboLine
.BrushObject
,
147 Points
[Count
-1].x
, /* From */
149 Points
[0].x
, /* To */
152 ROP2_TO_MIX(pdcattr
->jROP2
)); /* MIX */
161 IntGdiPolyPolygon(DC
*dc
,
166 if (PATH_IsPathOpen(dc
->dclevel
))
167 return PATH_PolyPolygon ( dc
, Points
, (PINT
)PolyCounts
, Count
);
171 if (!IntGdiPolygon ( dc
, Points
, *PolyCounts
))
173 Points
+=*PolyCounts
++;
180 /******************************************************************************/
189 * This function uses optimized Bresenham's ellipse algorithm. It draws
190 * four lines of the ellipse in one pass.
207 LONG PenWidth
, PenOrigWidth
;
208 LONG RadiusX
, RadiusY
, CenterX
, CenterY
;
209 PBRUSH pFillBrushObj
;
210 BRUSH tmpFillBrushObj
;
212 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
217 EngSetLastError(ERROR_INVALID_HANDLE
);
220 if (dc
->dctype
== DC_TYPE_INFO
)
223 /* Yes, Windows really returns TRUE in this case */
227 if (PATH_IsPathOpen(dc
->dclevel
))
229 ret
= PATH_Ellipse(dc
, Left
, Top
, Right
, Bottom
);
236 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
240 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
243 pdcattr
= dc
->pdcattr
;
245 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
246 DC_vUpdateFillBrush(dc
);
248 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
249 DC_vUpdateLineBrush(dc
);
251 pbrush
= PEN_LockPen(pdcattr
->hpen
);
254 DPRINT1("Ellipse Fail 1\n");
256 EngSetLastError(ERROR_INTERNAL_ERROR
);
260 PenOrigWidth
= PenWidth
= pbrush
->ptPenWidth
.x
;
261 if (pbrush
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
263 if (pbrush
->ulPenStyle
== PS_INSIDEFRAME
)
265 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
266 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
267 Left
+= PenWidth
/ 2;
268 Right
-= (PenWidth
- 1) / 2;
270 Bottom
-= (PenWidth
- 1) / 2;
273 if (!PenWidth
) PenWidth
= 1;
274 pbrush
->ptPenWidth
.x
= PenWidth
;
276 RectBounds
.left
= Left
;
277 RectBounds
.right
= Right
;
278 RectBounds
.top
= Top
;
279 RectBounds
.bottom
= Bottom
;
281 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
283 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
284 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
285 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
286 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
288 // Setup for dynamic width and height.
289 RadiusX
= max((RectBounds
.right
- RectBounds
.left
) / 2, 2); // Needs room
290 RadiusY
= max((RectBounds
.bottom
- RectBounds
.top
) / 2, 2);
291 CenterX
= (RectBounds
.right
+ RectBounds
.left
) / 2;
292 CenterY
= (RectBounds
.bottom
+ RectBounds
.top
) / 2;
294 DPRINT("Ellipse 1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
295 RectBounds
.left
,RectBounds
.top
,RectBounds
.right
,RectBounds
.bottom
);
297 DPRINT("Ellipse 2: XLeft: %d, YLeft: %d, Width: %d, Height: %d\n",
298 CenterX
- RadiusX
, CenterY
+ RadiusY
, RadiusX
*2, RadiusY
*2);
300 pFillBrushObj
= BRUSH_LockBrush(pdcattr
->hbrush
);
301 if (NULL
== pFillBrushObj
)
303 DPRINT1("FillEllipse Fail\n");
304 EngSetLastError(ERROR_INTERNAL_ERROR
);
309 RtlCopyMemory(&tmpFillBrushObj
, pFillBrushObj
, sizeof(tmpFillBrushObj
));
310 // tmpFillBrushObj.ptOrigin.x += RectBounds.left - Left;
311 // tmpFillBrushObj.ptOrigin.y += RectBounds.top - Top;
312 tmpFillBrushObj
.ptOrigin
.x
+= dc
->ptlDCOrig
.x
;
313 tmpFillBrushObj
.ptOrigin
.y
+= dc
->ptlDCOrig
.y
;
314 ret
= IntFillEllipse( dc
,
320 BRUSH_UnlockBrush(pFillBrushObj
);
324 ret
= IntDrawEllipse( dc
,
331 pbrush
->ptPenWidth
.x
= PenOrigWidth
;
332 PEN_UnlockPen(pbrush
);
334 DPRINT("Ellipse Exit.\n");
340 //When the fill mode is ALTERNATE, GDI fills the area between odd-numbered and
341 //even-numbered polygon sides on each scan line. That is, GDI fills the area between the
342 //first and second side, between the third and fourth side, and so on.
344 //WINDING Selects winding mode (fills any region with a nonzero winding value).
345 //When the fill mode is WINDING, GDI fills any region that has a nonzero winding value.
346 //This value is defined as the number of times a pen used to draw the polygon would go around the region.
347 //The direction of each edge of the polygon is important.
349 extern BOOL
FillPolygon(PDC dc
,
362 NtGdiPolyPolyDraw( IN HDC hDC
,
363 IN PPOINT UnsafePoints
,
364 IN PULONG UnsafeCounts
,
372 NTSTATUS Status
= STATUS_SUCCESS
;
374 INT nPoints
= 0, nMaxPoints
= 0, nInvalid
= 0, i
;
376 if (!UnsafePoints
|| !UnsafeCounts
||
377 Count
== 0 || iFunc
== 0 || iFunc
> GdiPolyPolyRgn
)
379 /* Windows doesn't set last error */
385 ProbeForRead(UnsafePoints
, Count
* sizeof(POINT
), 1);
386 ProbeForRead(UnsafeCounts
, Count
* sizeof(ULONG
), 1);
388 /* Count points and validate poligons */
389 for (i
= 0; i
< Count
; i
++)
391 if (UnsafeCounts
[i
] < 2)
395 nPoints
+= UnsafeCounts
[i
];
396 nMaxPoints
= max(nMaxPoints
, UnsafeCounts
[i
]);
399 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
401 Status
= _SEH2_GetExceptionCode();
405 if (!NT_SUCCESS(Status
))
407 /* Windows doesn't set last error */
411 if (nPoints
== 0 || nPoints
< nMaxPoints
)
413 /* If all polygon counts are zero, or we have overflow,
414 return without setting a last error code. */
420 /* If at least one poly count is 0 or 1, fail */
421 EngSetLastError(ERROR_INVALID_PARAMETER
);
425 /* Allocate one buffer for both counts and points */
426 pTemp
= ExAllocatePoolWithTag(PagedPool
,
427 Count
* sizeof(ULONG
) + nPoints
* sizeof(POINT
),
431 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
436 SafePoints
= (PVOID
)(SafeCounts
+ Count
);
440 /* Pointers already probed! */
441 RtlCopyMemory(SafeCounts
, UnsafeCounts
, Count
* sizeof(ULONG
));
442 RtlCopyMemory(SafePoints
, UnsafePoints
, nPoints
* sizeof(POINT
));
444 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
446 Status
= _SEH2_GetExceptionCode();
450 if (!NT_SUCCESS(Status
))
452 ExFreePoolWithTag(pTemp
, TAG_SHAPE
);
456 /* Special handling for GdiPolyPolyRgn */
457 if (iFunc
== GdiPolyPolyRgn
)
460 hRgn
= IntCreatePolyPolygonRgn(SafePoints
, SafeCounts
, Count
, (INT_PTR
)hDC
);
461 ExFreePoolWithTag(pTemp
, TAG_SHAPE
);
462 return (ULONG_PTR
)hRgn
;
468 EngSetLastError(ERROR_INVALID_HANDLE
);
473 if (dc
->dctype
== DC_TYPE_INFO
)
477 /* Yes, Windows really returns TRUE in this case */
481 DC_vPrepareDCsForBlit(dc
, dc
->rosdc
.CombinedClip
->rclBounds
,
482 NULL
, dc
->rosdc
.CombinedClip
->rclBounds
);
484 if (dc
->pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
485 DC_vUpdateFillBrush(dc
);
487 if (dc
->pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
488 DC_vUpdateLineBrush(dc
);
490 /* Perform the actual work */
494 Ret
= IntGdiPolyPolygon(dc
, SafePoints
, SafeCounts
, Count
);
496 case GdiPolyPolyLine
:
497 Ret
= IntGdiPolyPolyline(dc
, SafePoints
, SafeCounts
, Count
);
500 Ret
= IntGdiPolyBezier(dc
, SafePoints
, *SafeCounts
);
503 Ret
= IntGdiPolylineTo(dc
, SafePoints
, *SafeCounts
);
505 case GdiPolyBezierTo
:
506 Ret
= IntGdiPolyBezierTo(dc
, SafePoints
, *SafeCounts
);
509 EngSetLastError(ERROR_INVALID_PARAMETER
);
513 /* Cleanup and return */
514 DC_vFinishBlit(dc
, NULL
);
518 return (ULONG_PTR
)Ret
;
530 SURFACE
*psurf
= NULL
;
531 PBRUSH pbrLine
, pbrFill
;
532 BOOL ret
= FALSE
; // default to failure
538 ASSERT ( dc
); // caller's responsibility to set this up
540 pdcattr
= dc
->pdcattr
;
542 // Rectangle Path only.
543 if ( PATH_IsPathOpen(dc
->dclevel
) )
545 return PATH_Rectangle ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
548 /* Make sure rectangle is not inverted */
549 DestRect
.left
= min(LeftRect
, RightRect
);
550 DestRect
.right
= max(LeftRect
, RightRect
);
551 DestRect
.top
= min(TopRect
, BottomRect
);
552 DestRect
.bottom
= max(TopRect
, BottomRect
);
554 IntLPtoDP(dc
, (LPPOINT
)&DestRect
, 2);
556 DestRect
.left
+= dc
->ptlDCOrig
.x
;
557 DestRect
.right
+= dc
->ptlDCOrig
.x
;
558 DestRect
.top
+= dc
->ptlDCOrig
.y
;
559 DestRect
.bottom
+= dc
->ptlDCOrig
.y
;
561 /* In GM_COMPATIBLE, don't include bottom and right edges */
562 if (pdcattr
->iGraphicsMode
== GM_COMPATIBLE
)
568 DC_vPrepareDCsForBlit(dc
, DestRect
, NULL
, DestRect
);
570 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
571 DC_vUpdateFillBrush(dc
);
573 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
574 DC_vUpdateLineBrush(dc
);
576 pbrFill
= dc
->dclevel
.pbrFill
;
577 pbrLine
= dc
->dclevel
.pbrLine
;
584 psurf
= dc
->dclevel
.pSurface
;
593 if (!(pbrFill
->flAttrs
& GDIBRUSH_IS_NULL
))
595 BrushOrigin
= *((PPOINTL
)&pbrFill
->ptOrigin
);
596 BrushOrigin
.x
+= dc
->ptlDCOrig
.x
;
597 BrushOrigin
.y
+= dc
->ptlDCOrig
.y
;
598 ret
= IntEngBitBlt(&psurf
->SurfObj
,
601 dc
->rosdc
.CombinedClip
,
606 &dc
->eboFill
.BrushObject
,
608 ROP4_FROM_INDEX(R3_OPINDEX_PATCOPY
));
612 // Draw the rectangle with the current pen
614 ret
= TRUE
; // change default to success
616 if (!(pbrLine
->flAttrs
& GDIBRUSH_IS_NULL
))
618 Mix
= ROP2_TO_MIX(pdcattr
->jROP2
);
619 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
620 dc
->rosdc
.CombinedClip
,
621 &dc
->eboLine
.BrushObject
,
622 DestRect
.left
, DestRect
.top
, DestRect
.right
, DestRect
.top
,
623 &DestRect
, // Bounding rectangle
626 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
627 dc
->rosdc
.CombinedClip
,
628 &dc
->eboLine
.BrushObject
,
629 DestRect
.right
, DestRect
.top
, DestRect
.right
, DestRect
.bottom
,
630 &DestRect
, // Bounding rectangle
633 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
634 dc
->rosdc
.CombinedClip
,
635 &dc
->eboLine
.BrushObject
,
636 DestRect
.right
, DestRect
.bottom
, DestRect
.left
, DestRect
.bottom
,
637 &DestRect
, // Bounding rectangle
640 ret
= ret
&& IntEngLineTo(&psurf
->SurfObj
,
641 dc
->rosdc
.CombinedClip
,
642 &dc
->eboLine
.BrushObject
,
643 DestRect
.left
, DestRect
.bottom
, DestRect
.left
, DestRect
.top
,
644 &DestRect
, // Bounding rectangle
649 DC_vFinishBlit(dc
, NULL
);
651 /* Move current position in DC?
652 MSDN: The current position is neither used nor updated by Rectangle. */
659 NtGdiRectangle(HDC hDC
,
666 BOOL ret
; // default to failure
671 EngSetLastError(ERROR_INVALID_HANDLE
);
674 if (dc
->dctype
== DC_TYPE_INFO
)
677 /* Yes, Windows really returns TRUE in this case */
681 /* Do we rotate or shear? */
682 if (!(dc
->dclevel
.mxWorldToDevice
.flAccel
& MX_SCALE
))
684 POINTL DestCoords
[4];
685 ULONG PolyCounts
= 4;
687 DestCoords
[0].x
= DestCoords
[3].x
= LeftRect
;
688 DestCoords
[0].y
= DestCoords
[1].y
= TopRect
;
689 DestCoords
[1].x
= DestCoords
[2].x
= RightRect
;
690 DestCoords
[2].y
= DestCoords
[3].y
= BottomRect
;
691 // Use IntGdiPolyPolygon so to support PATH.
692 ret
= IntGdiPolyPolygon(dc
, DestCoords
, &PolyCounts
, 1);
696 ret
= IntRectangle(dc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
717 PBRUSH pbrushLine
, pbrushFill
;
719 LONG PenWidth
, PenOrigWidth
;
720 BOOL ret
= TRUE
; // default to success
723 ASSERT ( dc
); // caller's responsibility to set this up
725 if ( PATH_IsPathOpen(dc
->dclevel
) )
726 return PATH_RoundRect ( dc
, Left
, Top
, Right
, Bottom
,
727 xCurveDiameter
, yCurveDiameter
);
729 if ((Left
== Right
) || (Top
== Bottom
)) return TRUE
;
731 xCurveDiameter
= max(abs( xCurveDiameter
), 1);
732 yCurveDiameter
= max(abs( yCurveDiameter
), 1);
736 INT tmp
= Right
; Right
= Left
; Left
= tmp
;
740 INT tmp
= Bottom
; Bottom
= Top
; Top
= tmp
;
743 pdcattr
= dc
->pdcattr
;
745 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
746 DC_vUpdateFillBrush(dc
);
748 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
749 DC_vUpdateLineBrush(dc
);
751 pbrushLine
= PEN_LockPen(pdcattr
->hpen
);
754 /* Nothing to do, as we don't have a bitmap */
755 EngSetLastError(ERROR_INTERNAL_ERROR
);
759 PenOrigWidth
= PenWidth
= pbrushLine
->ptPenWidth
.x
;
760 if (pbrushLine
->ulPenStyle
== PS_NULL
) PenWidth
= 0;
762 if (pbrushLine
->ulPenStyle
== PS_INSIDEFRAME
)
764 if (2*PenWidth
> (Right
- Left
)) PenWidth
= (Right
-Left
+ 1)/2;
765 if (2*PenWidth
> (Bottom
- Top
)) PenWidth
= (Bottom
-Top
+ 1)/2;
766 Left
+= PenWidth
/ 2;
767 Right
-= (PenWidth
- 1) / 2;
769 Bottom
-= (PenWidth
- 1) / 2;
772 if (!PenWidth
) PenWidth
= 1;
773 pbrushLine
->ptPenWidth
.x
= PenWidth
;
775 RectBounds
.left
= Left
;
776 RectBounds
.top
= Top
;
777 RectBounds
.right
= Right
;
778 RectBounds
.bottom
= Bottom
;
780 IntLPtoDP(dc
, (LPPOINT
)&RectBounds
, 2);
782 RectBounds
.left
+= dc
->ptlDCOrig
.x
;
783 RectBounds
.top
+= dc
->ptlDCOrig
.y
;
784 RectBounds
.right
+= dc
->ptlDCOrig
.x
;
785 RectBounds
.bottom
+= dc
->ptlDCOrig
.y
;
787 pbrushFill
= BRUSH_LockBrush(pdcattr
->hbrush
);
788 if (NULL
== pbrushFill
)
790 DPRINT1("FillRound Fail\n");
791 EngSetLastError(ERROR_INTERNAL_ERROR
);
796 RtlCopyMemory(&brushTemp
, pbrushFill
, sizeof(brushTemp
));
797 brushTemp
.ptOrigin
.x
+= RectBounds
.left
- Left
;
798 brushTemp
.ptOrigin
.y
+= RectBounds
.top
- Top
;
799 ret
= IntFillRoundRect( dc
,
807 BRUSH_UnlockBrush(pbrushFill
);
811 ret
= IntDrawRoundRect( dc
,
820 pbrushLine
->ptPenWidth
.x
= PenOrigWidth
;
821 PEN_UnlockPen(pbrushLine
);
836 DC
*dc
= DC_LockDc(hDC
);
837 BOOL ret
= FALSE
; /* default to failure */
839 DPRINT("NtGdiRoundRect(0x%x,%i,%i,%i,%i,%i,%i)\n",hDC
,LeftRect
,TopRect
,RightRect
,BottomRect
,Width
,Height
);
842 DPRINT1("NtGdiRoundRect() - hDC is invalid\n");
843 EngSetLastError(ERROR_INVALID_HANDLE
);
845 else if (dc
->dctype
== DC_TYPE_INFO
)
848 /* Yes, Windows really returns TRUE in this case */
853 ret
= IntRoundRect ( dc
, LeftRect
, TopRect
, RightRect
, BottomRect
, Width
, Height
);
878 /* check parameters */
879 if (ulMode
& GRADIENT_FILL_TRIANGLE
)
881 PGRADIENT_TRIANGLE pTriangle
= (PGRADIENT_TRIANGLE
)pMesh
;
883 for (i
= 0; i
< nMesh
; i
++, pTriangle
++)
885 if (pTriangle
->Vertex1
>= nVertex
||
886 pTriangle
->Vertex2
>= nVertex
||
887 pTriangle
->Vertex3
>= nVertex
)
889 EngSetLastError(ERROR_INVALID_PARAMETER
);
896 PGRADIENT_RECT pRect
= (PGRADIENT_RECT
)pMesh
;
897 for (i
= 0; i
< nMesh
; i
++, pRect
++)
899 if (pRect
->UpperLeft
>= nVertex
|| pRect
->LowerRight
>= nVertex
)
901 EngSetLastError(ERROR_INVALID_PARAMETER
);
907 /* Lock the output DC */
908 pdc
= DC_LockDc(hdc
);
911 EngSetLastError(ERROR_INVALID_HANDLE
);
915 if(pdc
->dctype
== DC_TYPE_INFO
)
918 /* Yes, Windows really returns TRUE in this case */
922 psurf
= pdc
->dclevel
.pSurface
;
925 /* Memory DC with no surface selected */
927 return TRUE
; //CHECKME
930 /* calculate extent */
931 rclExtent
.left
= rclExtent
.right
= pVertex
->x
;
932 rclExtent
.top
= rclExtent
.bottom
= pVertex
->y
;
933 for (i
= 0; i
< nVertex
; i
++)
935 rclExtent
.left
= min(rclExtent
.left
, (pVertex
+ i
)->x
);
936 rclExtent
.right
= max(rclExtent
.right
, (pVertex
+ i
)->x
);
937 rclExtent
.top
= min(rclExtent
.top
, (pVertex
+ i
)->y
);
938 rclExtent
.bottom
= max(rclExtent
.bottom
, (pVertex
+ i
)->y
);
940 IntLPtoDP(pdc
, (LPPOINT
)&rclExtent
, 2);
942 rclExtent
.left
+= pdc
->ptlDCOrig
.x
;
943 rclExtent
.right
+= pdc
->ptlDCOrig
.x
;
944 rclExtent
.top
+= pdc
->ptlDCOrig
.y
;
945 rclExtent
.bottom
+= pdc
->ptlDCOrig
.y
;
947 ptlDitherOrg
.x
= ptlDitherOrg
.y
= 0;
948 IntLPtoDP(pdc
, (LPPOINT
)&ptlDitherOrg
, 1);
950 ptlDitherOrg
.x
+= pdc
->ptlDCOrig
.x
;
951 ptlDitherOrg
.y
+= pdc
->ptlDCOrig
.y
;
953 EXLATEOBJ_vInitialize(&exlo
, &gpalRGB
, psurf
->ppal
, 0, 0, 0);
955 ASSERT(pdc
->rosdc
.CombinedClip
);
957 DC_vPrepareDCsForBlit(pdc
, rclExtent
, NULL
, rclExtent
);
959 bRet
= IntEngGradientFill(&psurf
->SurfObj
,
960 pdc
->rosdc
.CombinedClip
,
970 EXLATEOBJ_vCleanup(&exlo
);
971 DC_vFinishBlit(pdc
, NULL
);
988 PTRIVERTEX SafeVertex
;
990 ULONG cbVertex
, cbMesh
;
992 /* Validate parameters */
993 if (!pVertex
|| !nVertex
|| !pMesh
|| !nMesh
)
995 EngSetLastError(ERROR_INVALID_PARAMETER
);
1001 case GRADIENT_FILL_RECT_H
:
1002 case GRADIENT_FILL_RECT_V
:
1003 cbMesh
= nMesh
* sizeof(GRADIENT_RECT
);
1005 case GRADIENT_FILL_TRIANGLE
:
1006 cbMesh
= nMesh
* sizeof(GRADIENT_TRIANGLE
);
1009 EngSetLastError(ERROR_INVALID_PARAMETER
);
1013 cbVertex
= nVertex
* sizeof(TRIVERTEX
) ;
1014 if(cbVertex
+ cbMesh
<= cbVertex
)
1020 /* Allocate a kernel mode buffer */
1021 SafeVertex
= ExAllocatePoolWithTag(PagedPool
, cbVertex
+ cbMesh
, TAG_SHAPE
);
1024 EngSetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1028 SafeMesh
= (PVOID
)((ULONG_PTR
)SafeVertex
+ cbVertex
);
1030 /* Copy the parameters to kernel mode */
1033 ProbeForRead(pVertex
, cbVertex
, 1);
1034 ProbeForRead(pMesh
, cbMesh
, 1);
1035 RtlCopyMemory(SafeVertex
, pVertex
, cbVertex
);
1036 RtlCopyMemory(SafeMesh
, pMesh
, cbMesh
);
1038 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1040 ExFreePoolWithTag(SafeVertex
, TAG_SHAPE
);
1041 SetLastNtError(_SEH2_GetExceptionCode());
1042 _SEH2_YIELD(return FALSE
;)
1046 /* Call the internal function */
1047 bRet
= GreGradientFill(hdc
, SafeVertex
, nVertex
, SafeMesh
, nMesh
, ulMode
);
1049 /* Cleanup and return result */
1050 ExFreePoolWithTag(SafeVertex
, TAG_SHAPE
);
1064 SURFACE
*psurf
= NULL
;
1071 dc
= DC_LockDc(hDC
);
1074 EngSetLastError(ERROR_INVALID_HANDLE
);
1077 if (dc
->dctype
== DC_TYPE_INFO
)
1080 /* Yes, Windows really returns TRUE in this case */
1084 pdcattr
= dc
->pdcattr
;
1086 if (pdcattr
->ulDirty_
& (DIRTY_FILL
| DC_BRUSH_DIRTY
))
1087 DC_vUpdateFillBrush(dc
);
1089 if (pdcattr
->ulDirty_
& (DIRTY_LINE
| DC_PEN_DIRTY
))
1090 DC_vUpdateLineBrush(dc
);
1094 IntLPtoDP(dc
, (LPPOINT
)&Pt
, 1);
1096 Ret
= NtGdiPtInRegion(dc
->rosdc
.hGCClipRgn
, Pt
.x
, Pt
.y
);
1098 IntGdiGetRgnBox(dc
->rosdc
.hGCClipRgn
,(LPRECT
)&DestRect
);
1102 psurf
= dc
->dclevel
.pSurface
;
1109 EXLATEOBJ_vInitialize(&exlo
, &gpalRGB
, psurf
->ppal
, 0, 0xffffff, 0);
1111 /* Only solid fills supported for now
1112 * How to support pattern brushes and non standard surfaces (not offering dib functions):
1113 * Version a (most likely slow): call DrvPatBlt for every pixel
1114 * Version b: create a flood mask and let MaskBlt blit a masked brush */
1115 ConvColor
= XLATEOBJ_iXlate(&exlo
.xlo
, Color
);
1116 Ret
= DIB_XXBPP_FloodFillSolid(&psurf
->SurfObj
, &dc
->eboFill
.BrushObject
, &DestRect
, &Pt
, ConvColor
, FillType
);
1118 EXLATEOBJ_vCleanup(&exlo
);